Hi @davidhodge931,
The star means that the tibble has row names (which are not displayed). Row names are normally dropped when making a tibble (better to have the data in a true column). See differences here using the mtcars
in-built dataframe which has row names:
suppressPackageStartupMessages(library(tidyverse))
head(mtcars)
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
#> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
#> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
#> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
#> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
#> Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
rownames(head(mtcars))
#> [1] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710"
#> [4] "Hornet 4 Drive" "Hornet Sportabout" "Valiant"
as_tibble(head(mtcars))
#> # A tibble: 6 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
as_tibble(head(mtcars), rownames=NA)
#> # A tibble: 6 x 11
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 21 6 160 110 3.9 2.62 16.5 0 1 4 4
#> 2 21 6 160 110 3.9 2.88 17.0 0 1 4 4
#> 3 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1
#> 4 21.4 6 258 110 3.08 3.22 19.4 1 0 3 1
#> 5 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2
#> 6 18.1 6 225 105 2.76 3.46 20.2 1 0 3 1
Created on 2021-09-10 by the reprex package (v2.0.1)
I'm trying not to be an idiot here, but I'm a little confused. You say "The star means that the tibble has row names", but in your example the case with the row names intact does not have an asterisk, but the case with the row names removed does have an asterisk. Isn't that the opposite of what your explanation?
The first case is a plain dataframe, not a tibble. A dataframe will display the row names if it has them.
The second case is when the dataframe has been converted to a tibble. The row names have been discarded by default. The third is a tibble with the row names intentionally kept. It has a * to show that the row names exist, but they are not displayed.
Ah, thank you. I assumed that rownames = NA
set the row names to missing/not available. I have to say it seems counterintuitive that NA
means keep the names, but I see (having read the help) that NULL
would be how you'd explicitly indicate row names should be dropped.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.