How to hold a value(Mean sq) with a string

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to hold a value(Mean sq) with a string

Felipe Carrillo
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?

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to hold a value(Mean sq) with a string

Erik Iverson
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?
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to hold a value(Mean sq) with a string

Jorge I Velez
In reply to this post by Felipe Carrillo
Hi Felipe,

Try this

 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)

temp=anova(lm(Efficiency~percentQ,data=dfr))
names(temp)
temp$"Mean Sq"  # First entry is MS percentQ and second one is MS residuals

HTH

Jorge




On Thu, Mar 6, 2008 at 5:49 PM, Felipe Carrillo <[hidden email]>
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?
>
> ______________________________________________
> [hidden email] 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.
>



--
Jorge Velez
Industrial Engineer
Master in Sciences (Candidate)
School of Statistics
National University of Colombia at Medellin
e-mail: [hidden email]

Visiting Fellow
Medical Genetics Branch, MGB
National Human Genome Research Institute, NHGRI
National Institutes of Health, NIH
Department of Health and Human Services, DHHS

35 Convent Drive, MSC 3717
Building 35, Room 1B-209
Bethesda, MD, USA 20892-3717

Office:  +1 (301) 451-74-06
Mobile: +1 (301) 300-37-32
Fax:     +1 (301) 496-71-84
e-mail: [hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.