Re: [R] Dynamic reference, right-hand side of function

2017-12-07 Thread PIKAL Petr
rther analysis and/or manipulation. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Love Bohman > Sent: Tuesday, December 5, 2017 1:23 AM > To: Jeff Newmiller > Cc: r-help@r-project.org; peter dalgaard > Subject: Re: [R]

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread Bert Gunter
0) > > > > datanames <- paste0("bb_", 2000:2002) > > datalist <- lapply(datanames, get) > > is.vector(datalist[1]) > > > > > > I learned a lot of code today, and I really appreciate it! A million > > thanks! > > My R-superpowe

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread William Dunlap via R-help
l, not as minuscule as when I woke up this > morning. > > All the best, > Love (or maybe LoveR, my future superhero name) > > > > -Ursprungligt meddelande- > Från: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] > Skickat: den 5 december 2017 00:01 > Till: L

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread Love Bohman
are, well, not as minuscule as when I woke up this morning. All the best, Love (or maybe LoveR, my future superhero name) -Ursprungligt meddelande- Från: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Skickat: den 5 december 2017 00:01 Till: Love Bohman Kopia: peter dalgaard ; r-help@r-project

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread Jeff Newmiller
g, I'm just struggling to learn a new language and partly a new way of thinking, and I really appreciate the corrections. I hope I someday will be able to handle lists in R as easy as I handle loops in Stata... Thanks again! Love -Ursprungligt meddelande- Fr?n: peter dalgaard [mailto:pd

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread William Dunlap via R-help
), as.vector(eval(as.name(varname > } > > -Ursprungligt meddelande- > Från: peter dalgaard [mailto:pda...@gmail.com] > Skickat: den 4 december 2017 16:39 > Till: Love Bohman > Kopia: r-help@r-project.org > Ämne: Re: [R] Dynamic reference, right-hand side of funct

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread Love Bohman
meddelande- Från: peter dalgaard [mailto:pda...@gmail.com] Skickat: den 4 december 2017 23:09 Till: Love Bohman Kopia: r-help@r-project.org Ämne: Re: [R] Dynamic reference, right-hand side of function Um, if you insist on doing it that way, at least use assign(varname, as.vector(get(varname)))

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread peter dalgaard
000:2007){ > varname <- paste0("aa_",year) > assign(paste0(varname), as.vector(eval(as.name(varname > } > > -Ursprungligt meddelande- > Från: peter dalgaard [mailto:pda...@gmail.com] > Skickat: den 4 december 2017 16:39 > Till: Love Bohman > Kopia:

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread Love Bohman
lp@r-project.org Ämne: Re: [R] Dynamic reference, right-hand side of function The generic rule is that R is not a macro language, so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. datanames <- paste0("aa_&

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread peter dalgaard
The generic rule is that R is not a macro language, so looping of names of things gets awkward. It is usually easier to use compound objects like lists and iterate over them. E.g. datanames <- paste0("aa_", 2000:2007) datalist <- lapply(datanames, get) names(datalist) <- datanames col1 <- lappl

Re: [R] Dynamic reference, right-hand side of function

2017-12-04 Thread Ek Esawi
Hi Love, I am not sure if I understand your question and it will help if you provided a sample data frame, sample of your code and sample of your output and the output you desire. Having said that, I think you could use cbind to join all datasets into a matrix and use the apply family of functions