Is it possible to report NAs in stargazer table?

Stargazer package gives me really nice descriptive table to include in latex document.

library(stargazer)
stargazer(attitude)

在这里输入图像描述

Is it possible to add a column reporting number of NAs for each of the variables?


这段代码将为您提供数据框中每行和每列的NAs数量

# make some data
count <- 10
data <- data.frame( a=runif(count), b=runif(count))

# add some NAs
data[data$a>0.5,]$a <- NA
data[data$b>0.5,]$b <- NA

# NAs per row
data$NACount <- apply(data, 1, function(x) {length(x[is.na(x)])})

# NAs per column
NACountsByColumn <- lapply(data, function(x) {length(x[is.na(x)])} )

The "N" column of stargazer does not count the NAs. Alhough there is not direct way to input NAs in the output table, you can simply calculate it by

nrow(dataset) - the number in "N" column

链接地址: http://www.djcxy.com/p/24994.html

上一篇: 将LME4模型结果转换为胶乳(具有长期支持)

下一篇: 是否有可能在Stargazer表中报告NAs?