[R] subsetting a matrix and filling other

antonio rodriguez antonio.raju at gmail.com
Tue Nov 7 20:30:23 CET 2006


Christos Hatzis escribió:
> Use a list to store the partial matrices:
>
> z <- vector("list", 189) 
>
> for(i in 1:189)
> 	z[[i]] <- subset(...)
>   
Hi Christos,

I've tried it but it died unexpectedly with a (Killed) message and the 
linux console prompt again. I think I have enough memory (512) and a 
pretty good processor (P4, 2.8)

Antonio



> -Christos
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of antonio rodriguez
> Sent: Tuesday, November 07, 2006 2:01 PM
> To: R-Help
> Subject: [R] subsetting a matrix and filling other
>
> Hi,
>
> Having a matrix F(189,6575) I want to do this:
>
> z1<-subset(F[,1], F[,1] >= 5 & F[,1] <= 10) .
> .
> .
> z189<-subset(F[,189], F[,189] >= 5 & F[,189] <= 10)
>
> I would prefer to have an empty matrix, say 'z' in order to fill its columns
> with the output of subsetting F. But each of the subsets can differ in
> length. It's to say:
>
> length(z1)
> 1189
>
> length(z2)
> 1238
>
> Don't know how to set up this with a for loop or the use of apply:
>
> z<-189
> for (i in 1:189)
> {z[i]<-subset(F.zoo[,i], F.zoo[,i] >= 5 & z1 <= 10)}
>
> Error in z[i] <- subset(F.zoo[, i], F.zoo[, i] >= 5 & z1 <= 10) :
>         nothing to replace with
>
> or
>
> z<-matrix(0,6575,189)
> for (i in 1:189)
> {z[i]<-subset(F.zoo[,i], F.zoo[,i] >= 5 & z1 <= 10)}
>
> new error
>
>
> Thanks,
>
> Antonio
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
>
>
>



More information about the R-help mailing list