tibble::tibble()

tibble(..., .rows = NULL, .name_repair = c("unique", "universal", "minimal", "check_unique", "check_unique", "check_names"))
Returns: tbl_df · Updated March 13, 2026 · Data Types
tibble tidyverse data-types data-frame

A tibble (pronounced “tibble”) is the tidyverse’s modern take on the classic R data.frame. Created by the tidyverse team, tibbles retain the core structure of data frames but with refinements that make them more predictable and easier to work with in data analysis pipelines.

Unlike traditional data frames, tibbles never automatically convert string vectors to factors, never change column names silently, and always print in a tidy format that shows you the data types and dimensions at a glance.

Syntax

tibble(
  ...,
  .rows = NULL,
  .name_repair = c("unique", "universal", "minimal", 
                   "check_unique", "check_unique", "check_names")
)

Parameters

ParameterTypeDefaultDescription
...named argumentsColumn definitions as name = value pairs
.rowsintegerNULLNumber of rows (automatically computed from ... if not specified)
.name_repaircharacter"unique"How to handle duplicate or invalid column names

Examples

Creating a tibble from scratch

library(tibble)

# Basic tibble creation
df <- tibble(
  name = c("Alice", "Bob", "Charlie"),
  age = c(25, 30, 35),
  score = c(85.5, 92.0, 78.5)
)

# Print displays data types
print(df)
#> # A tibble: 3 × 3
#>   name     age score
#>   <chr>  <dbl> <dbl>
#> 1 Alice     25  85.5
#> 2 Bob       30  92.0
#> 3 Charlie   35  78.5

Using tibble() vs data.frame()

# tibble: strings stay as character (not converted to factor)
df_tibble <- tibble(name = c("a", "b"), x = 1:2)
str(df_tibble)
#> tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
#>  $ name: chr [1:2] "a" "b"
#>  $ x   : int [1:2] 1 2

# data.frame: strings become factors by default
df_base <- data.frame(name = c("a", "b"), x = 1:2)
str(df_base)
#> 'data.frame': 2 obs. of  2 variables:
#>  $ name: Factor w/ 2 levels "a","b": 1 2
#>  $ x   : int  1 2

Column recycling with tibble()

# tibble enforces strict recycling rules
# This would fail (unlike data.frame which recycles silently)
try(tibble(x = 1:3, y = 1:2))
#> Error: tibble() requires each column to be same length

# tibble can recycle length-1 vectors automatically
tibble(x = 1:3, y = 1)
#> # A tibble: 3 × 2
#>       x     y
#>   <int> <dbl>
#> 1     1     1
#> 2     2     1
#> 3     3     1

Using tribble() for readable data entry

# tribble() allows row-wise data entry
df <- tribble(
  ~name,    ~age, ~city,
  "Alice",    25, "NYC",
  "Bob",      30, "LA",
  "Charlie",  35, "Chicago"
)
print(df)
#> # A tibble: 3 × 3
#>   name      age city  
#>   <chr>   <dbl> <chr> 
#> 1 Alice      25 NYC   
#> 2 Bob        30 LA    
#> 3 Charlie   35 Chicago

Common Patterns

Converting between data.frame and tibble

# Convert data.frame to tibble
as_tibble(iris)

# Convert tibble back to data.frame
as.data.frame(df)

# Check if an object is a tibble
is_tibble(df)
#> [1] TRUE

Subsetting behavior

df <- tibble(x = 1:3, y = c("a", "b", "c"))

# Tibble subsetting always returns a tibble
df[, "x"]
#> # A tibble: 3 × 1
#>       x
#>   <int>
#> 1     1
#> 2     2
#> 3     3

# Using $ returns a vector (not a factor)
df$x
#> [1] "a" "b" "c"

Name repair

# Handle duplicate column names
df <- tibble(
  "x" = 1,
  "x" = 2,
  .name_repair = "unique"
)
names(df)
#> [1] "x" "x.1"

# Universal names (make syntactic)
df <- tibble(
  "my var" = 1,
  "123" = 2,
  .name_repair = "universal"
)
names(df)
#> [1] "my.var"  "X123"

See Also