0

The code below works fine

library(data.table)
dt <- data.table(mtcars)[,.(cyl, gear, mpg)]
colsToSum <- c("cyl", "gear", "mpg")
dt[, F15_49 := rowSums(.SD), .SDcols = colsToSum]

but a version of this crashes R in RStudio with the message "R Session Aborted. R encountered a fatal error. The session was terminated." Followed by a Start New Session button. The code snippet that crashes is

ageColsToSum <- c("F15_19", "F20_24", "F25_29", "F30_34", "F35_39", "F40_44", "F45_49")
dt.SSP.scen.wide[, F15_49 := rowSums(.SD), .SDcols = ageColsToSum]

When I run the code in R in a shell I get the following message.

OMP: Error #15: Initializing libomp.dylib, but found libomp.dylib already initialized. OMP: Hint: This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/. Abort trap: 6

I don't know anything about openMP so I don't know what could be initializing libomp.dylib.

JerryN
  • 2,356
  • 1
  • 15
  • 49
  • What is `dt.SSP.scen.wide`? – AdamO Dec 22 '17 at 22:18
  • It's a data table that I have created using dcast on a different data table. The names in the ageColsToSum variable are numeric columns in dt.SSP.scen.wide. I realize this is not a reproducible example but don't know how to create one. – JerryN Dec 22 '17 at 22:26
  • maybe it is a memory problem. Try to increase the memory by using the memory.limit(100000000000) or try to unistal and install again some packages that can cause the problem – George Sotiropoulos Dec 22 '17 at 23:36
  • `rowSums` converts the whole data to a matrix. There are ways to avoid it. – David Arenburg Dec 23 '17 at 21:31

1 Answers1

2

I followed the directions at https://github.com/Rdatatable/data.table/wiki/Installation and installed the development version of data.table 1.10.5. My code now works.

JerryN
  • 2,356
  • 1
  • 15
  • 49