From 1e675010060ed31bf920170087e5bec4b04aa2e8 Mon Sep 17 00:00:00 2001 From: Johannes Boehm Date: Sat, 27 Aug 2022 16:45:01 +0200 Subject: [PATCH 1/2] documentation for print_result and midrule fix --- Project.toml | 2 +- README.md | 18 +++++++++++++++++- src/rendersettings/html.jl | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index c850a43..88c26ab 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "RegressionTables" uuid = "d519eb52-b820-54da-95a6-98e1306fdade" authors = ["Johannes Boehm "] -version = "0.5.7" +version = "0.5.8" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" diff --git a/README.md b/README.md index 4b2c358..26a8f06 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,15 @@ This package provides publication-quality regression tables for use with [FixedE In its objective it is similar to (and heavily inspired by) the Stata command [`esttab`](http://repec.sowi.unibe.ch/stata/estout/esttab.html) and the R package [`stargazer`](https://cran.r-project.org/web/packages/stargazer/). +## Table of Contents + +- [Installation](#Installation) +- [A brief demonstration](#a-brief-demonstration) +- [Function Reference](#function-reference) +- [Frequently Asked Questions](#frequently-asked-questions) + +## Installation + To install the package, type in the Julia command prompt ``` @@ -144,7 +153,7 @@ R2 0.014 0.014 Printing of `StatsBase.RegressionModel`s is experimental; please file as issue if you encounter problems printing them. -## Options +## Function Reference ### Function Arguments * `rr::Union{FixedEffectModel,DataFrames.TableRegressionModel}...` are the `FixedEffectModel`s from `FixedEffectModels.jl` (or `TableRegressionModel`s from `GLM.jl`) that should be printed. Only required argument. @@ -164,6 +173,7 @@ Printing of `StatsBase.RegressionModel`s is experimental; please file as issue i * `groups` is a `Vector` of labels used to group regressions. This can be useful if results are shown for different data sets or sample restrictions. Defaults to `[]`. * `print_fe_section` is a `Bool` that governs whether a section on fixed effects should be shown. Defaults to `true`. * `print_estimator_section` is a `Bool` that governs whether to print a section on which estimator (OLS/IV) is used. Defaults to `true`. +* `print_result` is a `Bool` that governs whether the table should be printed to `stdout`. Defaults to `true`. * `standardize_coef` is a `Bool` that governs whether the table should show standardized coefficients. Note that this only works with `TableRegressionModel`s, and that only coefficient estimates and the `below_statistic` are being standardized (i.e. the R^2 etc still pertain to the non-standardized regression). * `out_buffer` is an `IOBuffer` that the output gets sent to (unless an output file is specified, in which case the output is only sent to the file). * `renderSettings::RenderSettings` is a `RenderSettings` composite type that governs how the table should be rendered. Standard supported types are ASCII (via `asciiOutput(outfile::String)`) and LaTeX (via `latexOutput(outfile::String)`). If no argument to these two functions are given, the output is sent to STDOUT. Defaults to ASCII with STDOUT. @@ -211,3 +221,9 @@ to change the label for the row showing the number of observations in each regre * `__LABEL_STATISTIC_F_KP__` (default: "First-stage F statistic" in `asciiOutput()`) * `__LABEL_STATISTIC_P_KP__` (default: "First-stage p value" in `asciiOutput()`) * `__LABEL_STATISTIC_DOF__` (default: "Degrees of Freedom" in `asciiOutput()`) + +## Frequently Asked Questions + +*What's the best way to render regression tables in Pluto.jl?* + +Use `renderSettings = htmlOutput()` and `print_result = false`, and print the resulting `String` as `text/html`. [This page](https://jmboehm.github.io/regtables-pluto.jl.html) shows an example. \ No newline at end of file diff --git a/src/rendersettings/html.jl b/src/rendersettings/html.jl index a524668..ef4d451 100644 --- a/src/rendersettings/html.jl +++ b/src/rendersettings/html.jl @@ -17,7 +17,7 @@ function htmlOutput(outfile::String = "") # toprule: just a spacer toprule = "" # midrule: a with black border on bottom, and a spacer - midrule = "" + midrule = "" # bottomrule: a slightly larger spacer bottomrule = "" headerrule = htmlHeaderRule From 6057af921e62022e64c05fb1c14156e2871a0d88 Mon Sep 17 00:00:00 2001 From: Johannes Boehm Date: Sat, 27 Aug 2022 19:23:27 +0200 Subject: [PATCH 2/2] fix tests --- test/tables/test1_reference.html | 8 ++++---- test/tables/test2_reference.html | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/tables/test1_reference.html b/test/tables/test1_reference.html index 201594f..8d0beb9 100644 --- a/test/tables/test1_reference.html +++ b/test/tables/test1_reference.html @@ -4,7 +4,7 @@ SepalLength SepalWidth (1) (2) (3) (4) - + (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.506*** @@ -15,12 +15,12 @@ (0.154) SepalLength -0.313 (0.239) - + Species Yes Yes Yes isSmall Yes - + Estimator OLS OLS OLS IV - + N 150 150 150 150 R2 0.014 0.863 0.867 0.080 Adjusted R2 0.007 0.860 0.861 0.055 diff --git a/test/tables/test2_reference.html b/test/tables/test2_reference.html index d494d65..b5308d0 100644 --- a/test/tables/test2_reference.html +++ b/test/tables/test2_reference.html @@ -4,7 +4,7 @@ SepalLength Counts (1) (2) (3) - + (Intercept) 6.526*** 3.457*** 3.045*** (0.479) (0.309) (0.126) SepalWidth -0.223 0.399*** @@ -15,9 +15,9 @@ (0.202) Outcome: C -0.293 (0.193) - + Estimator OLS OLS NL - + N 150 150 9 R2 0.014 0.707