Perhaps I want to make this impossible, so I asked this question to find out if there is a way or not. After reading this question here in stackoverflow, I saw that there is a way to split the column in different columns, but this is not what I wanted, I have a brilliant application where I can have tables with values ββsuch as:
Phones price
Nokia 1234D - J298 6732 - LM 2 103$
Samsung 3342L - J2YY 4372 - YU 3 130$
Samsung 3042X - IKAA 3221 - GN 4 102$
So, the user comes and says that I want to separate these values ββin the Phones column as I want, so the idea that came to my mind was for the user to write something like ("," - "," " , "-"), because I mean separate nokia, 1234D, J298, 6732, LM2 in 5 columns with the specified delimiters.
Here is a sample code:
library(stringr)
c=c(" "," - "," "," - ")
mytable <-data.table(Phones=c("Nokia 1234D - J298 6732 - LM 2",
"Samsung 3342L - J2YY 4372 - YU 3",
"Samsung 3042X - IKAA 3221 - GN 4"),price= c("103$", "130$", "102$") )
aux = str_split_fixed(mytable$Phones, c, 5)
mytable<-data.table( aux, mytable$price)
But I get the following result, which is not what I want it to separate on my own, duplicates the first line:
V1 V2 V3 V4 V5 V2
1: Nokia 1234D - J298 6732 - LM 2 103$
2: Samsung 3342L J2YY 4372 YU 3 130$
3: Samsung 3042X - IKAA 3221 - GN 4 102$
4: Nokia 1234D J298 6732 LM 2 103$
If you have a better solution, this will be very helpful.