R custom package install from file error

前端 未结 2 624
梦毁少年i
梦毁少年i 2021-01-13 18:41

I\'ve been working on a R package for a simulation project, on my computer at home I\'ve used RStudio to build and install it successfully. However on another machine at uni

相关标签:
2条回答
  • 2021-01-13 19:15

    I found the problem was related to the Windows path backslashes in the roxygen comments in the R script. The solution is to change the backslashes to a single forward slash. Example: originally my roxygen info was like this:

    #'  Performs a search in MS Windows file system for all files in the
    #'  `C:\USERS\MYNAME` directory, and all directories below that
    

    which results in this warning message:

    * installing to library 'C:/Users/MYNAME/Documents/R/win-library/3.2'
    * installing *source* package 'whatever' ...
    ** R
    ** preparing package for lazy loading
    ** help
    Warning: C:/Users/MYNAME/Documents/R/CODE/whatever/man/func.Rd:11: unknown macro '\USERS'
    Warning: C:/Users/MYNAME/Documents/R/CODE/whatever/man/func.Rd:11: unknown macro '\MYNAME'
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    * DONE (whatever)
    

    The clue is that the text is orange instead of the usual blue in RStudio.

    So change the backslash to a forward slash and no warning message is produced and all the roxygen comment is now blue.

    #'  Performs a search in MS Windows file system for all files in the
    #'  `C:/USERS/MYNAME` directory, and all directories below
    

    0 讨论(0)
  • 2021-01-13 19:19

    I had encountered a similar error a few days ago. It is because you are installing to this directory:

     '\\ueahome5/ressci17/yrq12edu/data/Documents/R/win-library/2.15/speEaR'
    

    I guess it is connected to a network drive. What you should do is go to that network drive and copy the address explicitly like

     'M:/ressci17/yrq12edu/data/Documents/R/win-library/2.15/'
    

    And then use it to specify the library location when you install. For example:

    install.packages("speEaR_1.0.tar.gz", repos=NULL, type="source",lib='U:/ressci17/yrq12edu/data/Documents/R/win-library/2.15/')
    

    Or try devtools , unpack your tar ball and do something like:

    library(devtools)
    has_devel() ## check if your Rtools are properly installed
    check('speEaR')
    ##build('speEaR')
    install("speEaR",args='-l "U:/ressci17/yrq12edu/data/Documents/R/win-library/2.15/"')
    

    This is how I solved my problem.

    0 讨论(0)
提交回复
热议问题