[R] Reconciling 2 datasets

Jorge Ivan Velez jorgeivanvelez at gmail.com
Sat Jul 24 00:42:08 CEST 2010


Try

Empirical.df[Empirical.df$ID %in% Samples.v,]

See ?"%in%" for more informartion.

HTH,
Jorge



On Fri, Jul 23, 2010 at 6:38 PM, chipmaney <> wrote:
>
> I have a dataframe:
>
> Empirical.df <- data.frame(ID=c("MCUP1-2","MCUP2-5", "MCUP3-3",
> "MCUP4-3","MCUP5-9"), Cover=c(60,40,45,68,72))
>
>
> However, I only want to use a subset of Cover.df for my analysis. The
> samples I want to use are:
>
> Samples.v <- c("MCUP1-2", "MCUP4-3","MCUP5-9")
>
> How do I use indexing Empirical.df by Samples.v to return a new dataframe
> with only the data I am interested in?
>
> Here is what I mean:
>
> Cover.df <- Empirical.df[???,]
>
> returns:
>
> Cover.df
>>> Cover.df
>       ID        Cover
> 1 MCUP1-2    60
> 3 MCUP4-3    68
> 5 MCUP5-9    72
> --
> View this message in context: http://r.789695.n4.nabble.com/Reconciling-2-datasets-tp2300772p2300772.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