dataframe - Creating a seven day, average-by-week-of-year (or moving average?) in R -


I have data of a ton that I am feeding through R to make an average. Relevant data includes date and temperature readings, often there are many temperature readings for the same day. Dates are approximately 6 months.

Researchers requested by researchers were described as two for the following:

The average weekly a ???? 7 days rolling average (not calendar week) Average max 7 days rolling max

Therefore, if my data has begun on 1/1/13, then give me 1/1/13 and 1/7/13 All temperature readings should be average between, and then do this for the 1/8/13 item - 1/15/13 and so on. I have been told somewhere on the stack that it is actually called " average-by-year-by-year ", although I believe that I do not get enough that this is not how much the average is moving is . I have done some research, but overall it is that I am, I have great difficulty in understanding how the attitude of this problem is.

For the visual between you, it's essentially the way I'm dealing with the data (actual data.frame looks very different (given below) Look at the defect head) and several thousand records are long, but these are the two proper names for the relevant columns): DATE | TEMP ----------------- 1/2/13 34.4 1/2/13 36.4 1/2/13 34.3 1/4/13 45.6 1/4/13 33.5 1 / 5/13 45.2 1/6/13 53.9 1/7/13 34.6 1/7/13 36.2 1/8/13 22.4 1 / 9/13 30.8 1 / 9/13 33.2

I am looking at the XTS Library:

  xts (x = null, order.by = index (x), frequency = null, unique = TRUE, tzone = Sys.getenv ("TZ "), ...)   

It looks promising, but I can not understand it very much and the documentation is not helping too much.

xts (x = mydf, order.by = date (x), frequency = 7 ...?

thoughts? Thank you.

Duplicate head here Is a small sample of information:

  structure (list (5701 = 57 9: 584, site = C (101l, 101l, 101l, 101l, 101l, 101l ), Menthe = C (6 L, 6 L, 6 L, 6 L, 6 L, 6 L), Day = C (7 L, 7 L, 7 L, 7 L, 7 L, 7 L), Date = Structure (C (34 L, 34 L, 34 L, 34 L, 34 L, 34 L). LABEL = C ("10/1/2013", "10/10/2013", "10/11/2013" , "10/12/2013", "10/2/2013", "10/3/2013", "10/4/2013", "10/5/2013", "10/6/2013", " 10/8/2013 "," 10/8/2013 "," 10/9/2013 "," 6/10/2013 "," 6/11/2016 3 "," 9/9/2013 "), class = "Factor") , TIMESTAMP = Structure (784: 789, .label = C ("10/1/2013 0:00", "10/1/2013 1: 00", "10/1/2013 10:00", "10 / 1/2013 11:00 "," 10/1/2013 12:00 "," 10/1/2013 13:00 "," 10 / 1/2013 14:00 "," 10/1/2013 15: 00 "," 10/1/2013 16:00 "," 10/1/2013 17:00 "," 10/1/2013 18: 00 "," 10/1/2013 1 9:00 "," 10 "CECTI", "MINAT", "DEA", "DATE", "T" = "23" (23.376, 23.376, 23.833, 24.146, 24.219, 24.05), "CECTI", "MINAT", "DEA", "DATE" "Timestamp", "TEP", "XC"), line.Name = C (NA, 6L), class = "data.frame")    

sampled = 'DATE of 1/2/13 34.4 1/2/13 36.4 1/2/13 34.3 1/4/13 45.6 1 / 4/13 33.5 1/5 / 13 45.2 1/6/13 53.9 1/7/13 34.6 1/7/13 36.2 1/8/13 22.4 1 / 9/13 30.8 1 / 9/13 33.2 'Extra = Readable (Text = Sample, Header = T) Library (XTS) EX1 $ DATE = as.Date (ex1 $ date, format ='% m /% d /% y ') ex2 = xts (ex1 $ temp, order.by = ex1 $ DATE) xts:: Apply. Weekly (x2, mean)

This two does not sound like a moving average

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -