R: What are the best functions to deal with concatenating and averaging values in a data.frame?

前端 未结 3 798
时光取名叫无心
时光取名叫无心 2021-01-06 19:59

I have a data.frame from this code:

   my_df = data.frame(\"read_time\" = c(\"2010-02-15\", \"2010-02-15\", 
                                      \"2010-02-         


        
3条回答
  •  无人及你
    2021-01-06 20:28

    This illustrates how you could use aggregate to get the mean and standard deviation by your read_time.

    >aggregate(my_df$OD, by=list(my_df$read_time), function(x) mean(x))
    
         Group.1         x
    1 2010-02-15 0.1500000
    2 2010-02-16 0.2333333
    3 2010-02-17 0.5000000
    
    
    >aggregate(my_df$OD, by=list(my_df$read_time), function(x) sd(x))
         Group.1          x
    1 2010-02-15 0.07071068
    2 2010-02-16 0.15275252
    3 2010-02-17         NA
    

提交回复
热议问题