Package 'BOE'

Title: Work with the Boletin Oficial del Estado of Spain
Description: Queries the online site of the Boletin Oficial del Estado (BOE) for data.
Authors: Lluís Revilla Sancho [aut, cre]
Maintainer: Lluís Revilla Sancho <[email protected]>
License: MIT + file LICENSE
Version: 0.1.8.9007
Built: 2024-08-30 05:23:16 UTC
Source: https://github.com/rOpenSpain/BOE

Help Index


Check id of documents

Description

Given an id check if it is valid.

Usage

check_code(id)

valid_code(id, sumario = TRUE, BORME = FALSE)

Arguments

id

ID or CVE of the document (character).

sumario

Logical value if sumarios should be accepted.

BORME

Logical value if BORME journal should be accepted.

Value

A logical value if correct, errors if something is not right.

Functions

  • valid_code(): Returns logic values

Examples

check_code("BOE-S-20141006") # Normal way
check_code("BOE-S-2014-242") # Also accepted but not documented
# Will fail:
# check_code("BOE-S-2014")
valid_code("BOE-S-2014")

Elements: disposición and anuncio

Description

Functions to create CVE codes for the documents published on the BOE.

Usage

disposicion_cve(year, number)

disposicion(year, number)

anuncio_cve(year, number)

anuncio(year, number)

Arguments

year

Character or numeric value of the year of the element in YYYY format.

number

Character or numeric value of the element.

Value

A character vector

Functions

  • disposicion_cve(): Create the CVE of the diposicion.

  • disposicion(): For compatibility with previous version

  • anuncio_cve(): Create the CVE of the anuncio.

  • anuncio(): For compatibility with previous version

See Also

Other code generators: sumario_cve(), sumario_nbo()

Examples

disposicion_cve(2019, 242)
anuncio_cve(2019, 242)

Retrieve the XML content

Description

Look up on the internet and get the content

Usage

get_xml(query)

Arguments

query

A query to BOE.

See Also

query_xml()

Examples

id <- sumario_nbo(format(as.Date("2017/10/02", "%Y/%m/%d"), "%Y%m%d"))
url <- query_xml(id)
get_xml(url)

Last day of BOE

Description

Returns the date of the last BOE under normal circumstances.

Usage

last_date_boe()

Value

A date.

Examples

last_date_boe()

Open publications on the browser

Description

This function opens urls in your browser.

Usage

open_publications(sumario)

Arguments

sumario

A tidy sumario.

Value

A tab should open on your default browser with the pdf of the publications.

Examples

## Not run: 
sumario <- retrieve_sumario(last_date_boe())
url_publications(sumario[1:10, ])
## End(Not run)

Build a query for the webpage

Description

Look for the consolidated law online

Usage

query_consolidada(cve)

Arguments

cve

The CVE of the document you want.

Value

A query url.

Examples

cve <- disposicion_cve("2017", "117")
query_consolidada(cve)

Build a query for the webpage

Description

Build a query for the webpage

Usage

query_htm(cve)

Arguments

cve

The CVE of the document you want.

Value

A query url.

See Also

query_consolidada

Examples

cve <- sumario_cve("2017", "117")
query_htm(cve)

Query a pdf from the BOE

Description

To query a pdf you must know the number of the piece you are looking for and the date it was published.

Usage

query_pdf(year, month, day, code)

Arguments

year

Character of the number of the year: YYYY

month

Character of the number of the month: MM.

day

Character of the number of the day: DD.

code

Code of the publication to query.

Value

A link to the pdf.

Examples

cve <- sumario_cve("2017", "237")
query_pdf("2017", "10", "02", cve)

Build a query for an XML

Description

Build a query for an XML

Usage

query_xml(id)

Arguments

id

The id of the xml document you want.

Value

A query for the xml.

See Also

sumario_nbo()

Examples

id <- sumario_nbo(format(as.Date("2017/10/02", "%Y/%m/%d"), "%Y%m%d"))
cve <- sumario_cve("2017", "237") # Same document but by the CVE
query_xml(id)
query_xml(cve)

Retrieve information of a publication

Description

Tidy data from any document published on the BOE and BORME from the BOE.

Usage

retrieve_document(cve)

Arguments

cve

Character with the code of the document.

See Also

Other functions to retrieve documents: retrieve_sumario()

Examples

cve <- "BOE-A-2020-12109"
df <- retrieve_document(cve)

Retrieve the sumario

Description

Obtain a sumario and tidy it in a table.

Usage

retrieve_sumario(date, journal = "BOE")

Arguments

date

A Date of the sumario.

journal

Either BOE or BORME.

Value

A data.frame with one line for each publication.

See Also

tidy_sumario to learn about the format of the output

Other functions to retrieve documents: retrieve_document()

Examples

retrieve_sumario(last_date_boe())

Create the number of the sumario

Description

Create the number of the sumario

Usage

sumario_cve(year, number, journal = "BOE")

sumario(year, number, journal = "BOE")

Arguments

year

Character or numeric value of the year of the summary in YYYY format.

number

Number of the summary in NNN format.

journal

Either BOE or BORME.

Value

A character vector with the CVE of the sumario.

Functions

  • sumario(): For compatibility with previous version

See Also

sumario_nbo() if you want to retrieve the sumario by date and don't know the CVE.

Other code generators: element, sumario_nbo()

Examples

sumario_cve(2019, 242)

Create the number for sumario

Description

Creates the id for a sumario by the date it was published.

Usage

sumario_nbo(date, journal = "BOE")

sumario_xml(date, journal = "BOE")

Arguments

date

Date of the sumario

journal

Either BOE or BORME.

Value

A character vector

Functions

  • sumario_xml(): For compatibility with previous version

See Also

The id is different from the CVE, which can be created with sumario_cve().

Other code generators: element, sumario_cve()

Examples

sumario_nbo(Sys.Date())
sumario_nbo(format(as.Date("2009/01/01", "%Y/%m/%d"), "%Y%m%d"), journal = "BORME")

Supplementary summaries

Description

Creates the CVE of a summary of the supplements, either the judicial or notifications. These are only available for 3 months.

Usage

sumario_suplementos(year, number, type = "N")

Arguments

year

Character or numeric value of the year of the summary in YYYY format.

number

Number of the summary in NNN format.

type

Either J or N. J for judicial or N for notificaciones

Value

A CVE of the document

Examples

sumario_suplementos(2023, 1)

Supplement CVE

Description

Creates the CVE of a supplement, either the judicial or notifications. These are only available for 3 months.

Usage

suplemento_cve(year = 2023, number, type = "J")

Arguments

year

Character or numeric value of the year of the summary in YYYY format.

number

Number of the summary in NNN format.

type

Either J or N. J for judicial or N for notificaciones

Value

A CVE.

Examples

suplemento_cve(number = 1)

Tidy sumario from xml file

Description

Cleans in a tidy format the sumario file

Usage

tidy_sumario(x)

Arguments

x

A XML file.

Value

A data.frame with one line for each publication. Including date, sumario number, section, section text, departament, departament number, epigraph, brief text, publication code and number of pages of the pdf.

Examples

id <- sumario_nbo(format(as.Date("2017/10/02", "%Y/%m/%d"), "%Y%m%d"))
sumario_file <- get_xml(query_xml(id))
m <- tidy_sumario(sumario_file)

head(m)
tail(m)

Url to the publications

Description

Transform the date and publication code to the urls to the publications on pdf format.

Usage

url_publications(sumario)

Arguments

sumario

A tidy sumario.

Value

A character vector with the urls to get the publications in pdf format.

See Also

retrieve_sumario to obtain sumarios, and tidy_sumario to know the expected input.

Examples

sumario <- retrieve_sumario(last_date_boe())
url_publications(sumario[1:10, ])