Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在r中读取头带有逗号的csv文件_R_Excel_Csv - Fatal编程技术网

在r中读取头带有逗号的csv文件

在r中读取头带有逗号的csv文件,r,excel,csv,R,Excel,Csv,在excel中打开csv时,可以看到用逗号分隔的列名 e、 g 当我在R中读取这种类型的文件时,它将其读取为 rabbit..8am.carrot fox...12am..fish.salmon.. 1 2 4 4 2 3

在excel中打开csv时,可以看到用逗号分隔的列名 e、 g

当我在R中读取这种类型的文件时,它将其读取为

 rabbit..8am.carrot          fox...12am..fish.salmon..
            1                            2
            4                            4
            2                            3
            .                            .
            .                            .
            .                            .

有没有办法读取文件,这样我就可以拿回通讯录了。我试图通过在逗号上拆分来从列名中生成变量。

使用
read.table
时设置
check.names=FALSE
。请参见
?读取表格

> foo <- read.table(text="rabbit,8am,carrot          fox,12am,fish(salmon)
              1                            2
              4                            4", header=TRUE, check.names = FALSE)
> foo
  rabbit,8am,carrot fox,12am,fish(salmon)
1                 1                     2
2                 4                     4
>foo-foo
兔子,早上8点,胡萝卜狐狸,早上12点,鱼(鲑鱼)
1                 1                     2
2                 4                     4

我收到一个错误,说currfile我在谷歌上搜索了错误的答案,需要将fill=TRUE,sep=“,”添加到您的解决方案中。谢谢,这解决了我的问题!
> foo <- read.table(text="rabbit,8am,carrot          fox,12am,fish(salmon)
              1                            2
              4                            4", header=TRUE, check.names = FALSE)
> foo
  rabbit,8am,carrot fox,12am,fish(salmon)
1                 1                     2
2                 4                     4