screechOwl
screechOwl

Reputation: 28169

R package check in RStudio - function not found error

I am trying to build a package in R using RStudio / git.

When I run the check function on this file:

#' A function to print variable names for easy pasting to a new character vector.
#'
#' @param x a data.frame
#' @examples require(convPkg5);cat_names(iris)
#'

cat_names <- function(x){
  cat(paste(",'", names(x), "'", "\n", sep = ""))
}

I get this error message:

checking examples ... ERROR
Running examples in ‘convPkg5-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: cat_names
> ### Title: A function to print variable names for easy pasting to a new
> ###   character vector.
> ### Aliases: cat_names
> 
> ### ** Examples
> 
> require(convPkg5);cat_names(iris)
Error in cat_names(iris) : could not find function "cat_names"
Execution halted

All of the other files / functions have a similar structure but are not generating error messages. What am I missing?

Upvotes: 1

Views: 535

Answers (1)

jamesguy0121
jamesguy0121

Reputation: 1254

I don't know if you ever got this figured out, but I was having the same problem and found the solution for my issue in Hadley's R Packages book

You should be able to fix the problem by adding @export do your roxygen comments as below

#' A function to print variable names for easy pasting to a new character vector.
#'
#' @param x a data.frame
#' @examples require(convPkg5);cat_names(iris)
#'
#' @export

Upvotes: 1

Related Questions