[R] Show only header of str() function

Rui Barradas
Thu, 02 Sep 2021 11:31:17 -0000

Hello,

Not perfect but works for data.frames:


header_str <- function(x){
   capture.output(str(x))[[1]]
}
header_str(iris)
header_str(AirPassengers)
header_str(1:10)


Hope this helps,

Rui Barradas

?s 12:02 de 02/09/21, Luigi Marongiu escreveu:
> Hello, is it possible to show only the header (that is:
`'data.frame':
> x obs. of  y variables:` part) of the str function?
> Thank you
>