I have a dataset of schools, and I want to take out the prefix in front of the schools so it just has the school name (and sometimes a number). The prefix is is also listed in another column (tipo.organización), and so I want to take the value from tipo.organización and remove it from the name of the school (nombre.establecimiento).
I tried using gsub to remove part of the string from the name, but I couldn't just pass in the column name as a set of values to change. How could I get it to go through each value and compare to the tipo.organizacion column, and then delete what is not necessary?
data <- read.csv("...", header = TRUE)
data$nombre.establecimiento <-
as.character(data$nombre.establecimiento)
#Remove Duplicates
new <- data[!duplicated(data$nombre.establecimiento),]
#tried to take out values from other column
new$nombre.establecimiento <- gsub(new$tipo.organización, '',
new$nombre.establecimiento)
Thank you!!