Closes #332
Adds two new, top-level tinyplot() arguments:
weightsarg only passes through for the model-fit types (e.g.,"lm","glm") and distribution types (e.g.,"histogram","spineplot"). Passing through a top-levelweightsarg for a non-supported type is ignored, but triggers a warning (since it implies an unused statistical transformation).labelsarg only passes through fortype_textand is silently ignored otherwise.
Both of these are supported via NSE from the top-level, but users can also supply an equivalent atomic vector argument directly through the relevant type_*() constructor. For example, these two lines are equivalent:
plt(y ~ x, dat, type = "lm", weights = w) # top-level, nse plt(y ~ x, dat, type = type_lm(weights = dat$w) # type-level, vector
(However, the bottom variant is safer b/c it is incorporated into the model.frame computation, and so will correctly account for NAs across input columns, as well as subset operations.)
If both forms are provided at the same time, then the top-level variant wins out.
MWE
pkgload::load_all("~/Documents/Projects/tinyplot/") #> ℹ Loading tinyplot s77 = as.data.frame(state.x77) plt(`Life Exp` ~ Income, data = s77) plt_add(type = "lm") plt_add(type = "lm", weights = Population, col = "red")
ttnc = as.data.frame(Titanic) plt( Survived ~ Sex, data = ttnc, type = "spineplot", weights = Freq )
aq = transform(airquality, mnth = month.abb[Month]) # plt(Ozone ~ Temp, data = aq, type = type_text(labels = aq$mnth)) ## would fail b/c of NAs in Ozone plt(Ozone ~ Temp, data = aq, type = "text", labels = mnth)
Created on 2026-06-20 with reprex v2.1.1