options(htmltools.dir.version = FALSE) library(RefManageR) BibOptions(check.entries = FALSE, bib.style = "authoryear", cite.style = 'alphabetic', style = "markdown", first.inits = FALSE, hyperlink = FALSE, dashed = FALSE) my_bib = ReadBib("refs-geostat.bib", check = FALSE)
layout: true background-image: url(xaringan_stuff/img/r_geocomp_background.png) background-size: cover
install.packages("tidyverse")
sf (first release in 2016) implements the open standard data model simple features. Get sf with:
install.packages("sf")
The workshop also uses a dataset from the spData package, which can be installed with:
install.packages("spData")
For more on this see: github.com/Robinlovelace/geocompr.
knitr::include_graphics("https://stackoverflow.blog/wp-content/uploads/2017/10/tag_growth_scatter-1-771x675.png")
vignette("tidy-data")
):
- Each variable forms a column.
- Each observation forms a row.
- Each type of observational unit forms a table
background-image: url("https://pbs.twimg.com/media/CvzEQcfWIAAIs-N.jpg") background-size: cover
That's the topic of this workshop
background-image: url("https://media1.giphy.com/media/Hw5LkPYy9yfVS/giphy.gif")
Jakub Nowosad: developer of GeoPAT + more.
Jannes Muenchow, creator of RQGIS.
--
--
--
packagename::functionname()
library(sf) library(raster) library(spData)
us_states[1:3, 1:2]
Works just like normal data in the tidyverse
Beware of name conflicts though:
library(tidyverse)
states1 = us_states %>% slice(1) states2 = us_states %>% filter(grepl(pattern = "^A", x = NAME)) %>% top_n(n = 2, wt = total_pop_15)
rbind(states1, states2) # works bind_rows(states1, states2) # fails
Error in .subset2(x, i, exact = exact) : attempt to select less than one element in get1index
Work-around (see article in geocompr.github.io/geocompkg for more pitfalls):
us_data = st_set_geometry(us_states, NULL) d = bind_rows(us_data, us_data) d_sf = st_sf(d, geometry = c(us_states$geom, us_states$geom))
What do you hope to get out of today?
Take a look around RStudio
Load the packages we'll use in this practical
The practical
A group of us are thinking about starting-up the Leeds R Users group.
Email: r.users.leeds@gmail.com
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.