[R] use sample function to create new data frame

2010-11-21 Thread wangwallace
here is my original data frame a b c A B C [1,] 1 2 3 4 5 6 [2,] 7 8 9 10 11 12 [3,] 13 14 15 16 17 18 a, b, c are type I variables A, B, C are type II variables how can I create a new data frame in which: 1) in each row, there are one random number from type I

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

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.1 -

[R] the sample() function

2010-01-15 Thread Federico Bonofiglio
hello R-Wizards! again i'm invoking your presence!! since all the fuss about the paradoxes on a computer algorithm generating caos or un-determinancy, i recently grew quite curious about the mechanism underlying the procedure of NUMBER RADOMIZATION. could anyone of you, masters, attach me

Re: [R] the sample() function

2010-01-15 Thread Uwe Ligges
You can access the sources yourself. How to find the right file is described in Ligges, U. (2006): R Help Desk: Accessing the Sources. R News 6 (4), 43-45. http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf Best wishes, Uwe Ligges On 15.01.2010 10:54, Federico Bonofiglio wrote: hello