我有50个气象站1986-2015年的降水数据。
我需要对每个站2007至2015年期间的相关信息进行分类。我是说有三个变量:
我需要每个车站的结果。有人知道如何使用“拆分”来达到这个目的吗?请您从"read.table“开始写代码好吗?
发布于 2020-04-30 09:26:41
如果您的任务只是通过year拆分数据,则可以使用split
split(df, f = df$year)说明性数据:
(set.seed(123)
df <- data.frame(
station = sample(LETTERS[1:3],10, replace = T),
year = paste0("201", sample(1:9, 10, replace = T)),
precipitation = sample(333:444, 10, replace = T)
)结果:
$`2011`
station year precipitation
5 C 2011 406
8 C 2011 399
$`2013`
station year precipitation
7 B 2013 393
9 B 2013 365
$`2015`
station year precipitation
2 C 2015 410
$`2016`
station year precipitation
4 C 2016 444
$`2017`
station year precipitation
3 B 2017 404
$`2019`
station year precipitation
1 A 2019 432
6 A 2019 412
10 B 2019 349https://stackoverflow.com/questions/61510892
复制相似问题