Skip to content

Commit

Permalink
effectively fixed the bug in adding multipl columns
Browse files Browse the repository at this point in the history
  • Loading branch information
N-thony committed Aug 17, 2024
1 parent 6c162f4 commit 5e67018
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ DataSheet$set("public", "add_columns_to_data", function(col_name = "", col_data,
}
}

if(length(col_name) != num_cols) {
if(length(col_name) != num_cols && (num_cols == 1 || length(col_name) == 1)) {
use_col_name_as_prefix = TRUE
}
} else use_col_name_as_prefix = FALSE

replaced <- FALSE
previous_length = self$get_column_count()
Expand All @@ -712,9 +712,10 @@ DataSheet$set("public", "add_columns_to_data", function(col_name = "", col_data,
if(require_correct_length) stop("Length of new column must be divisible by the length of the data frame")
else curr_col <- rep(curr_col, length.out = self$get_data_frame_length())
}
print(use_col_name_as_prefix)
if(use_col_name_as_prefix) curr_col_name = self$get_next_default_column_name(col_name)
else curr_col_name = col_name
else curr_col_name = col_name[i]

curr_col_name <- make.names(iconv(curr_col_name, to = "ASCII//TRANSLIT", sub = "."))
new_col_names <- c(new_col_names, curr_col_name)
if(curr_col_name %in% self$get_column_names()) {
Expand Down

0 comments on commit 5e67018

Please sign in to comment.