Skip to content

Commit

Permalink
bugfix to not convert factors to numeric pefore PCA plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederik Ziebell committed Jul 15, 2024
1 parent d3e86e5 commit baea136
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions R/pca.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#' for a character vector x,
#' for a vector x,
#' check if all non-NA elements of x
#' can be converted to numeric
#' @param x A character vector
#' @param x A non-numeric vector
all_numeric <- function(x){

if(is.factor(x)){
return(FALSE)
}

x_no_na <- x[!is.na(x)]

if(length(x_no_na) == 0){
FALSE
} else {
return(FALSE)
}

suppressWarnings(
x_numeric <- as.numeric(x_no_na)
)
suppressWarnings(
x_numeric <- as.numeric(x_no_na)
)

all(!is.na(x_numeric))

all(!is.na(x_numeric))
}
}

.compute_pca <- function(obj, n_feats, scale_feats, na_frac, metadata, color_by){
Expand Down

0 comments on commit baea136

Please sign in to comment.