I got this two data frames:
variables = tibble(x = "A", y = "P")
description = tibble(x = "Area", y = "Perimeter")
And i want to reach this:
list(A = "Area", P = "Perimeter")
How can i do that?
You can unlist the dataframe and create a named list using setNames :
setNames(as.list(unlist(description)), unlist(variables))
#$A
#[1] "Area"
#$P
#[1] "Perimeter"
You can rename the dataframe column names instead of individual values as suggested by @Darren Tsai which make it shorter and simple.
as.list(setNames(description, variables))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With