The scripts below will demonstrate a few ways to import and download a csv into R using the ckanr library.Only csv, xls, xlsx, xml, html, json, shp, geojson, and txt files are downloadable using this script. See pages 15-17 of the documentation for additional details on fetching the other data types.
In CanWIN we allow users to dowload a dataset package and zip files. These are not downloadable using R. Refer to the Downloading Data help page for information on how to download data packages.
Downloading a csv using ckanr
Loading libraries
List of some attributes of datasets
View a list of the Theme, Package, and Tag names. These can help discover some of the available datasets. In CanWIN, groups are = themes, package = dataset and tag = keyword
Downloading resource file (dataset) directly to disk
Most of our data is in a csv format, if they are not grouped together into a zip file. If the file is zipped on the site, you’ll need to download directly from site.
Importing a resource file into R
Importing a csv into R requires the dyplr package (included in the Tidyverse package).