[英]Writing data frame to semicolon-delimited CSV where column data contains semi-colon?
如何写入以下数据完整的CSV? 我想将此数据写入带有分隔符作为分号的CSV文件中,但是第二行由于分号而移位。
我有一个包含以下数据的数据框:
a <- c(1,2,3,4)
b <- c("hello","hello;world","hey","there")
c <- c(10,20,30,40)
df <- data.frame(a,b,c)
df
df
a b c
1 1 hello 10
2 2 hello;world 20
3 3 hey 30
4 4 there 40
引用输出:
a<-c(1,2,3,4)
b<-c("hello","hello;world","hey","there")
c<-c(10,20,30,40)
df<-data.frame(a,b,c)
write.table(df, file="blah.csv",quote=TRUE, sep = ";")
给
"a";"b";"c"
"1";1;"hello";10
"2";2;"hello;world";20
"3";3;"hey";30
"4";4;"there";40
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.