Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
read.csv跳过列,尽管存在逗号_R - Fatal编程技术网

read.csv跳过列,尽管存在逗号

read.csv跳过列,尽管存在逗号,r,R,V2列为“34°49'00s,58°32'00w”。为什么read.csv会将其合并为一列,而有一个逗号将其分隔为两列 我应该更改什么以使其返回: str = "a,34° 49' 00\" S,58° 32' 00\" W,c,d" read.csv(textConnection(str), header = F) #prints: #V1 V2 V3 V4 #1 a 34° 49' 00 S,58° 32' 00 W c d 因为逗号

V2列为
“34°49'00s,58°32'00w”
。为什么read.csv会将其合并为一列,而有一个逗号将其分隔为两列

我应该更改什么以使其返回:

str = "a,34° 49' 00\" S,58° 32' 00\" W,c,d"  
read.csv(textConnection(str), header = F)
#prints:
#V1                        V2 V3 V4
#1  a 34° 49' 00 S,58° 32' 00 W  c  d

因为逗号被引用了。只需使用
quote=NULL

V1              V2            V3 V4 V5
1  a 34° 49' 00 S  58° 32' 00 W  c   d

字符串中嵌入了引号,只需获取read.csv即可忽略它们:

read.csv(textConnection(str), header = F, quote = NULL)
请注意,
read.csv(text=str,…)
可以用来代替
textConnection
> read.csv(textConnection(str), header = F,quote="")
  V1            V2            V3 V4 V5
1  a 34° 49' 00" S 58° 32' 00" W  c  d