问题描述
下面的代码可以正常工作
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]
但是此版本在RStudio中使R崩溃,并显示消息"R SessionAborted.R遇到致命错误.会话已终止."随后是开始新会话"按钮.崩溃的代码段是
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]
当我在外壳中的R中运行代码时,会收到以下消息.
When I run the code in R in a shell I get the following message.
OMP:错误#15:正在初始化libomp.dylib,但是发现libomp.dylib已经初始化.OMP:提示:这意味着OpenMP运行时的多个副本已链接到程序中.这很危险,因为它会降低性能或导致错误的结果.最好的办法是确保仅将单个OpenMP运行时链接到该流程中,例如通过避免在任何库中静态链接OpenMP运行时.作为不安全,不受支持,未记录的解决方法,您可以设置环境变量KMP_DUPLICATE_LIB_OK = TRUE以允许程序继续执行,但是可能会导致崩溃或静默地产生不正确的结果.有关更多信息,请参见> http://www.intel.com/software/products/support /.中止陷阱:6
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
我对openMP一无所知,所以我不知道该如何初始化libomp.dylib.
I don't know anything about openMP so I don't know what could be initializing libomp.dylib.
推荐答案
我按照 https://github.com/Rdatatable/data.table/wiki/Installation 并安装了data.table 1.10.5的开发版本.我的代码现在可以使用了.
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.
这篇关于data.table中的R行总和崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!