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
Use @examples
, not @example
(it's meant for code stored in external files)
来源:https://stackoverflow.com/questions/40516769/example-with-roxygen-for-r-package