Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1) If what is meant by mapping 01-24 to 00-23 is that 01 is mapped to 00, 02 is mapped to 01, etc. then here is a solution; otherwise see 2) below.</p> <p>The <code>gsubfn</code> function in the gsubfn package can pick out strings and apply a function to them replacing the match with the output of the function. We read the Lines in and then match a space, two characters and a colon replacing the two characters with a number one less. Finally we re-read it:</p> <pre><code>library(gsubfn) L &lt;- readLines(textConnection(Lines)) L2 &lt;- gsubfn(" (..):", ~ sprintf(" %02d:", as.numeric(..1)-1), L) DF &lt;- read.csv(textConnection(L2), as.is = TRUE) DF$Date &lt;- as.POSIXct(DF$Date, format = "%m/%d %H:%M:%S") </code></pre> <p>Thus the last bit of the result is:</p> <pre><code>&gt; tail(DF) Date Outdoor Indoor 21 01/01 20:00:00 25.9 21.1 22 01/01 21:00:00 25.8 21.3 23 01/01 22:00:00 25.6 21.4 24 01/01 23:00:00 25.5 21.5 25 01/02 00:00:00 25.4 21.6 26 01/02 01:00:00 25.3 21.8 </code></pre> <p>2) If what is meant by mapping 01-24 to 00-23 is that 01-23 get mapped to themelves and 24 gets mapped to 00 of the next day then calculate <code>DF</code> as shown above and then do this:</p> <pre><code>DF$Date &lt;- DF$Date + 3600 </code></pre> <p>so that the last bit of the result is:</p> <pre><code>&gt; tail(DF) Date Outdoor Indoor 21 2011-01-01 21:00:00 25.9 21.1 22 2011-01-01 22:00:00 25.8 21.3 23 2011-01-01 23:00:00 25.6 21.4 24 2011-01-02 00:00:00 25.5 21.5 25 2011-01-02 01:00:00 25.4 21.6 26 2011-01-02 02:00:00 25.3 21.8 </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.
 

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