Oh. Fantastic! Many thanks for this, Sarah!

Have a great week!

Ana




>________________________________
>From: Sarah Goslee <sarah.goslee@gmail.com>
>To: Ana Kolar <annakolar@yahoo.com>; r-help <r-help@r-project.org>
>Sent: Sunday, 26 June 2011, 17:06
>Subject: Re: [R] how to extract data from a function printout - example provided
>
>summary(m.out) is a list with items with those names. Once you know
>the names, you can extract them in the same way as you'd extract any
>element from a list: by name, by position, etc.
>
>On Sun, Jun 26, 2011 at 10:48 AM, Ana Kolar <annakolar@yahoo.com> wrote:
>> Thank you Sarah!
>> But names(summary(m.out)) gives only the names and no data. I actually need
>> to extract data (to get a table of data out of that list so that it can be
>> analysed further on).
>> Any idea regarding that?
>> Ana
>>
>> ________________________________
>> From: Sarah Goslee <sarah.goslee@gmail.com>
>> To: Ana Kolar <annakolar@yahoo.com>
>> Cc: R <r-help@r-project.org>
>> Sent: Sunday, 26 June 2011, 16:11
>> Subject: Re: [R] how to extract data from a function printout - example
>> provided
>>
>> 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@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
>
>
>
	[[alternative HTML version deleted]]

