Skip to content

Commit

Permalink
data.table works with dpasta and zzz_rs_fiddle
Browse files Browse the repository at this point in the history
bugfix by namespacing class in dfdf_paste
  • Loading branch information
jonocarroll committed Jul 23, 2018
1 parent 7b49708 commit f762241
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/dfdt_paste.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dfdt_construct <- function(input_table, oc = console_context(), class = NULL) {
message(paste0("Supplied large input_table (>=", .global_datapasta_env$max_rows ," rows). Was this a mistake? Use dp_set_max_rows(n) to increase the limit."))
return(NULL)
}
col_types <- lapply(input_table, class)
col_types <- lapply(input_table, base::class) # prevent clobbering by local class variable
#Store types as characters so the char lengths can be computed
input_table <- as.data.frame(lapply(input_table, as.character), stringsAsFactors = FALSE)
#Store types as characters so the char lengths can be computed
Expand Down
5 changes: 4 additions & 1 deletion R/dfiddle.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ zzz_rs_dfiddle <- function(){
tryCatch( expr = eval(parse(text = doc_context$text), envir = eval_env),
error = function(e) NULL)

if(tibble::is_tibble(selection_result) | is.data.frame(selection_result)){
if(tibble::is_tibble(selection_result) |
is.data.frame(selection_result)){
if(tibble::is_tibble(selection_result)) {
table_form <- tribble_construct(selection_result, oc = rstudio_context())
} else if (data.table::is.data.table(selection_result)) {
table_form <- dfdt_construct(selection_result, oc = rstudio_context(), class = "data.table")
} else {
table_form <- dfdt_construct(selection_result, oc = rstudio_context(), class = "data.frame")
}
Expand Down
2 changes: 2 additions & 0 deletions R/dpasta.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ dmdclip <- function(input){
dpasta <- function(input){
if(tibble::is_tibble(input)){
tribble_paste(input, output_context = guess_output_context())
}else if(data.table::is.data.table(input)){ # data.table inherits data.frame so test this first
dt_paste(input, output_context = guess_output_context())
}else if(is.data.frame(input)){
df_paste(input, output_context = guess_output_context())
}else if(is.vector(input)){
Expand Down

0 comments on commit f762241

Please sign in to comment.