如何在timeAverage函数中按两种属性类型对数据进行排序

时间:2019-06-17 18:21:43

标签: r aggregate average plyr openair

我有一个鸟类位置数据集,我想每周取这些经/纬度值的平均值,并按鸟类和季节进行排序。

以下是数据示例:

datexample <- data.frame(
  "site" = c("A","B"), 
  "bird" = c("1A","2A"), 
  "date" = c("2017-07-15", "2017-07-15", "2017-07-30", "2017-07-30"),
  "season" = c("Fall","Winter"), 
  "lat" =  c(45.25, 44.75, 44.75, 44.75), 
  "lon" = c(-61.75, -61.25, -61.75, -61.25)
)
datexample

这是我当前拥有的代码,它采用每只鸟的平均经/纬度,但未按季节对其进行排序。我尝试在函数中添加第二个“ type =”,但这不起作用。

library(openair)

datnew = timeAverage(datexample, avg.time = "week", statistic = "mean", type = "bird", interval = "season")
head(datnew) 

我想每周按鸟类和季节来获得鸟类的平均位置。

我是R的新手,所以我们将不胜感激!

0 个答案:

没有答案