当前位置: 动力学知识库 > 问答 > 编程问答 >

r - how to compare multiple values from one dataframe to specific values from another dataframe

问题描述:

I have two dataframes one like this containing hourly values

 date no no2 nox

1 2009-01-01 00:00:00 55.00000 63.00000 147.00000

2 2009-01-01 01:00:00 93.00000 74.00000 216.00000

3 2009-01-01 02:00:00 23.00000 46.00000 80.00000

4 2009-01-01 03:00:00 28.00000 42.00000 84.00000

5 2009-01-01 04:00:00 41.00000 65.00000 128.00000

6 2009-01-01 05:00:00 11.00000 32.00000 50.00000

7 2009-01-01 06:00:00 18.00000 36.00000 63.00000

8 2009-01-01 07:00:00 19.00000 44.00000 73.00000

9 2009-01-01 08:00:00 19.00000 42.00000 71.00000

10 2009-01-01 09:00:00 23.00000 44.00000 78.00000

11 2009-01-01 10:00:00 29.00000 48.00000 92.00000

12 2009-01-01 11:00:00 45.00000 65.00000 134.00000

13 2009-01-01 12:00:00 19.00000 50.00000 78.00000

14 2009-01-01 13:00:00 38.00000 48.00000 105.00000

15 2009-01-01 14:00:00 41.00000 73.00000 136.00000

16 2009-01-01 15:00:00 38.00000 63.00000 120.00000

17 2009-01-01 16:00:00 61.00000 57.00000 151.00000

18 2009-01-01 17:00:00 69.00000 48.00000 153.00000

19 2009-01-01 18:00:00 110.00000 117.00000 285.00000

20 2009-01-01 19:00:00 23.00000 50.00000 84.00000

21 2009-01-01 20:00:00 65.00000 55.00000 155.00000

22 2009-01-01 21:00:00 26.00000 44.00000 84.00000

23 2009-01-01 22:00:00 9.00000 32.00000 46.00000

24 2009-01-01 23:00:00 18.00000 46.00000 73.00000

and the second on as:

 date percentile.10

1 2009-01-01 -3.8

2 2010-01-01 -5.0

3 2011-01-01 -1.7

4 2012-01-01 -2.3

5 2013-01-01 -1.6

6 2014-01-01 -0.5

7 2015-01-01 -0.8

8 2016-01-01 -2.4

The first dataframe continues until 2016. Basically I need to compare a sequence of every 24 hours and see if nox column from the first df is higher than the percentile.10 from the second dataframe. However for each year the comparison must also change i.e for the 2009 the 24 sequence comparison (from the first dataframe) should be made with the first percentile but when the date/year changes in the first dataframe the comparison from the second dataframe must also change.

I really appreciate any help on how to do it.

PS: I am not an R expert

分享给朋友:
您可能感兴趣的文章:
随机阅读: