Hi Group,

I have a data frame below. Within this data frame there are  samples
(columns) that are measured  more than once. Samples are indicated by
"idx". So "id1" is present in columns 1, 3, and 5. Not every id is
repeated. I would like to create a new data frame so that the repeated
 ids are averaged. For example, in the new data frame, columns 1, 3,
and 5 of the original will be replaced by 1 new column  that is the
mean of these three. Thanks for any suggestions.

Juliet



myData <- data.frame("sample1.id1" =rep(1,10),
"sample1.id2"=rep(2,10),
"sample2.id1" = rep(2,10),
"sample1.id3" = 1:10,
"sample3.id1" = rep(1,10),
"sample1.id4" = 1:10,
"sample2.id2" = rep(1,10))

repeat_ids <- c("id1","id2")

______________________________________________
R-help@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.

Reply via email to