[R] Missing data (Na) and chi-square tests

Rui Barradas ruipbarradas at sapo.pt
Fri Oct 5 16:50:02 CEST 2012


Hello,

There are two ways,

1.
?sum  # see argument na.rm
sum(whatever, na.rm = TRUE)

2.
?table  # produces the 2x2 contingency table, if there are only 2 values

Also, you should provide us with a data example, especially since your 
code clearly doesn't work.
Use ?dput like this

dput( head(MyData, 20) )  # Then paste the output of this in a post.


Hope this helps,

Rui Barradas
Em 05-10-2012 14:26, Rerda escreveu:
> Dear everyone
>
> I am a bit of a computer imbecile and are having problems with R.
> I am using R in my research project to do chi-square tests on data imported
> from excel .
> However I have som missing data in one of my variables (columns) and I need
> R to "exclude" these and make chi-square test on the data that I have.
>
> I use a formula to make 2x2 tables which is:
> data <- matrix(c(sum(!Variable[Group....==1]), sum(Variable[DAAC....==1]),
> sum(!Variable[Group....==0]), sum(Variable[DAAC....==0])),2,2)
>
> How can I get R to ignore Na's in this formula?
>
> Many Regards
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Missing-data-Na-and-chi-square-tests-tp4645167.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list