Skip to content

Commit

Permalink
Handle NA columns for dropdowns specified in col_options.
Browse files Browse the repository at this point in the history
  • Loading branch information
DillonHammill committed Jul 27, 2020
1 parent 5b6a5a3 commit 053e0b0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions R/data_edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,22 @@ data_edit <- function(x,
# COLUMN OPTIONS - LOGICAL
if(!is.null(col_options)){
lapply(names(col_options), function(z){
if(is.logical(type.convert(col_options[[z]]))){
col_type <- type.convert(col_options[[z]], as.is = TRUE)
# CHECKBOXES
if(is.logical(col_type)){
if(!is.logical(x[, z])){
res <- type.convert(x[, z])
res <- type.convert(x[, z], as.is = TRUE)
if(!is.logical(res)){
res <- rep(NA, nrow(x))
}
x[, z] <<- res
}
# DROPDOWN MENUS
}else{
# NA TO EMPTY CHARACTERS
if(all(is.na(x[, z]))){
x[, z] <<- rep("", nrow(x))
}
}
})
}
Expand Down Expand Up @@ -330,6 +338,10 @@ data_edit <- function(x,
if(length(empty_col_names) > 0){
colnames(x_new)[empty_col_names] <- old_col_names[empty_col_names]
values[["x"]] <- x_new
# REVERT COLUMN NAME EDITS
}else if(col_names == FALSE){
colnames(x_new) <- old_col_names
values[["x"]] <- x_new
}
# ROW NAMES CANNOT BE EDITED
} else if ("rowHeaders" %in% names(input$x_changeHeaders)) {
Expand Down

0 comments on commit 053e0b0

Please sign in to comment.