如果我有一个字符串,想要在最后一个数字上分裂, 并保持最后一部分的分割hpw, 我能做到这一点吗?
x <- c("ID", paste0("X", 1:10, state.name[1:10]))
我喜欢
[1] NA "Alabama" "Alaska" "Arizona" "Arkansas"
[6] "California" "Colorado" "Connecticut" "Delaware" "Florida"
[11] "Georgia"
但将满足:
[1] "ID" "Alabama" "Alaska" "Arizona" "Arkansas"
[6] "California" "Colorado" "Connecticut" "Delaware" "Florida"
[11] "Georgia"
我可以通过下列方式获得第一部分:
unlist(strsplit(x, "[^0-9]*$"))
但想要第二部分。
提前感谢您