いくつかの監視サイトで降水データを含むデータセットがあります。
structure(list(date = structure(1:10, .Label = c("2010-01-01",
"2010-01-02", "2010-01-03", "2010-01-04", "2010-01-05", "2010-01-06",
"2010-01-07", "2010-01-08", "2011-01-01", "2011-01-02"), class = "factor"),
site1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), site2 = c(0.7, 0,
1.4, 0, 0, 0, 2.2, 0, 0, 2.2), site3 = c(0, 0, 0, 0, 0, 1.3,
0.6, 0, 1.3, 0.6), site4 = c(0L, 0L, 0L, 0L, 0L, 0L, 2L,
0L, 0L, 2L), site5 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), site6 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0), site7 = c(0, 0, 0, 1, 0, 4, 3,
1, 4, 3), site8 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), .Names = c("date",
"site1", "site2", "site3", "site4", "site5", "site6", "site7",
"site8"), class = "data.frame", row.names = c(NA, -10L))
毎年、すべてのサイトで 0 より大きい値の最初の発生を見つける必要があります。やり方がわかりません。結果は次のようになります [データ フレームは良好です]:
year site1 site2 site3 site4 site5 site6 site7 site8
2001 01-02 01-02 01-02 01-02 01-01 02-02 01-01 01-02
2002 01-03 01-02 02-02 01-02 01-02 01-03 01-02 04-02
2003 01-02 01-05 01-02 01-02 05-02 01-02 01-07 01-02
2004 05-02 01-02 01-02 07-02 01-02 05-02 01-02 01-06
Rでそれを行う方法は?
ありがとう、J.