0

I am new to R so, apologies if this question is trivial.

I'm trying to make a new column with the three categories (EUplus, americas and other) from one column "location" that has over thousands of values.

I am working with a tibble that I created from twitter data. So, the original column name is "location"

This is what the tibble looks like: enter image description here

And this is the code I have so far: The lists I made are the value names I want... and the values from the original column that I want to extract.

The two mutate lines of code are the ones I am having trouble with. enter image description here

Also, for reference, these are all the libraries I have loaded: enter image description here

Thank you!!

sabrina
  • 13
  • 3
  • Could you refer to [this post](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making a reproducible example, and edit your post accordingly? – Desmond Jun 02 '22 at 02:48

1 Answers1

0

This is untested but you could try

mutate(Standpoint = if_else(location %in% EUplus, 'EUplus', 
                            if_else(location %in% americas, 'Americas',
                                    if_else(location %in% other, 'Other', 0)))) %>%
  filter(Standpoint != 0)