soc_read | R Documentation |
Downloads and parses a dataset from a Socrata open data portal URL, returning it as a tibble or sf
object.
Metadata is also returned as attributes on the returned object.
soc_read(url, query = soc_query(), alias = "label", page_size = 10000)
url |
string; URL of the Socrata dataset. |
query |
|
alias |
string; Use of field alias values. There are three options:
|
page_size |
whole number; Maximum number of rows returned per request. |
A tibble with additional attributes containing dataset metadata.
If the dataset contains a single non-nested geospatial field, it will be returned as an sf
object.
The returned object has the following attributes:
Asset identifier (four-by-four ID).
Asset name.
Attribution or publisher of the asset.
Display name of the asset owner.
Provenance of asset (official or community).
Textual description of the asset.
Date asset was created.
Date asset data was last updated
Date asset metadata was last updated
Category label assigned by the domain.
Tags applied by the domain.
Metadata associated with the asset assigned by the domain.
A dataframe with the following columns:
Names of asset columns.
Labels of asset columns.
Datatypes of asset columns.
Description of asset columns.
Permanent URL where the asset can be accessed.
Direct asset link.
License associated with the asset.
soc_read(
"https://soda.demo.socrata.com/dataset/USGS-Earthquakes-2012-11-08/3wfw-mdbc/"
)
soc_read(
"https://soda.demo.socrata.com/dataset/USGS-Earthquakes-2012-11-08/3wfw-mdbc/",
soc_query(
select = "region, avg(magnitude) as avg_magnitude, count(*) as count",
group_by = "region",
having = "count >= 5",
order_by = "avg_magnitude DESC"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.