Marco Sciaini

Building a user interface for spatstat

31 Jul 2015


RStudio developed shiny, an R package that, quoting from their website, "makes it super simple for R users like you to turn analyses into interactive web applications that anyone can use". It leverages the power of R and its vast collection of packages to allow users to efficiently perform predesigned data tasks, such as visualization and/or statistics. Plus, shiny seems to be the new hypetrain of R, which is why I will jump right on it.

This post will introduce "shiny_spatstat", a user interface for spatstat. It is meant to be accessible for people that want to perform basic point pattern analyses.

In general there are two main areas for integrating shiny in my work:

The aim of this post is not to take you step-by-step through the construction of a reasonably full-featured simulation app. It is rather publishing the first, rough version (v0.1) of an app I had in mind for quite some time now. At this time, I view this app (with different data) as a companion to a poster I will present at an ecology conference in September. However, during coding the app I had a lot of ideas on how to further develop it and I hope to be able to produce something comparable to Programita in the end.

Enough of words, see shiny_spatstat here:

You can view the running app in fullscreen here (recommended).

Get and run it!

A Shiny basically consists of two files: a ui.r file and a server.r file. The ui.r file, as it says, provides the user interface, and the server.r file provides the server logic. These are the two main files you want to customize shiny_spatstat. Rstudio has a great tutorial for the basics.

To run the user interface locally:


... or download it from:


In conclusion, the idea is to develop a shiny app as a user interface for spatstat. shiny_spatstat (v1) should therefore be able to load datasets dynamically and allow to carry out the appropriate statistics.

Further things to do:

Find a hipper name
Load dynamically input files
More statistics
Progressbar for simulation runs
Exchange base R plots with interactive plots
Own CSS, for a distinct look

In subsequent posts I’ll outline the updates in the development being made in this app. If you have feedback or suggestions for improvements, comment here or post an Issue on the GitHub site.