RShiny_SwitchButton

A nice RShiny On/Off switch button

Why is the chekboxInput appearance so simple…?

RShiny input controls have a nice design that allows to produce nice web interfaces in a very simple way, but the ‘checkboxInput()’ button is really boring compared to its friends…I was looking for a nice way to present a On/Off (or True/False) switch button in my shiny interfaces but I did not find any, at least not especially designed for Rshiny.
Thankfully, there are many examples of switch button on the web, using pure CSS code or using a little javascript. I decided to take one in pure CSS and designed it so that it could be included in Rshiny with a few options.

The old checkbox:

New buttons :
statnmap.com - Rshiny on/off switch buttonstatnmap.com - Rshiny on/off switch button

A simple code for a new function ‘SwitchButton()’

This Rshiny ‘SwitchButton’ function allows to use nice on/off (or True/False) switch buttons instead of the default Rshiny ‘checkboxInput’ function. This only uses CSS code and does not make use of javascript. The ‘switchButton’ function includes two options:

  • Choose between a grey/blue (natural shiny) (col="GB") or a red/green button (col="RG")
  • Choose between TRUE/FALSE (type="TF"), ON/OFF (type="OO") or NULL (type="") button text

Steps to include it are easy:

  • Add CSS script ‘button.css’ in a ‘www’ folder in your Shiny app folder
  • Add R script ‘SwitchButton.R’ in a ‘Rsource’ folder in your Shiny app folder
  • Source the R script in your ‘ui.R’ script, before ‘shinyUI()’ function
  • Use the ‘button.css’ script as the template of your Rshiny interface (or merge it with your own customized css template).

You may see it in action on my shinyapps repository.
You can download the files on my github repository.

Screenshot

 

Starting with QGIS

Starting with QGIS

This 3-days course will teach you the most used functionalities of a mapping software using QGIS. You will learn how to create, import, manipulate and map vectors (shapefiles) and matrix (raster) spatial data. You will also learn digitizing and georeferencing images.

Spatial data manipulation

We will teach you common spatial data manipulation tools for shapefiles and rasters:

  • Creation of spatial layers
  • Projection of spatial layers into different coordinate reference systems
  • Spatial joints or attributes joints
  • Layer intersections
  • Polygons merge
  • Buffer area around spatial features
  • Rasters combinations and calculations
  • Digitial Elevation models features (slope, hillshade, …)

GIS software useful functionalities

You will learn the functionalities, for which GIS software are especially designed and ones allowing for better user experience.

  • Image georeferencing
  • Image digitizing
  • Advanced feature symbology
  • Diagrams
  • Bookmarks
  • Web interaction
  • Map edition for printing
statnmap.com - Image for georeferencing
Old non-georeferenced image
statnmap.com - Georeferenced and digitized image
Image after georeferencing and polygonization

To go further

To do some data analyses on your maps or to automatize your map production tasks, you may be interested in using the R-software. Take a look at my other courses on mapping with R.

Combination QGIS / R for GIS and mapping

Combination of QGIS and R

This 2-days course will allow you to compare possibilities offered by the mapping software QGIS and the programming language R. Indeed, for mapping purposes, you will see that these two softwares are complementary.
The first day, you will explore QGIS tools for spatial data manipulation. The second day, you will explore the same tools with R. Of course, some tools are better designed in a software than in the other…

A set of common tools

Depending on the question you have, you may be able to choose between QGIS and R for your data exploration. This course will help you choose. Both softwares, the one with graphical interface, the second with code writing, will allow to use classical mapping tools:

  • Spatial layer creation
  • Projection of spatial layers into different coordinate reference systems
  • Spatial joints or attributes joints
  • Layer intersections
  • Polygons merge
  • Buffer area around spatial features

Complementarity for specific tasks

Although R software is really powerful and although you may have great code writing skills, you may prefer to use the easy graphical interface of QGIS for some tasks. The opposite is also true.

  • Simple map visualization and exploration
  • Image digitizing et georeferencing
  • Statistics calculation
  • Spatial model construction
  • Tasks and reports automation
statnmap.com - QGIS interface
QGIS interface – French map of regions
statnmap.com - R output map
R output – French map of regions

To go further

If you know enough R code, you may be interested in integrating R code into QGIS for deeper statistical analyses or for sharing your analyses to users who do not want to write (and see) R code. We may explore R integration within QGIS.

With only one day for the exploration of each software in this course, we will only see the most common features. There are further course possibilities if you want to go further in using QGIS or R-software.

Please contact me for further information or specific demands.

GIS and mapping with R

GIS and mapping with R

In this 2-days course you will learn how to manipulate spatial data only using the R-software. You will create, import, modify and map vector (shapefiles of points, lines or polygons) and matrix (raster) layers.
You will be able to create your own maps with colors depending on variables of interest (attributes), without forgetting to add legend, spatial scale and metadata, but also while adding external data from openstreetmap or googlemap.

Spatial data manipulation and modeling tools

We will teach you common spatial data manipulation tools:

  • Projection of spatial layers into different coordinate reference systems
  • Spatial joints or attributes joints
  • Layer intersections
  • Polygons merge
  • Buffer area around spatial features

We will also approach specific tools designed for raster and digital elevation models (DEM) analyses, like slope calculation, levelplot, hillshade, …

statnmap.com - Course GIS with R software
Different use of mapping tools using R

To go further

For specific needs, we would be able to approach spatial interpolation tools (kriging) or spatial predictive models (see this other course).
We can also propose the equivalent course using QGIS mapping software to show you its complementarity with R for spatial data manipulations.

statnmap.com - kriging and interpolation with R
Examples of spatial interpolation maps with R


Contact me
for further information and on-demand course.

GLM and Species distribution modeling with R

Generalized Linear Models and Species Distribution Modeling

This 2-days course will teach you how to predict species distribution using the R-software. This is an initiation to statistics, Generalized Linear Models (GLM) and to the use of R spatial libraries.
In this course, species distribution modeling relies on GLM that link a variable of interest (probability of presence, abundance, density, biomass) to environmental covariates.

Zero-inflated dataset

We use a zero-inflated dataset, a dataset in which an important part of the data is absence of the species of interest. This is a good challenge for GLM modeling and, in ecology, this is rather the rule than the exception. This dataset allows to play with a variety of statistical distributions and tests.

Spatial data

Species distribution models couples outputs of GLM model to spatial information allowing to draw maps of distribution. During the course, you will use spatial data with spatial R libraries and functions to produce geo-referenced maps of predictions.

Goals

At the end of the course, you will be able to:

  • Explore data with different graphical analyses
  • Choose a statistical distribution adapted to your dataset
  • Fit a GLM model and analyze the outputs
  • Select the best model among different combinations of covariates
  • Use R spatial libraries to deal with spatial datasets
  • Use R spatial libraries to predict species distribution
  • Produce maps of predictions
GLM_SDM_Course
Example of species distribution output using classical R libraries

For any information, please contact me.