- 1. Difference in data frame (score: 1)
- Author: Tristan Lorino <tristan.lorino@lcpc.fr>
- Date: Tue, 20 Jun 2006 12:47:51 +0200
- I have a data frame like that: ID V2 V3 1 0.3 3 1 0.4 2 2 0.6 6 2 0.7 9 2 0.4 4 I would like to have: ID V2 V3 V4 1 0.3 3 3 1 0.4 2 -1 2 0.6 6 6 2 0.7 9 3 2 0.4 4 -5 that means all the first data fr
- /archives/html/s-news/2006-06/msg00043.html (7,216 bytes)
- 2. Re: Difference in data frame (score: 1)
- Author: "Dimitris Rizopoulos" <dimitris.rizopoulos@med.kuleuven.be>
- Date: Tue, 20 Jun 2006 13:00:46 +0200
- try the following: dat <- data.frame(ID = c(1, 1, 2, 2, 2), V2 = c(0.3, 0.4, 0.6, 0.7, 0.4), V3 = c(3, 2, 6, 9, 4)) dat$V4 <- unlist(tapply(dat$V3, dat$ID, function(x) c(x[1], diff(x)))) dat I hope i
- /archives/html/s-news/2006-06/msg00044.html (8,746 bytes)
This search system is powered by
Namazu