Skip to content
Merged

Dev #83

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5c5668f
Fix broken \link{} in movingAve2()/imovingSEM() @title tags
claude Aug 31, 2026
0b360c6
Restore as.named.vector.table()'s commented-out build logic
vertesy Aug 31, 2026
9b1b9c9
Merge pull request #73 from vertesy/main
vertesy Aug 31, 2026
63a6c7d
Merge pull request #71 from vertesy/fix/moving-deprecated-title-link
vertesy Aug 31, 2026
0ed1332
Forward ... to as.vector() in as.named.vector.table()
github-actions[bot] Aug 31, 2026
7cac0f6
Add missing @export to pU()
claude Aug 31, 2026
13242dc
Merge pull request #72 from vertesy/fix/as-named-vector-table-undefin…
vertesy Aug 31, 2026
89beb3d
Never auto-bump the package version
vertesy Aug 31, 2026
b9dcc8c
Bump AGENTS.md version stamp
vertesy Aug 31, 2026
7caa4da
Merge pull request #74 from vertesy/docs/no-auto-version-bump
vertesy Sep 1, 2026
9eb926e
Fix getCategories() always returning an empty vector
claude Sep 1, 2026
ee50823
Fix select_rows_and_columns() silently returning a vector for single …
claude Sep 1, 2026
26ea755
Fix rescale() silent divide-by-zero on constant/single-element input
claude Sep 1, 2026
86cc339
Fix as_tibble_from_namedVec() returning a character matrix, not a tib…
claude Sep 1, 2026
f78d297
Fix df.row.2.named.vector() always returning a list, never a vector
claude Sep 1, 2026
819c585
Require concise, structured PR descriptions
vertesy Sep 1, 2026
e386a56
Fix overflow in rescale()'s constant-input midpoint calculation
claude Sep 1, 2026
5d86ed1
Fix as_tibble_from_namedVec() rejecting duplicate/empty names after t…
claude Sep 1, 2026
9e3e65b
Fix df.row.2.named.vector() silently converting factor labels to inte…
claude Sep 1, 2026
d6f0df9
Merge branch 'dev' into fix/pU-missing-export
vertesy Sep 1, 2026
6d3ed47
Merge pull request #75 from vertesy/fix/pU-missing-export
vertesy Sep 1, 2026
73268c8
Merge pull request #81 from vertesy/docs/concise-pr-descriptions
vertesy Sep 1, 2026
ebd7591
Consolidate list-of-functions cleanup into one file.remove() call
vertesy Sep 1, 2026
814e7ce
Merge pull request #82 from vertesy/chore/consolidate-list-of-funs-cl…
vertesy Sep 1, 2026
ce087ff
Merge pull request #77 from vertesy/fix/select-rows-cols-drop
vertesy Sep 1, 2026
8171703
Merge remote-tracking branch 'origin/dev' into fix/rescale-divide-by-…
Copilot Sep 1, 2026
ed104a5
Merge branch 'dev' into fix/as-tibble-from-namedvec-transpose
vertesy Sep 1, 2026
2a8dece
Merge pull request #79 from vertesy/fix/as-tibble-from-namedvec-trans…
vertesy Sep 1, 2026
f697c27
Merge branch 'dev' into fix/df-row-2-named-vector-list-bug
vertesy Sep 1, 2026
0e6ca3a
Merge pull request #80 from vertesy/fix/df-row-2-named-vector-list-bug
vertesy Sep 1, 2026
9a63784
Merge branch 'dev' into fix/getCategories-always-empty
vertesy Sep 1, 2026
ce48d4a
Merge pull request #76 from vertesy/fix/getCategories-always-empty
vertesy Sep 1, 2026
9b343ff
Merge pull request #78 from vertesy/fix/rescale-divide-by-zero
vertesy Sep 1, 2026
25558cb
Avoid rescale midpoint overflow
Copilot Sep 1, 2026
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
14 changes: 11 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Guidance for Agents

Version: 2026.08.27-00:00
Version: 2026.08.31-00:01

## I: Generic (all @vertesy repos)

Expand Down Expand Up @@ -31,7 +31,14 @@ For each finding, state:
Keep only findings that can be explained clearly and concisely.
Do not flag formatting, line length, or missing tests.

### 3. Update the Source, Not Just the Documentation
### 3. Pull Request Descriptions

Open each PR with a few bullets per major change: what was wrong, how it was fixed, and whether it changes the function's output or behavior.

- Scale the description to the change: a typo or comment-only fix needs one short line, not a paragraph.
- Keep the whole description under 250 words; reserve that ceiling for genuinely complex PRs. If it doesn't fit, split the PR instead of writing more.

### 4. Update the Source, Not Just the Documentation

Documentation is generated from upstream sources: `.Rd` files from roxygen annotations and `DESCRIPTION` from `Development/Dependencies.R` via `config.R`.

Expand All @@ -41,7 +48,8 @@ Package rebuilds overwrite these files, so always update the upstream source fir

- New arguments go at the end, just before `...`. Never insert in the middle.
- Do not use tests.
- Whenever you are implementing a larger change (a bug fix, a substantial code change), you shoud increase the version number in `Development/config.R` by 0.0.1.
- Never update the package version unless the user explicitly requests a version change.
- Do not raise code review findings that ask for a package version change.

## III: CodeAndRoll2 specific

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CodeAndRoll2
Title: CodeAndRoll2 for vector, matrix and list manipulations
Version: 2.8.15
Version: 2.8.20
Authors@R:
person("Abel", "Vertesy", , "av@imba.oeaw.ac.at", role = c("aut", "cre"))
Description: CodeAndRoll2 is a set of more than 170 productivity functions
Expand Down
3 changes: 2 additions & 1 deletion Development/Create_the_CodeAndRoll2_Package.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ for (scriptX in ls.scripts.full.path) {
}
file.edit(paste0(repository.dir, "/R/list.of.functions.in.", package.name, ".det.md"))
file.edit(paste0(repository.dir, "/README.md"))
file.remove(paste0(repository.dir, "/R/list.of.functions.in.", package.name, ".det.md"))
# file.remove(paste0(repository.dir, "/R/list.of.functions.in.", package.name, ".det.md"))
file.remove(list.files(file.path(repository.dir, "R"), pattern = "^list\\.of\\.functions\\.in\\..+\\.det\\.md$", full.names = TRUE))

r$PackageTools()
PackageTools::copy_github_badge("active") # Add badge to readme via clipboard
Expand Down
2 changes: 1 addition & 1 deletion Development/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

DESCRIPTION <- list(
package.name = "CodeAndRoll2",
version = "2.8.15",
version = "2.8.20",
title = "CodeAndRoll2 for vector, matrix and list manipulations",
description = "CodeAndRoll2 is a set of more than 170 productivity functions for vector, matrix
and list manipulations and math. Used by MarkdownReports, ggExpress, SeuratUtils, etc.",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export(pAny)
export(pFilter)
export(pLength)
export(pSee)
export(pU)
export(pc_TRUE)
export(pc_in_total_of_match)
export(pc_overlap)
Expand Down
41 changes: 24 additions & 17 deletions R/CodeAndRoll2.R
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ pLength <- function(x) {
#' @param x The object whose unique elements to print and return. Default: None.
#' @param head_n Max number of unique elements to print. Default: 20
#' @return The input object `x`, unchanged.
#' @export
#' @examples
#' results <- c(1, 2, 2, 3, 3, 3) |>
#' pU() |>
Expand Down Expand Up @@ -834,7 +835,7 @@ table_decreasing_hybrid <- function(vec, first_elements = FALSE, useNA = "ifany"
#' @export
#' @examples getCategories(c("A" = 1, "B" = 1, "C" = 2, 3))
getCategories <- function(named_categ_vec) {
named_categ_vec[names(unique(named_categ_vec))]
named_categ_vec[!duplicated(named_categ_vec)]
}


Expand Down Expand Up @@ -963,12 +964,11 @@ as.named.vector.table <- function(table, verbose = TRUE,
stopifnot("table must be 1D" = length(dim(table)) <= 1)
stopifnot(Stringendo::HasNames(table))

# NOTE: BUG -- the lines that would actually build 'v' are commented out below,
# so 'v' is never defined; any call to this (deprecated) function errors.
# v <- as.vector(unclass(table)); attributes(v) <- NULL; # Atomic vector with names
# names(v) <- dimnames(table)[[1]]
# Even after unclass(), the dim attribute remains, and is.vector() only returns TRUE if
# an object has no attributes other than names.
v <- as.vector(unclass(table), ...)
attributes(v) <- NULL
names(v) <- dimnames(table)[[1]]

stopifnot(length(v) == length(table))
return(v)
Expand Down Expand Up @@ -1049,7 +1049,8 @@ df.col.2.named.vector <- function(df, col, names = NULL) {
df.row.2.named.vector <- function(df, row, names = NULL) {
stopifnot(length(row) == 1)

vec <- as.vector(df[row, , drop = TRUE])
row_list <- lapply(df[row, , drop = TRUE], function(x) if (is.factor(x)) as.character(x) else x)
vec <- unlist(row_list, use.names = FALSE)
names(vec) <- if (is.null(names)) colnames(df) else as.vector(unlist(df[names]))
return(vec)
}
Expand Down Expand Up @@ -1093,15 +1094,15 @@ tibble_summary_to_namedVec <- function(
#' @export
as_tibble_from_namedVec <- function(vec.w.names = c("a" = 1, "b" = 2), transpose = TRUE) {
stopifnot(!is.null(names(vec.w.names)))
# tbl <- dplyr::bind_rows(vec.w.names)
# if (transpose) t(tbl) else tbl

tbl <- tibble::tibble(
if (transpose) {
return(tibble::as_tibble_row(vec.w.names, .name_repair = "minimal"))
}

tibble::tibble(
name = names(vec.w.names),
value = unname(vec.w.names)
)

if (transpose) t(as.matrix(tbl)) else tbl
}


Expand Down Expand Up @@ -1274,8 +1275,14 @@ translate <- function(vec, old, new) {
#' @param upto max, Default: 100
#' @export
rescale <- function(vec, from = 0, upto = 100) {
vec <- vec - min(vec, na.rm = TRUE)
vec <- vec * ((upto - from) / max(vec, na.rm = TRUE))
vmin <- min(vec, na.rm = TRUE)
vmax <- max(vec, na.rm = TRUE)
if (vmax == vmin) {
vec[!is.na(vec)] <- from / 2 + upto / 2
return(vec)
}
vec <- vec - vmin
vec <- vec * ((upto - from) / (vmax - vmin))
vec <- vec + from
return(vec)
} # fun
Expand Down Expand Up @@ -2548,7 +2555,7 @@ select_rows_and_columns <- function(df, RowIDs = NULL, ColIDs = NULL) {
} else {
Stringendo::iprint("All row IDs found")
} # if
df <- df[true_rownames, ]
df <- df[true_rownames, , drop = FALSE]
} # if
if (length(ColIDs)) {
true_colnames <- intersect(colnames(df), ColIDs)
Expand All @@ -2558,7 +2565,7 @@ select_rows_and_columns <- function(df, RowIDs = NULL, ColIDs = NULL) {
} else {
Stringendo::iprint("All column IDs found")
}
df <- df[, true_colnames]
df <- df[, true_colnames, drop = FALSE]
} # if
Stringendo::iprint(dim(df))
return(df)
Expand Down Expand Up @@ -3927,7 +3934,7 @@ movingAve <- function(x, oneSide = 5, partial = TRUE) {


# _________________________________________________________________________________________________
#' @title Moving / rolling average (v2, filter) [Deprecated]
#' @title Moving / rolling average (v2, filter) (Deprecated)
#' @description Calculates the moving / rolling average of a numeric vector, using `filter()`.
#' Deprecated in favor of [movingAve()], which offers the same shrinking- vs. fixed-window
#' choice (via `partial`) in a single implementation. Note `n` here is the *total* window
Expand Down Expand Up @@ -3981,7 +3988,7 @@ movingSEM <- function(x, oneSide = 5, partial = TRUE) {


# _________________________________________________________________________________________________
#' @title imovingSEM [Deprecated]
#' @title imovingSEM (Deprecated)
#'
#' @description Calculates the moving / rolling standard error of the mean (SEM), shrinking the
#' window near the edges. Deprecated: identical to `movingSEM(x, oneSide, partial = TRUE)`, use
Expand Down
2 changes: 1 addition & 1 deletion man/imovingSEM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/movingAve2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.