Dataframes in a list; adding a new variable with name of dataframe

后端 未结 4 1616
猫巷女王i
猫巷女王i 2020-12-14 03:39

I have a list of dataframes which I eventually want to merge while maintaining a record of their original dataframe name or list index. This will allow me to subset etc acro

4条回答
  •  不思量自难忘°
    2020-12-14 03:59

    dlply function form plyr package could be an answer:

    library('plyr')
    df1 <- data.frame(x=c(1:5),y=c(11:15))
    df2 <- data.frame(x=c(1:5),y=c(11:15))
    mylist <- list(df1 = df1, df2 = df2)
    
    all <- ldply(mylist)
    

提交回复
热议问题