I have a variable "PULocation" which is a set of integers from 1 to 265. Each number represents a unique location in new York city. Then each location is located in one of the boroughs "Bronx", "Brooklyn", "ERW", "Manhattan", "Queens", "Staten Island", or "Unknown". In my dataset, I only have the PULocation variable defined by integers and I have separate information to know what each integer represents. I want to create a separate variable that defines the borough rather than the specific location, the issue is the integers are not organized by borough, they are scattered. Ive included the mapping below to show what I'm trying to explain.
I've tried this cab_sample$PUBorough <- ifelse(cab_sample$PULocationID == c(3,18,20,31,32,46,47,51,58,59,60,78, 81,94,119,126,136,147,159,167,168,169, 174,182,183,184,185,199,200,208,212,213, 220,235,240,241,242,247,248,250,254,259), "Bronx","NOTHING") But i get this error message back
Warning message: In cab_sample$PULocationID == c(3, 18, 20, 31, 32, 46, 47, 51, 58, : longer object length is not a multiple of shorter object length
Is there a way to do this maping?
This is the mapping of each integer
