-1

2016-11-02 09:38:53, 22822, 33067, 6.79, Abc, Cedfgh Pqrst 12Abc

I want to read the above-given data into 5 columns of the data frame. The Last column i.e column 5 can have delimiter character but it should be ignored and consider as one whole string in R.

Hence to put in R terms:

data.frame(Var1 = "2016-11-02 09:38:53", Var2 = "22822", Var3 = "33067", Var4 = "6.79", Var5 = "Abc, Cedfgh Pqrst 12Abc")
zx8754
  • 52,746
  • 12
  • 114
  • 209
rishm.msc
  • 361
  • 5
  • 16
  • how do you want the read in data frame to look? – Nate Nov 05 '16 at 20:24
  • 1
    Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – zx8754 Nov 05 '16 at 20:25
  • @NathanDay - I want the output in the above-given "data.frame" output. File is stored in CSV format and it has 5 columns but one of the rows has more than six delimiter character hence I want to "paste" the extraneous delimiter characters columns into a single column – rishm.msc Nov 05 '16 at 20:28
  • 1
    `tidyr::separate` is for exactly this purpose if the problem is that the line is in a single column of a `data.frame` – Akhil Nair Nov 05 '16 at 21:43

1 Answers1

1

just read it as 6 columns and then do:

df$var5 <- paste(df$var5, ",", "df$var6")

You'll get the data.frame as you've shown in expected output.

vagabond
  • 3,526
  • 5
  • 43
  • 76