[R] Attempting to plot two different time series together

Ezra Boyd ezgis76 at gmail.com
Fri Nov 6 17:49:34 CET 2015


Jeff -- Thank you for the clarification.

Ezra


On Fri, Nov 6, 2015 at 10:36 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:

> Please keep the list in the conversation.
>
> Yes stacking was my intention, since the graphical presentation does not
> need the same time basis.  However, your other analyses may indeed require
> that you interpolate or decimate to obtain aligned data records.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> On November 6, 2015 8:01:55 AM PST, Ezra Boyd <ezgis76 at gmail.com> wrote:
> >Jeff,
> >
> >Thank you very much for responding.  I actually read and worked through
> >most of ggplot2 and ggplot2 Essentials for this task, but was starting
> >to
> >think they were not what I needed.
> >
> >The problem that I cannot get over is that my two timeseries datasets
> >are
> >based on different samplings, 30-mins for the tidal and 6-mins for the
> >meteorological:
> >
> >Tidal Data
> >TS Stage_ft 1/9/2001 16:00 -0.41 1/9/2001 16:30 -0.43 1/9/2001 17:00
> >-0.44 1/9/2001
> >17:30 -0.43 1/9/2001 18:00 -0.4
> >Meteorological
> >DATETIME  WINDSPEED           DIR 8/15/2012 0:00 5.05 228 8/15/2012
> >0:06
> >4.08 225 8/15/2012 0:12 4.08 216 8/15/2012 0:18 4.47 222 8/15/2012 0:24
> >5.05
> >219 8/15/2012 0:30 3.5 226
> >
> >Do I understand your suggestion correctly that I should tidy up the
> >dataset
> >by stacking them in the dataframe, and then facet them using a type
> >column?
> >TS Stage_ft  WINDSPEED  DIR Type 1/9/2001 16:00 -0.41    T 1/9/2001
> >16:30
> >-0.43    T 1/9/2001 17:00 -0.44    T 1/9/2001 17:30 -0.43    T 1/9/2001
> >18:00 -0.4    T 8/15/2012 0:00 5.05 228    M 8/15/2012 0:06 4.08 225
> > M 8/15/2012
> >0:12 4.08 216    M 8/15/2012 0:18 4.47 222    M 8/15/2012 0:24 5.05
> >219    M 8/15/2012
> >0:30 3.5 226    M
> >Or, do I need to look into timeseries methods for combining datasets
> >with
> >different samplings?
> >
> >Thanks again and I appreciate you taking the time to share your
> >knowledge.
> >
> >Regards,
> >
> >Ezra
> >
> >
> >
> >
> >
> >
> >
> >
> >On Thu, Nov 5, 2015 at 7:25 PM, Jeff Newmiller
> ><jdnewmil at dcn.davis.ca.us>
> >wrote:
> >
> >> Seems like you would benefit from reading about long and wide data...
> >> perhaps  [1].
> >>
> >> If I am understanding what you want,  ggplot facetting should be able
> >to
> >> do what you want.  You first have to put the data in long form (e.g.
> >> variable, timestamp, value) before you give it to ggplot.
> >>
> >> If you want more specific help then you should provide a small sample
> >data
> >> set as one or more  R dputs as the Posting Guide recommends (see
> >footer,
> >> and  [2]).
> >>
> >> [1]
> >https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html
> >>
> >> [2]
> >>
> >
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> >>
>
> >---------------------------------------------------------------------------
> >> Jeff Newmiller                        The     .....       .....  Go
> >Live...
> >> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> >> Go...
> >>                                       Live:   OO#.. Dead: OO#..
> >Playing
> >> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> >> /Software/Embedded Controllers)               .OO#.       .OO#.
> >rocks...1k
> >>
>
> >---------------------------------------------------------------------------
> >> Sent from my phone. Please excuse my brevity.
> >>
> >> On November 5, 2015 7:00:18 AM PST, Ezra Boyd <ezgis76 at gmail.com>
> >wrote:
> >> >Hello,
> >> >
> >> >I am trying to create a plot (I guess two plots) using two different
> >> >time
> >> >series datasets, but I'm not sure of the best approach.  The data is
> >> >from a
> >> >tidal surge due to a hurricane and I would like to show the
> >> >relationship
> >> >between stage and windspeed/direction.
> >> >
> >> >One dataset is the tidal stage and it is sampled in 30 minutes
> >> >intervals.
> >> >The other dataset is windspeed and direction and it is sampled every
> >6
> >> >minutes.  I would like to display the tidal hydrograph and then also
> >> >show
> >> >windspeed and direction as a banner above it.  They would be two
> >> >separate
> >> >plots, but with identical x-axis (as opposed to one plot that has
> >both
> >> >tide
> >> >& wind.)
> >> >
> >> >Should I combine the two time series into one dataframe (with lots
> >of
> >> >NAs)
> >> >so that I can create the plots together, for example using pairs or
> >> >ggpairs? Or should I keep them separate, make the individual plots,
> >and
> >> >then work on the layout in graphic design software? I would prefer
> >the
> >> >former, but I just can't figure out how to make that work out.
> >> >
> >> >Also, is it possible to depict wind direction (which is given in
> >degree
> >> >clockwise from due north) with an arrow?
> >> >
> >> >Thank you very much,
> >> >
> >> >Ezra
> >>
> >>
>
>


-- 
Ezra Boyd, PhD
DisasterMap.net, LLC <http://DisasterMap.net>
ezgis <ezgis76 at gmail.com>76 at gmail.com <ezgis76 at gmail.com>
(504)533-4447

	[[alternative HTML version deleted]]



More information about the R-help mailing list