[R] str() to extract components
Hi, I have been dabbling with str() to extract values from outputs such as lmer etc and have found it very helpful sometimes. but only seem to manage to extract the values when the output is one simple table, any more complicated and I'm stumped :-( take this example of the extracted coeficients from a lmer analysis... using str(coef(lmer(resp3~b$age+b$size+b$pcfat+(1|sex), data=b))) yields Formal class 'lmer.coef' [package Matrix] with 3 slots ..@ .Data :List of 1 .. ..$ :`data.frame': 2 obs. of 4 variables: .. .. ..$ (Intercept): num [1:2] 1.07 1.13 .. .. ..$ b$age : num [1:2] 0.00702 0.00702 .. .. ..$ b$size : num [1:2] 0.0343 0.0343 .. .. ..$ b$pcfat: num [1:2] 0.0451 0.0451 ..@ varFac: list() ..@ stdErr: num(0) how do I get inside the first table to get the value 1.07 for instance? Any help much appreciated. Simon Pickett PhD student Centre For Ecology and Conservation Tremough Campus University of Exeter in Cornwall TR109EZ Tel 01326371852 __ R-help@stat.math.ethz.ch 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.
Re: [R] str() to extract components
On Tue, Feb 27, 2007 at 03:52:54PM -, Simon Pickett wrote: Hi, I have been dabbling with str() to extract values from outputs such as lmer etc and have found it very helpful sometimes. but only seem to manage to extract the values when the output is one simple table, any more complicated and I'm stumped :-( take this example of the extracted coeficients from a lmer analysis... using str(coef(lmer(resp3~b$age+b$size+b$pcfat+(1|sex), data=b))) yields Formal class 'lmer.coef' [package Matrix] with 3 slots ..@ .Data :List of 1 .. ..$ :`data.frame': 2 obs. of 4 variables: .. .. ..$ (Intercept): num [1:2] 1.07 1.13 .. .. ..$ b$age : num [1:2] 0.00702 0.00702 .. .. ..$ b$size : num [1:2] 0.0343 0.0343 .. .. ..$ b$pcfat: num [1:2] 0.0451 0.0451 ..@ varFac: list() ..@ stdErr: num(0) how do I get inside the first table to get the value 1.07 for instance? Any help much appreciated. may `unlist' would be enough? __ R-help@stat.math.ethz.ch 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.
Re: [R] str() to extract components
mod - lmer(resp3~b$age+b$size+b$pcfat+(1|sex), data=b) coef(mod)[1]$Subject[1,1] [EMAIL PROTECTED] wrote on 27/02/2007 16:52:54: Hi, I have been dabbling with str() to extract values from outputs such as lmer etc and have found it very helpful sometimes. but only seem to manage to extract the values when the output is one simple table, any more complicated and I'm stumped :-( take this example of the extracted coeficients from a lmer analysis... using str(coef(lmer(resp3~b$age+b$size+b$pcfat+(1|sex), data=b))) yields Formal class 'lmer.coef' [package Matrix] with 3 slots ..@ .Data :List of 1 .. ..$ :`data.frame': 2 obs. of 4 variables: .. .. ..$ (Intercept): num [1:2] 1.07 1.13 .. .. ..$ b$age : num [1:2] 0.00702 0.00702 .. .. ..$ b$size : num [1:2] 0.0343 0.0343 .. .. ..$ b$pcfat: num [1:2] 0.0451 0.0451 ..@ varFac: list() ..@ stdErr: num(0) how do I get inside the first table to get the value 1.07 for instance? Any help much appreciated. Simon Pickett PhD student Centre For Ecology and Conservation Tremough Campus University of Exeter in Cornwall TR109EZ Tel 01326371852 __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.