Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>First switch to a <code>Date</code> representation: <code>as.Date(df.MHwind_load$Date)</code></li> <li>Then call <code>weekdays</code> on the date vector to get a new factor labelled with day of week</li> <li>Then call <code>months</code> on the date vector to get a new factor labelled with name of month</li> <li>Optionally create a <code>years</code> variable (see below).</li> </ol> <p>Now <code>subset</code> the data frame using the relevant combination of these. Step 2. gets an answer to your task 3. Steps 3. and 4. get you to task 1. Task 2 might require a line or two of R. Or just select rows corresponding to, say, all the Mondays in a month and call <code>unique</code>, or its alter-ego <code>duplicated</code> on the results.</p> <p>To get you going...</p> <pre><code>newdf &lt;- df.MHwind_load ## build an augmented data set newdf$d &lt;- as.Date(newdf$Date) newdf$month &lt;- months(newdf$d) newdf$day &lt;- weekdays(newdf$d) ## for some reason R has no years function. Here's one years &lt;- function(x){ format(as.Date(x), format = "%Y") } newdf$year &lt;- years(newdf$d) # get observations from January to March of every year subset(newdf, month %*% in c('January', 'February', 'March')) # get all Monday observations subset(newdf, day == 'Monday') # get all Mondays in 1999 subset(newdf, day == 'Monday' &amp; year == '1999') # slightly fancier: _first_ Monday of each month # get the first weeks first.week.of.month &lt;- !duplicated(cbind(newdf$month, newdf$day)) # now pull out the mondays subset(newdf, first.monday.of.month &amp; day=='Monday') </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload