I have a large csv file that I have been trying to edit. I have been trying to create a new column titled race. There is currently a column called derived_race that has multiple races in it including White, Black or African American, Asian, joint, etc. I need to get the derived_race category down to White, Black, and Other. I have tried to use mutate to add another column, and the code that I used looked like this:
mutate(selected_public_2018_lar,Race = if (derived_race == 'White'){
print("White")
} else if (derived_race == 'Black or African American'){
print("Black")
}else {
print("Other")
})
I keep getting an error that looks like this:
Error: Problem with mutate()
input ..1
.
x Input ..1
can't be recycled to size 2316993.
ℹ Input ..1
is selected_public_2018_lar
.
ℹ Input ..1
must be size 2316993 or 1, not 179666.
Thanks in advance for any help!