Sébastien Wouters
Sébastien Wouters

Reputation: 141

How to make a checking function in R having the same style of output as devtools::check

I would like to make a function checking different aspects of a complex list that is outputted by one of my functions. This is to help parametrise this function; there are a lot of parameters influencing the output, and adapting the parametrisation to have the best-fitted output implies a lot of trial and error for the user. In order to facilitate that I would like to make a 'check' function, providing different quantified and logical tests of the output. Ideally, I would like it to have the same style as the output given by devtools::check() or devtools::build(), like this:

enter image description here

I tried to go inside the devtools::check() or devtools::build() functions, but could not find what they use to have this kind of output. Is it possible to have it for the task I have described ?

Upvotes: 0

Views: 110

Answers (1)

Terru_theTerror
Terru_theTerror

Reputation: 5017

Try to use cat inside your function in this way to map and show update on the function:

f<-function()
{
   cat("checking for file\n")
   cat("preparing\n")
}

Output:

f()
    checking for file
    preparing

Differents colours and palette could be added using package colorout.

This is the pattern used inside devtools package:

cat_rule(left = "Building", right = pkg$package, col = "cyan")

Upvotes: 1

Related Questions