Hi Rolf,

My apologies for the inconvenience caused  due to  my reply @ "R-help diges".
Thanks for providing me a clue to solve the problem .

I modify a bit to  populate a list. This is throwing an error
##### Error in `*tmp*`[[j]] : subscript out of bounds" 

myData <- read.table("table.data",
                 header=T,
                 sep="\t",
                 comment.char = "#"
                 );
 inp <- scan("table.data", what=list(comp=" ", A="", B="", C=""));
 n <- c(0:length(inp$comp));
 myList=list();
 for(i in n-1)
 {
    if(i < length(inp$comp))
    {
        j=i+1;
        myList[[j]][1] <-c(as.numeric(myData$A[i]));
        myList[[j]][2] <-c(as.numeric(myData$B[i]));
        myList[[j]][2] <-c(as.numeric(myData$C[i]));
    }

 }
 print(myList);

Any idea where i'm doing a mistake which is causing this error.

Thanks in advance.
 
 regards
Gaurav Kumar

--- On Fri, 10/7/09, Rolf Turner <r.tur...@auckland.ac.nz> wrote:

From: Rolf Turner <r.tur...@auckland.ac.nz>
Subject: Re: [R] How to Populate List
To: "gau...@gauravkumar.org" <gau...@gauravkumar.org>
Cc: "r-help@r-project.org" <r-help@r-project.org>
Date: Friday, 10 July, 2009, 1:39 AM


On 10/07/2009, at 2:55 AM, Gaurav Kumar wrote:

> Hi,
> 
> I'm new to R and would like to know, how one can populate the list with array 
> data.
> I'm reading a tab separated table in R. The data in the table looks something 
> like this.
> 
> #Table Data
> Comp    A    B    C
> Extracellular    103    268    535759
> Nucleus    45603    47783    442744
> 
> #R code
> myData <- read.table("table.data",
>                 header=T,
>                 sep="\t",
>                 comment.char = "#"
>                 );
> inp <- scan("table.data", what=list(comp=" ", A="", B="", C=""));
> n <- c(0:length(inp$comp));
> myList=list();
> for(i in n-1)
> {
>     obj 
><-c(as.numeric(myData$A[i]),as.numeric(myData$B[i]),as.numeric(myData$C[i]));
> 
> }
> 
> Need help to know if there is any function in R to push obj to myList

(a) You apparently ``replied'' to an R-help digest, and included megabytes
of totally irrelevant material in your post.  It took me several minutes to 
delete it.

STEP ONE:  LEARN HOW TO USE EMAIL!!!

(b) Do the following:

myList <- list();
for(i in n-1)
{
    myList[[i]] 
<-c(as.numeric(myData$A[i]),as.numeric(myData$B[i]),as.numeric(myData$C[i]));

}

    cheers,

        Rolf Turner

######################################################################
Attention:This e-mail message is privileged and confidential. If you are not 
theintended recipient please delete the message and notify the sender.Any views 
or opinions presented are solely those of the author.

This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com
######################################################################

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to