I am dealing with big data and I would like to replace column values by grep.
Here is a simple example:
data=data.frame(state=c("AlAbama","Alaaska","Arizoona"),
gender=c("male","female","female"))
datalist=data.frame(state=c("Alabama","Alaska","Arizona"))
In the data called "data", I have the states names written in a wrong way and I would like to replace them by the write names in datalist. So I would like to replace column values in "data" with column values in "datalist" using grep.
I have tried this:
data[grep(data[,"state"],datalist[,"state"])]
And this:
for (u in datalist$state){
data[grep(u,datalist$state)]
}
But it doesn't work.
Do you have any ideas how to solve this problem?
Sincerely yours, Mily