species <- c("frog1","frog1","frog1","frog1","frog1","frog1","frog1","frog1"
,"frog1","frog1","frog2","frog2","frog2","frog2","frog2",
"frog2","frog2","frog2","frog2","frog2")
month <- c(1,12,5,8,10,3,5,7,9,4,2,4,6,7,6,3,8,9,11,1)
number <- c(3,4,5,1,2,3,4,7,6,7,3,5,6,7,8,9,9,5,3,1)
a<- data.frame(species,month,number)
私のデータフレームは、異なる月に異なる数のカエル、カエルとカエルの2種類を捕獲したことを意味します。季節に最適な月を選択してください
私は月を4シーズンに変換したいと思います。最初のシーズンは1ヶ月目、12ヶ月目、2月目、4,3,5,3番目は7,6,8、そして10,9,11です。第1シーズン、第12月、第2月、第2シーズンを同じように選択したいと思っています。第2シーズンには、第1シーズン、第3シーズン、5ヶ月後などになります。たとえば、カエル1では2ヶ月の1と12がありますが、最初のシーズンには12ヶ月ではなく1ヶ月を取りに行きたいと思います。
2種類のカエルで最も重要な月を4つの季節に交互に選ぶことができる列を作成するにはどうすればいいですか?たとえば、カエル1では2と1と12があります。最初のシーズンは12月の代わりに1月を選びたいと思っています。
species <- c("frog1","frog1","frog1","frog1","frog1","frog1","frog1","frog1"
,"frog1","frog1","frog2","frog2","frog2","frog2","frog2",
"frog2","frog2","frog2","frog2","frog2")
month <- c(1,12,5,8,10,3,5,7,9,4,2,4,6,7,6,3,8,9,11,1)
number <- c(3,4,5,1,2,3,4,7,6,7,3,5,6,7,8,9,9,5,3,1)
choosemonth <- c("season1","","","","season4","","","season3","","season2",
"","season2","","season3","","","","season4","","season1")
b<- data.frame(species,month,number,choosemonth)