[R] t.test() with missing values
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Sep 13 18:50:59 CEST 2007
Birgit Lemcke wrote:
> Hello!
>
> I am using R 2.5.1 on a Apple Power Book G4 with Mac OS X 10.4.10 and
> I am still R beginner.
>
> I try to calculate a t.test() using this code:
>
> TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE)
>
> This works properly, but I have two variables with a lot of missing
> data and therefore get the error message:
>
> TTest66<-t.test(Fem66, Mal66, alternative= "two.sided", paired= TRUE)
> Fehler in var(x) : 'x' ist leer
>
> One of the two vectors looks like this:
>
> [1] 5.0 NA 4.5 6.0 0.8 NA 7.0 4.5 NA NA NA NA 5.0 NA 6.0 NA
> 5.0 NA 5.0 8.0 NA NA NA 8.0 NA 8.0 5.0 NA NA NA NA 8.0 NA 1.0
> [35] NA NA NA NA NA NA 5.0 NA 4.0 8.0 NA 6.0 6.0 4.5 3.5 NA
> NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
> [69] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA ....
>
> Is it possible to run a TTest inspite of all the missing data?
> I really need two know if may two vectors are significantly
> different. (If this results are then reliable is an other question)
>
Well, you're not showing the other one, but I have a hunch that
any(complete.cases(Fem66, Mal66)) will come out false, in which case
you don't have paired data and might get rid of paired=TRUE and have an
ordinary two sample test. (BTW paired data for females and males? Couples?)
> By the way is there a better possibility (and I guess there is) to
> save or export the t.test() results as textfile?
>
> Thanks in advance for your help.
>
> Greetings
>
> Birgit
>
> Birgit Lemcke
> Institut für Systematische Botanik
> Zollikerstrasse 107
> CH-8008 Zürich
> Switzerland
> Ph: +41 (0)44 634 8351
> birgit.lemcke at systbot.uzh.ch
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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.
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list