> -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 interme
28
-
David L Carlson
Department of Anthropology
Texas A&M 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
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 = apply(plabor[c("
3 matches
Mail list logo