DS4PS / cpp-523-sum-2020

Course shell for CPP 523 Foundations of Program Evaluation I for Summer 2020.
http://ds4ps.org/cpp-523-sum-2020/
3 stars 0 forks source link

Lab 03 - Pt. 2 - Stargazer #10

Open wahollan opened 4 years ago

wahollan commented 4 years ago

Hello Class, I am working on lab three and am having issues with part 2. When I try to run the stargazer function, this is what I get. What am I doing wrong?

image

lecy commented 4 years ago

What you are seeing is actually correct - it is the HTML table that gets embedded in the R Markdown document to produce the nicely-formatting table you see in notes. Try knitting the file and you will see that it comes out correct.

However, it is super annoying when you are trying to develop your code. You have to change type="html" to type="text" for local viewing of something meaningful, but then remember to change it back before knitting!

I recently figured out a trick. If you add the following to the chunk where you load packages then it will always knit as HTML, but you can also use the text output version locally and not worrying about forgetting to switch everything back before knitting.

# stargazer output type
sg.type <- "text"
sg.type <- "html"

Then use the argument type=sg.type (note no quotes because the variable sg.type is already text).

When you are working locally then execute the first line only: sg.type <- "text".

When you knit the file it will always use the HTML type because that version overwrites the text type from the previous line.

wahollan commented 4 years ago

Thank you for your help!