hack のためのネタ帳, etc,,,

状況

Windows 10 で RStudio から Microsoft Open R を使っているのだが
library("devtools")
install_github("larmarange/JLutils")
とすると
Downloading GitHub repo larmarange/JLutils@master
from URL https://api.github.com/repos/larmarange/JLutils/zipball/master
Installing JLutils
"C:/PROGRA~1/MIE74D~1/ROPEN~1/R-35~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  "C:/cygwin64/tmp/RtmpoV2dxq/devtools59a061971b65/larmarange-JLutils-1a31c14" --library="C:/Users/kou/HOME/R/win-library/3.5"  \
  --install-tests 

* installing *source* package 'JLutils' ...
** R
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'scales' 0.5.0 is already loaded, but >= 1.0.0 is required
ERROR: lazy loading failed for package 'JLutils'
* removing 'C:/Users/kou/HOME/R/win-library/3.5/JLutils'
In R CMD INSTALL
Installation failed: Command failed (1)
という結果に。
scales >= 1.0.0 なのに 0.5.0 が入ってるぞと言われてるんだけど、
install.packages("scales")
Installing package into ‘C:/Users/kou/HOME/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.5/PACKAGES'
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/bin/windows/contrib/3.5/scales_0.5.0.zip'
Content type 'application/zip' length 791166 bytes (772 KB)
downloaded 772 KB

package ‘scales’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\cygwin64\tmp\RtmpoV2dxq\downloaded_packages
という状況で埒が明かない。

available.packages を見ても
x = available.packages() %>% data.frame()
x[x$Package=="scales",]
       Package Version Priority     Depends                                                                           Imports LinkingTo
scales  scales   0.5.0     <NA> R (>= 2.13) RColorBrewer, dichromat, plyr, munsell (>= 0.2), labeling,\nRcpp, R6, viridisLite      Rcpp
                                  Suggests Enhances            License License_is_FOSS License_restricts_use OS_type Archs MD5sum
scales testthat (>= 0.8), bit64, covr, hms     <NA> MIT + file LICENSE            <NA>                  <NA>    <NA>  <NA>   <NA>
       NeedsCompilation File                                                 Repository
scales              yes <NA> https://mran.microsoft.com/snapshot/2018-08-01/src/contrib
ってな感じ。

なぜか Cygwin の R だと
x = available.packages() %>% data.frame()
x[x$Package=="scales",]
       Package Version Priority    Depends
scales  scales   1.1.0     <NA> R (>= 3.2)
                                                                                        Imports
scales farver (>= 2.0.0), labeling, munsell (>= 0.5), R6,\nRColorBrewer, viridisLite, lifecycle
       LinkingTo                                                  Suggests
scales      <NA> bit64, covr, dichromat, hms, testthat (>= 2.1.0), ggplot2
       Enhances            License License_is_FOSS License_restricts_use
scales     <NA> MIT + file LICENSE            <NA>                  <NA>
       OS_type Archs                           MD5sum NeedsCompilation File
scales    <NA>  <NA> 875fcbd3bf93934e076c7c877b8c5f05               no <NA>
                               Repository
scales https://cran.ism.ac.jp/src/contrib
なので、ぐぬぬという。


解決方法


よく見てみると Microsoft Open R の repository が snapshot/2018-08-01 とかなってやがる。
どうもこれが原因らしい。

RStudio の「Tools」→「Global Options」から Option のダイアログを開いて、「General」の「Basic」にある「R version」を
  • [Default] [64-bit] C:\Program Files\Microsoft\R Open\R-3.5.1
から
  • [64-bit] C:\Program Files\R\R-3.5.2
に変更して再起動してみたところ
x = data.frame(available.packages())
x[x$Package=="scales",]
       Package Version Priority    Depends                                                                                  Imports LinkingTo
scales  scales   1.1.0     <NA> R (>= 3.2) farver (>= 2.0.0), labeling, munsell (>= 0.5), R6,\nRColorBrewer, viridisLite, lifecycle      <NA>
                                                        Suggests Enhances            License License_is_FOSS License_restricts_use OS_type
scales bit64, covr, dichromat, hms, testthat (>= 2.1.0), ggplot2     <NA> MIT + file LICENSE            <NA>                  <NA>    <NA>
       Archs                           MD5sum NeedsCompilation File                           Repository
scales  <NA> 875fcbd3bf93934e076c7c877b8c5f05               no <NA> https://cran.rstudio.com/src/contrib
となったのだが、
update.packages()
install.packages("devtools")
した後、
library("devtools")
> library("devtools")
 要求されたパッケージ usethis をロード中です 
Error: package or namespace load failed for ‘usethis’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
  ‘Rcpp’ という名前のパッケージはありません 
Error:  パッケージ ‘usethis’ をロードできませんでした 
In addition: Warning messages:
1:  パッケージ ‘devtools’ はバージョン 3.5.3 の R の下で造られました  
2:  パッケージ ‘usethis’ はバージョン 3.5.3 の R の下で造られました  
とか訳の分からない状況に。

埒が明かないので、
CRAN から最新版の GNU R 3.6.1 を拾って来て、RStudio は「Use your machine's default version of R」にしといたら、
  • [Default] [64-bit] C:\Program Files\R\R-3.6.1
が選ばれ、無事
install_github("larmarange/JLutils")
Downloading GitHub repo larmarange/JLutils@master
√  checking for file 'C:\cygwin64\tmp\RtmpgNyT8d\remotes2550c691c96\larmarange-JLutils-1a31c14/DESCRIPTION' ...
-  preparing 'JLutils':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'JLutils_1.16.0.tar.gz'
   
Installing package into ‘C:/Users/kou/HOME/R/win-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package 'JLutils' ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'JLutils'
    finding HTML links ...  完了 
    A2Rplot                                 html  
    JLutils-package                         html  
    auto_index_group_rows                   html  
    best.cutree                             html  
    cutree.order                            html  
    get_legend                              html  
    gg909090                                html  
    ggchisq_res                             html  
    ggcross                                 html  
    grapes-p-grapes                         html  
Rd warning: C:/cygwin64/tmp/Rtmpm8RTk1/R.INSTALL3c18144f10c6/JLutils/man/grapes-p-grapes.Rd:15: file link 'paste0' in package 'base' does not exist and so has been treated as a topic
    inv_cumsum                              html  
    leading_zeros                           html  
    long_to_periods                         html  
    multiplot                               html  
    number                                  html  
    prop.ci                                 html  
    pvalue                                  html  
    round_preserve_sum                      html  
    s.freq                                  html  
    seq_heatmap                             html  
    seq_makeRiver                           html  
    stat_fill_labels                        html  
    finding level-2 HTML links ... done

    stat_stack_labels                       html  
    tidy.msSurv                             html  
    tidy.prevalence.msm                     html  
    tidy_chisq                              html  
    tidy_detailed                           html  
    tidy_model                              html  
    who_formatter                           html  
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (JLutils)
となった。

Microsoft Open R の方は
options()$repos
                                            CRAN                                        CRANextra 
"https://mran.microsoft.com/snapshot/2018-08-01"             "http://www.stats.ox.ac.uk/pub/RWin" 
ってな状況だったので、
options(repos=c(CRAN="https://mran.microsoft.com/",CRANextra="http://www.stats.ox.ac.uk/pub/RWin"))
options()$repos
                                CRAN                            CRANextra 
       "https://mran.microsoft.com/" "http://www.stats.ox.ac.uk/pub/RWin" 
としてみたところ
update.packages()
Warning: package 'boot' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'class' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'cluster' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'codetools' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'curl' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'foreign' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'jsonlite' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'KernSmooth' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'MASS' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'Matrix' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'mgcv' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'nlme' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'R6' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'rpart' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'RUnit' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
Warning: package 'survival' in library 'C:/Program Files/Microsoft/R Open/R-3.5.1/library' will not be updated
nlme :
 Version 3.1-137 installed in C:/Users/kou/HOME/R/win-library/3.5 
 Version 3.1-142 available at https://mran.microsoft.com
checkpoint :
 Version 0.4.4 installed in C:/Program Files/Microsoft/R Open/R-3.5.1/library 
 Version 0.4.7 available at https://mran.microsoft.com
doParallel :
 Version 1.0.13 installed in C:/Program Files/Microsoft/R Open/R-3.5.1/library 
 Version 1.0.15 available at https://mran.microsoft.com
iterators :
 Version 1.0.10 installed in C:/Program Files/Microsoft/R Open/R-3.5.1/library 
 Version 1.0.12 available at https://mran.microsoft.com
lattice :
 Version 0.20-35 installed in C:/Program Files/Microsoft/R Open/R-3.5.1/library 
 Version 0.20-38 available at https://mran.microsoft.com
RODBC :
 Version 1.3-15 installed in C:/Program Files/Microsoft/R Open/R-3.5.1/library 
 Version 1.3-16 available at https://mran.microsoft.com
Error in readRDS(dest) : unknown input format
みたいな感じでにっちもさっちも行かなくなってしまった。

とりあえず GNU R の方が動いているようなので良しとしよう。

参考

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

編集にはIDが必要です