Here i have a variable MyVar <- data.frame(read.csv("D:\\Doc.csv")) And now i am storing this variable name into a list. MyList <- list() MyList [length(MyList )+1]<- "MyVar" Now what is the requirement is, i need to call the variable name "MyVar" from the list "MyList " and get the data. ------------------------------------------------------------------------------------------------------------------------ i tried with get(MyList [1]). - it not work-out. Can you please help me ? - Thanks in advance Antony. -- View this message in context: http://r.789695.n4.nabble.com/Get-variable-data-Reading-from-the-list-tp4641559.html Sent from the R help mailing list archive at Nabble.com.
Hello, And this: get(MyList[[1]]) with [[ ]] instead of [ ] ? If you do for example: MyList <- list() MyList [length(MyList )+1]<- "MyVar" MyVar <- c(1:10) get(MyList[[1]]) It seems to do what you want -- View this message in context: http://r.789695.n4.nabble.com/Get-variable-data-Reading-from-the-list-tp4641559p4641563.html Sent from the R help mailing list archive at Nabble.com.
Thank you. From: arun kirshna [via R] [mailto:ml-node+s789695n4641565h53@n4.nabble.com] Sent: Tuesday, August 28, 2012 7:25 PM To: Akkara, Antony (GE Energy, Non-GE) Subject: Re: Get variable data Reading from the list Hi, MyList<-list() MyList[["MyVar"]]<-c(1:10) MyList[[1]] # [1] 1 2 3 4 5 6 7 8 9 10 A.K. ________________________________ If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Get-variable-data-Reading-from-the-list-tp 4641559p4641565.html To unsubscribe from Get variable data Reading from the list, click here <http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib e_by_code&node=4641559&code=YW50b255LmFra2FyYUBnZS5jb218NDY0MTU1OXwxNTUx OTQzMDI5> . NAML <http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view er&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.Bas icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem plate.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml -instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai l.naml> -- View this message in context: http://r.789695.n4.nabble.com/Get-variable-data-Reading-from-the-list-tp4641559p4641566.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
On Tue, Aug 28, 2012 at 8:19 AM, Rantony <antony.akkara at ge.com> wrote:> Here i have a variable > > MyVar <- data.frame(read.csv("D:\\Doc.csv"))read.csv() returns a data.frame so the outer call to data.frame() is superfluous.> > And now i am storing this variable name into a list. > > MyList <- list() > MyList [length(MyList )+1]<- "MyVar" > > Now what is the requirement is, > i need to call the variable name "MyVar" from the list "MyList " and get > the data. > ------------------------------------------------------------------------------------------------------------------------ > i tried with get(MyList [1]). - it not work-out.Close: You want get(MyList)[1] which gets the variable "MyList" -- else you are telling R to look for something called "MyList[1]" which is a rare, but not actually impossible object name. As before, you really don't want to be using get() and assign() for this sort of stuff though. Please do try to do things the idiomatic way: it'll be easier in the long run : I promise. Cheers, Michael> > Can you please help me ? > > - Thanks in advance > Antony. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Get-variable-data-Reading-from-the-list-tp4641559.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.