See ?ifelse.
Your num_value function needs to be rewritten in vector form using ifelse.
"Al R" wrote:
>
># trying to do a copy and a transform within a data frame, but getting the
>"arguments imply differing number of rows" error, and I'm not sure why
>
>a=c(1,2,3)
>b=c(2,3,4)
>c=c("Yes","No","
Look at the error messages generated and you will see:
Error in data.frame(list(a = c(1, 2, 3), b = c(2, 3, 4), c = c(2L, 1L, :
arguments imply differing number of rows: 3, 2
In addition: Warning messages:
1: In if (x == "Yes") { :
the condition has length > 1 and only the first element will
# trying to do a copy and a transform within a data frame, but getting the
"arguments imply differing number of rows" error, and I'm not sure why
a=c(1,2,3)
b=c(2,3,4)
c=c("Yes","No","Yes")
d=c("No","Yes","No")
df=data.frame(a,b,c,d)
# the following works fine!
df = transform(df, new=sapply(df[
3 matches
Mail list logo