Writes an ASCII text representation of an R object to a character string, or uses one to recreate the object. If applying this function to a data.frame, it will do this on each rows of given columns, and also transform columns between datetime and character.

ListUnpack(x, mutate = FALSE, vars = NULL)

ListPack(x, mutate = FALSE, vars = NULL,
  vars.time = vars(ends_with("Time")), tz = "UTC")

Arguments

x

An ojbect or a data.frame.

mutate

If TRUE, apply the function on the given columns. If FALSE, apply the function on the object.

vars, vars.time

A list of columns generated by vars(), a character vector of column names, a numeric vector of column positions, or NULL. vars.time is the columns names of datetime.

tz

a character string that specifies which time zone to parse the date with. The string must be a time zone that is recognized by the user's OS. If NULL, use the current time zone.

Value

Transformed object.

Examples

s <- flightscanner:::ListUnpack(LETTERS) flightscanner:::ListPack(s)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" #> [20] "T" "U" "V" "W" "X" "Y" "Z"
d <- flightscanner:::ListUnpack(iris, mutate = TRUE, vars = "Species") d <- flightscanner:::ListPack(d, mutate = TRUE, vars = "Species") d$Species <- unlist(d$Species) head(d)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3.0 1.4 0.2 setosa #> 3 4.7 3.2 1.3 0.2 setosa #> 4 4.6 3.1 1.5 0.2 setosa #> 5 5.0 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa