I can’t find my function in the R package

Asked

Viewed 87 times

1

I did a function on R and included it in my package I made. I clicked on clean and rebuild and soon after, I checked. Also, my function has been exported, and it appears listed in the NAMESPACE doc of the package. However, even so, when I open a new script and try to call the function (after opening the library) the function does not appear and R cannot find it, and gets this error message:

Error in "my_function"(tbl) : could not find Function "my_function".

Follow the function script below:

#' <descrição
#'
#' @encoding UTF-8
#' @description
#' Esta função distribui os grupos de repetição aninhados em novas linhas
#'
#' @encoding UTF-8
#' @param tble Tabela que contenha Grupo(s) de Repetição.
#'
#' @encoding UTF-8
#' @param separator Separador utilizado entre nomes do(s) Grupo(s) de 
#' Repetição
#' o nome da variável. O valor default é: '/'.
#'
#' @importFrom stringr str_detect
#'
#' @encoding UTF-8
#' @return Tibble contendo valores do(s) Grupo(s) de Repetição reorganizados 
#' @export
#'
#' @author -----------------------------
#' @author -----------------------------
#'
#'

rearrange_nestgroup <- function(tble, separator = '/') {

  final_tble <- rearrange_repgroup(tble)
  tble_colnames <- colnames(final_tble)

  if (any(str_detect(tble_colnames, '\\[\\d{1,6}\\]')) == TRUE) {
    rearrange_nestgroup(final_tble)

  } else {
    return(final_tble)
  } 
}

I wonder if there is something wrong in the function script so that it is not exported

Obs.: rearrange_repgroup function is in the same package with my functions

  • Welcome to Stack Overflow in English. Please click edit and translate the question.

  • Try to install your package with devtools::install()

  • 1

    if (any(.) == TRUE) is the same as if(any(.)). No need to explicitly compare with TRUE/FALSE because the value of any is already a logical value.

  • 1

    I managed to solve it! I did the clean and rebuild again and then reinstalled the package, it worked. Thank you!

  • 1

    Rui Barradas, did not know this, thanks for the suggestion I will adapt in function

  • There are still functions isTRUE and isFALSE which can be used in similar cases (in this case as I have already said it is not worth it). For example, to test the output of help("all.equal").

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.