[R] How to hold a value(Mean sq) with a string

Erik Iverson iverson at biostat.wisc.edu
Thu Mar 6 23:56:15 CET 2008


Assign your anova object a name, like

fm1 <- anova(lm(Efficiency~percentQ,data=dfr))

Then do

names(fm1)

and try

fm1$"Mean Sq"

Notice you were trying to find "Mean Sq" in dfr, your original data.frame.

-Erik Iverson

Felipe Carrillo wrote:
> Hi all:
>   Can someone advice me on how to hold the residuals
> Mean sq value on a string
>   so it can be used in other calculations.
>   I was trying something like this:
>   Msquare<-dfr$Mean sq  but fails..Thanks
> 
>  dfr <- read.table(textConnection("percentQ 
> Efficiency
> 1.565	 0.0125
> 1.94	 0.0213
> 0.876	 0.003736
> 1.027	 0.006
> 1.536	 0.0148
> 1.536	 0.0162
> 2.607	 0.02
> 1.456	 0.0157
> 2.16	 0.0103
> 1.698	 0.0196
> 1.64	 0.0098684
> 1.814	 0.0183
> 2.394	 0.0107
> 2.469	 0.0221
> 3.611	 0.0197
> 3.466	 0.0155
> 1.877	 0.0283
> 2.893	 0.0189
> 1.851	 0.009772
> 2.834	 0.0285
> 1.923	 0.022
> 2.581	 0.0159
> 2.361	 0.0053591
> 2.43	 0.0185
> 1.66	 0.0151
> 2.285	 0.0084034
> 2.285	 0.0124
> 2.37	 0.0122
> 2.392	 0.0146
> 2.244	 0.0175"), header=TRUE)
> 
> anova(lm(Efficiency~percentQ,data=dfr))
> Analysis of Variance Table
> 
> Response: Efficiency
>           Df     Sum Sq    Mean Sq F value  Pr(>F)
> percentQ   1 0.00014432 0.00014432  4.3774 0.04561 *
> Residuals 28 0.00092312 0.00003297
> 
> 
> 
> Felipe D. Carrillo
>   Fishery Biologist
>   US Fish & Wildlife Service
>   California, USA
> 
> 
> 
>       ____________________________________________________________________________________
> Looking for last minute shopping deals?
> 
> ______________________________________________
> 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