[R] formatting a list

Tomas Vaisar tvaisar at u.washington.edu
Sun Oct 21 23:40:44 CEST 2007


The data I have is tab delimited file with 7000 lines of 19 values each 
(representing 7000 permutations on 19 variables). I want to get it into 
the ROCR package which expects the data to be in lists - single list of 
19 values for each permutation, e.g. list of 7000 lists of 19 values each.

I hope this is little clearer.

Tomas

jim holtman wrote:
> What is it that you want to do?  The 'scan' statement give you a list
> of length 7000 with 19 entries each.  Do you want to create a matrix
> that has 7000 rows by 19 columns?  If so, then you just have to take
> the output of the 'scan' and do:
>
> x.matrix <- do.call('rbind', x)  # gives 7000 x 19 matrix.
>
> So I am still not sure exactly what your input is and what you want to
> do with it.
>
> On 10/21/07, Tomas Vaisar <tvaisar at u.washington.edu> wrote:
>   
>> Hi Jim,
>>
>> thanks a lot.  It works, however - my other problem is that I need to
>> transpose the original table before reading it into the list because the
>> data come from Excel and it can't handle 7000 columns.  I could read it
>> in R transpose end write into a new tab delim file and then read it back
>> in,  but I would think that there might be a way in R to do both.
>> Would you know about the way?
>>
>> Tomas
>>
>> jim holtman wrote:
>>     
>>> another choice is:
>>>
>>> x <- scan('temp.txt', what=c(rep(list(0), 19)))
>>>
>>> On 10/20/07, Tomas Vaisar <tvaisar at u.washington.edu> wrote:
>>>
>>>       
>>>> Hi,
>>>>
>>>> I am new to R and need to read in a file with 19 columns and 7000 rows
>>>> and make it into a list of 7000 lists with 19 items each.  For a
>>>> simpler case of 10 by 10 table I used x <-scan("file",
>>>> list(0,0,0,0,0,0,0,0,0,0)), perhaps clumsy, but it did the job.
>>>> However with the large 19x7000 (which needs to be transposed) I am not
>>>> sure how to go about it.
>>>>
>>>> Coudl somebody suggest a way?
>>>>
>>>> Thanks,
>>>>
>>>> Tomas
>>>>
>>>> ______________________________________________
>>>> 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