My character object looks like this:
"ID,MONTH_ID,FLAG\n70,201001,1\n71,201001,1\n94,201001,1\n95,201001,1\n102,201001,
1\n110,201001,1\n124,201001,1"
I want to convert it to data frame with every \n
a new row should be created.
Can someone please help me in this?
try :
x <- "ID,MONTH_ID,FLAG\n70,201001,1\n71,201001,1\n94,201001,1\n95,201001,1\n102,201001,1\n110,201001,1\n124,201001,1"
df <- read.table(text = x, sep =",", header = TRUE, stringsAsFactors = FALSE)
which gives:
ID MONTH_ID FLAG
1 70 201001 1
2 71 201001 1
3 94 201001 1
4 95 201001 1
5 102 201001 1
6 110 201001 1
7 124 201001 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With