Hello,
Just use ?cat and ?write.table with append = TRUE. Something like the
following.
txt <- "ampl.tab 2 1"
dat <- read.table(text = "
A B
2 3
4 6
2 0
", header = TRUE)
tmp <- "tmp.txt"
cat(txt, "\n", file = tmp) " Don't forget the newline "\n"
write.table(dat, file = tmp, append = TRUE, row.names = FALSE)
#unlink(tmp) # Clean up
Hope this helps,
Rui Barradas
Em 22-10-2014 01:32, YIHSU CHEN escreveu:
Hi guys;
I want to write some text at the first line of an output file. The output
file will be used for other software. In particular, the following text
"ampl.tab 2 1" needs to be added to the first line of an df output file.
As a hypothetic example, the output in text file should be like:
ampl.tab 2 1
A B
2 3
4 6
2 0
Thanks for help.
Yihsu
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.