[datatable-help] Random setnames() error although I don't even call this function.
Matthew Dowle
mdowle at mdowle.plus.com
Wed Sep 12 01:12:42 CEST 2012
This sounds like :
o Chris Neff for #2146: using := to add a column to the result of a
simple column subset such as DT[,list(x)], or after changing all
column names with setnames(), was an error. Fixed and tests added.
which was fixed just before 1.8.2 went to CRAN.
Please run test.data.table() on the Windows machine to ensure it returns
717 tests passed precisely. If not, then you managed to install a slightly
older version of 1.8.2 from R-Forge in the one or two day window that was
possible, after it was named 1.8.2 but before that fix was made. If so,
reinstalling from CRAN should fix it.
> Hi together,
>
> here's my code:
>
> library(data.table)
> test_fun <- function(DT, year) {
>
> adj_r2 <- DT[, list(Tau_1 = summary(lm(NI_1 ~
> Total_Assets))$adj.r.squared,
> Tau_2 = summary(lm(NI_2 ~
> Total_Assets))$adj.r.squared)]
>
>
> adj_r2[, Year := as.integer(year)]
>
> adj_r2
>
> }
>
> DT <- data.table(NI_1 = rnorm(1000),
> NI_2 = rnorm(1000),
> Total_Assets = rnorm(1000))
>
> test_fun(DT, 2000)
>
> This gives me the following error on my windows machine:
>
> Error in `[.data.table`(adj_r2, , `:=`(Year, as.integer(year))) :
> It appears that at some earlier point, names of this data.table have
> been
> reassigned. Please ensure to use setnames() rather than names<- or
> colnames<-. Otherwise, please report to datatable-help.
>
> My sessionInfo():
>
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
> LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
> LC_TIME=German_Germany.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] data.table_1.8.2
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.1
>
> Interestingly, on my Linux machine, everything works fine:
>
> Output there:
> Tau_1 Tau_2 Year
> 1: -0.0006947528 -0.0005516822 2000
>
> sessionInfo()
>
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
> LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
> LC_MONETARY=en_US.UTF-8
> [6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=C LC_NAME=C
> LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] iccFunctions_0.0.4 roxygen2_2.2.2 digest_0.5.2 dyn_0.2-8.1
> zoo_1.7-7 lubridate_1.1.0 data.table_1.8.2
>
> loaded via a namespace (and not attached):
> [1] brew_1.0-6 grid_2.15.1 lattice_0.20-10 plyr_1.7.1
> stringr_0.6.1 tools_2.15.1
>
> Therefore, could someone with a Windows machine confirm this error?
> Matthew, do you have an idea what is causing this?
>
> Thanks in advance,
>
> Christoph
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
More information about the datatable-help
mailing list