I can\'t combine the use of lapply and paste to combine two columns for multiple dataframes contained within a list. I\'ve looked through multiple sources, but can\'t find the a
I think this is what you're going for:
lapply(mylist, function(x) paste(x$Artist, x$Song, sep=" "))
We just need to define the little anonymous function to concatenate the columns.
[[1]]
[1] "Drake Gods Plan" "Ed Sheeran Perfect" "Bruno Mars Finesse"
[4] "Camilla Cabello Havana" "BlocBoy Look Alive"
[[2]]
[1] "Gucci Mane Black Beatles" "Migos Bad and Boujee"
[3] "Daft Punk Starboy" "Chainsmokers Closer"
A solution using purrr::map
from the tidyverse
library(tidyverse)
map(list(Current, Past), ~ paste(.$Artist, .$Song))
[[1]]
[1] "Drake Gods Plan" "Ed Sheeran Perfect" "Bruno Mars Finesse"
[4] "Camilla Cabello Havana" "BlocBoy Look Alive"
[[2]]
[1] "Gucci Mane Black Beatles" "Migos Bad and Boujee" "Daft Punk Starboy"
[4] "Chainsmokers Closer"