Hi together,
<div><br></div><div>here's my code:</div><div><br></div><div><div>library(data.table)</div><div>test_fun <- function(DT, year) {</div><div> </div><div> adj_r2 <- DT[, list(Tau_1 = summary(lm(NI_1 ~ Total_Assets))$adj.r.squared,</div>
<div> Tau_2 = summary(lm(NI_2 ~ Total_Assets))$adj.r.squared)]</div><div> </div><div> </div><div> adj_r2[, Year := as.integer(year)]</div><div> </div><div> adj_r2</div><div> </div><div>}</div>
<div><br></div><div>DT <- data.table(NI_1 = rnorm(1000),</div><div> NI_2 = rnorm(1000),</div><div> Total_Assets = rnorm(1000))</div><div><br></div><div>test_fun(DT, 2000)</div></div><div>
<br></div><div>This gives me the following error on my windows machine: </div><div><br></div><div><div>Error in `[.data.table`(adj_r2, , `:=`(Year, as.integer(year))) : </div><div> 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.</div>
</div><div><br></div><div>My sessionInfo():</div><div><br></div><div><div>R version 2.15.1 (2012-06-22)</div><div>Platform: x86_64-pc-mingw32/x64 (64-bit)</div><div><br></div><div>locale:</div><div>[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C LC_TIME=German_Germany.1252 </div>
<div><br></div><div>attached base packages:</div><div>[1] stats graphics grDevices utils datasets methods base </div><div><br></div><div>other attached packages:</div><div>[1] data.table_1.8.2</div><div><br>
</div><div>loaded via a namespace (and not attached):</div><div>[1] tools_2.15.1</div></div><div><br></div><div>Interestingly, on my Linux machine, everything works fine:</div><div><br></div><div>Output there:</div><div>
<div>
Tau_1 Tau_2 Year</div><div>1: -0.0006947528 -0.0005516822 2000</div></div><div><br></div><div>sessionInfo()</div><div><br></div><div><div>R version 2.15.1 (2012-06-22)</div><div>Platform: x86_64-pc-linux-gnu (64-bit)</div>
<div><br></div><div>locale:</div><div> [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 </div><div> [6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C </div>
<div>[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C </div><div><br></div><div>attached base packages:</div><div>[1] stats graphics grDevices utils datasets methods base </div><div><br></div><div>
other attached packages:</div><div>[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 </div><div><br></div><div>loaded via a namespace (and not attached):</div>
<div>[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 </div></div><div><br></div><div>Therefore, could someone with a Windows machine confirm this error? Matthew, do you have an idea what is causing this?</div>
<div><br></div><div>Thanks in advance, </div><div><br></div><div>Christoph</div><div><br></div>