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("colA","colB","colc")],1,prod,na.rm=T) The result are as follows: | ColA | ColB | Colc | colD | | 6 | 25 | 3 | 450 | | NA | NA | NA | 1 | | 3 | 2 | 19 | 114 | | 4 | 7 | NA | 28 | The second row results is 1 instead of being ignored. How do I deal with this issue because I do not want to exclude these data points with all NA's? Regards [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.