tibble (version 1.0)

data_frame: Build a data frame or list.

Description

data_frame is trimmed down version of data.frame that:
  1. Never coerces inputs (i.e. strings stay as strings!).
  2. Never addsrow.names.
  3. Never munges column names.
  4. Only recycles length 1 inputs.
  5. Evaluates its arguments lazily and in order.
  6. Addstbl_dfclass to output.
  7. Automatically adds column names.

Usage

data_frame(...)

data_frame_(xs)

lst(...)

lst_(xs)

Arguments

...
A set of name-value pairs. Arguments are evaluated sequentially, so you can refer to previously created variables.
xs
A list of unevaluated expressions created with ~, quote(), or lazy.

Details

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

See Also

as_data_frame to turn an existing list into a data frame.

Examples

Run this code
a <- 1:5
data_frame(a, b = a * 2)
data_frame(a, b = a * 2, c = 1)
data_frame(x = runif(10), y = x * 2)

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

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

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

# With the SE version, you give it a list of formulas/expressions
data_frame_(list(x = ~1:10, y = quote(x * 2)))

# data frames can only contain 1d atomic vectors and lists
# and can not contain POSIXlt
data_frame(x = data_frame(1, 2, 3))
data_frame(y = strptime("2000/01/01", "%x"))

Run the code above in your browser using DataCamp Workspace