Hi,
dat <- read.table(text="A B
1 0
2 2
3 1
4 NA",sep="",header=TRUE)
within(dat,{C<-A/B;C[!is.finite(C)]<-0})
#
within(dat,{C<-A/B;C[!is.finite(C)]<-NA})
A.K.
Hi R users,
Just wondering is it possible to divide two columns with some NA or Zero
values? E.g.:
A B
1 0
2 2
3 1
4 0
I want something like this:
A B C
1 0 0 (or NA)
2 2 1
3 1 3
4 0 0 (or NA)
Even though it is not meaningful to divide zero but the data I
got have these missing values in a time series... Ignoring them will not
have a material effect on my analysis.
Thanks!
______________________________________________
[email protected] mailing list
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.