Re: [R] Issues with the way Apply handled NA's

2016-11-16 Thread S Ellison
> -Original Message- > > You can check for an empty vector as follows: > ... > vals <- apply(plabor[c("colA","colB","colC")],1,function(x) > length(na.omit(x))) > vals # [1] 3 0 3 2 > <- ifelse(vals>0, plabor$colD, NA) > plabor A slightly more compact variant that avoids the

Re: [R] Issues with the way Apply handled NA's

2016-11-14 Thread David L Carlson
A 28 - David L Carlson Department of Anthropology Texas A University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Olu Ola via R-help Sent: Monday, November 14, 2016 2:52 PM To: R-hel

[R] Issues with the way Apply handled NA's

2016-11-14 Thread Olu Ola via R-help
Hello,I have a data set called plabor and have the following format: | ColA | ColB | Colc | | 6 | 25 | 3 | | NA | NA | NA | | 3 | 2 | 19 | | 4 | 7 | NA | I wanted to find the product of the three columns for each of the rows and I used the apply function follows: plabor$colD =