Obtaining Separate Summary Statistics by Categorical Variable with Stargazer Package

后端 未结 4 1140
轮回少年
轮回少年 2020-12-16 02:37

I would like to use stargazer to produce summary statistics for each category of a grouping variable. I could do it in separate tables, but I\'d like it all in one – if that

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 03:10

    invisible(lapply(levels(ToothGrowth$supp),stargazer))
    

    would do, but if you want separate \subsection{} in between, you probable should use something like

    invisible(lapply(levels(ToothGrowth$supp),function(sg){
        cat("\\subsection{add your text here}\n")
        print(stargazer(sg)
      })
    

提交回复
热议问题