2

I would like to show the data structure of a dataframe/Tibble BUT Without the attributes - attr(*, "spec")= at the end. Is there another command (or better way) that shows only lines 2 & 3?

## spec_tbl_df [4,238 × 2] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ male           : Factor w/ 2 levels "F","M": 2 1 2 1 1 1 1 1 2 2 ...
##  $ age            : num [1:4238] 39 46 48 61 46 43 63 45 52 43 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   male = col_factor(levels = c("0", "1"), ordered = FALSE, include_na = FALSE),
##   ..   age = col_double(),
##   .. )
##  - attr(*, "problems")=<externalptr>
zx8754
  • 52,746
  • 12
  • 114
  • 209
mccurcio
  • 1,294
  • 5
  • 25
  • 44

1 Answers1

4

We can use give.attr=FALSE. Example:

test <- `attr<-`(data.frame(), 'foo', 'bar')

str(test)
# 'data.frame': 0 obs. of  0 variables
# - attr(*, "foo")= chr "bar"

str(test, give.attr=FALSE)
# 'data.frame': 0 obs. of  0 variables
jay.sf
  • 60,139
  • 8
  • 53
  • 110