Supergrid - a new function to easily add grids to base R plots with major and minor grid lines, fully customisable and pseudo theming for re-use, super easy to use, read on to learn more!
Supergrid - a new function to easily add grids to base R plots with major and minor grid lines, fully customisable and pseudo theming for re-use, super easy to use, read on to learn more!
In part 2 of this guide looking at supergrid() - a new function to easily add grids to base R plots with major and minor grid lines - this part shows you how to create and add themes to re-use the same styles for different plots. Read on to learn more!
Principal component analysis (pca) is a great dimension reduction method to reduce large datasets to a smaller set, keeping the key, or principal components. R offers functions to carry out pca with ease, but creating good looking biplots in R can be quite involved, or require additional packages.
I've written a new, better biplot function, which makes creating beautiful looking biplots a breeze. And, its all written in base R, so does not require any additional packages to be installed. Just load the script and start plotting!
In the second part of my guide for principal components analysis (PCA) in R, I additionally cover loadings plots, adding convex hulls to your biplots, more customisation options, and show you some more examples of PCA biplots created using R's base functionality...
A quick guide to the different line types that are available to use in R, and how to use them. This guide will also show you how to create your own line type, and additionally covers line end styles (lend) and line join styles (ljoin).
A handy reference for lty, lend and ljoin!
There is no shortage of ways to do principal components analysis (PCA) in R. Many packages offer functions for calculating and plotting PCA, with additional options not available in the base R installation. R offers two functions for doing PCA: princomp() and prcomp(), while plots can be visualised using the biplot() function. However, the plots produced by biplot() are often hard to read and the function lacks many of the options commonly available for customising plots.
This guide will show you how to do principal components analysis in R using prcomp(), and how to create beautiful looking biplots using R's base functionality, giving you total control over their appearance. I'll also show you how to add 95% confidence ellipses to the biplot using the "ellipse" package.
Multi-panel plots and figures are used everywhere, especially in scientific papers to compare different graphs or datasets. And creating them has never been easier using R!
There are several functions and ways in which you can create multi-panel plots/figures, and in this guide I will show you how to use the layout() function (available in the base installation) to create them.
Following on from the previous guide looking at WorldClim data, in this guide I take a look at using RasterStacks to import WorldClim datasets. In the previous guide, we used RasterLayers to import the data, so what is the difference? A RasterStack is a collection of RasterLayers bundled together, or stacked into one object. If you're only dealing with a few RasterLayers, then a RasterStack might not be necessary. However, when the number of RasterLayers increase, it can be easier to work with RasterStacks.
For example, if you wanted to look at minimum, maximum, and mean temperature data, along with precipitation data from WorldClim, using RasterLayers would require you to create 48 separate objects. Using a RasterStack, you could instead create 4 objects containing all the data for each variable.
This guide will also take a look at some of the additional options you have when plotting RasterStacks and other raster objects. Did you know that when you plot a raster object in R using plot(), it actually invokes the raster::plot function, while standard objects (e.g. scatterplots) would invoke graphics::plot? The previous guide suggested you might want to plot a figure which includes separate plots for each month of the year, or you might want a minimum and maximum temperature plot? I'll show you how you can do this easily using RasterStacks and raster::plot.
In this guide, i'll show you another way in which you can get climate data, by using WorldClim global climate datasets. This guide will take you through all the steps for downloading, opening, extracting, and plotting the data using R.
I'll show you how you can make some good looking climate maps using WorldClim data, for anywhere in the world. And, the guide will also look at some of the differences between the WorldClim datasets and CRU datasets (we looked at this in earlier guides), and why you might choose to use one or the other.
In my previous guide, I showed you how to download and extract precipitation and temperature climate data from CRU datasets. Now that you have the raw data - i'll guide you through some of the ways in which you can work with, and manipulate this data.
From grouping your sample sites, to calculating annual data or seasonal data, to defining a climate period and then calculating changes to conditions since this period to observe climate change trends. I'll also show you how to plot the data to create climate graphs for your sites.