Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install plotly in r studio

Tags:

r

plotly

When I run plotly in my r studio, I got the following error

** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fopenmp -fPIC  -Wall -g -O2  -c assign.c -o assign.o
clang: error: unsupported option '-fopenmp'
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/data.table’
Warning in install.packages :
  installation of package ‘data.table’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/75/kpj4ysfd0cx4qyv5cgyhn3sw0000gn/T/RtmpZHPWIC/downloaded_packages’
> library(plotly)
Error: package or namespace load failed for ‘plotly’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘data.table’

After run the Command Sessioninfo() in R studio terminal, I got the following result:

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tibble_2.1.3  readr_1.3.1   tidyr_0.8.3   purrr_0.3.2   ggplot2_3.2.1 dplyr_0.8.3  

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5  xfun_0.8          remotes_2.1.0     colorspace_1.4-1  vctrs_0.2.0       testthat_2.2.1    htmltools_0.4.0   usethis_1.5.1     yaml_2.2.0       
[10] rlang_0.4.0       pkgbuild_1.0.6    pillar_1.4.2      glue_1.3.1        withr_2.1.2       sessioninfo_1.1.1 munsell_0.5.0     gtable_0.3.0      devtools_2.2.1   
[19] memoise_1.1.0     labeling_0.3      knitr_1.24        callr_3.3.1       ps_1.3.0          curl_4.0          Rcpp_1.0.2        backports_1.1.4   scales_1.0.0     
[28] desc_1.2.0        pkgload_1.0.2     fs_1.3.1          hms_0.5.1         digest_0.6.20     processx_3.4.1    grid_3.6.1        rprojroot_1.3-2   cli_1.1.0        
[37] tools_3.6.1       magrittr_1.5      lazyeval_0.2.2    crayon_1.3.4      pkgconfig_2.0.2   zeallot_0.1.0     ellipsis_0.3.0    prettyunits_1.0.2 assertthat_0.2.1 
[46] rstudioapi_0.10   R6_2.4.0          compiler_3.6.1  

After the clang -v command:

Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Does anyone know what happens? Since library(plotly) is not working right now

like image 216
Rieder Avatar asked Dec 02 '25 23:12

Rieder


1 Answers

The error comes from the installation of data.table, a package needed by plotly. The -fopenmp option used for compilation isn't supported on all platforms. I assume you're using macOS, and this option is known to cause errors with Apple LLVM 9 and later.

I think installing an OpenMP enabled compiler should solve your problem. See here to install data.table with an OpenMP enabled clang (section OpenMP enabled compiler for Mac).

Once you have data.table properly installed, running install.packages("plotly") should work.

like image 174
Biblot Avatar answered Dec 04 '25 14:12

Biblot