Hello, In R you just need to take the log of the whole whole data.frame where you have your pci* and store in a new variable. You do not need to use a "for" loop:
log.df <- log(your_data_frame) Regards, Carlos Ortega www.qualityexcellence.es On Sun, Oct 9, 2011 at 5:34 PM, deepankar <db...@econs.umass.edu> wrote: > Hi All, > > This is surely an easy question but somehow I am not being able to get it. > > I am using R 2.13.2 and have a data set where variable names like this > appear: > > pci1990, pci1991, ... , pci2009. > > "pci1990" has data on per capita income for 1990, "pci1991" has data on per > capita income for 1991, and so on. > > I would like to create the logarithm of per capita for each of the year and > could do so in STATA with the following commands: > > forvalues number = 1990/2009 { > gen lpci`number' = log(pci`number') > } > > What would be the corresponding set of commands in R? > > Thanks a lot in advance. > > Deepankar > > ______________________________**________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > [[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.