[R] How to select a subset <number of dimensions matter>
mailinglist.honeypot at gmail.com
Fri Oct 2 16:56:03 CEST 2009
On Oct 2, 2009, at 10:47 AM, Hyo Lee wrote:
> Hi guys,
> I need your help.
> I would like to select a subset from a dataset.
> This is the dimension of the dataset.
>  72 36 1916
> so, it's like.. there are 1916 of 72 * 36 matrix. ==> looks like 72
> * (
> 36*1916 )
> And I would like to select the first 72*36 matrix. This is how I did:
> Error in data1[, 1:36] : incorrect number of dimensions
You have an object with three dimensions, but only passing in two dims
to "slice" with.
> Do you have any idea how I should fix this?
This is a similar array : think of it as 5 10x2 matrices
R> m <- array(1:100, dim=c(10,2,5))
I can get the first 10x2 matrix like so:
[1,] 1 11
[2,] 2 12
[3,] 3 13
[4,] 4 14
[5,] 5 15
[6,] 6 16
[7,] 7 17
[8,] 8 18
[9,] 9 19
[10,] 10 20
The second would be: m[,,2]
Does answering the first question take care of the rest?
> *2) *I thought about another way to deal with this problem.
> Firstly, I name the each column variable:
> and then select:
>> one=subset(data1,subset=TRUE, select = lati1:lati36)
> but the problem is that, although I tried to select only 36 columns,
> command selects the all columns. (36*1916 =68976)
> I think if I can name all the variables at one time, say ,
> colnames(data1)=paste('lati',1:68976) ,then it wouldn't have been a
> (but obviously, <---this command does not work)
> Do you have any idea how to deal with this??
> *3)* After all, what I would really like to do is to transpose the
> The dataset I have above is 72*68976. (hard to export to csv; since
> column# is 18000 something.)
> I have to transpose the data.. obviously.
> But, the problem is, after I transpose the data and export it to
> csv, I
> can't really see the data.
> Besides, I think tranpose thing does not seem work as I want,
> Please help me,
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help