Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Turn list of tibbles into list of vectors

How can I turn a list of tibbles (all one col only) into a list of vectors?
The names of the list objects should stay the same and the col_name of the tibble should be omitted. Thanks for your help dear noble coders!

Example

a_tibble <- tibble(id = c('AB', 'DRR', 'FH', 'yyb'))
another_tibble <- tibble(id = c('AB', 'DXF', 'FH', 'DKH'))

list <- list(
  list1 = a_tibble,
  list2 = another_tibble,
  list3 = a_tibble,
  list4 = another_tibble)

expected result

result <- list(
  list1 = (c('AB', 'DRR', 'FH', 'yyb')),
  list2 = (c('AB', 'DXF', 'FH', 'DKH')),
  list3 = (c('AB', 'DRR', 'FH', 'yyb')),
  list4 = (c('AB', 'DXF', 'FH', 'DKH'))
)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You may unlist each list

lapply(list, unlist, use.names = FALSE)

#$list1
#[1] "AB"  "DRR" "FH"  "yyb"

#$list2
#[1] "AB"  "DXF" "FH"  "DKH"

#$list3
#[1] "AB"  "DRR" "FH"  "yyb"

#$list4
#[1] "AB"  "DXF" "FH"  "DKH"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading