I am using the new package , dplyr and facing some difficulties.
mutate(df,isOdd=digit%%2) or transform(df,isOdd=digit%%2) Both of which work perfectly.
I am asking a question on passing custom method.
IsItOdd <- function(x) { if(x%%2==0) result<-"even" else result<-"odd" return(result) } transform(df,isOdd=IsItOdd(digit)) This doesnt work because the whole column of all the digit is passed to the function. Is there a way to make this work by just passing that one cell to the function instead of the whole column ?
transform(df,isOdd=vapply(digit, IsItOdd, ""))ortransform(df,isOdd=Vectorize(IsItOdd)(digit))?