我想在R中制作一个摘要星形表,它给出了相应的观察数N,平均值,标准差,变量“educ”和“exper”的最小值和最大值。我使用以下代码在Latex中生成一个表。
rm(list = ls())
wage2 <- read_csv("~/homework/wage2.txt")
library(stargazer)
stargazer(wage2[c("educ","exper")], type = "latex", digits=1,flip = TRUE)
我得到以下输出。如您所见,该表出现,但它是空的。如果我使用标准R数据(例如数据(“mtcars”)),它就可以工作。任何人都有一个想法,我的数据可能有什么问题?通常的R命令 summary(wage2)工作正常,但我不能在Latex中使用它。 谢谢!
% Table created by stargazer v.5.2 by Marek Hlavac, Harvard University.
E-mail: hlavac at fas.harvard.edu
% Date and time: Mo, Mai 07, 2018 - 16:40:31
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{@{\extracolsep{5pt}}lcc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
Statistic \\
\hline \\[-1.8ex]
N \\
Mean \\
St. Dev. \\
Min \\
Max \\
\hline \\[-1.8ex]
\end{tabular}
\end{table}
数据如下所示:
> str(wage2)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 935 obs. of 17 variables:
$ wage : int 769 808 825 650 562 1400 600 1081 1154 1000 ...
$ hours : int 40 50 40 40 40 40 40 40 45 40 ...
$ IQ : int 93 119 108 96 74 116 91 114 111 95 ...
$ KWW : int 35 41 46 32 27 43 24 50 37 44 ...
$ educ : int 12 18 14 12 11 16 10 18 15 12 ...
$ exper : int 11 11 11 13 14 14 13 8 13 16 ...
- attr(*, "spec")=List of 2
..$ cols :List of 17
.. ..$ wage : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ hours : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ IQ : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ KWW : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ educ : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. ..$ exper : list()
.. .. ..- attr(*, "class")= chr "collector_integer" "collector"
.. .. ..- attr(*, "class")= chr "collector_double" "collector"
..$ default: list()
.. ..- attr(*, "class")= chr "collector_guess" "collector"
..- attr(*, "class")= chr "col_spec"
> head(wage2)
# A tibble: 6 x 17
wage hours IQ KWW educ exper tenure age married black south
urban sibs brthord
<int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
<int> <int> <int>
1 769 40 93 35 12 11 2 31 1 0 0
1 1 2
2 808 50 119 41 18 11 16 37 1 0 0
1 1 NA
3 825 40 108 46 14 11 9 33 1 0 0
1 1 2
4 650 40 96 32 12 13 7 32 1 0 0
1 4 3
5 562 40 74 27 11 14 5 34 1 0 0
1 10 6
6 1400 40 116 43 16 14 2 35 1 1 0
1 1 2
# ... with 3 more variables: meduc <int>, feduc <int>, lwage <dbl>