search for: vdummyfunc

Displaying 1 result from an estimated 1 matches for "vdummyfunc".

Did you mean: dummyfunc
2011 Dec 27
2
sapply Call Returning " the condition has length > 1" Error
Dear all, Happy new year! I have a question re using sapply. Below is a dummy example that would replicate the error I saw.  ##Code Starts here DummyFunc <- function(x) { if (x > 0) { return (x) } else { return (-x) } } Y = data.frame(val = c(-3:7)) sapply(Y, FUN = DummyFunc) ##Code ends here When I run it, I got:      val  [1,]   3  [2,]   2  [3,]   1  [4,]   0  [5,]  -1  [6,]  -2