Skip to content
Prev 140196 / 398506 Next

vlookup in R

# Setup the translation map
transMap <- c(A="R", B="R", C="R", D="B", F="B");

# The input data
v3 <- c("A", "C", "D", "F", "A", "C", "B", "B", "B", "B", "A", "D");

# The translated data
v4 <- transMap[v3];

df2 <- data.frame(V3=v3, V4=v4);

I recommend you to read 'An Introduction to R' that comes with any R
installation.  There is a lot of useful stuff in there; it takes many
reads to grasp parts of it but it is worth it if you're going to use R
for more than, say, two weeks. You can find it via help.start().

/Henrik
On Mon, Mar 24, 2008 at 8:25 AM, Sachin J <sachinj.2006 at yahoo.com> wrote: