How to read a .csv file containing apostrophes into R?

前端 未结 3 739
故里飘歌
故里飘歌 2021-02-06 22:51

I am having difficulty getting R to read a .txt or .csv file that contains apostrophes.

Some of my columns contain descriptive text, such as \"Attends to customers\' n

3条回答
  •  误落风尘
    2021-02-06 22:59

    Thoroughly studying the options in ?read.table will pay off in the long run. The default values for quoting characters is quote = "\"'", which is really only two characters after R parses that expression, single-quote and double-quote. You can remove them both from consideration using quotes=NA. It's sometimes necessary to also remove the 'comment.char' defaulting to "#", and it may be helpful to change 'as.is' to TRUE to prevent strings from getting converted to factors.

提交回复
热议问题