I can't read in data to R

后端 未结 3 751
猫巷女王i
猫巷女王i 2021-01-07 07:32

I am trying to read in some data that is is a text file that looks like this:

2009-08-09 - 2009-08-15 0   2   0
2009-08-16 - 2009-08-22 0   1   0
2009-08-23          


        
3条回答
  •  孤街浪徒
    2021-01-07 08:11

    The file you are reading is probably using some encoding other than ASCII. ?read.table shows

     read.table(file, header = FALSE, sep = "", quote = "\"'",
                ... 
                fileEncoding = "", encoding = "unknown")
    
    fileEncoding: character string: if non-empty declares the encoding used
              on a file (not a connection) so the character data can be
              re-encoded.  See 'file'. 
    

    So perhaps try setting the fileEncoding parameter. If you don't know the encoding, perhaps try "utf-8" or "cp-1252". If that does not work, then if you pastebin a snippet of your actual file, we may be able to identify the encoding.

提交回复
热议问题