2
votes

I am dabbling around writing my first R-package, and was wondering how one can add those yellow comment boxes that pop up when you hover over the function argument (when you've hit tab in the function). See here:

Example

This is my code:

#' A web function
#'
#' This function allows you to call a website.
#' @param url put in a url
#' @keywords web
#' @export
#' @examples
#' webpage("google")

webpage <- function(url){
    if(!is.character(url)){
       url <- as.character(url)
} else{
     utils::browseURL(paste0("https://www.", url, ".com", collapse = ","))
  }
}

I use devtools with roxygen2 to document and build the package - all the files are there, and the package/function works once installed and loaded. The only thing is that the comment, #' @param url put in a url, I wrote does not show up as a yellow box.

Any idea(s) what the problem might be?

1
The yellow boxes seem like RStudio rather than R per se. Perhaps you should add the RStudio tag. - John Coleman
did you try restarting RStudio and librarying your package again? - Vincent Bonhomme
@VincentBonhomme, yes I tried restarting RStudio, and loading the package again, but it didn't work...I compared it with other R-packages to make sure the yellow boxes would pop up for those, and they did... - Primesty
So, it just resolved itself...apparently, when you have a function with several arguments, you get a list of said arguments, as in the picture above. When there is only one argument, then you have to start typing the argument and use code completion to bring up the list. Then, when you hover over the 'url' argument, it shows the yellow description box... - Primesty
great! could you answer your own question then? - Vincent Bonhomme

1 Answers

1
votes

The issue resolved itself...apparently, when you have a function with several arguments, you get a list of said arguments, as in the picture above. When there is only one argument, then you have to start typing the argument and use code completion to bring up the list. Then, when you hover over the 'url' argument, it shows the yellow description box...