Skip to content

Commit

Permalink
Merge pull request IDEMSInternational#9091 from N-thony/bug_fix_addin…
Browse files Browse the repository at this point in the history
…g_column

Bug fixes in adding columns
  • Loading branch information
Patowhiz authored Sep 21, 2024
2 parents 8be0416 + 5e67018 commit fb93fb5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 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,8 +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())
}
if(use_col_name_as_prefix) curr_col_name = self$get_next_default_column_name(col_name[i])
else curr_col_name = col_name[[i]]
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[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 fb93fb5

Please sign in to comment.