[R] Loop over several Variables, add on question

Bert Gunter gunter.berton at gene.com
Fri Nov 2 14:50:12 CET 2012


Inline.

On Fri, Nov 2, 2012 at 5:34 AM, bchr <bochristoph at web.de> wrote:
> 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).

Your claim is bogus. This is a very foolish strategy for "learning" R.
Go through the Introduction to R tutorial now, and you will save
yourself a lot of time and grief. Your confusion and wasted efforts
are caused by incorrect expectations about how R works, which is
**not** like the other software you mention.

To quote Rolf Turner on this list:

"
(1) Learn something about R; don't just hammer and hope.  Read the
introductory manuals and scan the FAQ.."

Cheers,
Bert

  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. (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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm




More information about the R-help mailing list