Re: [R] error when copy and transform within a data frame

2010-07-19 Thread Jeff Newmiller
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","

Re: [R] error when copy and transform within a data frame

2010-07-19 Thread jim holtman
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

[R] error when copy and transform within a data frame

2010-07-19 Thread Al R
# 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[