2
votes

I'm trying to get a unique table of summary statistics (eg. mean) for two variables in my data.frame (prezzo and prezzo_unit_2 - sorry for not being generic) by several groups corresponding to categorical variables. Since I was not able to do it, I tried to walk around the problem by creating a list of several summaryBy (library doBy) and then applying stargazer to the list. Unfortunately, stargazer gives this error message:

Error in if (.global.summary[i] == TRUE) { : 
  missing value where TRUE/FALSE needed

Also, if i run stargazer over any subset of two elements from my list, it works.

Any ideas? Thanks a lot.

Here is what I did:

lista<-list(summaryBy(prezzo+prezzo_unit_2~DOP, data=DB_ristr_no_outlayers, FUN=mean, var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~Organic, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~italia.nel.nome, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~portogallo.nel.nome, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~spagna.nel.nome, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~grecia.nel.nome, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~altra.origine.nel.nome, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~nessuna.origine.nel.nome, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~packaging, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~materiale, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~scatola, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~premium, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~monovarietale, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~formato_0_250, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~formato_251_500, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~formato_501_1000, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~formato_oltre_1000, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE),
            summaryBy(prezzo+prezzo_unit_2~recensito, data=DB_ristr_no_outlayers, FUN=mean,var.names=c("prezzo", "prezzo al lt"), keep.names=TRUE)
            )

stargazer(lista, type="text", style="aer", summary=FALSE, title="any_title", out="any_title.xls")
1

1 Answers

3
votes

I just had the same problem. Looking at the source code, when using a list of objects as input, the summary parameter must be a logical vector of the same length as your input list.

stargazer(my.list,summary=rep(F,length(my.list)))

This should work, if you do not want to have summary statistics. Adjust to your liking. Sadly, this is not documented in the help file. ?stargazer only gives the case for a single data.frame:

summary: a logical value indicating whether the package should output a summary statistics table when given a data frame. If FALSE, the package will instead output the contents of the data frame.