Interactive browsing of myClim objects. The main interactive menu consists of:

  • Plot
  • States
  • Data

# === First install dependencies ===
requiered_packages <- c("purrr", "stringr", "lubridate", "ggplot2", "plotly",
                        "myClim", "shiny", "shinyjs", "dplyr", "DT",
                        "tibble", "shinythemes", "callr", "RColorBrewer")
missing_packages <- requiered_packages[!(requiered_packages %in% installed.packages()[,"Package"])]
if(length(missing_packages)) install.packages(missing_packages)

if(!("shinyTree" %in% installed.packages()[,"Package"])) {
    remotes::install_github("shinyTree/shinyTree")
}

# === Install myClimGui ===
install.packages("http://labgis.ibot.cas.cz/myclim/myClimGui_latest.tar.gz",
                 repos=NULL, build_vignettes=TRUE)

Plot

On the left side of the running Shiny myClimGui, you can see a tree structure of your localities, loggers, and sensors. Here, you can select which time-series you wish to browse in the viewer. Only selected time-series are shown. After selecting the localities/loggers/sensors you wish to browse, you have to hit the Show button.

Browsing Options

There are several options in Plot mode, including Multi Select, Plotly, and Color by Logger in the left panel. On the right side of the screen, you can also set the time span of the data you wish to browse, i.e., limit the plot region to certain dates.

  • If none of the options is selected, all loggers and sensors in the selected localities are plotted.
  • Multi-select: allows selecting any combination of locality, logger, and sensor.
  • Plotly: switches from the ggplot graphical device to Plotly (allows better zooming, image export, querying microclimate data values by clicking on the plot; it is much slower than the default ggplot).

  • Color by Logger: useful for repeated downloads at the same locality or when there are multiple loggers at a locality, to distinguish which sensor line in the plot belongs to a specific logger. Otherwise, lines are colored by sensor type.

Facet Options

You can use the dropdown menu at the top of the screen to drive the facet options. You can choose to facet by physical, locality, or NULL.

  • Physical: facets by physical elements (each physical element has its own plotting window; identical physical elements from multiple loggers are plotted together).

  • Locality: facets by locality, with each locality having its own plotting window. This allows plotting a maximum of 2 physical elements together. When plotting a single physical element, data are not scaled, but when plotting 2 physical elements, data are scaled to fit the plotting region.

  • NULL: a single plotting window for all time-series, allowing plotting a maximum of 2 physical elements together. When plotting a single physical element, data are not scaled, but when plotting 2 physical elements, data are scaled to fit the plotting region.

User Interaction

When you draw a rectangle (select region) with the mouse in the plotting window and double-click in the selected region, the plot will zoom in. You can zoom multiple times. To return to see the full data range, you can hit refresh on the right-hand side or double-click outside the selected region.

When you wish to select specific sensors across all localities, you can filter them in Sensors window above the localities/loggers/sensors tree.

States

In myClim, any part of a time-series can hold states. You can add states to a specific region of your time-series, e.g., error, sensor out of soil, compromised shielding. Note that you will see only the states of the sensors you have selected in the Plot section. After clicking on a specific state (row), a plot showing the data region will pop up under the states table. You can click multiple rows, and they will be plotted in different colors on the plot.

You can edit the text of the tag in the table after double-clicking the cell, the same as the text of the value.

You can also edit the range of the tag by clicking the “edit range” button and selecting a new start/end from the popup calendar.

You can also add a new tag by clicking the “New” button, where you specify the start, end, and tag. Note, that adding a new state will apply it to all sensors selected in the Plot section.

Save interactive edits into myClim object

To save your edits (editing states) you need to send mcg_run() into the new object. After your edits, hit Return. This will create new object in R environment including your edits.


# === Saving your edits ===
# edit states, hit "return", save modified object into R environment. 
states.edit <- myClimGui::mcg_run(myClim::mc_data_example_agg) 

# === Browsing only, no edits saving ===
myClimGui::mcg_run(myClim::mc_data_example_agg) 

Data

This is the section where you can browse your time-series row by row, column by column in a table. For now, you are not allowed to modify data in the table. You can use the table view, e.g., to find the exact datetime when some issue occurred to place the quality tag precisely. Note that you will see only the data of the sensors you have selected in the Plot section and only in the range your plot is zoomed to.

Run myClimGui in background

Normally, when you run a Shiny app from RStudio, the console “freezes” as it executes commands from Shiny. To avoid this behavior, you can use the mcg_run_bg function, which is a wrapper for the parallel console from the callr package. This allows you to open your web browser, use myClimGui there, and still be able to work in RStudio as usual, without any freezing. To retrieve your modified object, you need to query the environment by calling $get_result().

# launch  process in web browser
proc <- myClimGui::mcg_run_bg(myClim::mc_data_example_agg)

# retrieve the result after click Return button
data <- proc$get_result()

WARNINGS

  • Once you call mcg_run and Shiny starts, the RStudio console is “frozen,” handling commands from Shiny. You are not able to work in the console simultaneously with running Shiny. If you wish to work in consle and the same time run Shiny app use function mcg_run_bg.
  • Be patient; it is Shiny, and it is relatively slow, performing all your commands one by one. This means if you start nervously clicking the buttons, thinking it is not responding, you will eventually see Shiny performing all your actions one by one.
  • When using Plotly mode, combining two physical elements (e.g., temperature and soil moisture) in a single plotting window, be mindful of the scaling. Plotly will show you scaled values instead of your real data. The solution is to plot by physical element, i.e., plot a single physical element in a single plotting window, avoiding the combination of two variables with different value ranges.