Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print.xtable only displays, doesn't save to disk

Tags:

r

xtable

Is anyone else having this problem?

> d <- data.frame(x=1:5, y=6:10)
> print(d, type="html", file="d:/delete/test5.html")
  x  y
1 1  6
2 2  7
3 3  8
4 4  9
5 5 10

My R version is version 2.12.2 and xtable version is xtable_1.5-6.

like image 741
Tom Avatar asked Dec 13 '22 12:12

Tom


1 Answers

You haven't created an xtable object, only a data frame. So print is running the appropriate method for a data frame which doesn't include the writing to file options. Try:

d <- data.frame(x=1:5, y=6:10)
x <- xtable(d)
print(x, type="html", file="d:/delete/test5.html")

More generally, if you want to write things to a file, you can try cat.

like image 140
joran Avatar answered Dec 21 '22 22:12

joran