nathaneastwood
nathaneastwood

Reputation: 3764

Using special character functions in packages

I want a function in my package which subsets based on certain conditions, e.g.

#' @export
`[.tmp` <- function (...) {...}

I have saved this file as package_name/R/[.tmp.R but I am getting the following error when I try to build the package.

Warning: S3 methods '[.tmp' was declared in NAMESPACE but not found

My NAMESPACE file is shown below.

# Generated by roxygen2 (4.1.0): do not edit by hand

S3method("[",tmp)
S3method(plot,tmp)
export(tmp)

Any ideas?

Upvotes: 3

Views: 199

Answers (1)

BrodieG
BrodieG

Reputation: 52657

Rename your file subset.tmp.R and re-run devtools::document or whatever you are using to generate the NAMESPACE / Rd files.

From Writing R Extensions:

The code files to be installed must start with an ASCII (lower or upper case) letter or digit and have one of the extensions9 .R, .S, .q, .r, or .s.

Also, look in your man folder and see what the auto-generated file names are for your old [.tmp.R file. Notice how roxygen2 renames the files to sub- or some such to comply with the requirement I point out above.

It would be nice if the package building process alerted you to this problem.

Upvotes: 3

Related Questions