R custom package install from file error

前端 未结 2 625
梦毁少年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
    

提交回复
热议问题