read.csv跳过列,尽管存在逗号
V2列为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 因为逗号
“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