Questions tagged [crayon]

7 questions
6
votes
1 answer

How to print a R dataframe with colors?

With the crayon package, one can create colored strings: library(crayon) dat <- data.frame(X=c(yellow("foobar"), green("baz")), Y = cyan("qux")) Here is the encoded dat: > dat X Y 1 \033[33mfoobar\033[39m…
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
3
votes
1 answer

underline column names in R

How do you underline column names in R? I tried saving a string and then using that with library(crayon) string1 <- underline("hello") string2 <- underline("hello2") colnames(table) <- c(string1, string2) However string1 prints as…
user9445536
  • 141
  • 1
  • 1
  • 9
2
votes
0 answers

(Automatically) display hexadecimal strings in RStudio console in their respective color?

I am aware that packages like crayon can make the RStudio console output appear in all kinds of colors when manually asked to do so with functions such as blue() (https://github.com/r-lib/crayon). What would really be awesome, however, would be a…
Paul Schmidt
  • 1,072
  • 10
  • 23
2
votes
0 answers

Custom colored console prompt using crayon

In R I can create a custom console prompt via: options(prompt = "foo> ") And I can use the crayon package to make it a certain color: options(prompt = crayon::blue("foo> ")) However, in RStudio, color changes never take effect until the prompt is…
joran
  • 169,992
  • 32
  • 429
  • 468
1
vote
2 answers

customise R help files - font colouring

I'm wondering is it possible to customise R help files so that certain text is colour coded and easier to read. rdoc already does this except that it sends the output to the console. I would instead, like it to be sent to the help panel (i'm using…
user63230
  • 4,095
  • 21
  • 43
0
votes
2 answers

R printing non-printable crayon color codes when printing to sink()

I have two Windows machines. Both Windows 10. When I run the following code on each, I get two very different outputs: library(tibble) sink(file.path(tempdir(), "test.log"), append = FALSE) print(as_tibble(mtcars)) sink() One machine…
David J. Bosak
  • 1,386
  • 12
  • 22
0
votes
1 answer

How can I get an accurate character count when using crayon-formatted strings?

crayon is a package for adding color to printed output, e.g. library(crayon) message(red('blue'), green('green'), blue('red')) However, nchar used on its output is wrong: # should be 4 characters nchar(red('1234')) # [1] 14 I tried all the…
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198