- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
- Related Articles
- How to convert multiple columns into single column in an R data frame?
- How to a split a continuous variable into multiple groups in R?
- How to split a data frame in R into multiple parts randomly?
- How to combine multiple columns into one in R data frame without using column names?
- How to convert first letter of multiple string columns into capital in R data frame?
- How to convert first letter of multiple string columns into capital in data.table object in R?
- How do I split a multi-line string into multiple lines?
- How to convert multiple columns in an R data frame into a single numerical column along with a column having column names as factor?
- Write a program in Python to split the date column into day, month, year in multiple columns of a given dataframe
- How to split a vector into chunks in R?
- How to split a number into digits in R?
- How to find the mean of multiple columns based on a character column in R?
- How to split a long string into a vector of substrings of equal sizes in R?
- Excel tutorial: split text, number, and date cells (separate into multiple columns)
- How to split a data frame by column in R?

Advertisements