在满足特定条件的列中选择观察值

问题描述 投票:0回答:2

我有一个看起来很简单的问题但却让我很难过。我的时间序列数据如下:

Year Percentile Value
1990 p.10 20
1990 p.50 30
1990 p.90 40

我试图选择对应于第10个百分位数的价值观察值(例如,第10页)。

r percentile
2个回答
0
投票

正如Jan所说,dplyr::filter对这类事情很有帮助。 library(dplyr) percentiledata <- dplyr::filter(data, Percentile == "p.10")


0
投票
 subset(dat,grepl("10",Percentile))
  Year Percentile Value
1 1990       p.10    20
© www.soinside.com 2019 - 2024. All rights reserved.