R: loop through data frame extracting subset of data depending on date

后端 未结 5 1653
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 14:29

I have a large data frame that consists of data that looks something like this:

        date    w    x    y    z    region
1    2012 01    21   43   12    3   NO         


        
5条回答
  •  北海茫月
    2021-02-06 14:52

    After sub-setting your dataset by date, imagine that the function you would like to apply to each subset is to find the mean of the column x. You could do it this way: (df is your dataframe)

     library(plyr)
     ddply(df, .(date), summarize, mean = mean(x))
    

提交回复
热议问题