0

I work with R-Studio (Version 0.98.1102) and use the stargazer package (5.1). It all works properly, but when I use the type="html" function, my output looks quite ugly, there is no frame, no lines, it's just a white document with numbers and text. Even when i change the style="" function to different inputs, it always looks the same.

Has anyone an idea? I'm working with a MacBook Pro, but I don't think that this should be a problem.... Thank you very much for your help!


@bgoldst thank you!

but when I type the same thing:

stargazer(attitude, type="html", out="test.html")

i also get that code, but my HTML-Output is different from yours. I don't habe this three black lines in the table, and the font looks a bit different.

So it definitely must be a problem with my computer...I cannot understand that :)

JonesRu
  • 1
  • 1
  • 2

2 Answers2

1

I'm working on OSX and I had the same problem visualizing the HTML output in Safari. I solved the problem by adding the option

out.header = TRUE

to stargazer. For example:

stargazer(attitude, type="html", out="test.html", out.header=TRUE)

creates the file test.html. When I open it in Safari it looks like this:

enter image description here

When out.header=TRUE, stargazer adds a HTML header to the output file. Otherwise it only saves the chunk that creates the table.

Belethia
  • 368
  • 2
  • 9
0

I took a look at the stargazer package, and it seems pretty limited to me. I tried running:

stargazer(attitude,type='html');
##
## <table style="text-align:center"><tr><td colspan="6" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">Statistic</td><td>N</td><td>Mean</td><td>St. Dev.</td><td>Min</td><td>Max</td></tr>
## <tr><td colspan="6" style="border-bottom: 1px solid black"></td></tr><tr><td style="text-align:left">rating</td><td>30</td><td>64.633</td><td>12.173</td><td>40</td><td>85</td></tr>
## <tr><td style="text-align:left">complaints</td><td>30</td><td>66.600</td><td>13.315</td><td>37</td><td>90</td></tr>
## <tr><td style="text-align:left">privileges</td><td>30</td><td>53.133</td><td>12.235</td><td>30</td><td>83</td></tr>
## <tr><td style="text-align:left">learning</td><td>30</td><td>56.367</td><td>11.737</td><td>34</td><td>75</td></tr>
## <tr><td style="text-align:left">raises</td><td>30</td><td>64.633</td><td>10.397</td><td>43</td><td>88</td></tr>
## <tr><td style="text-align:left">critical</td><td>30</td><td>74.767</td><td>9.895</td><td>49</td><td>92</td></tr>
## <tr><td style="text-align:left">advance</td><td>30</td><td>42.933</td><td>10.289</td><td>25</td><td>72</td></tr>
## <tr><td colspan="6" style="border-bottom: 1px solid black"></td></tr></table>

This shows up like this on a web page:

attitude-table

There don't seem to be many graphical customization options to the stargazer() command. I tried all the supported styles, and the only ones that had any effect were 'commadefault', which changed the decimals to commas in the numbers, 'io', which capitalized the statistic names for some reason, and 'jpam', which slightly modified the column names (e.g. Max became Maximum and St. Dev. became SD).

I don't have much personal experience with generating graphical source from R data, but my impression has been that R Shiny is the best-established and most-used library for that purpose, and the samples look pretty damn good, so I'd suggest looking there.

bgoldst
  • 34,190
  • 6
  • 38
  • 64
  • thank you! but when I type the same thing: stargazer(attitude, type="html", out="test.html") i also get that code, but my HTML-Output is different from yours. I don't habe this three black lines in the table, and the font looks a bit different. So it definitely must be a problem with my computer...I cannot understand that :) – JonesRu Apr 13 '15 at 21:32
  • It might be browser-related; I'm on the latest Firefox. But it's probably not worth chasing the culprit here, that's not really standard HTML anyway, to code a divider line in a table using a border on an empty row. I suggest looking into [R Shiny](http://shiny.rstudio.com/), rather than pursuing `stargazer`. – bgoldst Apr 13 '15 at 21:37