Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting Specific Dates in R
    primarykey
    data
    text
    <p>I am wondering how to create a subset of data in R based on a list of dates, rather than by a date range.</p> <p>For example, I have the following data set <code>data</code> which contains 3 years of 6-minute data. </p> <pre><code> date zone month day year hour minute temp speed gust dir 1 09/06/2009 00:00 PDT 9 6 2009 0 0 62 2 15 156 2 09/06/2009 00:06 PDT 9 6 2009 0 6 62 13 16 157 </code></pre> <p>I have used <code>breeze&lt;-subset(data, ws&gt;=15 &amp; wd&gt;=247.5 &amp; wd&lt;=315, select=date:dir)</code> to select the rows which meet my criteria for a sea breeze, which is fine, but what I want to do is create a subset of the days which contain those times that meet my criteria. </p> <p>I have used... </p> <pre><code>as.character(breeze$date) trimdate&lt;-strtrim(breeze$date, 10) breezedate&lt;-as.Date(trimdate, "%m/%d/%Y") breezedate&lt;-format(breezedate, format="%m/%d/%Y") </code></pre> <p>...to extract the dates from each row that meets my criteria so I have a variable called <code>breezedate</code> that contains a list of the dates that I want (not the most eloquent coding to do this, I'm sure). There are about two-hundred dates in the list. What I am trying to do with the next command is in my original dataset <code>data</code> to create a subset which contains only those days which meet the seabreeze criteria, not just the specific times.</p> <pre><code>breezedays&lt;-(data$date==breezedate) </code></pre> <p>I think one of my issues here is that I am comparing one value to a list of values, but I am not sure how to make it work. </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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