Thanks that makes perfect sense!
Chris
On 3/19/09 1:17 PM, Dimitris Rizopoulos wrote:
well, you need to keep track of the rows you sampled, e.g.,
dat <- data.frame(x = rnorm(20), y = rnorm(20), w = rnorm(20))
ii <- seq_len(nrow(dat))
ind1 <- sample(ii, 10)
ind2 <- ii[!ii %in% ind1]
dat[ind1, ]
well, you need to keep track of the rows you sampled, e.g.,
dat <- data.frame(x = rnorm(20), y = rnorm(20), w = rnorm(20))
ii <- seq_len(nrow(dat))
ind1 <- sample(ii, 10)
ind2 <- ii[!ii %in% ind1]
dat[ind1, ]
dat[ind2, ]
I hope it helps.
Best,
Dimitris
Christopher David Desjardins wrote:
I
I have a data frame in long format and I would like to randomly divide
this data frame in half. The data frame consists of 39622 rows and I
initially tried ...
randomsample1 <- data[sample(nrow(data),19811), ]
Where allows me to randomly select half of the rows and assign them to
randomsample
3 matches
Mail list logo