[R] array dimension changes with assignment

Duncan Murdoch murdoch at stats.uwo.ca
Tue May 13 16:31:28 CEST 2008


On 5/13/2008 12:47 AM, Knut M. Wittkowski wrote:
> Why does the assignment of a 3178x93 object to 
> another 3178x93 object remove the dimension attribute?

Your example is not reproducible.  When I make one that is reproducible, 
I don't see the error:

 > GT <- array(dim = c(6,3178,93))
 > dim(GT)
[1]    6 3178   93
 > GT[1,,] <- array(dim=c(3178,93))
 > dim(GT)
[1]    6 3178   93

(This was done in R 2.7.0.)

So I'd suggest that you try to make the example reproducible, and you'll 
likely discover that something else you did caused the loss of dimension.

Duncan Murdoch

> 
>  > GT <- array(dim = c(6,nrow(InData),ncol(InSNPs)))
>  > dim(GT)
> [1]    6 3178   93
> 
>  > SNP1 <- InSNPs[InData[,"C1"],]
>  > dim(SNP1)
> [1] 3178   93
> 
>  > SNP2 <- InSNPs[InData[,"C2"],]
>  > dim(SNP2)
> [1] 3178   93
> 
>  > dim(pmin(SNP1,SNP2))
> [1] 3178   93
> 
>  > GT[1,,] <- pmin(SNP1,SNP2)
>  > dim(GT)
> NULL    # why??????????????????????????????????????
> 
>  > GT[2,,] <- pmax(SNP1,SNP2)
> Error in GT[2, , ] <- pmax(SNP1, SNP2) : incorrect number of subscripts
> 
> 
> Knut M. Wittkowski, PhD,DSc
> ----------------------------------------------------
> Sr Research Associate,    The Rockefeller University
> Biometrician,    The Rockefeller University Hospital
> Director, Biostatistics/Epidemiology/Research Design
> Center for Clinical and Translational Science (CCTS)
> apl. Professor,  Eberhard-Karls-University, Tübingen
> 1230 York Ave #121B, Box 322, New York, NY 10021, US
> Tel: +1 (212) 327-7175,       Fax: +1 (212) 327-8450
> kmw at rockefeller.edu,   www.rockefeller.edu/ccts/rdbs
> 
> 	[[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.



More information about the R-help mailing list