istacbase: Download data from the ISTACBASE API

Description Usage Arguments Value Note Examples

View source: R/istacbase.R

Description

This function downloads the requested information using the ISTACBASE API.

Usage

1
2
istacbase(istacbase_table, islas = "all", label = TRUE,
  POSIXct = FALSE, startdate, enddate, freq, mrv, cache)

Arguments

istacbase_table

Character string with the ID of the table requested. This ID corresponds to the ID column from cache.

islas

Character vector of islands name requested. Default value is special code of all. Valid values for islands are: El Hierro, La Palma, La Gomera, Tenerife, Gran Canaria, Fuerteventura and Lanzarote.

label

if FALSE, the data frame returned has the codes used in ISTACBASE API, if TRUE, the data frame returned has the labels used in ISTACBASE API. Default value is FALSE.

POSIXct

if TRUE, additonal columns fecha and periodicidad are added. fecha converts the default date into a POSIXct. periodicidad denotes the time resolution that the date represents. Useful for freq filter, If FALSE, these fields are not added.

startdate

Numeric. Must be in %Y form (i.e. four digit year).

enddate

Numeric. Must be in %Y form (i.e. four digit year).

freq

Character String. For fetching yearly ("anual"), biannual ("semestral"), quaterly ("trimestral"), monthly("mensual"), bi-weekly("quincenal"), weekly("semanal") values. Currently works along with mrv.

mrv

Numeric. The number of Most Recent Values to return. A replacement of startdate and enddate, this number represents the number of observations you which to return starting from the most recent date of collection.

cache

Data frame with tables from ISTACBASE API.

Value

Data frame with all available requested data.

Note

The POSIXct parameter requries the use of lubridate (>= 1.5.0). All dates are rounded down to the floor. For example a value for the year 2016 would have a POSIXct date of 2016-01-01. If this package is not available and the POSIXct parameter is set to TRUE, the parameter is ignored and a warning is produced.

startdate, enddate, freq, mrv with POSISXct=FALSE are ignored when POSCIXct is set to FALSE. and a warning is produced.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Percentiles de renta disponible (año anterior al de la entrevista) por hogar en Canarias y años.
istacbase("soc.cal.enc.res.3637")

# query using startdate and enddate
# Percentiles de renta disponible (año anterior al de la entrevista) por hogar en Canarias y años.
istacbase("soc.cal.enc.res.3637", POSIXct = TRUE, startdate = 2010, enddate = 2015)


# query using \code{islas} filter
# Población según sexos y edades año a año. Islas de Canarias y años.
istacbase("dem.pob.exp.res.35", islas = "Fuerteventura")

# if you want the most recent values
istacbase("dem.pob.exp.res.35", POSIXct = TRUE, mrv = 4)

rOpenSpain/istacbaser documentation built on June 4, 2020, 5:07 p.m.