[R] Str info. Thanks for helping
Ivan Calandra
ivan.calandra at uni-hamburg.de
Thu May 5 10:27:47 CEST 2011
Hi William!
So... many things to say
First, your first steps are completely unnecessary.
Just do this:
data1 <- read.csv(file.choose(), header=TRUE)
data1$IND <- factor(data1$IND)
M <- manova(as.matrix(data1[,-1])~data1$IND, data=data1)
Though I don't understand why this doesn't work:
M <- manova(.~IND, data=data1)
Error in eval(expr, envir, enclos) : object '.' not found
Second, this doesn't work either:
S<-summary(M, test="Pillai")
Error in summary.manova(M, test = "Pillai") : residuals have rank 11 < 12
And I don't know what that means since I never do manova, but it's not
really where you're stuck, I guess
Third, where you're stuck. Is this what you want?
SA<-summary.aov(M)
out <- lapply(seq_along(SA), FUN=function(x) unlist(SA[[x]][1,]))
mat <- do.call("rbind", out)
row.names(mat) <- names(SA)
Fourth, I wouldn't use as.vector(). I'm no R expert, but I have the
impression that it is useless in this case. It probably has its use in
some situations, but I think as.matrix(), as.data.frame() and so on
would be more useful to you.
And last, reply to the list as well!! Since attached files are not
transferred, copy the output from dput(data1) into the email, like this:
data1 <- structure(list(IND = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
...
"Dep1", "Dep2", "Dep3", "Dep4", "Dep5", "Dep6", "Dep7", "Dep8",
"Dep9", "Dep10", "Dep11", "Dep12"), row.names = c(NA, -133L), class =
"data.frame") ## copy the whole thing, right!!
HTH,
Ivan
Le 5/5/2011 02:41, Reith, William [USA] a écrit :
> CSV file is attached.
>
> I am doing a manova test. Followed by a summary.aov to determine which of the 12 dependent variables are significant and warrant further testing. There is only one independent variable which is categorical with 4 factors.
>
> R Code:
>
> data1<- read.csv(file link, header=TRUE)
> as.matrix(data1)
> X<-data1[,1]
> Dep1<-data1[,2]
> Dep2<-data1[,3]
> Dep3<-data1[,4]
> Dep4<-data1[,5]
> Dep5<-data1[,6]
> Dep6<-data1[,7]
> Dep7<-data1[,8]
> Dep8<-data1[,9]
> Dep9<-data1[,10]
> Dep10<-data1[,11]
> Dep11<-data1[,12]
> Dep12<-data1[,13]
> Y<-cbind(Dep1, Dep2, Dep3, Dep4, Dep5, Dep6, Dep7, Dep8, Dep9, Dep10, Dep11, Dep12)
> M<- manova(Y ~ as.factor(X), data=data1)
>
> S<-summary(M, test="Pillai")
> S1<-as.vector(S$stats[1,])
> L<-mat.or.vec(12,3)
> SA<-summary.aov(M)
>
> #Stops working here. I want to save the numbers from each Dep"i" test as a matrix or vector. S1 above works for the manova test, but I don't know how to reference my values for summary.aov
>
> SA1<-SA[" Response Dep1"]
>
>
> Thank you so much for any help you can give,
>
> William
>
>
>
> -----Original Message-----
> From: Ivan Calandra [mailto:ivan.calandra at uni-hamburg.de]
> Sent: Wednesday, May 04, 2011 4:38 PM
> To: Reith, William [USA]
> Cc: r-help at r-project.org
> Subject: Re: Str info. Thanks for helping
>
> It looks from str(SA) that Response IPS1 is a data.frame of class "anova", which probably cannot be coerced to vector.
>
> Maybe you can use unlist() instead of as.vector()
> Or something like
> SA[["Response IPS1"]]["as.factor(WSD)",] ## to select the first row only, even maybe with unlist()
>
> Without a better REPRODUCIBLE example, I cannot tell more (maybe some others can, that's why I reply to the list)
>
> HTH,
> Ivan
>
>
> Le 4 mai 2011 à 20:17, reith_william at bah.com a écrit :
>
>> I am still waiting for this to get posted so I thought I would email it to you.
>>
>> SA gives the output:
>>
>> Response IPS1 :
>> Df Sum Sq Mean Sq F value Pr(>F)
>> as.factor(WSD) 3 3.3136 1.10455 23.047 5.19e-12 ***
>> Residuals 129 6.1823 0.04793
>> ---
>> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>> .
>> .
>> .
>> There are 11 more just like this output. Just increment IPS1 to IPS2, etc.
>>
>>
>> Goal: save "3 3.3136 1.10455 23.047 5.19e-12" as a vector.
>>
>>
>> Str(SA) gives the output:
>>
>> str(SA)
>>> str(SA)
>> List of 12
>> " $ Response IPS1 :Classes 'anova' and 'data.frame': 2 obs. of 5 variables:"
>> ..$ Df : num [1:2] 3 129
>> ..$ Sum Sq : num [1:2] 3.31 6.18
>> ..$ Mean Sq: num [1:2] 1.1045 0.0479
>> ..$ F value: num [1:2] 23 NA
>> ..$ Pr(>F) : num [1:2] 5.19e-12 NA
>>
>>
>> There are several more but they are just repeats of this one only with IPS2, IPS3,...
>>
>> The command:
>>
>>> SA1<-as.vector(SA$"Reponse IPS1")
>> Returns
>>
>>> NULL
>> As do several variations I have tried. Any ideas.
>
>
> --
> Ivan CALANDRA
> PhD Student
> University of Hamburg
> Biozentrum Grindel und Zoologisches Institut und Museum
> Abt. Säugetiere
> Martin-Luther-King-Platz 3
> D-20146 Hamburg, GERMANY
> +49(0)40 42838 6231
> ivan.calandra at uni-hamburg.de
>
> **********
> http://www.for771.uni-bonn.de
> http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
>
--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de
**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
More information about the R-help
mailing list