M. Beausoleil M. Beausoleil - 4 months ago 56
Markdown Question

How to make an object from a class table print as a table in stargazer?

I'm using a markdown document to write text from R. At some point, I want to add a table that I calculated using the

table()
function. But it's not working.

library(stargazer)
x=structure(c(2075L, 49L), .Dim = 2L, .Dimnames = structure(list(
c("0", "1")), .Names = ""), class = "table")

stargazer(x)

Error in objects[[i]]$zelig.call :
$ operator is invalid for atomic vectors


What's going on and how do I fix it?

Answer

How about something like this?

stargazer(as.data.frame(x),
          type = 'text',
          summary = FALSE,
          rownames = FALSE)
Comments