[R] subtraction based on two groups in a dataframe
Remko Duursma
remkoduursma at gmail.com
Tue Sep 28 03:12:50 CEST 2010
Try something like this:
dfr <- read.table(textConnection(" plate.id well.id Group HYB
rlt1
1 P1 A1 Control SKOV3hyb 0.190
2 P1 A2 Control SKOV3hyb 0.210
3 P1 A3 Control SKOV3hyb 0.205
4 P1 A4 Control SKOV3hyb 0.206
5 P1 A5 Control SKOV3hyb 0.184
385 P1 A1 ovca SKOV3hyb 0.184
386 P1 A2 ovca SKOV3hyb 0.229
387 P1 A3 ovca SKOV3hyb 0.214
388 P1 A4 ovca SKOV3hyb 0.226
389 P1 A5 ovca SKOV3hyb 0.217 "))
difs <- lapply(split(dfr,dfr$plate.id), function(x)x$rlt1[x$Group ==
"Control"] - x$rlt1[x$Group == "ovca"])
dfr$Diff <- Reduce(c,difs)
greetings,
Remko
--
View this message in context: http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2716469.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list