How to use lapply and paste on multiple dataframes in a list

前端 未结 2 1850
Happy的楠姐
Happy的楠姐 2021-01-21 16:50

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

2条回答
  •  离开以前
    2021-01-21 17:17

    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"     
    

提交回复
热议问题