Re: [R] help in vectorization

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 12 Jul 2006 - 14:25:32 EST

Try this:

with(merge(dtf, dtf2), data.frame(y, m, inc = inc/def))

On 7/11/06, Dimitri Szerman <dimitrijoe@ipea.gov.br> wrote:
> Hi,
>
> I have two data frames. One is like
>
> > dtf = data.frame(y=c(rep(2002,4), rep(2003,5)),
> + m=c(9:12, 1:5),
> + def=c(.74,.75,.76,.78,.80,.82,.85,.85,.87))
>
> and the other
>
> dtf2 = data.frame(y=rep( c(2002,2003),20),
> m=c(trunc(runif(20,1,5)),trunc(runif(20,9,12))),
> inc=rnorm(40,mean=300,sd=150) )
>
> What I want is to divide dtf2$inc by dtf1$def by the "levels" of y and m
> (inc is income and def is the deflator). Any help in vectorizing this is
> welcome.
>
> Thank you,
> Dimitri



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 12 15:40:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 12 Jul 2006 - 16:17:39 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.