From fde1a5014066998ac7b3e63aa3fa49a45e7df175 Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Thu, 26 Jun 2025 09:21:42 +0200 Subject: [PATCH] helper functions for nivce labels and FreesearchR color palette --- R/theme.R | 15 +++++++++++++-- man/FreesearchR_palette.Rd | 20 ++++++++++++++++++++ man/unique_short.Rd | 23 +++++++++++++++++++++++ man/visual_summary.Rd | 28 ++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 man/FreesearchR_palette.Rd create mode 100644 man/unique_short.Rd create mode 100644 man/visual_summary.Rd diff --git a/R/theme.R b/R/theme.R index 7f8c7f7..2bcc269 100644 --- a/R/theme.R +++ b/R/theme.R @@ -46,7 +46,7 @@ FreesearchR_colors <- function(choose = NULL) { secondary = "#FF6F61", success = "#00C896", warning = "#FFB100", - danger = "#FF3A2F", + danger = "#CC2E25", extra = "#8A4FFF", info = "#11A0EC", bg = "#FFFFFF", @@ -60,7 +60,18 @@ FreesearchR_colors <- function(choose = NULL) { } } - +#' Use the FreesearchR colors +#' +#' @param n number of colors +#' +#' @returns character vector +#' @export +#' +#' @examples +#' FreesearchR_palette(n=7) +FreesearchR_palette <- function(n){ + rep_len(FreesearchR_colors(),n) +} diff --git a/man/FreesearchR_palette.Rd b/man/FreesearchR_palette.Rd new file mode 100644 index 0000000..f0033c2 --- /dev/null +++ b/man/FreesearchR_palette.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/theme.R +\name{FreesearchR_palette} +\alias{FreesearchR_palette} +\title{Use the FreesearchR colors} +\usage{ +FreesearchR_palette(n) +} +\arguments{ +\item{n}{number of colors} +} +\value{ +character vector +} +\description{ +Use the FreesearchR colors +} +\examples{ +FreesearchR_palette(n=7) +} diff --git a/man/unique_short.Rd b/man/unique_short.Rd new file mode 100644 index 0000000..6a9d7b1 --- /dev/null +++ b/man/unique_short.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visual_summary.R +\name{unique_short} +\alias{unique_short} +\title{Create unique short names of character vector items based on index} +\usage{ +unique_short(data, max = 15) +} +\arguments{ +\item{data}{character vector} + +\item{max}{maximum final name length} +} +\value{ +character vector +} +\description{ +The function will prefer original names, and only append index to long +strings. +} +\examples{ +c("kahdleidnsallskdj", "hej") |> unique_short() +} diff --git a/man/visual_summary.Rd b/man/visual_summary.Rd new file mode 100644 index 0000000..4a508ea --- /dev/null +++ b/man/visual_summary.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/visual_summary.R +\name{visual_summary} +\alias{visual_summary} +\title{Ggplot2 data summary visualisation based on visdat::vis_dat.} +\usage{ +visual_summary(data, legend.title = "Data class", ...) +} +\arguments{ +\item{data}{data} + +\item{...}{optional arguments passed to data_summary_gather()} +} +\value{ +ggplot2 object +} +\description{ +Ggplot2 data summary visualisation based on visdat::vis_dat. +} +\examples{ +data_demo <- mtcars +data_demo[sample(1:32, 10), "cyl"] <- NA +data_demo[sample(1:32, 8), "vs"] <- NA +visual_summary(data_demo) +visual_summary(data_demo, palette.fun = scales::hue_pal()) +visual_summary(dplyr::storms) +visual_summary(dplyr::storms, summary.fun = data_type) +}