How to split a string column into multiple columns in R?
https://www.tutorialspoint.com/how-to-split-a-string-column-into-multiple-columns-in-r
-
13-09-2020 - |
Question
How to split a string column into multiple columns in R?
This can be done with the help of tidyr package.
Example
> 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
Advertisements
Non affilié à Tutorialspoint