[R] Subscripting

Greg Snow Greg.Snow at imail.org
Wed Feb 10 20:40:12 CET 2010


Something like:

> df3 <- df2[ !(df2$date %in% df1$date), ]

Might be what you want.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of GL
> Sent: Wednesday, February 10, 2010 12:26 PM
> To: r-help at r-project.org
> Subject: [R] Subscripting
> 
> 
> Dataframe1 contains a list of specific dates. Dataframe2 contains a
> large
> dataset, one element of which is Date. How do I create a subset of
> Dataframe2 that excludes the dates from Dataframe1? I know how to do it
> with
> a left outer join vs null in SQL, but I can't figure out how to do it
> more
> directly via the subcripts that already exist?
> 
> Dateframe1
> 
> Date
> 1/1/2010
> 1/18/2010
> 
> 
> Dataframe2
> 
> Date Attribute Count
> 1/1/2010 Red 5
> 1/15/2010 Green 2
> 1/18/2010 Purple 8
> 1/19/2010 Yellow 3
> 
> ResultingDataframe (Dataframe2 minus the rows that have Dates in
> Dataframe1)
> 
> Date Attribute Count
> 1/15/2010 Green 2
> 1/19/2010 Yellow 3
> 
> --
> View this message in context: http://n4.nabble.com/Subscripting-
> tp1476330p1476330.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list