fixest
fixest copied to clipboard
etable highlighting feature
trafficstars
I am having trouble implementing the etable highlighting features from the vignette-- perhaps I am missing a necessary package somewhere. Please let me know how I can fix this issue.
This is my code:
options(echo = T)
pacman::p_load(fixest, tinytex, pdftools)
## Show information about the R session
print(R.Version())
sessionInfo()
packageVersion("fixest")
## Follow the example from the vignette (https://lrberge.github.io/fixest/articles/etable_new_features.html)
dict = c(
"(Intercept)" = "Constant",
Petal.Length = "Petal length",
Petal.Width = "Petal width",
Sepal.Length = "Sepal length",
Sepal.Width = "Sepal width",
note1 = dsb(
"*Notes*: This is a note that illustrates how to access notes ",
"from the dictionary."
),
source = "*Sources*: Somewhere from the net."
)
setFixest_dict(dict)
my_style = style.tex("aer", model.format = "(i)")
setFixest_etable(style.tex = my_style, markdown = TRUE, page.width = "a4")
nm = names(iris)
est = feols(.[nm[1]] ~ .[nm[2:4]], iris, fsplit = ~Species)
etable(
est,
arraystretch = 1.5,
file = "test-table.tex",
replace = T,
highlight = .(
"Sepal@1",
"cyan4, square" = "Petal.L@3-4",
"thick5, sep8, darkgreen!90, se" = "Petal.W"
)
)
## Generate a Latex document
latex_content <- '\\documentclass{article}
\\usepackage{booktabs}
\\usepackage{tikz}
\\begin{document}
\\input{test-table.tex}
\\end{document}'
file_conn <- file("output.tex")
cat(latex_content, file=file_conn)
close(file_conn)
## Compile the LaTeX file to generate a PDF
system("pdflatex --interaction=nonstopmode output.tex")
This is the stdout:
> options(echo = T)
> pacman::p_load(fixest, tinytex, pdftools)
>
> ## Show information about the R session
> print(R.Version())
$platform
[1] "x86_64-apple-darwin17.0"
$arch
[1] "x86_64"
$os
[1] "darwin17.0"
$system
[1] "x86_64, darwin17.0"
$status
[1] ""
$major
[1] "4"
$minor
[1] "2.0"
$year
[1] "2022"
$month
[1] "04"
$day
[1] "22"
$`svn rev`
[1] "82229"
$language
[1] "R"
$version.string
[1] "R version 4.2.0 (2022-04-22)"
$nickname
[1] "Vigorous Calisthenics"
> sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur/Monterey 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pdftools_3.3.3 tinytex_0.45 fixest_0.11.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.10 lattice_0.20-45 zoo_1.8-12
[4] grid_4.2.0 nlme_3.1-157 pacman_0.5.1
[7] dreamerr_1.2.3 qpdf_1.3.2 sandwich_3.0-2
[10] Formula_1.2-5 tools_4.2.0 numDeriv_2016.8-1.1
[13] xfun_0.39 compiler_4.2.0 askpass_1.1
> packageVersion("fixest")
[1] ‘0.11.1’
>
>
> ## Follow the example from the vignette (https://lrberge.github.io/fixest/articles/etable_new_features.html)
> dict = c(
+ "(Intercept)" = "Constant",
+ Petal.Length = "Petal length",
+ Petal.Width = "Petal width",
+ Sepal.Length = "Sepal length",
+ Sepal.Width = "Sepal width",
+ note1 = dsb(
+ "*Notes*: This is a note that illustrates how to access notes ",
+ "from the dictionary."
+ ),
+ source = "*Sources*: Somewhere from the net."
+ )
>
> setFixest_dict(dict)
>
> my_style = style.tex("aer", model.format = "(i)")
> setFixest_etable(style.tex = my_style, markdown = TRUE, page.width = "a4")
>
> nm = names(iris)
> est = feols(.[nm[1]] ~ .[nm[2:4]], iris, fsplit = ~Species)
>
> etable(
+ est,
+ arraystretch = 1.5,
+ file = "test-table.tex",
+ replace = T,
+ highlight = .(
+ "Sepal@1",
+ "cyan4, square" = "Petal.L@3-4",
+ "thick5, sep8, darkgreen!90, se" = "Petal.W"
+ )
+ )
>
> ## Generate a Latex document
> latex_content <- '\\documentclass{article}
+ \\usepackage{booktabs}
+ \\usepackage{tikz}
+
+ \\begin{document}
+
+ \\input{test-table.tex}
+
+ \\end{document}'
>
> file_conn <- file("output.tex")
> cat(latex_content, file=file_conn)
> close(file_conn)
>
> ## Compile the LaTeX file to generate a PDF
> system("pdflatex --interaction=nonstopmode output.tex")
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./output.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/latex/booktabs/booktabs.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-li
sts.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
) (/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.d
ef
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
df.def)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2022/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ
erarithmetics.code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
) (/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfint.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathproce
ssing.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.cod
e.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.
code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.co
de.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretranspare
ncy.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.
code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.
tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.
tex)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-0-65.sty)
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-1-18.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgffor.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex)
) (/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/math/pgfmath.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.cod
e.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothan
dlers.code.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.cod
e.tex)
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarytopaths.code.tex)))
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
(./output.aux)
(/usr/local/texlive/2022/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2022/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./test-table.tex
! Package pgfkeys Error: I do not know the key '/tikz/fit', to which you passed
'(marker-f1-a.north west) (marker-f1-b.south east)', and I am going to ignore
it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.52 ...jrnhd{f1} 0.6508$^{***}$ \markSEqjrnhd{f1}
& 0.6548$^{***}$ & 0.38...
! Package pgfkeys Error: I do not know the key '/tikz/fit', to which you passed
'(marker-f2-a.north west) (marker-f2-b.south east)', and I am going to ignore
it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.54 ...{***}$ & 0.9455$^{***}$ \markSEtlcvqz{f2}
\\
! Package pgfkeys Error: I do not know the key '/tikz/fit', to which you passed
'(marker-f3-a.north west) (marker-f3-b.south east)', and I am going to ignore
it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.57 ... & (0.1981) \markSEvhrkmh{f3}
\\
) [1{/usr/local/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./output.aux) )
(see the transcript file for additional information)</usr/local/texlive/2022/te
xmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2022/texm
f-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/local/texlive/2022/texmf-d
ist/fonts/type1/public/amsfonts/cm/cmsy7.pfb>
Output written on output.pdf (1 page, 36441 bytes).
Transcript written on output.log.
>
output.pdf looks like this:
Thank you for all of your help and for an excellent package!
I can reproduce this. To fix it, you also need to load a special tikz library: \usetikzlibrary{fit}. This should probably be mentioned in the docs.
Here's an example with an R Markdown document but you can simply use the command above in a tex file.
---
output: pdf_document
header-includes:
- \usepackage{booktabs}
- \usepackage{tikz}
- \usetikzlibrary{fit}
---
```{r, eval=TRUE, results="asis"}
library(fixest)
nm = names(iris)
est = feols(.[nm[1]] ~ .[nm[2:4]], iris, fsplit = ~Species)
etable(
est,
arraystretch = 1.5,
tex = TRUE,
replace = T,
highlight = .(
"Sepal@1",
"cyan4, square" = "Petal.L@3-4",
"thick5, sep8, darkgreen!90, se" = "Petal.W"
)
)
```
Two quick thoughts:
- We should probably just take a stance on recommending TinyTex as the most convenient way to ensure that you have all of the necessary libraries that integrate well with your R installation. Looking at the docs, I believe the "TinyTex" bundle covers all of the necessary libraries. So users could just do something like:
# install.package("tinytex")
tinytex::install_tinytex(bundle = "TinyTeX")
- The two etable vignettes should really be combined at this point. I'll try to take a crack at this when I get a sec (ha!) and put in a PR for Laurent to look at.