r-scripts

How to debug your package in a {rhub} fedora container before sending to CRAN?

It is not the first time I present how to debug on an other platform before sending your package to CRAN. This time, before submission {checkhelper} failed on ‘fedora’ image provided by {rhub}. How to debug your package using this platform when your using an other OS? Let’s speak about docker and …

Read more

Share your R work following good dev practices from a single notebook

You write R scripts and you would like to share them with other users, in a sustainable and maintainable way. You already write your code in a notebook (Rmarkdown or Quarto) and share its HTML output. You would like to document the chunks, and make this documentation visible in a separate HTML page. …

Read more

Add {tmap} point layer with multiple symbol border colors and width

It’s been a while since my last blog post. Indeed, my free time is used to improve packages like “{fusen}: Inflate your package from a simple flat Rmd” , “{attachment}: Tools to deal with dependencies in scripts, Rmd and packages” or “{gitlabr}: An R client for the GitLab API”. Hence, drawing some …

Read more

Debug your package that failed on CRAN with {rhub}

If you sent packages on CRAN, you may have encountered some fails on different operating systems configurations that you never heard about before: Solaris, debian clang, fedora gcc, … Package {rhub} allows to test your package on some of them, prior to sending to CRAN. But, how to debug directly on …

Read more

How to debug your package on Win-Builder before sending to CRAN?

CRAN submission can be difficult as your package is checked on multiple OS and R versions that you may not be able to check yourself locally. Thankfully, some services like {rhub} and Win-Builder prevent some unfortunate CRAN errors. But how to debug code that is run on an external server, without …

Read more

Buffer areas for nearest neighbours or national marine areas delineation

A few weeks ago, Christina Buelow asked on Twitter how she could create the polygons of coastal waters using the land polygons, and making sure there is no overlap in buffer areas. This would make it possible to know which land area is closest to any place in the sea. Let’s explore what solution …

Read more

Find most retweeted tweets of the #rspatial bot

Bots that retweet #rspatial and #BioImageAnalysis tweets are working well. It is now time to add a little functionnality with the best retweeted tweet of the month, a function added to {tweetrbot} package. […] You can retrieve the updated dataset for all tweets here and the dataset for the …

Read more

#30DayMapChallenge: 30 days building maps (3) - Earth is spherical

The #30DayMapChallenge was initiated by Topi Tjukanov on Twitter. This is open to anyone who would like to show a map, whatever the software is. In this blog post, I will show maps made with R. I add constraints to myself for fun. This week, I will create maps that remind map makers that Earth is …

Read more

#30DayMapChallenge: 30 days building maps (2) - tmap

The #30DayMapChallenge was initiated by Topi Tjukanov on Twitter. This is open to anyone who would like to show a map, whatever the software is. In this blog post, I will show maps made with R. I add constraints to myself for fun. This week, I will use {tmap} to create maps. This follows previous …

Read more

#30DayMapChallenge: 30 days building maps (1) - ggplot2

The #30DayMapChallenge was initiated by Topi Tjukanov on Twitter. This is open to anyone who would like to show a map, whatever the software is. In this blog post, I will show maps made with R. I add constraints to myself for fun. This week, I will use {ggplot2} to create maps. […] […] …

Read more

Follow moving particle trajectory over raster with {rayshader}

{rayshader} is a fantastic package for 3D mapping, but it comes with the limitations of {rgl}. I always found it a shame not being able to travel in all directions over my 3D objects. In this blog post, I will show a trick to simulate particle trajectory in 3 dimensions like in a “first person” …

Read more

Create a twitter bot on a Raspberry Pi 3 using R

With Marion Louveaux, we decided that we had to build a Twitter bot for our preferred hashtag. We explored different possibilities but truth is I couldn’t resist building it using R and {rtweet}. Here are the steps I used to set up a Twitter bot on my Raspberry Pi. […] I use package {rtweet} …

Read more

Render mesh3d objects with rayshader and rayrender

People like to show 3D images in their presentations because it usually impresses the audience. Does it really ? I do not care ! I am just looking for an opportunity to play with some 3D images… This blog post is a detailed version of some 3D images shown during my presentation “Everything but maps …

Read more

Kaggle survey 2018: Maps of programming languages used and repartition of reproducibility issues

Last year I participated to the Kaggle survey data challenge. The challenge objective: tell a data story about a subset of the data science community represented in this survey, through a combination of both narrative text and data exploration. I used this opportunity to build ternary choropleth …

Read more

Play with spatial tools on 3D cells images

Let’s play with mapping tools on non-maps data ! {rayshader} is nice on raster maps, but what about using it on segmentized plant cell? […] I wanted to find a good reason to play with Tyler Morgan-Wall packages for 3D visualisation of raster data: {rayshader} and {rayfocus}. Using cell …

Read more

Introduction to mapping with {sf} & Co.

At the “Rencontres R 2018” in Rennes, I proposed a brief introduction to mapping using the recent {sf} package and some other interesting packages. This blog post is an extended version of my presentation allowing me to share the code of the different maps that appeared on it. It’s still a brief …

Read more

Spatial interpolation on Earth as a 3D sphere

Earth map is usually presented flat. Geographical coordinates usually go from -180° to +180°. Spatial interpolations using coordinates may be tricky as -180° is equal to +180°. Here I propose a way to realize spatial interpolations on Earth as a sphere and then map the outputs in 3D using rgl. The …

Read more

Translation of rmarkdown documents using a data frame

In my post “Rmarkdown conditional chunks to create multilingual pdf and html with images”, I proposed a way to create a rmarkdown document to be printed in two different languages. If you deal with more than two languages, your document may become difficult to read. Moreover, if you work with …

Read more

SDMSelect: Cross-validation model selection and species distribution mapping

This library has originally been created for covariates selection to predict species distribution (biomass, density or presence/absence). Its final aim is thus to produce maps of predicted distributions (Look at vignette SDM_Selection). However, the core of the library is a N-times k-fold …

Read more

Polygons tint band with leaflet and simple feature (library sf)

Let’s use some French regions polygons and attribute one colour to each region. I like piratepal colours of library yarrr. […] To create the doughnuts using original and buffer polygons, I used st_difference. However as discussed with edzer in the sf github repository, I had to transform the …

Read more

How to fill a hatched area polygon with holes in leaflet with R

I built a R package, available on my statnmap github, to provide the function hatched.SpatialPolygons. This function is based on the plot method for SpatialPolygons of library sp. I modified the functions and sub-functions to remove all code for direct drawing and allow to output a …

Read more

Plot a specific image in a delimited polygon as repeated pattern on a map

##Plot an image pattern in a delimited polygon […] Let us define a SpatialPolygonsDataFrame to work on. Let’s also define the specific polygon in which to draw the forest. […] ###Draw a point grid with emoji in a specific polygon We can sample points in the polygon area using …

Read more

Rmarkdown conditional chunks to create multilingual pdf and html with images

In the upper output files, I list some of the tips I have to use to make this work and some bonus: […] I will modify this list if I face new difficulties or I find better ways to do things. […] The complete list of tips can be seen on the following web pages (embedded in iframes). Rmd …

Read more

Add multiple layers in leaflet widget with R

Library leaflet with R is well integrated with pipe writing (%>%). Thus, it is really easy to add multiple layers and options in a leaflet widget. If you want to add a lot of layers in your widget, it is not necessary to provide a “addPolygons” for each of these layers, you can simply use a loop. …

Read more

Rshiny expert image comparison app

The expert image comparison was long: 40min for the small analysis and 3h for the complete one. As the shinyapp is freely hosted on the Rstudio shinyapps.io servers, it was not possible to save outputs of a specific session on the server. Thus, the web application has been built such that the …

Read more

Bayesian life cycle model: OpenBUGS code

The OpenBUGS code presented below is the additional material of a publication. This is the life cycle model of a marine species (the sole in the Eastern Channel). The Bayesian hierarchical model incorporates indices of juvenile spatialized abundance, larval dispersion, adult abundance indices and …

Read more

Mapping, spatial analyses and GIS with R

If you download the following presentation, you will find a presentation of different functions in the R-software useful for spatial data manipulations. Choosing the right libraries allows to create, import, modify, manipulate and map vector (shapefiles) or matrix (raster) spatial data. Your spatial …

Read more

Sensitivity of Inverse Community matrix

This script is the supplemental material of two publications on trophic network analyses. This allows to test for uncertainties of direct and indirect effects of small variation in biomass of a trophic network compartment on the rest of the ecosystem. […] Lassalle Geraldine, Bourdaud Pierre, …

Read more