-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a44bc3
commit ffc3434
Showing
123 changed files
with
176,564 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
cap-location: margin | ||
css: 'custom.css' | ||
output: | ||
pagedown::html_paged: | ||
toc: true | ||
self_contained: false | ||
toc-title: 'IPUMS PMA Codebook: <br>Pregnancy Termination Variables' | ||
lot: false | ||
lof: false | ||
paged-footnotes: true | ||
--- | ||
|
||
```{r, echo=FALSE,results='hide', message=FALSE} | ||
source(here::here("r/utilities.r")) | ||
set_postpath("2022-12-09-data-dictionary") | ||
library(ipumsr) | ||
library(tidyverse) | ||
library(gtsummary) | ||
library(gt) | ||
dat <- read_ipums_micro( | ||
ddi = "data/pma_00180.xml", | ||
data = "data/pma_00180.dat.gz" | ||
) | ||
``` | ||
|
||
|
||
```{r, echo = FALSE, results='asis'} | ||
dd <- dat %>% ipums_var_info() %>% slice(-c(1:12)) | ||
dd$tbl <- dd$var_name %>% | ||
map( | ||
~if(dat[[.x]] %>% is.labelled){ | ||
dat %>% | ||
select(!!.x) %>% | ||
mutate(across(where(is.labelled), ~.x %>% as_factor %>% fct_drop)) %>% | ||
tbl_summary() %>% | ||
modify_footnote(update = list(stat_0 ~ NA)) %>% | ||
bold_labels() %>% | ||
as_gt() %>% | ||
tab_options( | ||
column_labels.hidden = TRUE, | ||
table.font.names = "cabrito_sans_norm_regular", | ||
table.width = gt::pct(100), | ||
table.font.size = ".8em" | ||
) | ||
} | ||
) | ||
dd %>% | ||
pwalk(function(...){ | ||
text <- list(...) | ||
text$var_name %>% | ||
paste("#", ., "{.unnumbered} \n\n") %>% | ||
paste(text$var_desc, "\n\n") %>% | ||
cat() | ||
if(is.null(text$tbl)){ | ||
cat("*Table omitted for space constraints*\n\n") | ||
} else { | ||
text$tbl %>% as_raw_html() %>% cat() | ||
} | ||
}) | ||
``` | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
cap-location: margin | ||
css: 'custom.css' | ||
output: | ||
pagedown::html_paged: | ||
toc: true | ||
self_contained: false | ||
toc-title: 'IPUMS PMA Codebook: <br>Pregnancy Termination Variables' | ||
lot: false | ||
lof: false | ||
paged-footnotes: true | ||
--- | ||
|
||
```{r, echo=FALSE,results='hide', message=FALSE} | ||
source(here::here("r/utilities.r")) | ||
set_postpath("2022-12-09-data-dictionary") | ||
library(ipumsr) | ||
library(tidyverse) | ||
library(gtsummary) | ||
library(gt) | ||
dat <- read_ipums_micro( | ||
ddi = "data/pma_00180.xml", | ||
data = "data/pma_00180.dat.gz" | ||
) | ||
``` | ||
|
||
|
||
```{r, echo = FALSE, results='asis'} | ||
dd <- read_rds("data/dd.rds.gz") %>% | ||
slice(-c(1:12)) %>% | ||
mutate( | ||
var_name = var_name %>% | ||
paste("#", ., "{.unnumbered}"), | ||
comp = comp %>% | ||
str_replace("Comparability", "#### Comparability {.unnumbered}\n"), | ||
avail = avail %>% | ||
str_replace_all("\n", "\n - ") %>% | ||
str_replace("Availability", "#### Availability {.unnumbered}\n"), | ||
universe = universe %>% | ||
str_replace_all("\n", "\n - ") %>% | ||
str_replace("Universe", "#### Universe {.unnumbered}\n") | ||
) | ||
dd %>% | ||
ungroup() %>% | ||
pwalk(function(...){ | ||
text <- list(...) | ||
cat(text$var_name, "\n\n") | ||
cat(text$var_desc, "\n\n") | ||
cat(text$comp, "\n\n") | ||
cat(text$avail, "\n\n") | ||
cat(text$universe, "\n\n") | ||
cat("#### Results {.unnumbered} \n\n") | ||
if(is.null(text$tbl)){ | ||
cat("*Table omitted for space constraints*\n\n") | ||
} else { | ||
text$tbl %>% as_raw_html() %>% cat() | ||
} | ||
}) | ||
``` | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
_posts/2022-12-09-data-dictionary/codebook2_files/paged-0.19/css/default-fonts.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@import 'https://fonts.googleapis.com/css?family=Old+Standard+TT'; | ||
|
||
body { | ||
font-family: 'Old Standard TT', Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, 'source-han-serif-sc', 'Source Han Serif SC', 'Source Han Serif CN', 'Source Han Serif TC', 'Source Han Serif TW', 'Source Han Serif', 'Songti SC', 'Microsoft YaHei', serif; | ||
} | ||
blockquote { | ||
font-family: 'Old Standard TT', Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, 'STKaiti', 'KaiTi', '楷体', 'SimKai', 'DFKai-SB', 'NSimSun', serif; | ||
} | ||
code { | ||
font-family: Consolas, Courier, "Courier New", 'STKaiti', 'KaiTi', 'SimKai', monospace; | ||
} | ||
pre, code { | ||
font-size: .95em; | ||
} |
170 changes: 170 additions & 0 deletions
170
_posts/2022-12-09-data-dictionary/codebook2_files/paged-0.19/css/default-page.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* page size */ | ||
@page { | ||
size: 6in 9in; /* var(--pagedjs-width) doesn't work in browser when printing */ | ||
} | ||
@page :blank { | ||
|
||
} | ||
|
||
/* store some string variables */ | ||
.shorttitle1 { | ||
string-set: h1-text content(text); | ||
} | ||
|
||
.shorttitle2 { | ||
string-set: h2-text content(text); | ||
} | ||
|
||
/* left page */ | ||
.running-h1-title { | ||
position: running(runningH1Title); | ||
width: var(--running-title-width); | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
.running-h1-title:before { | ||
content: string(h1-text); | ||
} | ||
|
||
@page chapter:left { | ||
@top-left { | ||
content: counter(page); | ||
} | ||
@top-right { | ||
content: element(runningH1Title); | ||
white-space: nowrap !important; | ||
} | ||
} | ||
|
||
/* right page */ | ||
.running-h2-title { | ||
position: running(runningH2Title); | ||
width: var(--running-title-width); | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
} | ||
.running-h2-title:before { | ||
/* We would want to write: */ | ||
/* content: string(h2-text, start); */ | ||
/* However, this is yet unsupported by Paged.js, see https://gitlab.coko.foundation/pagedjs/pagedjs/-/issues/38 */ | ||
content: string(h2-text); | ||
} | ||
@page chapter:right { | ||
@top-right { | ||
content: counter(page); | ||
} | ||
@top-left { | ||
content: element(runningH2Title); | ||
white-space: nowrap !important; | ||
} | ||
} | ||
|
||
/* New chapter page */ | ||
@page chapter:first { | ||
@top-left { | ||
content: none; | ||
} | ||
@top-right { | ||
content: none; | ||
} | ||
@bottom-right { | ||
content: counter(page); | ||
} | ||
} | ||
@page :first { | ||
@top-left { | ||
content: none; | ||
} | ||
@top-right { | ||
content: none; | ||
} | ||
@bottom-right { | ||
content: none !important; | ||
} | ||
background-image: var(--front-cover); | ||
background-position: center; | ||
background-size: contain; | ||
background-repeat: no-repeat; | ||
} | ||
|
||
/* Front cover */ | ||
.front-cover { | ||
break-after: recto; | ||
} | ||
|
||
/* Front page or title page */ | ||
.front-page { | ||
counter-reset: page 1; | ||
} | ||
|
||
/* Front matter*/ | ||
@page frontmatter:left { | ||
@top-left { | ||
content: counter(page, lower-roman); | ||
} | ||
@top-right { | ||
content: element(runningH1Title); | ||
white-space: nowrap !important; | ||
} | ||
} | ||
@page frontmatter:right { | ||
@top-right { | ||
content: counter(page, lower-roman); | ||
} | ||
@top-left { | ||
content: element(runningH1Title); | ||
white-space: nowrap !important; | ||
} | ||
} | ||
@page frontmatter:first { | ||
@top-left { | ||
content: none; | ||
} | ||
@top-right { | ||
content: none; | ||
} | ||
@bottom-right { | ||
content: counter(page, lower-roman); | ||
} | ||
} | ||
|
||
/* last page or back cover */ | ||
.back-cover { | ||
break-before: verso; | ||
} | ||
.pagedjs_page:nth-last-of-type(1) { | ||
background-image: var(--back-cover); | ||
background-position: center; | ||
background-size: contain; | ||
background-repeat: no-repeat; | ||
} | ||
|
||
/* page breaks; aka CSS fragmentation */ | ||
.level1 { | ||
break-before: recto; | ||
page: chapter; | ||
} | ||
.front-matter-container .level1 { | ||
page: frontmatter; | ||
} | ||
.section > h1, .section > h2, .section > h3, .section > h4, .section > h5, .section > h6 { | ||
break-after: avoid; | ||
} | ||
.footenotes { | ||
break-before: always; | ||
break-after: always; | ||
} | ||
.figure { | ||
break-inside: avoid; | ||
} | ||
|
||
/* reset page numbering for main content */ | ||
.main .level1:first-child h1 { | ||
counter-reset: page 1; | ||
} | ||
|
||
/* do not break captions */ | ||
caption { | ||
break-inside: avoid; | ||
break-after: avoid; | ||
} |
Oops, something went wrong.