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
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)],
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
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
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
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
6 matches
Mail list logo