Suppose getwd() yields "C:/Users/Tom/Documents/Tom_Levers_Git_Repository".
In this repository, I have directory TomLeversRBox.
In this box, I have modules calculate_probability.R and print.message.R.
In the module calculate_probability.R, I have the following function.
box::use(./print.message)
box::use(stats[pnorm])
#' @export
calculate_probability <- function() {
message <- paste("Probability: ", round(pnorm(1.644854, 0, 1, lower.tail = TRUE), 2), sep = "")
class(message) <- "message"
return(message)
}
In the module print.message.R, I have the following function.
#' @export
print.message <- function(message) {
cat(message)
}
In RStudio's console, I run install.packages("box").
I run box::use(TomLeversRBox/calculate_probability[calculate_probability]).
I run calculate_probability().
I receive the following output.
[1] "Probability: 0.95"
attr(,"class")
[1] "message"
How do I add to generic function print the message method print.message, and print only Probability: 0.95?
I have also tried box::use(TomLeversRBox/calculate_probability[calculate_probability], TomLeversRBox/print.message[print.message]).
I strongly prefer to only use box::use(TomLeversRBox/calculate_probability[calculate_probability]).