[R] Reconciling 2 datasets

Bert Gunter gunter.berton at gene.com
Sat Jul 24 00:42:31 CEST 2010


Have you read AN INTRODUCTION TO R?

?%in%

Bert Gunter
Genentech Nonclinical Statistics

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of chipmaney
> Sent: Friday, July 23, 2010 3:39 PM
> To: r-help at r-project.org
> Subject: [R] Reconciling 2 datasets
> 
> 
> 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