Storing multiple data frames into one data structure - R

前端 未结 3 715
情歌与酒
情歌与酒 2020-12-24 14:16

Is it possible to have multiple data frames to be stored into one data structure and process it later by each data frame? i.e. example

df1 <- data.frame(c         


        
3条回答
  •  有刺的猬
    2020-12-24 15:02

    Just put the data.frames in a list. A plus is that a list works really well with apply style loops. For example, if you want to save the data.frame's, you can use mapply:

    l = list(df1, df2)
    mapply(write.table, x = l, file = c("df1.txt", "df2.txt"))
    

    If you like apply style loops (and you will, trust me :)) please take a look at the epic plyr package. It might not be the fastest package (look data.table for fast), but it drips with syntactic sugar.

提交回复
热议问题