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.
– Luiz Augusto
Try to install your package with
devtools::install()
– Tomás Barcellos
if (any(.) == TRUE)
is the same asif(any(.))
. No need to explicitly compare withTRUE/FALSE
because the value ofany
is already a logical value.– Rui Barradas
I managed to solve it! I did the clean and rebuild again and then reinstalled the package, it worked. Thank you!
– Ricardo N. F. Castro
Rui Barradas, did not know this, thanks for the suggestion I will adapt in function
– Ricardo N. F. Castro
There are still functions
isTRUE
andisFALSE
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 ofhelp("all.equal")
.– Rui Barradas