tibble (version 1.4.2)

tibble: Build a data frame or list

Description

tibble() is a trimmed down version of data.frame() that:

  • Never coerces inputs (i.e. strings stay as strings!).

  • Never adds row.names.

  • Never munges column names.

  • Only recycles length 1 inputs.

  • Evaluates its arguments lazily and in order.

  • Adds tbl_df class to output.

  • Automatically adds column names.

data_frame() is an alias to tibble().

tibble_() and its alias data_frame_() use lazy evaluation and are deprecated. New code should use tibble() or data_frame() with quasiquotation.

lst() is similar to list(), but like tibble(), it evaluates its arguments lazily and in order, and automatically adds names.

lst_() uses lazy evaluation and is deprecated. New code should use lst() with quasiquotation.

Usage

tibble(...)

data_frame(...)

lst(...)

Arguments

...

A set of name-value pairs. Arguments are evaluated sequentially, so you can refer to previously created variables. These arguments are processed with rlang::quos() and support unquote via !! and unquote-splice via !!!.

See Also

as_tibble() to turn an existing list into a data frame.

Examples

Run this code
# NOT RUN {
a <- 1:5
tibble(a, b = a * 2)
tibble(a, b = a * 2, c = 1)
tibble(x = runif(10), y = x * 2)

lst(n = 5, x = runif(n))

# tibble never coerces its inputs
str(tibble(letters))
str(tibble(x = list(diag(1), diag(2))))

# or munges column names
tibble(`a + b` = 1:5)

# You can splice-unquote a list of quotes and formulas
tibble(!!! list(x = rlang::quo(1:10), y = quote(x * 2)))

# data frames can only contain 1d atomic vectors and lists
# and can not contain POSIXlt
# }
# NOT RUN {
tibble(x = tibble(1, 2, 3))
tibble(y = strptime("2000/01/01", "%x"))
# }
# NOT RUN {
lst(n = 5, x = runif(n))

# You can splice-unquote a list of quotes and formulas
lst(!!! list(n = rlang::quo(2 + 3), y = quote(runif(n))))

# }

Run the code above in your browser using DataCamp Workspace