helper functions for nivce labels and FreesearchR color palette

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-06-26 09:21:42 +02:00
parent 91e2772a86
commit fde1a50140
No known key found for this signature in database
4 changed files with 84 additions and 2 deletions

View file

@ -46,7 +46,7 @@ FreesearchR_colors <- function(choose = NULL) {
secondary = "#FF6F61", secondary = "#FF6F61",
success = "#00C896", success = "#00C896",
warning = "#FFB100", warning = "#FFB100",
danger = "#FF3A2F", danger = "#CC2E25",
extra = "#8A4FFF", extra = "#8A4FFF",
info = "#11A0EC", info = "#11A0EC",
bg = "#FFFFFF", 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)
}

View file

@ -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)
}

23
man/unique_short.Rd Normal file
View file

@ -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()
}

28
man/visual_summary.Rd Normal file
View file

@ -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)
}