From 4e27db04d511b518c83b9103d703681e5edd876a Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 23 Oct 2025 12:12:08 +0200 Subject: [PATCH] added use all columns option in utils --- R/exploratory_pca_report.R | 29 +++++++++++++++++++++++++++++ R/utils.R | 13 ++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 R/exploratory_pca_report.R diff --git a/R/exploratory_pca_report.R b/R/exploratory_pca_report.R new file mode 100644 index 0000000..91a2989 --- /dev/null +++ b/R/exploratory_pca_report.R @@ -0,0 +1,29 @@ +#' Exploratory PCA Report +#' +#' @description +#' +#' +#' @details +#' +#' +#' +#' @param argument1 < Explain type of argument and what it does here. If you set +#' a default value, give a reason why it is default unless this is obvious.> +#' @param argument2 integer, . The default value is 42. +#' @param ... Further arguments passed to . +#' +#' @references +#' +#' +#' @returns +#' +#' +#' @export # remove if the function should not be visible to the user +#' +#' @examples +#' + +add_pca_coordinates <- function(data, columns, id_column="id", use_all_numeric_columns =FALSE) { + +} \ No newline at end of file diff --git a/R/utils.R b/R/utils.R index bd08a31..69d8439 100644 --- a/R/utils.R +++ b/R/utils.R @@ -14,14 +14,17 @@ check_columns_exist <- function(df, columns) { #' @export -filter_columns_with_id <- function(df, columns, id_column = "id") { +filter_columns_with_id <- function(df, columns, id_column_name = "id", all = FALSE) { # all data is supposed to have an id column - required_cols <- c(id_column, columns) - + if (all){ + required_cols <- c(id_column_name, columns) + } else { + required_cols = colnames(df) + } check_columns_exist(df, required_cols) - if (length(unique(df[[id_column]])) != length(df[[id_column]])) { - stop(paste("Column ", id_column, " is not unique and therefore cannot be used as id")) + if (length(unique(df[[id_column_name]])) != length(df[[id_column_name]])) { + stop(paste("Column ", id_column_name, " is not unique and therefore cannot be used as id")) } df_filtered <- df[, required_cols]