[R] Replacement function using grouping variable

PIKAL Petr petr.pikal at precheza.cz
Thu Sep 19 13:15:10 CEST 2013


Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Alecia M Moser
> Sent: Thursday, September 19, 2013 7:01 AM
> To: r-help at r-project.org
> Subject: [R] Replacement function using grouping variable
> 
> Hello -
> 
> I am looking for a function that would allow me to replace specific
> columns in one data frame with columns in another data frame using a
> grouping variable.
> 
> df <- read.csv("data.csv", header=T)
> df1 <- aggregate(df[, c(8,9,10,11,12,27,28)], by=list(df$ID),
> FUN=function(x) sub("(.*):", "\\1.", x))
> 
> How do I replace columns (8,9,10,11,12,27,28) in df with those from df1
> using the ID column?

Maybe ?merge.

Petr

> 
> Thank you,
> 
> Alecia
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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