Skip to content
Draft
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
29 changes: 29 additions & 0 deletions R/exploratory_pca_report.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Exploratory PCA Report
#'
#' @description
#' <What the function does, 1 or 2 sentences>
#'
#' @details
#' <Any text written here goes into the "Details" section>
#'
#'
#' @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, <doing stuff>. The default value is 42.
#' @param ... Further arguments passed to <name functions>.
#'
#' @references
#' <include here any relevant literature references>
#'
#' @returns
#' <Describe the output of the function. This part goes into the "Value" section>
#'
#' @export # remove if the function should not be visible to the user
#'
#' @examples
#' <write here any example code. These are small simple examples on how to use
#' the function or to highlight specific features>

add_pca_coordinates <- function(data, columns, id_column="id", use_all_numeric_columns =FALSE) {

}
15 changes: 9 additions & 6 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ check_columns_exist <- function(df, columns) {
TRUE
}


filter_columns_with_id <- function(df, columns, id_column = "id") {
#' @export
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]
Expand Down
Loading