-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using set() "Internal error, please report" #2996
Comments
please be sure to setDT() after reading from .rda
…On Thu, Aug 9, 2018, 11:36 PM Joseph M. Burling ***@***.***> wrote:
Get an internal error with set() when loading an object to an environment
and getting then using object from same environment.
*Example:*
library(data.table)
print(sessionInfo())
load_tmp_rda <- function(v, folder, env) {
obj_name <- paste0("tmp", v)
filename <- file.path(folder, paste0(obj_name, ".rda"))
load(filename, env)
obj <- get(obj_name, env)
message(obj_name, " has ", nrow(obj), " rows")
set(obj, NULL, "version", v)
}
# doesn't work
local({
tmp1 <- data.table(runif(10000))
tmp_dir <- tempdir()
tmp_file <- file.path(tmp_dir, "tmp1.rda")
save(tmp1, file=tmp_file)
this <- environment()
load_tmp_rda(1L, tmp_dir, this)
})
# works
local({
tmp1 <- data.table(runif(10000))
obj_name <- paste0("tmp", 1L)
this <- environment()
obj <- get(obj_name, this)
set(obj, NULL, "version", 1L)
})
*Output:*
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.11.4
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 pillar_1.3.0 compiler_3.5.1 plyr_1.8.4 bindr_0.1.1 tools_3.5.1 digest_0.6.15 packrat_0.4.9-3 evaluate_0.11
[10] tibble_1.4.2 gtable_0.2.0 pkgconfig_2.0.1 rlang_0.2.1 rstudioapi_0.7 bindrcpp_0.2.2 gridExtra_2.3 stringr_1.3.1 dplyr_0.7.6
[19] styler_1.0.2 knitr_1.20 rprojroot_1.3-2 grid_3.5.1 tidyselect_0.2.4 glue_1.3.0 R6_2.2.2 rmarkdown_1.10 ggplot2_3.0.0
[28] purrr_0.2.5 mejr_1.2.0.9000 magrittr_1.5 rematch2_2.0.1 backports_1.1.2 scales_0.5.0 htmltools_0.3.6 rfmt_1.0 assertthat_0.2.0
[37] colorspace_1.3-2 stringi_1.1.7 lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4
tmp1 has 10000 rows
Error in set(obj, NULL, "version", v) :
Internal error, please report (including result of sessionInfo()) to data.table issue tracker: oldtncol (0) < oldncol (1) but tl of class is marked.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2996>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHQQdTr2LGGttcAEzq8a9PtMJa_uH5e6ks5uPP-zgaJpZM4V3iVv>
.
|
using library(data.table)
load_tmp_rda <- function(v, folder, env) {
obj_name <- paste0("tmp", v)
filename <- file.path(folder, paste0(obj_name, ".rda"))
load(filename, env)
obj <- get(obj_name, env)
setDT(obj) ## added this line
message(obj_name, " has ", nrow(obj), " rows")
set(obj, NULL, "version", v)
}
local({
tmp1 <- data.table(runif(10000))
tmp_dir <- tempdir()
tmp_file <- file.path(tmp_dir, "tmp1.rda")
save(tmp1, file=tmp_file)
this <- environment()
load_tmp_rda(1L, tmp_dir, this)
})
#tmp1 has 10000 rows error is gone. |
Probably we can improve the error message, it sounds like you did something really scary to see Can have a branch if |
Is there not an FAQ about this issue? Or something in the Wiki? Would like to refer to something in the error message... |
In the FAQ, under "Reading data.table from RDS or RData file" , it says to use alloc.col. I always use setDT. If that's recommended or just as good as alloc.col, maybe the FAQ can be updated to match. |
error message has to point to |
Get an internal error with set() when loading an object to an environment and getting then using object from same environment.
Example:
Output:
The text was updated successfully, but these errors were encountered: