Stargazer打印零而不是我的数据

时间:2016-01-04 19:58:45

标签: r stargazer

我制作了一个数据集,我试图让Stargazer按原样打印,但是在最后一栏中它不会打印除零之外的任何内容。

my_object<-structure(list(labels_for_t_test = structure(c(4L, 3L, 2L, 1L), 
                .Label = c("% who report excessive drinking", "% with a BMI 30 or above", "Mentally unhealthy days per month", 
                           "Physically unhealthy days per month"), class = "factor"), 
                           `estimate.mean of x` = c(3.81651019006183,3.45526222746022, 30.4518625528841, 14.7764967356577), 
                           `estimate.mean of y` = c(3.69675958188153, 3.5731520223152, 28.8823529411765, 15.6045118082481), 
                            statistic.t = c(6.41504498947883, -6.74576716155339, 17.0617198661627, -8.02284265433504), 
                            p.value = c(1.48603650334571e-10, 1.62589843848316e-11, 3.19751229848406e-63, 1.19147131984837e-15)), 
                            .Names = c("labels_for_t_test", "estimate.mean of x", "estimate.mean of y", "statistic.t", "p.value"), 
                            row.names = c("Physically.Unhealthy.Days", "Mentally.Unhealthy.Days", "X..Obese", "X..Excessive.Drinking"), class = "data.frame")
                                                                                                                                                                                                 -6.74576716155339, 17.0617198661627, -8.02284265433504), p.value = c(1.48603650334571e-10, 
stargazer(my_object, title="Results of Welch Two Sample t-tests Comparing Counties with 10 or More Gun Deaths and Counties with Fewer", 
      digits=15, digits.extra= 100, type="html", rownames = FALSE,
      out="t tests test.html", summary = FALSE,
      covariate.labels = c("Variable","--mean for >=10 gun deaths--", "--mean for <10--", "t-statistic", "p-value"))

我已经使用digits=100运行此功能,但在p值列中它仍然没有显示任何内容。理想情况下,我希望用科学记数法打印p值,但如果它根本不认识到这些值,那么这显然是一个更大的问题。我很难过,我真的很感激任何帮助!

1 个答案:

答案 0 :(得分:1)

正如我所提到的,当你的最大p值为1.48 * 10 ^ -10时,我无法想到只会说p = 0的插座。

但如果你坚持用科学记数法打印,只需转换那个专栏,然后再转到观星者身上:

my_object$p.value <- format(my_object$p.value, width = 4, digits = 3)

(随意玩参数...)

然后stargazer应按预期工作。