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:
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.
Also, for reference, these are all the libraries I have loaded:
Thank you!!
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.