weix1
2010-Apr-29 15:36 UTC
[R] how to parse out fitting statistics and write them into a data frame?
hello, everyone: I am conducting t test between drug and control for about 50,000 gene using the following syntax (treatment is factor): result<- lapply(split(data, data$gene),function(x) lm(value~treatment,x) however, the result is a list and i do not know whether more model fitting statistics (like p value of t test) is included in "result" or not. If i print the first element of resut i got the followings:> result[1]$`1007_s_at` Call: lm(formula = logvalue ~ treatment, data = x) Coefficients: (Intercept) treatmentveh 8.9403 0.3232> summary(result[1])Length Class Mode 1007_s_at 13 lm list>So my question is whether more fitting statistics (other than coefficient estimation, like p value) are included in the "result". If yes, how can I parse them into a data frame so that i can output those statistics into a .csv file that can be shared with my clients. If not, how can I modify the code so that more stat can be computed and stored? any constructive suggestions are welcome. -- View this message in context: http://r.789695.n4.nabble.com/how-to-parse-out-fitting-statistics-and-write-them-into-a-data-frame-tp2075707p2075707.html Sent from the R help mailing list archive at Nabble.com.
D Sonderegger
2010-Apr-29 16:54 UTC
[R] how to parse out fitting statistics and write them into a data frame?
> however, the result is a list and i do not know whether more model fitting > statistics (like p value of t test) is included in "result" or not. If i > print the first element of resut i got the followings: >The structure command is extremely helpful here.> str(result)will give you all the information about what is returned by a call from lm. Using that information you can extract anything you want.> str(summary(result))shows you how to get at the stuff in the summary (most of which is also somewhere in the lm object). -- View this message in context: http://r.789695.n4.nabble.com/how-to-parse-out-fitting-statistics-and-write-them-into-a-data-frame-tp2075707p2075874.html Sent from the R help mailing list archive at Nabble.com.