Re: [R] split function

2010-02-26 Thread rusers.sh
Thanks. I think i mistake the sampling() with split(). 2010/2/26 David Winsemius > > On Feb 26, 2010, at 2:40 PM, rusers.sh wrote: > > Your method seems to only re-express the data "data.frame(x, g)" using >> another format. >> > > In all fairness to the first respondent to your question, that

Re: [R] split function

2010-02-26 Thread David Winsemius
On Feb 26, 2010, at 2:40 PM, rusers.sh wrote: Your method seems to only re-express the data "data.frame(x, g)" using another format. In all fairness to the first respondent to your question, that _was_ what it appeared you were requesting. My other thoughts would be: > cbind(x[order(g)],

Re: [R] split function

2010-02-26 Thread Henrique Dallazuanna
So, I don't understand what you want, you want add the factor to split result, isn't? #Example set.seed(1234) n <- 3; nn <- 10 g <- factor(round(n * stats::runif(n * nn))) #factor x <- rnorm(n * nn) + sqrt(as.numeric(g))#value xg <- split(x, g) xg xgD <- split(data.frame(x, g), g) sapply(x

Re: [R] split function

2010-02-26 Thread rusers.sh
Your method seems to only re-express the data "data.frame(x, g)" using another format. The results are really from the generated data frame. Maybe be not good. > table(g) g 0 1 2 3 7 9 8 6 I hope to randomly split the value 'x' according to the different sample sizes of different levels, displaye

Re: [R] split function

2010-02-26 Thread Henrique Dallazuanna
Try this: split(data.frame(x, g), g) On Fri, Feb 26, 2010 at 3:55 PM, rusers.sh wrote: > Hi, >  I am using split function and wonder how to add the factor to the splitted > results. > #Example > n <- 3; nn <- 10 > g <- factor(round(n * stats::runif(n * nn)))   #factor > x <- rnorm(n * nn) + sqrt

[R] split function

2010-02-26 Thread rusers.sh
Hi, I am using split function and wonder how to add the factor to the splitted results. #Example n <- 3; nn <- 10 g <- factor(round(n * stats::runif(n * nn))) #factor x <- rnorm(n * nn) + sqrt(as.numeric(g))#value xg <- split(x, g) xg $`0` [1] 0.82513702 -0.03911584 2.32955347 0.36745335