[R-pkg-devel] Run Examples Not Found
Michael Chirico
m|ch@e|ch|r|co4 @end|ng |rom gm@||@com
Wed May 7 23:18:06 CEST 2025
Hi Mat, glancing at what I believe to be your package sources [1]
You have non-R exposition in your \examples{...}. Examples are code --
you should be able to run them like any other code.
Moreover, they should be self-contained -- expecting the user to
create 'oildata' themselves won't work.
Why not use
oildata <- read.csv(system.file("extdata", "oildata.csv", package="olr"))
Inside the example instead?
You might also consider turning 'oildata' into a proper data object
exported by your package [2]
Mike C
PS your text got mangled, it's quite hard to read your message -- I've
made a best effort to do so. Look how it renders [3]. Please turn on
'Plain text mode' for messages to this list to avoid this issue.
[1] https://github.com/MatHatter/olr_r/blob/4eeca43a947823aadddd97cbc9bafc43401c2848/olr/man/olr.Rd#L38-L51
[2] https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Data-in-packages
[3] https://stat.ethz.ch/pipermail/r-package-devel/2025q2/011641.html
On Wed, May 7, 2025 at 1:11 PM Mat Fok via R-package-devel
<r-package-devel using r-project.org> wrote:
>
> Hi,
> My example sources data from olr/inst/extdata and I point to it in my example. I do not include the `dontrun{}` function around this @examples as I want to be able to click "Run Examples" in my Help documentation but I get the error /Example/olr not found. I was thinking maybe I should have a folder called Example, but ChatGPT said no. I have searched online for this but the most relevant thing I have found was stackoverflow.com/questions/76365640/r-roxygen-examples-example-foo-bar-not-found, but no one answered and it is over a year old.
>
> |
> |
> |
> | | |
>
> |
>
> |
> |
> | |
> R Roxygen @examples /Example/foo_bar not found
>
> I am creating an R package and can't run the examples when using devtools::load_all()I always get /Example/func...
> |
>
> |
>
> |
>
>
>
> Here is my example:
> #' @examples#' # Option 1: Manual loading from package (if preferred)#' # file <- system.file("extdata", "crudeoildata.csv", package = "olr", mustWork = TRUE)#' # crudeoildata <- read.csv(file, header = TRUE)#' # dataset <- crudeoildata[, -1]#'#' # Option 2: Preferred - using load_custom_data()#' dataset <- load_custom_data("crudeoildata.csv", exclude_first_column = TRUE)#'#' responseName <- "CrudeOil"#' predictorNames <- c("RigCount", "API", "FieldProduction", "RefinerNetInput",#' "OperableCapacity", "Imports", "StocksExcludingSPR", "NonCommercialLong",#' "NonCommercialShort", "CommercialLong", "CommercialShort", "OpenInterest")#'#' olr(dataset, responseName, predictorNames, adjr2 = FALSE)
> Here is my file structure:
> olr/├── DESCRIPTION├── NAMESPACE├── .Rhistory├── R/│ ├── olr_function.R│ └── utils.R├── man/│ ├── olr.Rd│ └── load_custom_data.Rd└── inst/ └── extdata/ └── crudeoildata.csv
> How do I Run Examples properly?
> Thanks,
> Mathew Fok
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
More information about the R-package-devel
mailing list