Example with Roxygen for R Package

ぐ巨炮叔叔 提交于 2019-12-02 05:33:40

问题


I'm trying to add an example of a function within my package. That for I want to use roxygen2. I'm doing the following (just a part of my code, at the end of roxygen2 documentation and until the code of the function starts ...

#' @import  EcoHydRology
#' @export
#' @example
#' Tx <- 29
#' Tn <- 13
#' rain <- 100
#' lat <- 1
#' Ion <- 10
#' DOY <- 44
#' z <- 450
#' c <- 2.4
#' B <- 0.004
#'
#' BC_alt(Tx, Tn, rain, lat, lon, DOY, z, c, B)



BC_alt <- function(Tx, Tn, rain, lat, lon, DOY, z, c, B){



  #Extraterrestrial solar radiation (with EcoHydRology package)
  lat_rad <- lat*pi/180

  A <- 0.75+(2*10^(-5)*z)

... So when I than try to Build & Reload, I get an error message

>     Fehler in file(con, "r") : kann Verbindung nicht öffnen
>     Ruft auf: suppressPackageStartupMessages ... process_examples -> unlist -> lapply -> FUN -> file
>     Zusätzlich: Warnmeldung:
>     In file(con, "r") :
>       kann Datei '/Users/Manuelito/Dropbox/CIAT/SolariradianceBC/SolariradianceBC/Tx <-
> 29
>     Tn <- 13
>     rain <- 100
>     lat <- 1
>     Ion <- 10
>     DOY <- 44
>     z <- 450
>     c <- 2.4
>     B <- 0.004
>     
>     BC_alt(Tx, Tn, rain, lat, lon, DOY, z, c, B)' nicht öffnen: No such file or directory

sorry it is partly in german. Principally it says it can't find such a file.

But I don't get how I have to do it that it works. Do I have to create a new script for the function so the @example command can find it? I think something is wired with the file path the script of my function is called BristowCampbell.R and its file path is /Users/Manuelito/Dropbox/CIAT/SolariradianceBC/SolariradianceBC/R/BrisowCampbell.R so that's maybe the reason why it can't find it. But anyway in the error message its saying it can't find the file but i'm only calling a function in a script. I think I kind didn't understand how to use @example from roxygen2. I would be vary glad, if anybody could give me a hint. Thank you very much Manuel


回答1:


Use @examples, not @example (it's meant for code stored in external files)



来源:https://stackoverflow.com/questions/40516769/example-with-roxygen-for-r-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!