Stargazer 打印零而不是我的数据
Stargazer printing zeros instead of my data
我制作了一个数据集,并试图让 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 值,但如果它根本无法识别这些值,那显然是一个更大的问题。我很困惑,非常感谢任何帮助!
正如我提到的,我想不出一个出口会因为你最大的 p-value 是 1.48*10^-10 时只说 p = 0 而对你皱眉。
但是如果你坚持用科学记数法打印,只需在传递给 stargazer 之前转换该列:
my_object$p.value <- format(my_object$p.value, width = 4, digits = 3)
(随意调整参数...)
那么 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 值,但如果它根本无法识别这些值,那显然是一个更大的问题。我很困惑,非常感谢任何帮助!
正如我提到的,我想不出一个出口会因为你最大的 p-value 是 1.48*10^-10 时只说 p = 0 而对你皱眉。
但是如果你坚持用科学记数法打印,只需在传递给 stargazer 之前转换该列:
my_object$p.value <- format(my_object$p.value, width = 4, digits = 3)
(随意调整参数...)
那么 stargazer
应该会按预期工作。