Is there a way to print small data.frames to the console in a more readable manner?
For example, would it be possible to output to the console:
I had the same problem recently and came across the huxtable package. It is very flexible and maybe a litte overkill for just nicer console output, but it served me very well.
Here is how you could solve your problem using huxtable:
library(huxtable)
library(magrittr)
small_iris <- iris[1:5, ]
iris_hux <-
hux(small_iris) %>%
add_colnames() %>%
set_bold(row = 1, col = everywhere, value = TRUE) %>%
set_all_borders(TRUE)
I think all functions speak for themselves. For a thorough introduction, see https://hughjonesd.github.io/huxtable/huxtable.html#adding-row-and-column-names.
print_screen(iris_hux) yield this output (in the console!):
I have not figured out yet how to suppress the bottom information on the column names. So if someone knows, please comment!
EDIT: In order to suppress the column names at the bottom, use colnames = FALSE inside print_screen().