[R] 'for' loop, two variables

2008-07-29 Thread Oehler, Friderike (AGPP)
Dear Rusers, I am still an unexperienced builder of functions and loops, so my question is very basic: Is it possible to introduce a second variable (j) into my loop. To examplify: # This works fine: fn - function (x) {if (x46 x52) 1 else 0} res -NULL for (i in 40:60) res -c(res,fn(i)) res

[R] rm(l*)

2008-07-14 Thread Oehler, Friderike (AGPP)
Dear Rusers, how can I designate various objects the names of which start (or end) with the same letter to remove them all together? For instance: ls() a,b,c,l1,l2,x rm(list=ls(l*)) ls() a,b,c,x Is there some parallel to the MySQL query: where col1 like l% Thanks a lot in advance, Friderike

[R] aggregate months to years

2008-07-14 Thread Oehler, Friderike (AGPP)
Many thanks for the recent answers to my question about pattern recognition. The hint to grep and the pattern argument brought me a big deal forward. # Now, I have a data frame: DATE - c(1930-01-01, 1930-01-01, 1930-02-01, 1931-01-01, 1931-02-01, 1931-03-01) # almost all months until 1999-12-01.