Skip to content

feat: random_ggplot('ts'), random_mock(), random_text(var=) — issues #4 #1 #3#16

Open
VincentGuyader wants to merge 10 commits into
masterfrom
feat/text-variants-and-ts-plot
Open

feat: random_ggplot('ts'), random_mock(), random_text(var=) — issues #4 #1 #3#16
VincentGuyader wants to merge 10 commits into
masterfrom
feat/text-variants-and-ts-plot

Conversation

@VincentGuyader
Copy link
Copy Markdown
Member

Summary

# Type Résumé
#4 feat random_ggplot() gains a "ts" type (alias "timeseries") returning a time-series oriented plot, with a Date on the x axis. 3 variants (economics$unemploy line, AirPassengers line+point, economics$psavert area). "ts" is part of the random pool.
#1 feat New exported random_mock(widths, heights = 3, labels = NULL): builds a quick "zoning" of a Shiny UI as a row of bordered, labelled bootstrap columns, returned as a self-contained htmltools::tagList (CSS <style> + columns) droppable inside fluidPage() / bslib::page_fluid(). Default labels are short random lorem snippets.
#3 feat random_text() gains a var integer argument: var = 1 keeps the historical output byte-for-byte, higher values return distinct (wrapping) slices of the lorem corpus — useful for repeated calls in a list.
#13 fix random_ggplot("line") no longer triggers ggplot2's size → linewidth deprecation warning. (Also addressed in PR #15; trivial to reconcile.)

New dependency: htmltools in Imports (already a transitive dep via plotly / DT / dygraphs).

Test plan (TDD, red first)

  • New test files written before the implementation and watched fail for the right reason:
    • tests/testthat/test-ggplot-ts.R"ts"/"timeseries" returns a ggplot whose data has a Date date column, build emits no warning, "ts" in the random pool.
    • tests/testthat/test-mock.R — tagList of bootstrap columns, custom labels, recycling of heights/labels, auto labels, widths validation.
    • tests/testthat/test-text-var.Rvar = 1 ≡ historical behaviour, distinct var ⇒ distinct text, size preserved, large var wraps (no NA), combines with offset, validation.
  • Added a coverage test for random_ggplotly() (previously uncovered).
  • devtools::test(): 3398 PASS / 0 FAIL / 0 WARN.
  • R CMD check --no-manual (tarball): 0 error / 0 warning / 1 note (utils import unused — pre-existing on master).
  • Package coverage: 98.07% → 98.76%; R/Plot.R, R/Mock.R, R/Text.R at 100%.

Tracking notes in dev/SUIVI_AUTONOME.md.

Closes #1
Closes #3
Closes #4

VincentGuyader added a commit that referenced this pull request May 12, 2026
Addresses pr-reviewer nits on #16: explicit heights guard with tests,
and distinct wrapping default labels via random_text(var = i).
@VincentGuyader
Copy link
Copy Markdown
Member Author

CI status: R-CMD-check is green on all 5 platforms (macOS, Windows, Ubuntu devel/release/oldrel-1), 0 error / 0 warning.

The only red check is test-coverage, which fails at setup with This request has been automatically failed because it uses a deprecated version of actions/cache: v2 — that workflow (.github/workflows/test-coverage.yaml) is still on r-lib/actions/...@v1 + actions/cache@v2. This is pre-existing on master and on every branch; modernising the workflows is already handled by #14 / #15, so I deliberately did not duplicate that change here.

Ready for review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new prototyping helpers and improves existing generators in {shinipsum}: time-series ggplots, UI “zoning” mocks for Shiny layouts, and deterministic text variants for repeated placeholder text use.

Changes:

  • Extend random_ggplot() with a new "ts" / "timeseries" type and include it in the random pool; also remove ggplot2 sizelinewidth deprecation warning for the "line" type.
  • Add new exported random_mock() to generate a bootstrap-row mock UI layout as a self-contained htmltools::tagList().
  • Extend random_text() with a var argument for repeatable “variant” slices of the lorem corpus, plus new tests and documentation updates.

Reviewed changes

Copilot reviewed 13 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
R/Plot.R Adds "ts" time-series ggplot variants, alias handling, and updates geom_line() to use linewidth.
R/Text.R Adds var argument with validation and variant/wrapping logic for both char- and word-based outputs.
R/Mock.R Introduces random_mock() and internal CSS helper for Shiny UI layout zoning.
R/globals.R Extends globalVariables() to cover new NSE columns used by the "ts" plots.
tests/testthat/test-ggplot-ts.R Adds tests for "ts"/"timeseries" behavior, Date x-axis, no-build-warnings, and pool inclusion.
tests/testthat/test-ggplot.R Adds deterministic random_ggplotly() coverage test using non-optional plot types.
tests/testthat/test-mock.R Adds tests for random_mock() output structure, recycling, auto labels, and input validation.
tests/testthat/test-text-var.R Adds tests for random_text(var=) backward compatibility, variation, wrapping, and validation.
DESCRIPTION Adds htmltools to Imports; adds MASS/hexbin to Suggests; updates RoxygenNote.
NAMESPACE Exports random_mock; imports new symbols from attempt, ggplot2, and htmltools.
NEWS.md Documents the new features and the ggplot2 deprecation warning fix.
man/random_ggplot.Rd Updates docs to include "ts" and its behavior.
man/random_text.Rd Updates docs to include the new var argument.
man/random_mock.Rd Adds documentation for the new random_mock() function.
man/shinipsum-package.Rd Minor formatting adjustment in package description.
.Rbuildignore Adds dev/ to build ignore patterns.
dev/SUIVI_AUTONOME.md Adds internal development tracking notes for the implemented issues.
Files not reviewed (4)
  • man/random_ggplot.Rd: Language not supported
  • man/random_mock.Rd: Language not supported
  • man/random_text.Rd: Language not supported
  • man/shinipsum-package.Rd: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/Text.R Outdated
@@ -21,18 +26,38 @@ random_text <- function(nchars = NULL, nwords = NULL, offset=0){
~ !is.null(.x),
"You can't chose both nchars and nwords"
Comment thread R/Text.R Outdated
} else {
n <- length(shinipsum::lorem_words)
shift <- (var - 1L) * nwords
idx <- ((1 + offset:nwords + offset + shift) - 1L) %% n + 1L
Comment thread R/Plot.R Outdated
Comment on lines 16 to 20
@@ -18,7 +18,10 @@ random_ggplot <- function(type = c("random", "point", "bar",
"density", "density_2d", "dotplot",
"hex", "freqpoly", "histogram",
"ribbon", "raster", "tile",
@VincentGuyader VincentGuyader requested a review from Copilot May 12, 2026 10:57
VincentGuyader added a commit that referenced this pull request May 12, 2026
- typo 'chose' -> 'choose' in random_text() error message
- rewrite random_text() var>1 word-indexing without ambiguous +/: precedence
- de-duplicate 'tile' in random_ggplot() type choices (was biasing the
  random pool) + add a no-duplicates test
@VincentGuyader
Copy link
Copy Markdown
Member Author

Thanks @copilot — all three points addressed in dce10a3:

  1. `R/Text.R` — "chose" → "choose": fixed (it was a pre-existing typo in the nchars / nwords mutual-exclusion error message).
  2. `R/Text.R` — ambiguous `+`/`:` precedence for `var > 1`: the word-based branch is rewritten explicitly — start <- (offset + (var - 1L) * nwords) %% n; idx <- ((start + seq.int(0L, nwords)) %% n) + 1L. It now returns a consistent nwords + 1 words for any var > 1, with wrap-around, and var == 1 is still byte-for-byte the historical output.
  3. `R/Plot.R` — "tile" listed twice in `type`: de-duplicated in both the formals and the roxygen @param, which removes the sampling bias for type = "random". Added a regression test asserting anyDuplicated(eval(formals(random_ggplot)$type)) == 0. (The unreachable "tile" = sample(160:161, 1) switch branch is left untouched — pre-existing, harmless, out of scope here.)

Re: the red test-coverage check — that's the pre-existing actions/cache@v2 auto-fail in the old workflow, fixed by #14; unrelated to this PR.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 17 changed files in this pull request and generated 4 comments.

Files not reviewed (4)
  • man/random_ggplot.Rd: Language not supported
  • man/random_mock.Rd: Language not supported
  • man/random_text.Rd: Language not supported
  • man/shinipsum-package.Rd: Language not supported

Comment thread R/Plot.R
Comment on lines 15 to +21
random_ggplot <- function(type = c("random", "point", "bar",
"boxplot","col", "tile",
"line", "bin2d", "contour",
"density", "density_2d", "dotplot",
"hex", "freqpoly", "histogram",
"ribbon", "raster", "tile",
"violin")) {
"ribbon", "raster",
"violin", "ts")) {
Comment thread R/Plot.R
Comment on lines 49 to +53
"ribbon" = sample(140:141, 1),
"raster" = sample(150:151, 1),
"tile" = sample(160:161, 1),
"violin" = sample(170:171, 1)
"violin" = sample(170:171, 1),
"ts" = sample(180:182, 1)
Comment thread R/Text.R
Comment on lines 24 to 28
stop_if_all(
list(nchars, nwords),
~ !is.null(.x),
"You can't chose both nchars and nwords"
"You can't choose both nchars and nwords"
)
Comment thread NEWS.md Outdated
the lorem-ipsum corpus on repeated calls (#3).
* Fixed a `ggplot2` deprecation warning in `random_ggplot("line")`
(`size` -> `linewidth`) (#13).
* Added a `NEWS.md` file to track changes to the package.
- new type 'ts' (alias 'timeseries') with 3 Date-axis variants
  (economics unemploy/psavert, AirPassengers)
- fix geom_line(size=) -> linewidth deprecation warning (#13)
- add coverage for random_ggplotly()
- TDD: tests/testthat/test-ggplot-ts.R written first (red), then implementation
- random_mock(widths, heights, labels) returns a htmltools::tagList of
  bordered bootstrap columns to sketch a Shiny UI zoning
- new Imports: htmltools
- declare psavert/passengers globals, ignore dev/ in build
- TDD: tests/testthat/test-mock.R written first (red), then implementation
- random_text(..., var = N): var = 1 keeps the historical output,
  higher values return distinct (wrapping) slices of the lorem corpus
- TDD: tests/testthat/test-text-var.R written first (red), then implementation
Addresses pr-reviewer nits on #16: explicit heights guard with tests,
and distinct wrapping default labels via random_text(var = i).
… Suggests

random_ggplotly() with no arg could build a density_2d/hex variant whose
rendering needs MASS/hexbin, absent on minimal CI images. Pin the test to
package-free geom types, and declare MASS + hexbin in Suggests so the
density_2d / hex types of random_ggplot() work (also clears the --as-cran
test ERROR).
- typo 'chose' -> 'choose' in random_text() error message
- rewrite random_text() var>1 word-indexing without ambiguous +/: precedence
- de-duplicate 'tile' in random_ggplot() type choices (was biasing the
  random pool) + add a no-duplicates test
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 17 changed files in this pull request and generated 3 comments.

Files not reviewed (4)
  • man/random_ggplot.Rd: Language not supported
  • man/random_mock.Rd: Language not supported
  • man/random_text.Rd: Language not supported
  • man/shinipsum-package.Rd: Language not supported

Comment thread R/Text.R Outdated
} else {
n <- length(shinipsum::lorem_words)
start <- (offset + (var - 1L) * nwords) %% n
idx <- ((start + seq.int(0L, nwords)) %% n) + 1L
Comment thread R/Plot.R
Comment on lines 48 to +53
"histogram" = sample(130:131, 1),
"ribbon" = sample(140:141, 1),
"raster" = sample(150:151, 1),
"tile" = sample(160:161, 1),
"violin" = sample(170:171, 1)
"violin" = sample(170:171, 1),
"ts" = sample(180:182, 1)
Comment thread NEWS.md Outdated
the lorem-ipsum corpus on repeated calls (#3).
* Fixed a `ggplot2` deprecation warning in `random_ggplot("line")`
(`size` -> `linewidth`) (#13).
* Added a `NEWS.md` file to track changes to the package.
- merge the duplicate (unreachable) 'tile' switch branch:
  sample(c(40:41, 160:161), 1) so variants 160/161 are reachable
- drop the stale 'Added a NEWS.md file' bullet (NEWS.md already exists)
@VincentGuyader
Copy link
Copy Markdown
Member Author

Thanks @copilot — re-review handled in 3307c48:

  • "tile" duplicated in formals()$type and the "chose" → "choose" typo: these were already fixed in the previous commit (81c4f58); the re-review was looking at the earlier state.
  • R/Plot.R — unreachable "tile" = sample(160:161, 1) switch branch: merged into a single branch — "tile" = sample(c(40:41, 160:161), 1) — so the 160/161 variants are now reachable (and exercised by the 100-iteration random_ggplot() test, with 0 zero-coverage lines in Plot.R).
  • NEWS.md — "Added a NEWS.md file" bullet: removed (the file already exists; the bullet was inherited from master and not informative).

CI is fully green (6/6, test-coverage included after the rebase on the merged #14).

)

The var>1 word branch produced nwords+1 indices. Use seq_len(nwords) so
exactly nwords words come back; var==1 stays byte-for-byte the legacy
output. Add a word-count test for var>1.
@VincentGuyader
Copy link
Copy Markdown
Member Author

Re-review @copilot717dfce:

  • NEWS.md "Added a NEWS.md file" bullet and the duplicate "tile" switch branch: both already fixed in 3307c48 — the re-review ran against an earlier commit. The current NEWS.md has no such bullet, and R/Plot.R has a single "tile" = sample(c(40:41, 160:161), 1) branch (so 40-41 and 160-161 are all reachable; Plot.R has 0 zero-coverage lines).
  • R/Text.Rvar > 1 returned nwords + 1 words: fixed — idx <- ((start + seq_len(nwords) - 1L) %% n) + 1L, so it now returns exactly nwords words for any var > 1, with a word-count regression test. (var == 1 is intentionally left byte-for-byte identical to the legacy output — the legacy 1 + offset:nwords + offset slicing is its own pre-existing off-by-one, out of scope for this PR.)

CI: green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time series option for random_ggplot() Other lorem ipsum options for random_text() mock_frame()

2 participants