Hi, for your cor() command you will want to specify the "use" argument as either "complete.obs" or as "pairwise.complete.obs". The difference between the two is that the former only uses those observations for which ALL information in "a" is available, whereas the latter uses information that is available for all pairwise comparisons between variables in "a". For the example below, use="c" would exclude observations 6 and 5, whereas use="p" would exclude observations 6 and 5 for correlations between x and y, and x and z, but it would only exclude observation 5 for the correlation between y and z
x=c(1,2,3,4,5,NA) y=c(2,3,3.5,4.75,NA,7) z=c(5,8,7,6,NA,11) a=data.frame(x,y,z) cor(a) cor(a,use="c") cor(a,use="p") Cheers, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von paul murima Gesendet: Tuesday, December 02, 2008 11:33 PM An: r-help@r-project.org Cc: [EMAIL PROTECTED] Betreff: [R] Null values In R. Hi everyone. I am having problems with NULL values. I understand in R one can command the program to skip null values. Can some one help me on the command line for that. Do i enter is as part of the string in: a<- read.table("filename.csv", header = T, row.names=1, sep=","); My problem is largely when i attempt to use correlation for my data... xcc <- cor(a); The error i get is as follows Error in cor(a) : missing observations in cov/cor In addition: Warning message: In cor(a) : NAs introduced by coercion Regards Paul Murima ______________________________________________ R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.