I have a data frame with a numerical ID variable which identify the Primary, Secondary and Ultimate Sampling Units from a multistage sampling scheme. I want to split the origina
You could use for example use substring:
substring
df <- data.frame(ID = c(501901, 501902)) splitted <- t(sapply(df$ID, function(x) substring(x, first=c(1,2,4), last=c(1,3,6)))) cbind(df, splitted) # ID 1 2 3 #1 501901 5 01 901 #2 501902 5 01 902