Re: [R] parttioning a matrix corresponding to different levels of y

From: sayan dasgupta <kittudg_at_gmail.com>
Date: Fri, 04 Jun 2010 11:36:49 +0530

Suman take a look if this suffices your purpous

x <- data.frame(y=as.factor(sample(0:2,1000,replace=TRUE)),x=runif(1000))

x1 <- x[x$y==0,]
x2 <- x[x$y==1,]
x3 <- x[x$y==2,]

On Fri, Jun 4, 2010 at 10:29 AM, suman dhara <suman.dhara89_at_gmail.com>wrote:

> Sir,
> I have a problem regarding partitioning a matrix.I state my problem as
> follows:
>
> I have a y vector of length say 1000.Variable y has 4 levels say
> 0,1,2.Corresponding to each y(response), I have a x-vector(explanatory) as
> a
> row of X matrix.Now, I want to partition the X matrix into 3 submatrices
> say
> x1,x2,x3 corresponding to each level of y.Is there any function to do this
> in R or how can I do this in R?
>
> For your convinience I attach a sample version of data.
>
Use dput() and paste it in your mail

>
> Thanks,
> Suman Dhara
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 04 Jun 2010 - 06:09:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jun 2010 - 06:40:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive