如何写入包含以下数据的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
答案 0 :(得分:1)
引用输出:
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