[R] how to extract data from a function printout - example provided
Sarah Goslee
sarah.goslee at gmail.com
Sun Jun 26 16:11:56 CEST 2011
As a start, run matchit() for a test dataset and look at:
names(m.out)
and
names(summary(m.out))
You can save those named components in the usual ways.
Sarah
On Sun, Jun 26, 2011 at 10:06 AM, Ana Kolar <annakolar at yahoo.com> wrote:
> Hi there,
>
> Does anyone know how to extract data from a function that prints out two or more summaries? In the function below (the whole code is provided) we get 5 different tables of data. I would like to split each of these tables in a separate file (while the function itself shouldn't be changed), so that further analysis on each data set could be carried out. Your help is deeply appreciated. Have a good day. Ana
>
>
> Here is the code:
>
> library(MatchIt)
>
> f <- treat ~ age + I(age^2) + educ + I(educ^2) + black + hispan +
> married + nodegree + re74 + I(re74^2) + re75 + I(re75^2)
>
> d <- lalonde
>
> m <- "nearest"
>
> matching <- function(formula,data,method){
> library(MatchIt)
> m.out <- matchit(formula=f, data=d, method=m)
> print(m.out)
> print(summary(m.out))
> }
>
> matching(f,d,m)
>
> [[alternative HTML version deleted]]
>
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list