Thanks a lot - extremely heplful!
While I'll definitely try to use merge in the future, in my situation
I run into problems with memory (files are too large).
However, Phil's suggestion is perfect for me - sped me up considerably!
Thank you, again!
Dimitri
On Mon, Nov 8, 2010 at 2:51 PM, Phil Spec
Dimitri -
While merge is most likely the fastest way to solve
your problem, I just want to point out that you can use
a named vector as a lookup table. For your example:
categories = my.lookup$category
names(categories) = my.lookup$names
creates the lookup table, and
my.df$category = catego
Try this:
merge(my.df, my.lookup)
On Mon, Nov 8, 2010 at 5:43 PM, Dimitri Liakhovitski <
dimitri.liakhovit...@gmail.com> wrote:
> Hello!
> Hope there is a nifty way to speed up my code by avoiding loops.
> My task is simple - analogous to the vlookup formula in Excel. Here is
> how I programmed
Hello!
Hope there is a nifty way to speed up my code by avoiding loops.
My task is simple - analogous to the vlookup formula in Excel. Here is
how I programmed it:
# My example data frame:
set.seed(1245)
my.df<-data.frame(names=rep(letters[1:3],3),value=round(rnorm(9,mean=20,sd=5),0))
my.df<-my.df
4 matches
Mail list logo