Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
This is a quickie post and specific to package maintainers who use roxygen2.
Legal Disclaimer: This worked for me but make sure there’s not a corner case that would make it not work for you. In other words back your stuff up think it through, and tread lightly.
Welp I updated to the latest version of roxygen2, 4.0.0. Works well and some new niceties and handling. Anyway after you use it for the first time and if you have @S3method in your code it throws a warning along the lines of:
Warning messages: @S3method is deprecated. Please use @export instead
Inconvenient to make the change if you have a small amount of functions in your package but a pain in the tush if you have tons. Obviously you’ll want to do this as @S3method is deprecated but it doesn’t make it hurt any less. It’s kinda like a a root canal, it’s for the good of the dental well being but it’s still painful. But then a thought occurred to me. Why not be lazy efficient? Read in the files, grepl to find the "#' @S3" and then replace with "#' @export". I tried it with the following code. You’ll have to supply your path to the location of the package’s R directory.
Now this may not be the best approach, hey it may even be wrong but I’ll rely on Cunningham’s Law to sort it out:
pth <- "C:/Users/trinker/qdap/R"
fls <- file.path(pth, dir(pth))
FUN <- function(x) {
cont <- readLines(x)
cont[grepl("#' @S3", cont)] <- "#' @export"
cont[length(cont) + 1] <- ""
cat(paste(cont, collapse="\n"), file=x)
}
lapply(fls, FUN)R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
