-2

I have an excel sheet with one column being a long list ranging from about 201-960. In a second column I have that list categorized where 1-6 values of the list are put into a category.

Secondly, I have a large dataset in excel (12,000+ column length) where a row has a value from the first column, but I would like to apply the category to this dataset. I am aware of the IF() function in excel, but my dataset is too large to use this method.

Any feedback is greatly appreciated. Thanks.

Dataset

Categories

ScoMo
  • 1
  • Hi there and welcome to SO. Please give us some context to your question. Take a look at https://stackoverflow.com/help/how-to-ask for hints. It's a good start to give some data, make a https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and give an example of your desired output. And data as screenshots... well...https://xkcd.com/2116/ – Martin Gal May 19 '20 at 21:08
  • Maybe `match(Dataset$col, Categories$col)`. This will work if the values in the `Dataset`'s column are all in the `Categories`' column. – Rui Barradas May 19 '20 at 21:20

1 Answers1

1

I suppose, you want to merge two data.frames using a given column. I made a small example:

dt1 <- data.frame(Strat=1:5, StratDesc=c("a", "b", "c", "d", "e"))
dt2 <- data.frame(x=rnorm(5), y=rnorm(5), Strat=1:5)

merge(dt2, dt1, by=c("Strat"))
Martin Gal
  • 16,640
  • 5
  • 21
  • 39