Re: [R] use sample function to create new data frame

2010-11-21 Thread wangwallace
Gong, thanks!! but your syntax did work out as I would expect. here following are the reasons: each row from my original data frame represents data from one subject. when the one type I number and the two type II numbers are drawn from the original data frame, both type I number and type II numb

Re: [R] use sample function to create new data frame

2010-11-20 Thread Wu Gong
Hi, I would try to sample by row index and column index. Hope it helps. df <- data.frame(matrix(1:18,nrow=3,ncol=6,byrow=TRUE)) colnames(df) <- c(letters[1:3],LETTERS[1:3]) ## Generate a new data frame with 10 rows one <- two <- three <- numeric(10) for (i in 1:10) { ## Sample from type I col