[R] extracting data

Peter Ehlers ehlers at ucalgary.ca
Tue Jun 28 19:37:00 CEST 2011


On 2011-06-28 09:54, Ana Kolar wrote:
> Hi Sarah,
>
> Thank you for your response. Here is a toy example:
>
>
> library(MatchIt)
> data(lalonde)
>
> A<-lalonde
> f<-treat ~ age + I(age^2) + educ + I(educ^2) + black + hispan +
>      married + nodegree + re74 + I(re74^2) + re75 + I(re75^2)
> m<-"nearest"
> m.out.base<- matchit(formula=f, data=A, method=m)
>
> B<- match.data(m.out.base)
>
> An<- nrow(A)
> Bn<- nrow(B)
>
> Cn<- An - Bn
> C<- ??

Can't you just use

  idx <- setdiff(rownames(A), rownames(B))
  C <- A[idx, ]

Peter Ehlers

>
>
>
>
>> ________________________________
>> From: Sarah Goslee<sarah.goslee at gmail.com>
>> To: Ana Kolar<annakolar at yahoo.com>
>> Cc: R<r-help at r-project.org>
>> Sent: Tuesday, 28 June 2011, 18:44
>> Subject: Re: [R] extracting data
>>
>> Hi Ana,
>>
>> On Tue, Jun 28, 2011 at 12:28 PM, Ana Kolar<annakolar at yahoo.com>  wrote:
>>> Let's say I have an original data set which is called A and data extracted from this original data set, called B. Based on these A and B data set I would like to get data set C which includes all the remaining data from the data set A after we exclude data of the data set B.
>>>
>>> Any idea how to do this?
>>
>> Yes. Several.
>>
>> But to know which one to suggest, I need to know more about your data.
>>
>> How about a toy example, so the list members can see your index
>> variables, etc? Or how you created the subset B, and why you can't
>> just use the opposite of that procedure?
>>
>> Sarah
>> --
>> Sarah Goslee
>> http://www.functionaldiversity.org
>>
>>
>>
> 	[[alternative HTML version deleted]]
>



More information about the R-help mailing list