Hello, This is very basic and very frustrating. Suppose this:>A=5 >B=5 >C=10> ls()"A" "B" "C" I would like this>xpto()5 5 10 How can I do xpto()? Thanks Rui [[alternative HTML version deleted]]
Hi Rui, how about this sapply(ls(),get) cheers Am 29.04.2013 13:07, schrieb Rui Esteves:> Hello, > > This is very basic and very frustrating. > > Suppose this: >> A=5 >> B=5 >> C=10 > >> ls() > "A" > "B" > "C" > > I would like this >> xpto() > 5 > 5 > 10 > > How can I do xpto()? > > Thanks > Rui > > [[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. >-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
Hi,?res<- unlist(mget(ls())) names(res)<-NULL ?res #[1]? 5? 5 10 A.K. ----- Original Message ----- From: Rui Esteves <ruimaximo at gmail.com> To: r-help at r-project.org Cc: Sent: Monday, April 29, 2013 7:07 AM Subject: [R] How to "call" an object given a string? Hello, This is very basic and very frustrating. Suppose this:>A=5 >B=5 >C=10> ls()"A" "B" "C" I would like this>xpto()5 5 10 How can I do xpto()? Thanks Rui ??? [[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.
This is FAQ 7.21 The most important part of that answer is the last few lines where it says in effect "Don't Do This" and shows the basics of using a list instead. On Mon, Apr 29, 2013 at 5:07 AM, Rui Esteves <ruimaximo@gmail.com> wrote:> Hello, > > This is very basic and very frustrating. > > Suppose this: > >A=5 > >B=5 > >C=10 > > > ls() > "A" > "B" > "C" > > I would like this > >xpto() > 5 > 5 > 10 > > How can I do xpto()? > > Thanks > Rui > > [[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. >-- Gregory (Greg) L. Snow Ph.D. 538280@gmail.com [[alternative HTML version deleted]]