-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathflatten.Rd
More file actions
71 lines (61 loc) · 1.98 KB
/
flatten.Rd
File metadata and controls
71 lines (61 loc) · 1.98 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
64
65
66
67
68
69
70
71
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/superseded-flatten.R
\name{flatten}
\alias{flatten}
\alias{flatten_lgl}
\alias{flatten_int}
\alias{flatten_dbl}
\alias{flatten_chr}
\alias{flatten_dfr}
\alias{flatten_dfc}
\alias{flatten_df}
\title{Flatten a list of lists into a simple vector}
\usage{
flatten(.x)
flatten_lgl(.x)
flatten_int(.x)
flatten_dbl(.x)
flatten_chr(.x)
flatten_dfr(.x, .id = NULL)
flatten_dfc(.x)
}
\arguments{
\item{.x}{A list to flatten. The contents of the list can be anything for
\code{flatten()} (as a list is returned), but the contents must match the
type for the other functions.}
}
\value{
\code{flatten()} returns a list, \code{flatten_lgl()} a logical
vector, \code{flatten_int()} an integer vector, \code{flatten_dbl()} a
double vector, and \code{flatten_chr()} a character vector.
\code{flatten_dfr()} and \code{flatten_dfc()} return data frames created by
row-binding and column-binding respectively. They require dplyr to
be installed.
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}
These functions were superseded in purrr 1.0.0 because their behaviour was
inconsistent. Superseded functions will not go away, but will only receive
critical bug fixes.
\itemize{
\item \code{flatten()} has been superseded by \code{\link[=list_flatten]{list_flatten()}}.
\item \code{flatten_lgl()}, \code{flatten_int()}, \code{flatten_dbl()}, and \code{flatten_chr()}
have been superseded by \code{\link[=list_c]{list_c()}}.
\item \code{flatten_dfr()} and \code{flatten_dfc()} have been superseded by \code{\link[=list_rbind]{list_rbind()}}
and \code{\link[=list_cbind]{list_cbind()}} respectively.
}
}
\examples{
x <- map(1:3, \(i) sample(4))
x
# was
x |> flatten_int() |> str()
# now
x |> list_c() |> str()
x <- list(list(1, 2), list(3, 4))
# was
x |> flatten() |> str()
# now
x |> list_flatten() |> str()
}
\keyword{internal}