r - plot time series with constraint -


i have big dataset , i'd plot zizi vs hour each hour while variables looks this:

> datasetjc$hour[1:100]   [1] 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  [40] 23 23 23 23 23 23 23 23 23 23 23 23 23 23  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  [79]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   > datasetjc$zizi[1:100]   [1]  2 27  2  3 45  0  6  0 15  8  3  1  4  0  0 15  1 13  0 15 23  8 21  2  0  9 43 26 31 33 11  0  4  7 26  2 25 14  1  [40]  3  1  6  3  4  3  2 27  2  3 45  0  7  0 15  8  3  1  4  0  4 26  0 15  1  4  0 15 14 12 23  8  3 21 13  2  0 32 43  [79] 31 11  4  0  4  7 26 10  2 25 25  1  1  4  4 23  3  2 27  2 45  0 >  

i have minutes, dates , days vaiables. each data separated 5 minutes. how can plot?

thx

if take question "how hourly summaries of data taken @ 5 minute intervals", classic split-apply-combine. average data group great summary of different techniques.

for particular example, in vanilla r use aggregate or by function.

> df <- data.frame(hour=c(1,1,2,2,3,3,4,4), zizi=1:8) > aggregate(zizi ~ hour, data=df, mean)   hour zizi 1    1  1.5 2    2  3.5 3    3  5.5 4    4  7.5 

if wish summarize date/hour, use +:

> aggregate(zizi ~ hour + day, data=df, mean) 

for more advanced versions of this, recommend investing time in learning either dplyr or data.table, both excellent libraries doing more complex versions of extremely common task.

also future reference, see how make great r reproducible example? suggestions on how pose question more clearly.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -