indicator.Rmd
library(indicators)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnipThe aim of the indicator S3 class to test the schema of individually created or individually imported indicators. It makes sure that the minimal level of metadata, such as keywords are present to place the indicator to the correct place in an existing observatory. Its constructor fills out trivial metadata automatically, such as creation or update day.
test_indicator <- indicator (
x <- data.frame (
geo = rep(c("NL", "BE", "LU"), 4), # only checked to be factor or character
time = rep(c(2016:2019),3), # must be a Date, an integer, or coercible to integer.
value = runif(12, 1,100), # must be a numeric or an integer
estimate = rep("actual", 12) # only checked to be factor or character
),
shortcode = "dmo_test_1",
indicator_code = NULL, # indicaotr_code is used for machine-created codes, and if not present, equals shortcode
indicator_name = "Test Indicator", # if not present, equalst the shortcode
description = "A curated, human description",
description_at_source = NULL, # this is the machine-created description which may be very cumbersome
code_at_source = NULL, # for machine-read indicators, can be omitted
original_source = NA_character_, # if omitted, the observatory itself
doi = NULL, # if omitted, fills it with "<not yet assigned or unknown>"
date_earliest = NULL, # if omitted, takes the minimum value of x$time
date_latest = NULL, # if omitted, takes the maximum value of x$time
keyword1 = "music", keyword2 = "economy", keyword3 = "demand", keyword4 = "pcr"
)Generally, the shortcode = "dmo_test_1" and indicator_name = "Test Indicator" should be suggested by the data curator, and approved by the observatory, because they will be the main identifiers. They are differentiated from indicator_code and description_at_source machine generated versions (see get_eurostat_indicator()) and not always very useful. Eurostat’s labelling is not comprehensive and the machine read and created descriptions are often not extremely helpful.
The description = "A curated, human description" is strongly encouraged. Machines can read much data, but if an expert curator cannot give it a meaningful name, then it is unlikely to be a useful, usable indicator, and will look bad on our websites and documentations. Nevertheless, any of the shortcode and indicator_code, and any of the description_at_source and description will suffice.
The actual indicator values in parameter x are tested to be well-formatted and tidy.
Currently it has only one method, the print method, which prints up to the first 10 observations with a short summary. The keyword1 places the indicator into music, or greendeal, or economy. The keyword2 places it in a pillar or main chapter, such as music economy in the Digita Music Observatory. At least four keywords are needed to place the indicator in our observatories, but more keywords for further use or search are allowed.
print(test_indicator)
#> indicator [dmo_test_1] music - economy - demand
#> A curated, human description
#> Source: music.dataobservatory.eu ; DOI: <not yet assigned or unknown>
#> The first 10 observations of 12
#> geo time value estimate
#> 1 NL 2016 20.39054 actual
#> 2 BE 2017 53.83797 actual
#> 3 LU 2018 64.35804 actual
#> 4 NL 2019 27.43403 actual
#> 5 BE 2016 51.83833 actual
#> 6 LU 2017 23.01166 actual
#> 7 NL 2018 78.33366 actual
#> 8 BE 2019 62.48335 actual
#> 9 LU 2016 45.44383 actual
#> 10 NL 2017 96.51245 actualThe metadata that is needed for placement in one of the existing or planned observatory databases is stored as attributes metadata in the R object. This serves mainly as a security function. If the metadata is not present and cannot be guessed, the indicator is not created. The contents of the indicator object with the metadata can further be placed into the database.
attributes(test_indicator)
#> $names
#> [1] "geo" "time" "value" "estimate"
#>
#> $class
#> [1] "indicator" "data.frame"
#>
#> $row.names
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12
#>
#> $shortcode
#> [1] "dmo_test_1"
#>
#> $indicator_code
#> [1] "dmo_test_1"
#>
#> $indicator_name
#> [1] "Test Indicator"
#>
#> $description
#> [1] "A curated, human description"
#>
#> $description_at_source
#> [1] NA
#>
#> $code_at_source
#> [1] NA
#>
#> $original_source
#> [1] "music.dataobservatory.eu"
#>
#> $last_update_data
#> [1] "2021-05-31"
#>
#> $date_earliest
#> [1] 2016
#>
#> $date_latest
#> [1] 2019
#>
#> $observations
#> [1] 12
#>
#> $doi
#> [1] "<not yet assigned or unknown>"
#>
#> $keyword1
#> [1] "music"
#>
#> $keyword2
#> [1] "economy"
#>
#> $keyword3
#> [1] "demand"
#>
#> $keyword4
#> [1] "pcr"
#>
#> $keywords
#> [1] "music" "economy" "demand" "pcr"
#>
#> $observatory
#> [1] "music.dataobservatory.eu"