Hello when I use rstudio (1.1.383 I am stuck on this version) and roxygens 6.1.1 and I try to build my package making sure NAMEPACE is generated by roxygen the following function:
#' Are all elements ox x elements in y
#' @export
#' @examples
#' all.in(x=c(1, 2), y=c(1, 3, 2)) #TRUE
#' all.in(x=c(NA, NULL), y=c(NA, NULL, 0)) #TRUE
#' all.in(x=c('a','b'), c('a','ab')) #FALSE
all.in <- function(x, y){
return( all(x %in% y) )
}
is converted as the following in NAMESPACE
S3method(all,"in")
So it is fairly obvious that there is something going on with the all and in functions there but this is not what I want. Is there a way to tell roxygen2 to do the right thing ?
Not sure how to fix this, but the reason it's happening is because in R convention is to use dots for S3 methods, so roxygen assumes that what you are trying to do is to create a function called all for a class called in. You can avoid this with calling your function all_in, for example of a workaround.
Hello, I do not think there is any instruction in the R manual that requires functions to use _ not dots.
As it is it looks like a bug in roxygen2 to me
You've written that you don't understand why roxygen is doing what it's doing and I've explained why it's happening. You are right, there is no rule against using dots in function names, but generally it is considered (not by everyone, but by some) a bad practice for exactly the reason I've explained: you don't know in advance whether it's a name of a function or s3 method.
In this specific case, there's little chance of something having the "in" class. But it's not guaranteed, and doing a find/replace to swap in _ seems easier than remembering a list of class names that'd break stuff.
Hello thanks for your answer, I knew I saw something once but could not find out where.
That will solve my issue.
With regards to my point, I think it was just miscommunication, I was just saying that "you should not be using dots" was not a good answer (I was not sure what you were suggesting)
Thanks