[英]Output summary statistics with stargazer
初學者問題在這里。 我正在嘗試將基本統計信息輸出到數據框的觀星器中。
wagesub = wagepan[, c("educ", "black", "hisp", 'exper', 'expersq', 'married', 'union')]
x = summary(wagesub)
我試過:
stargazer(x)
stargazer(x, type = "text", title = "Variable Summary", digits = 3, out = "table.txt")
它給了我以下錯誤:
名稱錯誤(x)<-值:“名稱”屬性 [7] 必須與向量 [3] 的長度相同
任何幫助,將不勝感激。 謝謝
我認為你做錯了,因為沒有給出輸入數據我正在使用 iris。 如果您在 iris 上運行相同的命令,您顯示的錯誤也可以復制。
從文檔:
第一個參數(省略號)只接受這些東西:
...一個或多個模型對象(用於回歸分析表)或數據框/向量/矩陣(用於匯總統計,或內容的直接輸出)。 它們也可以作為列表(甚至列表中的列表)包含在內。
你應該這樣做:
stargazer::stargazer(iris,summary = TRUE, out = 'tab.txt')
輸出:
=============================================================
Statistic N Mean St. Dev. Min Pctl(25) Pctl(75) Max
-------------------------------------------------------------
Sepal.Length 150 5.843 0.828 4.300 5.100 6.400 7.900
Sepal.Width 150 3.057 0.436 2.000 2.800 3.300 4.400
Petal.Length 150 3.758 1.765 1.000 1.600 5.100 6.900
Petal.Width 150 1.199 0.762 0.100 0.300 1.800 2.500
-------------------------------------------------------------
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.