Converts data objects to tibbles.
as_tbl_data(x, row_names = FALSE)
x | Data frame or data frame-like input. |
---|---|
row_names | Logical indicating whether to convert non-null row names into the first column. |
## data with row names d <- data.frame(x = rnorm(5), y = rnorm(5), row.names = letters[1:5]) ## convert to tibble as_tbl_data(d)#> # A tibble: 5 x 2 #> x y #> <dbl> <dbl> #> 1 -1.40 1.15 #> 2 0.255 -1.82 #> 3 -2.44 -0.247 #> 4 -0.00557 -0.244 #> 5 0.622 -0.283## convert to tibble and create row_names variable as_tbl_data(d, row_names = TRUE)#> # A tibble: 5 x 3 #> row_names x y #> <chr> <dbl> <dbl> #> 1 a -1.40 1.15 #> 2 b 0.255 -1.82 #> 3 c -2.44 -0.247 #> 4 d -0.00557 -0.244 #> 5 e 0.622 -0.283