简体   繁体   中英

Trouble with downloading certain packages from github in R

I get an error when I try to download and install some packages from github on my Mac, eg lubripack. How do I locate what the error actually means? And how to solve it?

I run: install_github("Espanta/lubripack") . I have tried with different libpaths and with force=TRUE .

This is from the console:

checking for file '/private/var/folders/nc/vs1bpbqn095bbx84qcwwm4bm0000gn/T/RtmpMn5l2o/remotes8cb7b2460a1/Espanta-lubripack-b1dd9ee/DESCRIPTION'... OK preparing 'lubripack': checking DESCRIPTION meta-information... OK checking for LF line-endings in source and make files and shell scripts checking for empty or unneeded directories building 'lubripack_0.1.tar.gz' Error: Failed to install 'lubripack' from GitHub: (converted from warning) line 1 appears to contain an embedded nul

You may not need to worry about installing the package from github - since the package only contains a single function , I'd simply copy the code for that function and use it (citing the author if/when appropriate).

lubripack <- function(...,silent=FALSE){

  #check names and run 'require' function over if the given package is installed
  requirePkg<- function(pkg){if(length(setdiff(pkg,rownames(installed.packages())))==0)
                                    require(pkg, quietly = TRUE,character.only = TRUE)
                            }

  # list of packages to install and load
  packages <- as.vector(unlist(list(...)))
  if(!is.character(packages))stop("No numeric allowed! Input must contain package names to install and load")

  if (length(setdiff(packages,rownames(installed.packages()))) > 0 )
                      install.packages(setdiff(packages,rownames(installed.packages())),
                                       repos = c("https://cran.revolutionanalytics.com/", "http://owi.usgs.gov/R/"))

  res<- unlist(sapply(packages, requirePkg))

  if(silent == FALSE && !is.null(res)) {cat("\nBellow Packages Successfully Installed:\n\n")
                                        print(res)
                                        }
}

It works for me even on R 4.0.2

lubripack(list("dplyr"))

Bellow Packages Successfully Installed:

dplyr 
 TRUE 

And for reference

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS  10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

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

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

other attached packages:
[1] dplyr_1.0.0  gtools_3.8.2

loaded via a namespace (and not attached):
 [1] crayon_1.3.4     R6_2.4.1         lifecycle_0.2.0  magrittr_1.5     pillar_1.4.6     rlang_0.4.7      rstudioapi_0.11  vctrs_0.3.2     
 [9] generics_0.0.2   ellipsis_0.3.1   tools_4.0.2      glue_1.4.1       purrr_0.3.4      compiler_4.0.2   pkgconfig_2.0.3  tidyselect_1.1.0
[17] tibble_3.0.3    

Try this First run

install.packages("remotes")

once done Run this: - remotes::install_github("Espanta/lubripack")

Ignore the warning I am able to load the library I am not sure if this library is up to date like Dirk Eddelbuettel mentioned But its loading在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM