Stargazer, no output

r, stargazer

Solution

Your data are in a `tibble` object. If you convert this object to a `data.frame`, `stargazer`works nicely.

df <- structure(list(D_PUBLIC = c(0, 0, 0, 1, 0, 1), 
                D_PRIVATE = c(1, 1, 1, 0, 0, 0), 
                D_SUBSIDIARY = c(0, 0, 0, 0, 1, 0), 
                D_DIVERSIFY = c(1, 0, 0, 0, 0, 0), 
                ALL_CASH = c(0, 0, 0, 0, 0, 0), 
                ALL_EQUITY = c(1, 0, 1, 1, 0, 0)), 
                .Names = c("D_PUBLIC", "D_PRIVATE", "D_SUBSIDIARY", 
                 "D_DIVERSIFY", "ALL_CASH", "ALL_EQUITY"), 
                 row.names = c(NA, -6L), 
                 class = c("tbl_df", "tbl", "data.frame"))
df

#######################
# A tibble: 6 × 6
  D_PUBLIC D_PRIVATE D_SUBSIDIARY D_DIVERSIFY ALL_CASH ALL_EQUITY
     <dbl>     <dbl>        <dbl>       <dbl>    <dbl>      <dbl>
1        0         1            0           1        0          1
2        0         1            0           0        0          0
3        0         1            0           0        0          1
4        1         0            0           0        0          1
5        0         0            1           0        0          0
6        1         0            0           0        0          0


stargazer(as.data.frame(df), type="text")

=====================================
Statistic    N Mean  St. Dev. Min Max
-------------------------------------
D_PUBLIC     6 0.333  0.516    0   1 
D_PRIVATE    6 0.500  0.548    0   1 
D_SUBSIDIARY 6 0.167  0.408    0   1 
D_DIVERSIFY  6 0.167  0.408    0   1 
ALL_CASH     6 0.000  0.000    0   0 
ALL_EQUITY   6 0.500  0.548    0   1 
-------------------------------------

Problem

I have recently installed R to work on a dataset for a University project. After succesfully downloading the package "stargazer" in R Studio and loading it into my script, I imported my dataset from an excel sheet. However,whenever I run the stargazer command in a very simple form (see Picture), I dont get any output. I am new to R, so is there anything obvious that I am missing in order to run the stargazer command properly? I am working on MacOSX 10.12.4 and R 3.3.1

Original source