Search code examples
rxtable

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


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.


Solution

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