## \mainmatter
## ----gdsl, echo=FALSE, message=FALSE----------------------------------------------------------------
d = readr::read_csv("extdata/gis-vs-gds-table.csv")
knitr::kable(x = d,
caption = paste("Differences in emphasis between software",
"packages (Graphical User Interface (GUI) of",
"Geographic Information Systems (GIS) and R)."),
caption.short = "Differences between GUI and CLI",
booktabs = TRUE)
## Reproducibility is a major advantage of command line interfaces, but what does it mean in practice?
## We define it as follows: "A process in which the same results can be generated by others using publicly accessible code."
##
## This may sound simple and easy to achieve (which it is if you carefully maintain your R code in script files), but has profound implications for teaching and the scientific process [@pebesma_r_2012].
## ----01-introduction-2, eval=FALSE, echo=FALSE------------------------------------------------------
## a = osmdata::getbb("Hereford")
## b = osmdata::getbb("Bialystok")
## rowMeans(a)
## rowMeans(b)
## ----interactive-demo, eval=FALSE-------------------------------------------------------------------
## library(leaflet)
## popup = c("Robin", "Jakub", "Jannes")
## leaflet() |>
## addProviderTiles("NASAGIBS.ViirsEarthAtNight2012") |>
## addMarkers(lng = c(-3, 23, 11),
## lat = c(52, 53, 49),
## popup = popup)
## ----interactive, fig.cap="The blue markers indicate where the authors are from. The basemap is a tiled image of the Earth at night provided by NASA. Interact with the online version at geocompr.robinlovelace.net, for example by zooming in and clicking on the pop-ups.", out.width="100%", fig.scap="Where the authors are from.", echo=FALSE----
if (knitr::is_latex_output()){
knitr::include_graphics("images/interactive.png")
} else if (knitr::is_html_output()){
# library(leaflet)
# popup = c("Robin", "Jakub", "Jannes")
# interactive = leaflet() |>
# addProviderTiles("NASAGIBS.ViirsEarthAtNight2012") |>
# addMarkers(lng = c(-3, 23, 11),
# lat = c(52, 53, 49),
# popup = popup)
# library(htmlwidgets)
# saveWidget(interactive, file = "interactive.html")
# file.copy("interactive.html", "~/geocompr/geocompr.github.io/static/img/interactive.html")
knitr::include_url("https://geocompr.github.io/img/interactive.html")
}
## ----cranlogs, fig.cap="Downloads of selected R packages for working with geographic data from early 2013 to present. The y axis shows the average number of dailly downloads from the popular cloud.r-project.org CRAN mirror with a 91-day rolling window (log scale).", echo=FALSE, fig.scap="The popularity of spatial packages in R."----
knitr::include_graphics("images/01-cranlogs.png")
## ----revdep, echo=FALSE, message=FALSE--------------------------------------------------------------
top_dls = readr::read_csv("extdata/top_dls.csv")
knitr::kable(top_dls[1:5, 1:2], digits = 0,
caption = paste("The top 5 most downloaded packages that depend",
"on sf, in terms of average number of downloads",
"per day over the previous month. As of",
min(top_dls$date), " there are ", nrow(top_dls),
" packages which import sf."),
caption.short = "Top 5 most downloaded packages depending on sf.",
booktabs = TRUE,
col.names = c("Package", "Downloads"))
# cranlogs::cran_top_downloads(when = "last-month") # most downloaded pkgs
## ---- eval=FALSE, echo=FALSE------------------------------------------------------------------------
## # Aim: show n. pkgs that depend on sf and sp
## revdep_sp = devtools::revdep(pkg = "sp")
## length(revdep_sp) # 622 # 2022-05-29
## revdep_sf = devtools::revdep(pkg = "sf")
## length(revdep_sf) # 479 # 2022-05-29
## ---- echo=FALSE, results='asis'--------------------------------------------------------------------
res = knitr::knit_child('_01-ex.Rmd', quiet = TRUE, options = list(include = FALSE, eval = FALSE))
cat(res, sep = '\n')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.