这可以在tidyr软件包的帮助下完成。
> library(tidyr) > data = data.frame(attr = c(1,5,12,17), type=c('class_and_memory','class_and_memory_2')) > data %>% + separate(type, c("class", "memory"), "_and_") attr class memory 1 1 class memory 2 5 class memory_2 3 12 class memory 4 17 class memory_2