-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathlist_c.Rd
More file actions
63 lines (54 loc) · 1.93 KB
/
list_c.Rd
File metadata and controls
63 lines (54 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/list-combine.R
\name{list_c}
\alias{list_c}
\alias{list_cbind}
\alias{list_rbind}
\title{Combine list elements into a single data structure}
\usage{
list_c(x, ..., ptype = NULL)
list_cbind(
x,
...,
name_repair = c("unique", "universal", "check_unique"),
size = NULL
)
list_rbind(x, ..., names_to = rlang::zap(), ptype = NULL)
}
\arguments{
\item{x}{A list. For \code{list_rbind()} and \code{list_cbind()} the list must
only contain only data frames or \code{NULL}.}
\item{...}{These dots are for future extensions and must be empty.}
\item{ptype}{An optional prototype to ensure that the output type is always
the same.}
\item{name_repair}{One of \code{"unique"}, \code{"universal"}, or \code{"check_unique"}.
See \code{\link[vctrs:vec_as_names]{vctrs::vec_as_names()}} for the meaning of these options.}
\item{size}{An optional integer size to ensure that every input has the
same size (i.e. number of rows).}
\item{names_to}{By default, \code{names(x)} are lost. To keep them, supply a
string to \code{names_to} and the names will be saved into a column with that
name. If \code{names_to} is supplied and \code{x} is not named, the position of
the elements will be used instead of the names.}
}
\description{
\itemize{
\item \code{list_c()} combines elements into a vector by concatenating them together
with \code{\link[vctrs:vec_c]{vctrs::vec_c()}}.
\item \code{list_rbind()} combines elements into a data frame by row-binding them
together with \code{\link[vctrs:vec_bind]{vctrs::vec_rbind()}}.
\item \code{list_cbind()} combines elements into a data frame by column-binding them
together with \code{\link[vctrs:vec_bind]{vctrs::vec_cbind()}}.
}
}
\examples{
x1 <- list(a = 1, b = 2, c = 3)
list_c(x1)
x2 <- list(
a = data.frame(x = 1:2),
b = data.frame(y = "a")
)
list_rbind(x2)
list_rbind(x2, names_to = "id")
list_rbind(unname(x2), names_to = "id")
list_cbind(x2)
}