[R] Loop over several Variables, add on question

John Kane jrkrideau at inbox.com
Fri Nov 2 15:30:02 CET 2012


In Line

John Kane
Kingston ON Canada


> -----Original Message-----
> From: bochristoph at web.de
> Sent: Fri, 2 Nov 2012 05:34:48 -0700 (PDT)
> To: r-help at r-project.org
> Subject: Re: [R] Loop over several Variables, add on question
> 
> Hey Petr,
> 
> thanks for answering. First to your question: I use rename from the
> reshape
> package.
> You are probably right to assume that I do not  have a to extensive
> reading
> background in R - basically I had to dive right in (which probably isn't
> a
> good idea, but I could not change that).  Having a solid background in
> other
> statistics packages (stata, SPSS) I now find myself putting quite a lot
> of
> effort into presumably easy to do things like recoding, merging, looping
> etc. 

A solid background is SAS, & SPSS is a disadvantage in using R. I assume that the same applies for Stata.  

 Google for "R for sas and spss users pdf" and read Bob's short comparison of the differences to look out for.  An even better alternative but which may take longer is to get his book. http://onlinelibrary.wiley.com/doi/10.1111/j.1751-5823.2012.00179_24.x/abstract .

Moving from the older stats packages to R is often mindrwrenching.  After Bob's book you probably need to at least skim "Introduction to R" .

>(I really dont want to mention how long it took me to get that
> recode
> done in the first place ...). So in any case I am sorry if I am bothering
> you with somewhat strange problems...
> 
> Nevertehless even though your proposed solution did work 'as is' it did
> not
> when I remodelled it to my data
> vec<-paste0("y", 1:5)
> ti[grep("y",vec)]<- paste0("tiy", 1:5)
> It did produce no error message but the variable names did not change.
> Could
> the problem be that ti in my case is not a vector but a dataframe (the
> y's
> being variables in that dataframe?)
> 
> All the best
> 
> Bernhard
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Loop-over-several-Variables-add-on-question-tp4648216p4648225.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.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!




More information about the R-help mailing list