Skip to content

Commit

Permalink
* IMPRoVeD: umx_is_class robust to being given a tibble
Browse files Browse the repository at this point in the history
closes #101 (might need to re-open if there are more cases of where toggling drop from TRUE to FALSE interferes with data types)
  • Loading branch information
tbates committed Aug 16, 2019
1 parent df44470 commit e023276
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
3 changes: 2 additions & 1 deletion R/misc_and_utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -4519,6 +4519,7 @@ umx_scale <- function(df, varsToScale = NULL, coerce = FALSE, attr = FALSE, verb
#' umx_is_class(mtcars, c("character", "numeric"))
#' # Is zygosity a factor (note we don't drop = F to keep as dataframe)
#' umx_is_class(twinData[,"zygosity", drop=FALSE], classes = "factor")
#' umx_is_class(mtcars$mpg) # report class of this column (same as class(mpg))
umx_is_class <- function(df, classes=NULL, all = TRUE){
if(!is.data.frame(df)){
if(is.null(classes)){
Expand All @@ -4532,7 +4533,7 @@ umx_is_class <- function(df, classes=NULL, all = TRUE){
i = 1
if(is.null(classes)){
for (n in colNames) {
bIsOK[i] = class(df[, n])[1]
bIsOK[i] = class(df[, n, drop = TRUE])[1]
i = i + 1
}
return(bIsOK)
Expand Down
44 changes: 22 additions & 22 deletions man/umxPower.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/umx_is_class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/umx_set_silent.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e023276

Please sign in to comment.