R中的read.csv无法正确读取列名称

IAM*_*bby 5 r

我有一个csv文件,其内容我正在尝试读入R.但是我的列名称没有正确显示,它在第一列的名称中显示了一些奇怪的字符.(请注意,任何情况都是如此)我尝试阅读的csv文件)

请参阅下面的R代码

> mycsvfile = read.csv('C:\\Users\\wdsuser\\Desktop\\mycsvfile.csv')
> mycsvfile
  ï..col1  col2
1   hello world
2   first  last
3     bye   bye
> names(mycsvfile)
[1] "ï..col1" "col2"   
> mycsvfile$col2
[1] world last  bye  
Levels: bye last world
> mycsvfile$col1
NULL
Run Code Online (Sandbox Code Playgroud)

这就是我的文本文件的外观

col1,col2
hello,world
first,last
bye,bye
Run Code Online (Sandbox Code Playgroud)

R版:

> R.version
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          1.2                         
year           2014                        
month          10                          
day            31                          
svn rev        66913                       
language       R                           
version.string R version 3.1.2 (2014-10-31)
nickname       Pumpkin Helmet
Run Code Online (Sandbox Code Playgroud)

Col*_*vel 7

这是编码的问题:

read.csv('C:\\Users\\wdsuser\\Desktop\\mycsvfile.csv', fileEncoding="UTF-8-BOM")
Run Code Online (Sandbox Code Playgroud)

应该管用.