Description Usage Arguments Value Note Author(s) References Examples
Flatten a named, nested list of atomic vectors to a single level using the concatenated list/atomic vector names as the names of the single tiered list.
1 |
x |
A nested, named list of vectors. |
sep |
A separator to use for the concatenation of the names from the nested list. |
... |
ignored. |
Returns a flattened list.
The order of the list is sorted alphabetically. Pull requests for the option to return the original order would be appreciated.
StackOverflow user @Michael and Paul Foster and Tyler Rinker <tyler.rinker@gmail.com>.
https://stackoverflow.com/a/41882883/1000343
https://stackoverflow.com/a/48357114/1000343
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 | x <- list(
urban = list(
cars = c('volvo', 'ford'),
food.dining = list(
local.business = c('carls'),
chain.business = c('dennys', 'panera')
)
),
rural = list(
land.use = list(
farming =list(
dairy = c('cows'),
vegie.plan = c('carrots')
)
),
social.rec = list(
community.center = c('town.square')
),
people.type = c('good', 'bad', 'in.between')
),
other.locales = c('suburban'),
missing = list(
unknown = c(),
known = c()
),
end = c('wow')
)
x
flatten(x)
flatten(x, ' -> ')
## Not run:
## dictionary from quanteda
require(quanteda); library(textreadr); library(dplyr)
mydict <- https://provalisresearch.com/Download/LaverGarry.zip" %>%
textreadr::download(") %>%
unzip(exdir = tempdir()) %>%
`[`(1) %>%
quanteda::dictionary(file = .)
mydict
flatten(as.list(mydict))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.