[R] write.csv feature/bug with pipe
ivo welch
ivowel at gmail.com
Mon Mar 12 01:54:32 CET 2007
gentoo linux, version 2.4.1:
> d= as.data.frame(matrix(1:20, 4, 5))
> d
V1 V2 V3 V4 V5
1 1 5 9 13 17
2 2 6 10 14 18
3 3 7 11 15 19
4 4 8 12 16 20
> write.csv(d, file="d1.csv");
> write.csv(d, file=pipe("cat > d2.csv"))
> write.csv(d, file=pipe("gzip -c > d3.csv.gz"), col.names=T)
Warning message:
attempt to change 'col.names' ignored in: write.csv(d, file =
pipe("gzip -c > d4.csv.gz"), col.names = T)
exit and
$ head d1.csv
"","V1","V2","V3","V4","V5"
"1",1,5,9,13,17
"2",2,6,10,14,18
"3",3,7,11,15,19
"4",4,8,12,16,20
$ head d2.csv
"1",1,5,9,13,17
"2",2,6,10,14,18
"3",3,7,11,15,19
"4",4,8,12,16,20
is it a bug or a feature that when pipe is used, the col.names is set
to false? I guess I can invoke write.table to get the headers back.
regards,
/iaw
More information about the R-help
mailing list