Population data set, k's, M's and dots, I removed for '1799' using this line:
p$'1799' <- str_replace_all(p$'1799', c("(\d+)k" = "\1000", "(\d+)M" = "\1000000","(\d+)\." = "" ))
How to I iterate over the other years?
I was thinking for-loop, but it does not work:
p_new <- p
for(i in 2:ncol(p_new)) {
p_new[ , i] <- str_replace_all(p_new[ , i], c("(\d+)k" = "\1000", "(\d+)M" = "\1000000","(\d+)\." = "" ))
}
p_new
I have to do this before pivoting the dataset.
All suggestions are welcome.