# Load required packages
pacman::p_load(tidyverse, readr, magrittr, cowplot, googleway, ggplot2, ggrepel,
ggspatial, libwgeom, sf, rnaturalearth, rnaturalearthdata)
## Installing package into 'C:/Users/spatt/Documents/R/win-library/4.0'
## (as 'lib' is unspecified)
## Warning: package 'libwgeom' is not available (for R version 4.0.2)
## Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/4.0:
## cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/4.0/PACKAGES'
## Warning in p_install(package, character.only = TRUE, ...):
## Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
## logical.return = TRUE, : there is no package called 'libwgeom'
## Warning in pacman::p_load(tidyverse, readr, magrittr, cowplot, googleway, : Failed to install/load:
## libwgeom
# Load the data;
# note: be sure that the data is in the same working directory
jade<- read_csv("jade_data.csv")
## Rows: 657 Columns: 55
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (53): 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, ...
## dbl (2): Latitude, Longitude
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Cleaning the data is probably the most time intensive part of many studies. The goal here is to format your data into the “tidy” format. Your data is “tidy” when each observation has its own row in your dataset.
jade %<>%
pivot_longer(cols = 1:43, names_to = "year")
# write a csv file
#write.csv(jade, "jade_tidy.csv")
world <- ne_countries(scale = "medium", returnclass = "sf")
ggplot(data = world) +
geom_sf() +
geom_point(data = jade, mapping = aes(x = Longitude, y = Latitude))
## Warning: Removed 215 rows containing missing values (geom_point).