Skip to content

Instantly share code, notes, and snippets.

@MarinaGolivets
Last active October 1, 2023 15:03
Show Gist options
  • Save MarinaGolivets/c02b833329d43d6ab34ad33d6fd709f5 to your computer and use it in GitHub Desktop.
Save MarinaGolivets/c02b833329d43d6ab34ad33d6fd709f5 to your computer and use it in GitHub Desktop.
An R script to download data files from the LEDA trait database
# load packages
library(rvest)
library(here)
# create a new forder for storing data
folder_name <- here(paste0("leda_", lubridate::today()))
dir.create(folder_name)
# extract URLs and download files
read_html("https://uol.de/en/landeco/research/leda/data-files") %>%
html_elements(xpath = "//a/@href") %>%
html_text() %>%
grep("Data_files", ., value = TRUE) %>%
lapply(., function(x) download.file(x, here(folder_name, stringr::str_extract(x, "\\/([^/]*)$"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment