Ravi S. Shankar <ravis <at> ambaresearch.com> writes:

> I am trying to get an output like this
> Hi
> Hello
> 1           a           b

# The easy way: good for logging of results, but commands print too,
# depending how you run it
df = data.frame(a=rep("a",3),b=rep("b",3))
sink(file="a.txt")
cat("Hello\n")
print(df)
sink()

# a bit better
cat("Hello\n",file="b.txt")
write.table(df,file="b.txt",append=TRUE,col.names=FALSE,
  row.names=FALSE,quote=FALSE)


Dieter

______________________________________________
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.

Reply via email to