Package 'dcatapchr'

Title: Create DCAT-AP CH Metadata Files
Description: Create DCAT-AP CH metadata files, typically in rdf format.
Authors: Sandro Burri [aut, cre]
Maintainer: Sandro Burri <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.1
Built: 2025-01-22 04:56:30 UTC
Source: https://github.com/SwissStatsR/dcatapchr

Help Index


Adds quotes to a character string

Description

Adds quotes to a character string

Usage

add_quotes(x)

Arguments

x

a character string (or vector)


Check language validity ("de", "fr", "it", "en")

Description

Check language validity ("de", "fr", "it", "en")

Usage

check_language(language)

Arguments

language

one of "de", "fr", "it" or "en"


Create a dcat:accessService property in DCAT-AP CH standard

Description

Create a dcat:accessService property in DCAT-AP CH standard

Usage

dcat_accessService(x = dcat_DataService())

Arguments

x

things to include in a dcat:accessService, typically one or more dcat:DataService


Create a dcat:accessURL property in DCAT-AP CH standard

Description

Create a dcat:accessURL property in DCAT-AP CH standard

Usage

dcat_accessURL(
  access_url = "https://www3.ti.ch/DFE/DR/USTAT/allegati/cubo/cubi_POL_01_csv.zip"
)

Arguments

access_url

url of the resource

Mandatory property of dcat:Distribution (dcat_distribution())


Create a dcat:byteSize property in DCAT-AP CH standard

Description

Create a dcat:byteSize property in DCAT-AP CH standard

Usage

dcat_byteSize(size = 0)

Arguments

size

size of the resource (in bytes)

Property of dcat:Distribution (dcat_distribution())


Create a DCAT-AP CH Catalog (dcat:Catalog)

Description

Create a DCAT-AP CH Catalog (dcat:Catalog)

Usage

dcat_catalog(
  catalog_endpoint = "https://swisstopo/catalog-endpoint.rdf",
  datasets = "<dcat:dataset rdf:resource=\"https://swisstopo/123\"/>",
  ...
)

Arguments

catalog_endpoint

URL/URI of the catalog endpoint

datasets

character vector with one or more dcat:dataset(s), see dcat_dataset()

...

any other property to be included to a dcat:Catalog

Details

A dcat:Catalog class, created with dcat_catalog(), can/must have the following properties (M stands for mandatory; R for recommended):

Value

A character vector of length greater than one, where each element is a line of the catalog in rdf format. The catalog can be exported in a file with unix file endings and UTF-8 encoding with write_unix().

Examples

dcat_catalog()
dcat_catalog(catalog_endpoint = "")


# Add some properties (...)
dcat_catalog(
  title = dct_title("Catalogo Ustat", language = "it"),
  description = dct_description("Descrizione catalogo", language = "it")
)

Create a dcat:contactPoint property in DCAT-AP CH standard

Description

Create a dcat:contactPoint property in DCAT-AP CH standard

Usage

dcat_contactPoint(
  nodeID = paste(sample(letters), collapse = ""),
  email = "[email protected]",
  fn = "Ufficio di statistica del Canton Ticino (Ustat)"
)

Arguments

nodeID

organization id (character string)

email

email address

fn

name of the organization

Mandatory property of dcat:Dataset (dcat_dataset())


Create a DCAT-AP CH DataService (dcat:DataService)

Description

Create a DCAT-AP CH DataService (dcat:DataService)

Usage

dcat_DataService(about = "", endpointURL = dcat_endpointURL(), ...)

Arguments

about

url of the DataService

endpointURL

enpointURL of the dataset, see dcat_endpointURL()

...

any other property to be included to a dcat:Dataset

Details

A dcat:DataService class, created with dcat_DataService(), can/must have the following properties (M stands for mandatory; R for recommended):

Value

A character vector of length greater than one.


Create a DCAT-AP CH Dataset (dcat:dataset)

Description

A dcat:dataset must have one or more dcat:distribution(s).

Usage

dcat_dataset(
  title = dct_title(),
  description = dct_description(),
  publisher = dct_publisher(),
  contactPoint = dcat_contactPoint(),
  identifier = dct_identifier(),
  distribution = dcat_distribution(),
  ...
)

Arguments

title

title of the dataset, see dct_title(). Can be multilingual.

description

description of the dataset, see dct_description(). Can be multilingual.

publisher

publisher of the dataset, see dct_publisher().

contactPoint

contactPoint of the dataset, see dcat_contactPoint().

identifier

identifier of the dataset, see dct_identifier().

distribution

one or more distributions, see dcat_distribution()

...

any other property to be included to a dcat:Dataset

Details

A dcat:Dataset class, created with dcat_dataset(), can/must have the following properties (M stands for mandatory; R for recommended):

Value

A character vector of length greater than one.


Create a dcat:distribution/dcat:Distribution property

Description

Create a dcat:distribution/dcat:Distribution property

Usage

dcat_distribution(
  issued = dct_issued(),
  access_url = dcat_accessURL(),
  license = dct_license2(),
  ...
)

Arguments

issued

dct:issued property, see dct_issued().

access_url

dcat:accessURL property, see dcat_accessURL().

license

dct:license property, see dct_license().

...

any other property to be included to a dcat:Distribution

Details

A dcat:Dataset class, created with dcat_dataset(), can/must have the following properties (M stands for mandatory; R for recommended):

Value

A character vector of length greater than one.

Examples

dcat_distribution()

dcat_distribution(description = dct_description("Un archivio zip con un csv"))

Create a dcat:downloadURL property in DCAT-AP CH standard

Description

Create a dcat:downloadURL property in DCAT-AP CH standard

Usage

dcat_downloadURL(
  download_url = "https://www3.ti.ch/DFE/DR/USTAT/allegati/cubo/cubi_POL_01_csv.zip"
)

Arguments

download_url

url of the resource

Property of dcat:Distribution (dcat_distribution())


Create a dcat:endpointDescription property in DCAT-AP CH standard

Description

Create a dcat:endpointDescription property in DCAT-AP CH standard

Usage

dcat_endpointDescription(x = "")

Arguments

x

a url


Create a dcat:endpointURL property in DCAT-AP CH standard

Description

Create a dcat:endpointURL property in DCAT-AP CH standard

Usage

dcat_endpointURL(x = "")

Arguments

x

a url


Create a dcat:keyword property in DCAT-AP CH standard

Description

Create a dcat:keyword property in DCAT-AP CH standard

Usage

dcat_keyword(x = "", language = c("de", "fr", "it", "en"))

Arguments

x

keyword

language

one of "de", "fr", "it" or "en"

Examples

dcat_keyword()
dcat_keyword("Cani", language = "it")
dcat_keyword("Hunde", language = "de")

Create a dcat:landingPage property in DCAT-AP CH standard

Description

Create a dcat:landingPage property in DCAT-AP CH standard

Usage

dcat_landingPage(x = "https://www.example.com")

Arguments

x

an url (character string). Default: https://www.example.com

Examples

dcat_landingPage()

Create a dcat:servesDataset property in DCAT-AP CH standard

Description

Create a dcat:servesDataset property in DCAT-AP CH standard

Usage

dcat_servesDataset(x = "https://example.com")

Arguments

x

a url

Examples

dcat_servesDataset("https://example.com")

Create a dcat:service property in DCAT-AP CH standard

Description

Create a dcat:service property in DCAT-AP CH standard

Usage

dcat_service(x = "")

Arguments

x

things to include in a dcat:service, typically one or more dcat:DataService


Create a dcat:theme property in DCAT-AP CH standard

Description

Create a dcat:theme property in DCAT-AP CH standard

Usage

dcat_theme(x = "http://dcat-ap.ch/vocabulary/themes/work")

Arguments

x

a theme url


Create a dcat:themeTaxonomy property in DCAT-AP CH standard

Description

Create a dcat:themeTaxonomy property in DCAT-AP CH standard

Usage

dcat_themeTaxonomy(
  x = "http://publications.europa.eu/resource/authority/data-theme"
)

Arguments

x

an url


Create a dct:accrualPeriodicity property in DCAT-AP CH standard

Description

Create a dct:accrualPeriodicity property in DCAT-AP CH standard

Usage

dct_accrualPeriodicity(
  freq = c("https://publications.europa.eu/resource/authority/frequency/ANNUAL",
    "https://publications.europa.eu/resource/authority/frequency/QUARTERLY",
    "https://publications.europa.eu/resource/authority/frequency/MONTHLY",
    "https://publications.europa.eu/resource/authority/frequency/DAILY")
)

Arguments

freq

frequency with which a dataset is updated (see https://publications.europa.eu/resource/authority/frequency)


Create a dct:description property in DCAT-AP CH standard

Description

Create a dct:description property in DCAT-AP CH standard

Usage

dct_description(description = "", language = "it")

Arguments

description

character string with a description

language

language of the title (one of "it", "de", "fr", "en")


Create a dct:format property in DCAT-AP CH standard

Description

Create a dct:format property in DCAT-AP CH standard

Usage

dct_format(
  x = "http://publications.europa.eu/resource/authority/file-type/CSV"
)

Arguments

x

a filetype resource url/uri. See https://publications.europa.eu/resource/authority/file-type


Create a dct:identifier property in DCAT-AP CH standard

Description

Create a dct:identifier property in DCAT-AP CH standard

Usage

dct_identifier(identifier = "xyz456@cantone_ticino")

Arguments

identifier

character string with and identifier


Create a dct:issued property in DCAT-AP CH standard

Description

Create a dct:issued property in DCAT-AP CH standard

Usage

dct_issued(date = Sys.Date(), hour_minutes_seconds = "00:00:00")

Arguments

date

date or character vector in yyyy-mm-dd format

hour_minutes_seconds

hour, minutes and seconds (default: "00:00:00")


Create a dct:language property in DCAT-AP CH standard

Description

Create a dct:language property in DCAT-AP CH standard

Usage

dct_language(language = c("de", "fr", "it", "en"))

Arguments

language

two-letters abbreviation of the language (one of "de", "fr", "it" or "en")


Create a dct:license property in DCAT-AP CH standard

Description

Create a dct:license property in DCAT-AP CH standard

Usage

dct_license(about = "http://dcat-ap.ch/vocabulary/licenses/terms_open")

dct_license2(
  license = c("NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired",
    "NonCommercialAllowed-CommercialAllowed-ReferenceRequired",
    "NonCommercialAllowed-CommercialWithPermission-ReferenceNotRequired",
    "NonCommercialAllowed-CommercialWithPermission-ReferenceRequired")
)

Arguments

about

a dct:license uri. See https://www.dcat-ap.ch/vocabulary/licenses/20210623.html

license

one of the licenses allowed in opendata.swiss

See also https://dcat-ap.ch/vocabulary/licenses/20210623.html#terms_open for a list of possible licenses.


Create a dct:modified property in DCAT-AP CH standard

Description

Create a dct:modified property in DCAT-AP CH standard

Usage

dct_modified(date = Sys.Date(), hour_minutes_seconds = "00:00:00")

Arguments

date

date or character vector in yyyy-mm-dd format

hour_minutes_seconds

hour, minutes and seconds (default: "00:00:00")


Create a dct:publisher property in DCAT-AP CH standard

Description

Create a dct:publisher property in DCAT-AP CH standard

Usage

dct_publisher(
  publisher = "https://www.ti.ch/ustat",
  foaf_name = "Ufficio di statistica del Cantone Ticino (Ustat)"
)

Arguments

publisher

character string with a publisher (usually an URL)

foaf_name

name of the organization/publisher


Create a dct:rights property in DCAT-AP CH standard

Description

Create a dct:rights property in DCAT-AP CH standard

Usage

dct_rights(
  license = c("NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired",
    "NonCommercialAllowed-CommercialAllowed-ReferenceRequired",
    "NonCommercialAllowed-CommercialWithPermission-ReferenceNotRequired",
    "NonCommercialAllowed-CommercialWithPermission-ReferenceRequired")
)

Arguments

license

one of the licenses allowed in opendata.swiss

See also https://dcat-ap.ch/vocabulary/licenses/20210623.html#terms_open for a list of possible licenses.


Create a dct:spatial property in DCAT-AP CH standard

Description

Create a dct:spatial property in DCAT-AP CH standard

Usage

dct_spatial(x = "Switzerland")

Arguments

x

spatial reference (default: "Switzerland")


Create a dct:temporal property in DCAT-AP CH standard

Description

Create a dct:temporal property in DCAT-AP CH standard

Usage

dct_temporal(startDate = Sys.Date() - 1, endDate = Sys.Date())

Arguments

startDate

start date (default: Sys.Date() - 1). Date in yyyy-mm-dd format

endDate

end date (default: Sys.Date()). Date in yyyy-mm-dd format


Create a dct:title property in DCAT-AP CH standard

Description

Create a dct:title property in DCAT-AP CH standard

Usage

dct_title(title = "", language = "it")

Arguments

title

character string with a title

language

language of the title (one of "it", "de", "fr", "en")

Mandatory property of dcat:Catalog (V2) (dcat_catalog()) and dcat:Dataset (dcat_dataset()), recommended property of dcat:Distribution (dcat_distribution())


A closure to create a function that generates a tag like ...

Description

A closure to create a function that generates a tag like ...

Usage

f_gen_tag(tag = "dct:identifier")

Arguments

tag

character string with the desired tag

Examples

# Create an f function to generate a dct:identifier tag
f <- f_gen_tag(tag = "dct:identifier")
f(x = "an_identifier")

A closure to create a function that generates a tag like

Description

A closure to create a function that generates a tag like

Usage

f_gen_tag2(tag = "dcat:accessURL", rdf_resource = "rdf:resource")

Arguments

tag

character string with the desired tag

rdf_resource

character string that comes afer the tag (default: "rdf:resource")

Examples

# Create an f function to generate a dcat:accessURL tag
f <- f_gen_tag2(tag = "dcat:accessURL")
f(x = "https://www.example.com")

Create a foaf:homepage tag

Description

Create a foaf:homepage tag

Usage

foaf_homepage(x = "http://www.example.com")

Arguments

x

an url of a homepage


Generate a tag like ...

Description

Generate a tag like ...

Usage

gen_tag(tag = "dct:identifier", x = "...")

Arguments

tag

character string with the desired tag

x

the content to be encapsulated inside the tag


Generate a tag like

Description

Generate a tag like

Usage

gen_tag2(
  tag = "dcat:accessURL",
  x = "https://example.com",
  rdf_resource = "rdf:resource"
)

Arguments

tag

character string with the desired tag

x

the content to be encapsulated inside the tag. Note that this content is enclosed in quotation marks (by the function)

rdf_resource

character string that comes afer the tag (default: "rdf:resource")


Indent a character vector by some spaces

Description

Indent a character vector by some spaces

Usage

indent(x, nspaces = 2L)

Arguments

x

a character vector

nspaces

number of desired spaces to indent (default: 2)


Prepare a dataset to be exported in rdf/xml

Description

Prepare a dataset to be exported in rdf/xml

Usage

rdf_dataset(
  dataset = dcat_dataset(),
  namespaces = c("xmlns:foaf=\"http://xmlns.com/foaf/0.1/\"",
    "xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"",
    "xmlns:hydra=\"http://www.w3.org/ns/hydra/core#\"",
    "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
    "xmlns:dcat=\"http://www.w3.org/ns/dcat#\"",
    "xmlns:dct=\"http://purl.org/dc/terms/\"",
    "xmlns:vcard=\"http://www.w3.org/2006/vcard/ns#\"",
    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\"",
    "xmlns:schema=\"http://schema.org/\"")
)

Arguments

dataset

a dataset created with dcat_dataset()

namespaces

character vector with xml/rdf namespaces


Create a character vector with some xml/rdf namespaces

Description

Create a character vector with some xml/rdf namespaces

Usage

rdf_namespaces(
  namespaces = c("xmlns:foaf=\"http://xmlns.com/foaf/0.1/\"",
    "xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"",
    "xmlns:hydra=\"http://www.w3.org/ns/hydra/core#\"",
    "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"",
    "xmlns:dcat=\"http://www.w3.org/ns/dcat#\"",
    "xmlns:dct=\"http://purl.org/dc/terms/\"",
    "xmlns:vcard=\"http://www.w3.org/2006/vcard/ns#\"",
    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\"",
    "xmlns:schema=\"http://schema.org/\""),
  nspaces = 2L
)

Arguments

namespaces

character vector with xml/rdf namespaces

nspaces

number of spaces to indent (default: 2)


Write a character vector to a file with unix file endings and UTF-8 encoding

Description

Write a character vector to a file with unix file endings and UTF-8 encoding

Usage

write_unix(x, filename)

Arguments

x

a character vector

filename

filename