strsplit
is not required here. read.table
should work fine. Try:
read.table(text = as.character(Data$X), header=FALSE, fill=TRUE)
You will have to rename the resulting variable names though.
Question
I have following data
Data <- data.frame(
X = ("123 234 345 456","222 333 444 555 666" )
)
Data
# X
# 123 234 345 456
# 222 333 444 555 666
A String in one cell, and the length of string is not same in each row
I want the following result
>Result
# X Y Z A B
# 123 234 345 456
# 222 333 444 555 666
one word in one cell
Can anybody help?
Solution
strsplit
is not required here. read.table
should work fine. Try:
read.table(text = as.character(Data$X), header=FALSE, fill=TRUE)
You will have to rename the resulting variable names though.