Last active
October 1, 2023 15:03
-
-
Save MarinaGolivets/c02b833329d43d6ab34ad33d6fd709f5 to your computer and use it in GitHub Desktop.
An R script to download data files from the LEDA trait database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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