如何强制R使用32位版本的已安装软件包/库?

时间:2019-06-13 17:24:31

标签: r windows version-control package rstudio

  

目标:我想在Windows 10企业版上为32位R 3.6.0安装dssrip软件包。

我同时安装了32位和64位版本的R 3.6.0。在RStudio(1.2.1522)中,我将默认版本设置为32位,然后启用packrat创建新项目。我在项目文件夹内的.Rprofile文件中添加了以下几行。

#### -- Packrat Autoloader (version 0.5.0) -- ####
source("packrat/init.R")
#### -- End Packrat Autoloader -- ####

dir.create("packages", recursive = TRUE, showWarnings = FALSE)
.libPaths("./packages")
message("Using library: ", .libPaths()[1])

options(dss_jre_location="C:\\Program Files (x86)\\HEC\\HEC-DSSVue\\java")
Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\HEC\\HEC-DSSVue\\java")

安装

install.packages(c("devtools", "rJava", "plyr", "reshape2", "stringr", "tidyverse"),
                 dependencies = TRUE)
library(rJava)
devtools::install_github("eheisman/DSS-Rip",
                         args = "--no-multiarch")

错误

Installing package into ‘C:/Users/user007/Documents/ttn/R/Projects/dssrip/packages’
(as ‘lib’ is unspecified)
* installing *source* package 'dssrip' ...
** using staged installation
** R
** demo
** byte-compile and prepare package for lazy loading
Note: possible error in 'month(d, label = TRUE, ': unused arguments (label = TRUE, abbr = TRUE) 
** help
*** installing help indices
  converting help for package 'dssrip'
    finding HTML links ... done
    AF_PER_CFS_DAY                          html  
    dss_path_functions                      html  
    fixTimestamps                           html  
    getColumnsByName                        html  
    getDT                                   html  
    getFullDT                               html  
    getFullTSC                              html  
    getLooseTSC                             html  
    getMetadata                             html  
    getTSC                                  html  
    hydro_axis_trans                        html  
    hydrologic_date_functions               html  
    initialize.dssrip                       html  
    model_error_measurement                 html  
    nash.sutcliffe                          html  
    opendss                                 html  
    rmse                                    html  
    tsc.to.dt                               html  
    tsc.to.xts                              html  
    weibullProbs                            html  
    xts.to.tsc                              html  
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
Error: package or namespace load failed for 'rJava':
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 
  'C:/Users/user007/Documents/ttn/R/Projects/dssrip/packages/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.

Error : package 'rJava' could not be loaded
Error: loading failed
Execution halted
ERROR: loading failed for 'x64'
* removing 'C:/Users/user007/Documents/ttn/R/Projects/dssrip/packages/dssrip'
Error in i.p(...) : 
  (converted from warning) installation of package 
  ‘C:/Users/user007/AppData/Local/Temp/Rtmp8UP9Mb/file2d9c5e446300/dssrip_0.1.tar.gz’ had non-zero exit status

Java版本

C:\Program Files (x86)\HEC\HEC-DSSVue\java\bin>java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode)

C:\Program Files (x86)\HEC\HEC-DSSVue\java\bin>java -d64
Unrecognized option: -d64
Could not create the Java virtual machine.

我尝试使用本机R(C:\Program Files\R\R-3.6.0\bin\i386\Rgui.exe),但也无济于事。

在此先感谢任何指针!

2 个答案:

答案 0 :(得分:0)

您是否尝试过使用RStudio->工具->常规,然后单击顶部的“更改”按钮以允许您更改R版本。将打开一个下拉菜单,您可以在其中选择32位版本并激活它。不过,您必须重新启动RStudio才能实现。

答案 1 :(得分:0)

更新:我必须卸载并删除所有内容,并从头开始才能使dssrip正常工作。

.Rprofile文件中放入以下几行:

options(dss_jre_location="C:\\Program Files (x86)\\HEC\\HEC-DSSVue\\java")
Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\HEC\\HEC-DSSVue\\java")

安装所有依赖项:

install.packages(c("devtools", "rJava", "data.table", "plyr", "reshape2", "stringr", "tidyverse"),
                 dependencies = TRUE)

请注意,要强制R仅安装32位版本,我必须改用this syntax

devtools::install_github("eheisman/DSS-Rip",
                         INSTALL_opts = "--no-multiarch")