Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ knitr::opts_chunk$set(
options(balancing.quiet = TRUE)
```

# balancing
# balancing <a href="https://r-causal.github.io/balancing/"><img src="man/figures/logo.png" align="right" height="138" alt="balancing website" /></a>

<!-- badges: start -->
[![R-CMD-check](https://github.com/r-causal/balancing/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-causal/balancing/actions/workflows/R-CMD-check.yaml)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# balancing
# balancing <a href="https://r-causal.github.io/balancing/"><img src="man/figures/logo.png" align="right" height="138" alt="balancing website" /></a>

<!-- badges: start -->

Expand Down
1 change: 1 addition & 0 deletions data-raw/logo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports/
13 changes: 13 additions & 0 deletions data-raw/logo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Package logo

The text-free artwork was generated with the built-in image-generation tool.
`prompt.txt` records the artwork prompt. `sticker.svg` adds editable typography
and a border clipped to the 1.74 by 2 inch hexagon.

Run `Rscript data-raw/logo/build.R` from the package root to export a 600 dpi
print PNG and an SVG with outlined text to `exports/`, then install the README
logo with `usethis::use_logo()`.

The build requires the R packages base64enc, magick, rsvg, systemfonts, and
usethis, plus Baskerville installed locally.
The artwork, fonts, and print tools are not package runtime dependencies.
Binary file added data-raw/logo/artwork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions data-raw/logo/build.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Run from the package root: Rscript data-raw/logo/build.R
args <- commandArgs(trailingOnly = FALSE)
script <- sub("^--file=", "", args[grepl("^--file=", args)])
source_dir <- dirname(normalizePath(script))
root <- normalizePath(file.path(source_dir, "../.."))
svg <- paste(readLines(file.path(source_dir, "sticker.svg")), collapse = "\n")
families <- regmatches(svg, gregexpr('font-family="[^"]+"', svg))[[1]]
families <- unique(sub('font-family="([^"]+)"', "\\1", families))
missing <- setdiff(families, systemfonts::system_fonts()$family)
if (length(missing)) {
stop(
"Install the source fonts before rebuilding: ",
paste(missing, collapse = ", ")
)
}
art <- base64enc::dataURI(
file = file.path(source_dir, "artwork.png"),
mime = "image/png"
)
svg <- sub("artwork.png", art, svg, fixed = TRUE)
exports <- file.path(source_dir, "exports")
dir.create(exports, showWarnings = FALSE)
print_png <- file.path(exports, "logo.png")
raster <- rsvg::rsvg_png(charToRaw(svg), width = 1044, height = 1200)
magick::image_write(
magick::image_read(raster),
path = print_png,
format = "png",
density = "600x600"
)

# Outline the text separately to avoid resampling the embedded artwork.
text_only <- gsub("<image[^>]*/>", "", svg)
text_only <- gsub("<rect[^>]*/>", "", text_only)
text_only <- gsub('<polygon id="sticker-border"[^>]*/>', "", text_only)
print_svg <- file.path(exports, "logo.svg")
rsvg::rsvg_svg(charToRaw(text_only), print_svg, width = 1740, height = 2000)
outlined <- paste(readLines(print_svg), collapse = "\n")
inner <- sub("(?s).*?<svg[^>]*>", "", outlined, perl = TRUE)
inner <- sub("</svg>\\s*$", "", inner, perl = TRUE)
without_text <- gsub("(?s)<text[^>]*>.*?</text>", "", svg, perl = TRUE)
combined <- sub("</svg>", paste0(inner, "</svg>"), without_text, fixed = TRUE)
stopifnot(!grepl("<text[ >]", combined))
writeLines(combined, print_svg)

usethis::proj_set(root)
options(usethis.overwrite = TRUE)
usethis::use_logo(print_png)
1 change: 1 addition & 0 deletions data-raw/logo/prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use case: stylized-concept. A full-bleed fine-art OIL PAINTING for the balancing R package sticker. Portrait 3:4, no typography anywhere. This must look like a beautiful physical painting, NOT a logo, icon, isolated cutout, clipart, vector, digital mascot or product render. Paint an intimate still life in a quiet artist's studio: an old narrow balance beam made of weathered wood rests perfectly level across a simple dark triangular fulcrum on a worn pale stone table. A squat antique brass calibration weight with a round lifting knob sits at each end, matched size and equal distance so it is truly balanced. Show the objects in subtle three-quarter perspective with convincing depth, but the balance is visibly level. The brass weights have irregular tarnish and warm reflected light, not shiny perfect gold. A large soft window-light shape enters from upper left across a muted smoky teal wall, casting a long painterly shadow behind the arrangement. Rich thick brush marks and palette-knife scrapes, lost and found edges, delicious ochre, blue-black, pale celadon, dirty cream and warm sienna. Like a refined 20th-century European still-life painting reproduced in an art book. Strong expressive composition, asymmetrical lighting and architectural shadows, absolutely no heavy uniform outlines. The image fills the whole rectangular canvas with painted wall and tabletop, NO transparent background, no empty white backdrop. Main balance occupies central width x12%-88%, y30%-63%; lower quarter is painted quiet dark teal tabletop/shadow for real lettering later. No text, numbers, labels, watermark, border, hexagon, writing or decorative symbols.
6 changes: 6 additions & 0 deletions data-raw/logo/sticker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions pkgdown/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pkgdown/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Binary file added pkgdown/favicon/web-app-manifest-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/web-app-manifest-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tests/testthat/_snaps/ipw.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
x2), method = bw_entropy(), estimand = "ate")

Outcome Model:
Call: stats::glm(formula = formula, family = family, data = data, weights = .wts)
Call: stats::glm(formula = y ~ exposure, family = family, data = data,
weights = .wts)

Marginal estimates:
estimate std.err z ci.lower ci.upper conf.level
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ipw.R
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ test_that("an ipw() result prints for a balancing fit", {
)
w <- as.numeric(stats::weights(fit))
outcome_mod <- fit_outcome(y ~ exposure, data, w, stats::binomial())
# R versions differ in whether glm() stores the formula symbol or its value.
outcome_mod$call$formula <- quote(y ~ exposure)

result <- ipw(fit, outcome_mod)

Expand Down
Loading