DS4PS / cpp-528-spr-2021

https://ds4ps.org/cpp-528-spr-2021/
0 stars 0 forks source link

Lab 04 - Stargazer Package #33

Open kirstenronning opened 3 years ago

kirstenronning commented 3 years ago

Hello, whenever I use the Stargazer Package to create a table in my RMarkdown file, it generates a bunch of code describing the table, rather than the actual table itself like what is produced in the Tutorial.

Here is my code:

reg.data <- d

reg.data$mhv.growth[ reg.data$mhv.growth > 200 ] <- NA
#reg.data$p.prof <- regdata$p.prof
reg.data$p.vacant <- log10( reg.data$p.vacant + 1 )
#reg.data$p.white <- regdata$p.white

m1 <- lm( mhv.growth ~ p.prof, data=reg.data )
m2 <- lm( mhv.growth ~ p.prof, data=reg.data )
m3 <- lm( mhv.growth ~ p.white, data=reg.data )
m4 <- lm( mhv.growth ~ p.prof + p.vacant + p.white, data=reg.data )

stargazer( m1, m2, m3, m4,
           type = S_TYPE, digts=2,
           omit.stat = c("rsq", "f") )

Here is a screenshot of the output:

Screen Shot 2021-04-06 at 6 27 31 PM

When I knit the file, the same code appears as the output, rather than the table. Is there something that I am missing?

cenuno commented 3 years ago

@kirstenronning

This is the actual HTML code that creates your stargazer output; however, you probably want it to be rendered instead of being shown as text (like it currently is). To do so, you need to supply a parameter within the R chunk in your RMD file.

Whenever you call stargazer(), please have your R chunk look like this:

{r, results="asis"}

kirstenronning commented 3 years ago

Thank you!