R how to read a .csv file with different separators

19,673

Read a csv with read.csv(). You can specify sep="" to be whatever you need it to be. But as noted below, , is the default value for the separator.

R: Data Input

For example, csv file with comma as separator to a dataframe, manually choosing the file:

df <- read.csv(file.choose())

Share:
19,673
Buzz Lightyear
Author by

Buzz Lightyear

Updated on June 05, 2022

Comments

  • Buzz Lightyear
    Buzz Lightyear almost 2 years
    ItemID,Sentiment,SentimentSource,SentimentText
    
    1,0,Sentiment140,     ok thats it you win.
    
    2,0,Sentiment140,    i think mi bf is cheating on me!!!       T_T
    
    3,0,Sentiment140,"    I'm completely useless rt now. Funny, all I can do is twitter. "
    

    How would you read a csv file like this into R?

  • G. Grothendieck
    G. Grothendieck about 10 years
    header=TRUE, sep = "," are the default for read.csv so they need not be specified.