I have a dataframe of about 81,000 rows. They all contain a vector with the following data
0193,02394,2093,Alabama,Alabama,23094,23193,24311,24411
I'm trying to get a table with all the 81,000 rows separated into three columns containing the names and the last number. each row will look like this:
Alabama | Alabama | 24411
So far, my code looks like this:
pop.dat <- data.frame()
for (i in 1:nrow(pop.data)){
pop.dat <- rbind(pop.dat, t(data.frame(data.frame(strsplit(as.character(pop.data[i,]), ','))[c(7:8, 13),])))
}
It works well, but it is way too slow! Can anyone help me speed it up? Maybe use an apply function or something.