Zweifler
Zweifler

Reputation: 451

How does one omit the data types line when printing a tibble?

In R, is there a way to omit the data types line when printing a tibble? I would like to declutter calls to tibble objects but can't find an option to achieve this.

Upvotes: 2

Views: 148

Answers (1)

MrFlick
MrFlick

Reputation: 206187

There is info on costuming the output in the pillar package: vignette("extending", package="pillar") .

it looks like you can customize the tbl_format_body. We can extend this generic method to respond to a class where you don't want the type to appear. For example

tbl_format_body.notype <- function (x, setup, ...) {
  force(setup)
  setup$body[-2]
}
notype <- function(x) {
  class(x) <- c("notype", class(x))
  x
}
notype(tibble(a=1:3, b=letters[1:3]))
# # A tibble: 3 x 2
#       a b    
# 1     1 a    
# 2     2 b    
# 3     3 c 

Here I just dropped the second row which I assume usually has the types. You can read all about the stuff you can do on that guide though.

Upvotes: 2

Related Questions