Re: [R] Loop over several Variables, add on question

2012-11-02 Thread bchr
Hey John, thanks for making me notice that document - I just skipped over it the past hour and I think I like that very condensed If you want to do this ->it works like that approach. Besides that I had the impression, though that it's content - while more strongly condensed - is basically not too

Re: [R] Loop over several Variables, add on question

2012-11-02 Thread John Kane
In Line John Kane Kingston ON Canada > -Original Message- > From: bochrist...@web.de > Sent: Fri, 2 Nov 2012 05:34:48 -0700 (PDT) > To: r-help@r-project.org > Subject: Re: [R] Loop over several Variables, add on question > > Hey Petr, > > thanks for answer

Re: [R] Loop over several Variables, add on question

2012-11-02 Thread bchr
Thanks very much Petr, that one did just fine! I just wanted to say that it's not that I did no reading at all (in fact I use a book called R for Stata users by Muenchen/Hilbe and another German book called Programming in R when you translate the title) - so yes I am aware that R works quite diff

Re: [R] Loop over several Variables, add on question

2012-11-02 Thread PIKAL Petr
g > 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 -

Re: [R] Loop over several Variables, add on question

2012-11-02 Thread Bert Gunter
Inline. On Fri, Nov 2, 2012 at 5:34 AM, bchr 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 prob

Re: [R] Loop over several Variables, add on question

2012-11-02 Thread bchr
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 s

Re: [R] Loop over several Variables, add on question

2012-11-02 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of bchr > Sent: Friday, November 02, 2012 11:57 AM > To: r-help@r-project.org > Subject: [R] Loop over several Variables, add on question > > Hey ev

[R] Loop over several Variables, add on question

2012-11-02 Thread bchr
Hey everyone, I have again a loop question: After generating the dataset using Jan’s approach from my previous posting (http://r.789695.n4.nabble.com/Loop-over-several-variables-td4648112.html) I want to rename the Variables in the new dataset so that all y will be called tiy. Doing it separately

Re: [R] Loop over several variables

2012-11-01 Thread bchr
Oh hey Jan, sorry, I just saw I did not read correctly and mistook your quote of Don's mail as a signature. So thank's to you for the second posting Bernhard -- View this message in context: http://r.789695.n4.nabble.com/Loop-over-several-variables-tp4648112p4648132.html Sent from the R help

Re: [R] Loop over several variables

2012-11-01 Thread bchr
Hey Don, I just saw your second post ... that's even better! Thanks again Bernhard -- View this message in context: http://r.789695.n4.nabble.com/Loop-over-several-variables-tp4648112p4648131.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Loop over several variables

2012-11-01 Thread bchr
Hey Don, many thanks, I tried that and it works just fine. I have two questions though: 1. In Addition to generating the t1-t5 (I have five iterations, in fact), the code will generate an additional ti(without subscript), which seems to be a copy of ti5. Is that what it should do ( and if yes, wh

Re: [R] Loop over several variables

2012-11-01 Thread Jan van der Laan
Or ti <- aggregate(dataframename[paste0("y", 1:3)], by=dataframename["aggregationvar"], sum,na.rm=TRUE) which gives you all results in one data.frame. Jan "MacQueen, Don" schreef: Many ways. Here is one: ### supposing you have y1, y2, and y3 in your data frame for (i in

Re: [R] Loop over several variables

2012-11-01 Thread MacQueen, Don
Many ways. Here is one: ### supposing you have y1, y2, and y3 in your data frame for (i in 1:3) { yi <- paste('y',i,sep='') ti <- aggregate(dataframename[[yi]], by=data.frame(dataframename$aggregationvar), sum,na.rm=TRUE) assign( paste('ti',i,sep='') , ti, '.GlobalE

[R] Loop over several variables

2012-11-01 Thread bchr
Hey everybody, I am looking for a way to loop commands over several variables in a dataframe. Basically I want to do something like this: ti1<-aggregate(dataframename$y1, by=data.frame(dataframename$aggregationvar), sum,na.rm=TRUE) This works fine as it is but i wan