markwestcott34 / stargazer-booktabs Goto Github PK
View Code? Open in Web Editor NEWFork of stargazer, adding booktabs support for pretty LaTeX tables from R.
License: GNU General Public License v2.0
Fork of stargazer, adding booktabs support for pretty LaTeX tables from R.
License: GNU General Public License v2.0
When outputting a table from R using your Stargazer fork I get an error:
Extra }, or forgotten \endgroup. ...}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} }
Package array Error: Illegal pream-token ({5pt): `c' used. ...}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} }
It seems to come from
stargazer-booktabs/R/stargazer-internal.R
Lines 4364 to 4365 in 1d59762
Manually replacing {5pt}
with @{\extracolsep{5pt}}
works.
MWE:
R:
sample <- data.frame(x = c(1,2,3), y = c(4,5,6))
stargazer(sample,
type = "latex", summary = TRUE, float = FALSE,
digits = 2, align = TRUE)
Latex:
\documentclass[]{article}
\usepackage{booktabs}
\usepackage{dcolumn}
\begin{document}
% Table created by stargazer v.5.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: ons., okt 04, 2017 - 10:56:05
% Requires LaTeX packages: dcolumn
\begin{table}
\begin{tabular}{{{5pt}}lD{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} D{.}{.}{-2} }
\toprule
Statistic & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Max} \\
\midrule \\[-2.1ex]
x & 3 & 2.00 & 1.00 & 1 & 3 \\
y & 3 & 5.00 & 1.00 & 4 & 6 \\
\midrule \\[-2.1ex]
\end{tabular}
\end{table}
\end{document}
Exporting tables to .tex gives an error. Using your example:
t <- data.frame(Income = runif(20),
Wealth = runif(20),
Children = runif(20),
Age = runif(20),
male = rep(c(T,F),times=10))
c1 <- lm(Income ~ Age, data = t, subset = male == T)
c2 <- lm(Wealth ~ Age, data = t, subset = male == F)
c3 <- lm(Children ~ Age, data = t)
stargazer(c1,c2,c3,
style="aer", out = tempfile(fileext = ".tex"),
omit.table.layout = "n",
omit.stat=c("adj.rsq", "f", "ser"),
omit=c("Constant"),
float=T,
title = "Columns for dependent variables",
add.lines = list(c("Controls","N","N","N")))
Error in if (nchar(text.matrix[r, c]) > max.length[real.c]) { :
missing value where TRUE/FALSE needed
When using stargazer-booktabs
to output a LaTeX table reproducing the contents of a data frame (so with the summary
option set to FALSE
) I get the following error:
Error in paste(.formatting.alignment, "c", sep = "") :
object '.formatting.alignment' not found
Here is a simple example to illustrate the issue:
> df <- data.frame(Name = c("John", "Abigail", "Paul"),
+ Age = c(30, 25, 49))
> stargazer(df, summary=FALSE)
% Table created by stargazer v.5.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Fri, Jul 27, 2018 - 12:58:39
\begin{table}[!htbp] \centering
\caption{}
\label{}
Error in paste(.formatting.alignment, "c", sep = "") :
object '.formatting.alignment' not found
The code above works fine prior to installing stargazer-booktabs
. I did a clean install of both stargazer
and stargazer-booktabs
today prior to running this code. In the past I've had no issues with stargazer-booktabs
for regression output.
Thank you very much for your time and for this very useful fork!
sample <- data.frame(x = c(1,2,3), y = c(4,5,6))
stargazer(sample,
type = "latex", summary = TRUE, float = FALSE,
digits = 2, align = TRUE)
After installing stargazer-booktabs
via devtools
, whenever I try to produce tables with stargazer
the following error is produced:
Error in if (class(objects[[i]]) %in% c("coeftest", "lmerMod", "glmerMod", :
the condition has length > 1
Also, it is somewhat unclear to me how stargazer-booktabs
works. After installing from github via devtools
, does simply loading stargazer
and using it normally produce output with \toprule, \midrule, and \bottomrule? Or does it only produce these when compiling in an RMarkdown document with booktabs
loaded?
Hello! I would love to give this a try but I am at a loss on how to install this. Could you give me a quick jump start on this? Thanks!
It's pretty unclear what one has to do to use this library. Spare some details in the README.md?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.