I am incredibly new to R. and am working on a project where it takes the variables of a column are different countries. however, some are spelled differently, or named differently. forexample some variables for "United states" would be "USA", "Ahem....Amerca", "'merica", "USSA" "USAUSAUSA". I want to be able to rename them simply to "United States" as well as only keep variables that are/resemble "United states", "Canada" and "United Kingdom" and omit/delete the entire row completely.
I have been thinking about using multiple if-statements inside a for-loop or using case_when. but im not entirely sure how to actually write the code to do it.
im looking to look through one column with 2460 rows and look for specific words and order of letters and change it to "United States"
CandyData <- #is the dataframe the column is in
for ( row in 1:length(CandyData))
{
if (x == "USA"| "Ahem...Amerca"|"merica"|"USSA"|"USAUSAUSA")
{x = "United States" }
else if
{x.omit }
}
I don't really have any errors because I haven't been able to make it work properly.