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 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.19
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
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.19",
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
10 changes: 8 additions & 2 deletions R/CodeAndRoll2.R
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,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 + (upto - from) / 2
return(vec)
}
vec <- vec - vmin
vec <- vec * ((upto - from) / (vmax - vmin))
vec <- vec + from
return(vec)
} # fun
Expand Down