December 12, 2016
()
library()
install.packages()
knitr
: a package for RmarkdownKnitr is the system that merges R code and Markdown to produce documents that depend on data
It has many functions. We used two of them:
kable()
is a function to produce nicer tables
pander()
from the pander packageknitr::opts_chunk$set()
to set the default options for each chunklibrary(knitr)
before using any function of the packageX:
drive (when using lab computers)reshape2
: a package to change the shape of dataWe will work on reshape2
, melt()
and aggregate()
tomorrow
Take a look at the
Centennial Earthquake Catalog
The original data is not in an easy format
For this exercise you can get the data from
http://anaraven.github.io/static/earthquakes.txt
The world map can be drawn with the following commands
library(maps) map('world')
The magnitude \(M\) of an earthquake is related to the released energy \(E\) (in joules) according to the following expression1: \[\log_{10}(E) = 5.24 +1.44 M,\] which is valid for earthquakes over magnitude 5.
Calculate the energy of each earthquake