Skip to content

A quick introduction to R so that students of the Utrecht University Paleontology—fauna course can try exercise 8 in R

Notifications You must be signed in to change notification settings

japhir/2020-02_paleontology

Repository files navigation

Making Paleontology—fauna excercise 8 in R

Preparation

If you’re curious about learning R, this exercise could be a fun little first challenge!

While excel works, it often introduces problems that shouldn’t be there: in this exercise it isn’t able to plot the age in millions of years ago (Ma) as a date, because it doesn’t have enough digits for conversion. As a workaround you can convert it to kyr in stead.

That is obviously stupid. And it’s not the only frustrating excel thing you may run into. One of the nice things about using a scripting language—such as python or R—instead, is that your work becomes reproducible and you and others can use your tricks again in the future!

Here we show you how you could do this exercise in R. Please play around first and enjoy the struggle for a bit.

installation

Install R and RStudio. R is the programming language and RStudio is a friendly graphical interface (or technically Integrated Development Environment) for R.

If you don’t know how, you can follow many online guides, such as this edX course. Note that for Mac users there are some additional installation steps required.

Install the required packages—extensions of R that make life even easier!—by opening RStudio and going to the bottom-left panel (the terminal) and typing, e.g.:

install.packages("ggplot2")

Or, if you want to use ggplot2, dplyr, purrr, etc., which I highly recommend, install them all at once with:

install.packages("tidyverse")

since they are part of the tidyverse, a collection of packages that makes R amazing.

load the libraries

These commands make the package functions available for use in your session:

library(readr)      # to read in the csv file (or use readxslx to read in excel files)
library(ggplot2)    # for plotting
library(patchwork)  # for composite plots
library(dplyr)      # for tidy data manipulation
library(tidyr)

getting started

As a start, I highly recommend reading through the freely available book R for data science by Hadley Wickham. You can also try the datacamp Introduction to R online course, which helped me get started initially. One last resource to get you started is to install the package swirl and interactively learn the basics right from R.

install.packges("swirl")
library(swirl)
swirl()

getting help

When you have problems or questions, have a look at any error messages if present and consult the documentation of the function of interest with, ?function_name or search for a topic with ??topic.

e.g., enter:

?ggplot

in the terminal.

If When you have questions, search! This is not considered cheating! StackOverflow, your search engine, and sometimes even twitter #Rlang are your friends!

About

A quick introduction to R so that students of the Utrecht University Paleontology—fauna course can try exercise 8 in R

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published