Skip to content

Commit 556b0a0

Browse files
authored
Merge pull request #37 from aidanhorn/aidan-PR/docs
Documentation improvements
2 parents 387bb74 + d684894 commit 556b0a0

14 files changed

+100
-68
lines changed

R/read_dataset.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ read_dataset <- function(id, tidy = FALSE, ...) {
125125
}
126126

127127
read_econdata <- function(id, tidy = FALSE, ...) {
128+
.Deprecated("read_dataset")
128129
read_dataset(id = id, tidy = tidy, ...)
129130
}
130131

R/write_dataset.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ write_dataset <- function(x, method = "stage", ...) {
119119
}
120120

121121
write_econdata <- function(x, create = FALSE, update = FALSE, stage = TRUE, ...) {
122+
.Deprecated("write_dataset")
122123
if (create || update) {
123124
stop("Create and update no longer supported, please use 'write_dataset'")
124125
}

R/write_release.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
write_release <- function(id, version, providerid, description, method = "release", ...) {
1+
write_release <- function(id, version, description, method = "release", ...) {
22

33

44
# Parameters ----

man/econdatar-package.Rd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
}
1111
\details{
1212

13-
This package provides an interface to Codera Analytic's econometric data service (https://codera.co.za) and the EconData database (https://www.econdata.co.za) in particular.
13+
This package provides an interface to \href{https://codera.co.za/}{Codera Analytics'} econometric data service and the \href{https://www.econdata.co.za/}{EconData} database in particular.
1414
1515
EconData enables automation of analytical workflows that depend on public domain or third-party data. It is also a leading-edge forecast management system, enabling data and model automation and best practice data and model governance. EconData supports data-sharing across databases and within institutions, codifies modelling process flows and provides user-level access control. EconData makes it easy to securely manage and share model scenarios and forecast vintages.
1616
17-
The EconData Registry provides a central data glossary of data concepts and the information necessary to access and interpret data and associated metadata.
17+
The EconData Registry provides a central data glossary of data concepts and the information necessary to access and interpret data and associated metadata. The Registry can be queried through this package's \code{\link{read_registry}} function.
1818

1919
Codera also uses EconData to automate models, do research, and create value-added products such as interactive scenario dashboards. These dashboards and forecasts are made available to our clients.
2020
}
@@ -24,8 +24,8 @@ Maintainer: \packageMaintainer{econdatar}
2424
}
2525
\keyword{ package }
2626
\seealso{
27-
https://www.econdata.co.za
28-
https://econdata.co.za
27+
\href{https://www.econdata.co.za}{https://www.econdata.co.za}
28+
\href{https://econdata.co.za}{https://econdata.co.za}
2929
}
3030
\examples{
3131
\dontrun{

man/read_database.Rd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ read_database(id, include_series = FALSE, tidy = FALSE, \dots)
1515
\arguments{
1616
\item{id}{Data set identifier. May be \code{"all"}}
1717
\item{include_series}{If \code{TRUE} series (and their metadata) with obervations omitted are included in the return (series are discarded when \emph{tidy} is \code{TRUE}).}
18-
\item{x}{A raw API return object to be tidied. Can also be done directly in \code{read_database()} by setting \code{tidy = TRUE}}.
18+
\item{x}{A raw API return object to be tidied. Can also be done directly in \code{read_database()} by setting \code{tidy = TRUE}}
1919

20-
\item{\dots}{Further \emph{Optional} arguments:
20+
\item{\dots}{Further \emph{optional} arguments:
2121
\tabular{llll}{
2222
\code{agencyid} \tab\tab character. Defaults to \code{ECONDATA}. Agency responsible for the metadata creation/maintenance. \cr
2323
\code{version} \tab\tab character. Version(s) of the data (different versions will have different metadata), or \code{"all"} to return all available versions. \cr
@@ -27,7 +27,7 @@ read_database(id, include_series = FALSE, tidy = FALSE, \dots)
2727
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}.}
2828
}
2929
\details{
30-
An EconData account (http://econdata.co.za) is required to use this function. The user must provide an API token that can be found on the \emph{Account} page of the online portal, a GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret")}, when available.
30+
An \href{https://econdata.co.za/}{EconData} account is required to use this function. The user must provide an API token, which can be found on the \emph{Account} page of the online portal. A GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret")}, when available.
3131
}
3232
\value{
3333
If \code{tidy = FALSE}, an unnamed list of data frames is returned. Each data frame further has a \code{"metadata"} attribute providing information about the data set.

man/read_dataset.Rd

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
read_dataset
66
}
77
\description{
8-
Returns the data for the given data set - ECONDATA:id(version), as a list, or as tidy \emph{data.table}'s. Available data sets can be looked up using \code{read_database()} or from the web platform (http://econdata.co.za). Tidying can be done directly within \code{read_dataset()}, or ex-post using \code{tidy_data()}.
8+
Returns the data for the given data set - ECONDATA:id(version), as a list, or as tidy \emph{data.table}'s. Available data sets can be looked up using \code{read_database()} or from the \href{https://www.econdata.co.za/}{web platform}. Tidying can be done directly within \code{read_dataset()}, or ex-post using \code{tidy_data()}.
99
}
1010
\usage{
1111
read_dataset(id, tidy = FALSE, \dots)
@@ -15,38 +15,30 @@ read_dataset(id, tidy = FALSE, \dots)
1515
\arguments{
1616
\item{id}{Data set identifier.}
1717
\item{x}{A raw API return object to be tidied. Can also be done directly in \code{read_dataset()} by setting \code{tidy = TRUE}. See \code{tidy} below for tidying options.}
18-
\item{wide}{Should the tidied data be returned in \emph{wide} or \emph{long} format.}
18+
\item{wide}{Specifies whether the tidied data be returned in \emph{wide} or \emph{long} format.}
1919
20-
\item{\dots}{Further \emph{Optional} arguments:
20+
\item{\dots}{Further \emph{optional} arguments:
2121
\tabular{llll}{
2222
\code{agencyid} \tab\tab character. Defaults to \code{ECONDATA}. Agency responsible for the metadata creation/maintenance. \cr
2323
\code{version} \tab\tab character. Version(s) of the data (different versions will have different metadata), or 'all' to return all available versions. \cr
24-
\code{series_key} \tab\tab character. A character vector specifying a subset of time series (see the web platform (export function) for details). \cr
24+
\code{series_key} \tab\tab character. A character vector specifying a subset of time series (see the web platform (export function) for an example). The series key is composed of a few dimensions, separated with full-stops. In the syntax of the argument, include various concept codes \emph{within each dimension}, separated by a + character. The function then downloads the union of all the possible combinations of the concept codes chosen. Please see \href{https://econdata.co.za/fast-econdatar-downloads/}{our blog post}.\cr
2525
\code{release} \tab\tab character (optionally with format \%Y-\%m-\%dT\%H:\%M:\%S, to be coerced to a date/time). The release description, which will return the data associated with that release (if the given description matches an existsing release); or a date/time which will return the data as it was at the given time; or 'latest' which will return the latest release; or 'unreleased' which will return any unreleased data (useful for data that is updated more often than it is released, e.g. daily data). \cr
2626
\code{file} \tab\tab character. File name for retrieving data sets stored as JSON data from disk (output of \code{read_dataset()}. \cr
27-
}
28-
}
29-
30-
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}. If \code{TRUE}, \code{read_dataset()/tidy_data()} admit the following additional arguments:
27+
}}
28+
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}. If \code{TRUE}, \code{read_dataset()/tidy_data()} admit the following additional arguments:}
29+
\item{\dots}{
3130
\tabular{llll}{
3231
\code{wide} \tab\tab logical, default: \code{TRUE}. Returns data in a column-based format, with \code{"label"} and \code{"source_identifier"} attributes to columns (when available) and an overall "metadata" attribute to the table, otherwise a long-format is returned. See Value. \cr
33-
3432
\code{codelabel} \tab\tab logical, default: \code{FALSE}. If \code{wide = TRUE}, setting \code{codelabel = TRUE} the data key will be used to generate the \code{"label"}, when available. \cr
35-
3633
\code{combine} \tab\tab logical, default: \code{FALSE}. If \code{wide = FALSE}, setting \code{combine = TRUE} will combine all data and metadata into a single long table, whereas the default \code{FALSE} will return data and metadata in separate tables, for more efficient storage. \cr
37-
3834
\code{origmeta} \tab\tab logical, default: \code{FALSE}. If \code{wide = FALSE}, setting \code{origmeta = TRUE} will combine all metadata fields attached to the series in the dataset as they are. The default is to construct a standardized set of metadata variables, and then drop those not observed. See also \code{allmeta}. \cr
39-
4035
\code{allmeta} \tab\tab logical, default: \code{FALSE}. If \code{wide = FALSE}, setting \code{allmeta = TRUE} always returns the full set of metadata fields, regardless of whether they are recorded for the given dataset. It is also possible that there are series with zero observations in a dataset. Such series are dropped in tidy output, but if \code{combine = FALSE}, \code{allmeta = TRUE} retains their metadata in the metadata table. \cr
41-
4236
\code{prettymeta} \tab\tab logical, default: \code{TRUE}. Attempts to make the returned metadata more human readable replacing each code category and enumeration with its name. It is advisable to leave this set to \code{TRUE}, in some cases, where speed is paramount you may want to set this flag to \code{FALSE}. If multiple datasets are being querioed this option is automatically set to \code{FALSE}. \cr
43-
44-
\code{release} \tab\tab logical, default: \code{FALSE}. \code{TRUE} allows you to apply \code{tidy_data()} to objects returned by \code{read_release()}. All other flags to \code{tidy_data()} are ignored.
45-
}
46-
}
37+
\code{release} \tab\tab logical, default: \code{FALSE}. \code{TRUE} allows you to apply \code{tidy_data()} to objects returned by \code{read_release()}. All other flags to \code{tidy_data()} are ignored.
38+
}}
4739
}
4840
\details{
49-
An EconData account (http://econdata.co.za) is required to use this function. The user must provide an API token that can be found on the \emph{Account} page of the online portal, a GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret")}, when available.
41+
An \href{http://econdata.co.za/}{EconData} account is required to use this function. The user must provide an API token, which can be found on the \emph{Account} page of the online portal; a GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret")}, when available.
5042
}
5143
\value{
5244
If \code{tidy = FALSE}, a list of data frames is returned, where the names of the list are the EconData series codes, and each data frame has a single column named 'OBS_VALUE' containing the data, with corresponding dates attached as rownames. Each data frame further has a \code{"metadata"} attribute providing information about the series. The entire list of data frames also has a \code{"metadata"} attribute, providing information about the dataset. If multiple datasets (or versions of a dataset if \code{version} is specified as 'all') are being queried, a list of such lists is returned.
@@ -83,6 +75,17 @@ CPI_ANL_ALLMETA <- tidy_data(CPI_ANL, wide = FALSE, allmeta = TRUE) # v2.0 has s
8375
MARKET_RATES <- read_dataset(id = "MARKET_RATES",
8476
series_key = "CMJD003.B.A",
8577
release = "unreleased")
78+
79+
# library(tibble)
80+
data_raw <- read_dataset(id = "POPULATION_DATA_REG",
81+
tidy = TRUE,
82+
wide = FALSE,
83+
compact = FALSE)
84+
str(data_raw)
85+
print(names(data_raw$data))
86+
print(names(data_raw$metadata))
87+
as_tibble(data_raw$data)
88+
as_tibble(data_raw$metadata) |> view()
8689
}
8790
}
8891
\keyword{ load }

man/read_econdata.Rd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
read_econdata
66
}
77
\description{
8-
Returns the data for the given data set - ECONDATA:id(version), as a list, or as tidy \emph{data.table}'s. Available data sets can be looked up from the web platform (http://www.econdata.co.za). Tidying can be done directly within \code{read_econdata()}, or ex-post using \code{tidy_data()}.
8+
This function is deprecated, in favour of \code{\link{read_dataset}}. During development, please replace this function with the newer function name.
9+
10+
Returns the data for the given data set - ECONDATA:id(version), as a list, or as tidy \emph{data.table}'s. Available data sets can be looked up from the \href{http://www.econdata.co.za/}{web platform}. Tidying can be done directly within \code{read_econdata()}, or ex-post using \code{tidy_data()}.
911
}
1012
\usage{
1113
read_econdata(id, tidy = FALSE, \dots)
@@ -16,7 +18,7 @@ tidy_data(x, \dots)
1618
\item{id}{Data identifier.}
1719
\item{x}{A raw API return object to be tidied. Can also be done directly in \code{read_econdata()} by setting \code{tidy = TRUE}. See \code{tidy} below for tidying options.}
1820
19-
\item{\dots}{Further \emph{Optional} arguments:
21+
\item{\dots}{Further \emph{optional} arguments:
2022
\tabular{llll}{
2123
\code{agencyid} \tab\tab character. Defaults to \code{ECONDATA}. Agency responsible for the metadata creation/maintenance. \cr
2224
\code{version} \tab\tab character. Version(s) of the data (different versions will have different metadata), or 'all' to return all available versions. \cr
@@ -26,7 +28,8 @@ tidy_data(x, \dots)
2628
}
2729
}
2830
29-
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}. If \code{TRUE}, \code{read_econdata()/tidy_data()} admit the following additional arguments:
31+
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}. If \code{TRUE}, \code{read_econdata()/tidy_data()} admit the following additional arguments:}
32+
\item{\dots}{
3033
\tabular{llll}{
3134
\code{wide} \tab\tab logical, default: \code{TRUE}. Returns data in a column-based format, with \code{"label"} and \code{"source_identifier"} attributes to columns (when available) and an overall "metadata" attribute to the table, otherwise a long-format is returned. See Value. \cr
3235

@@ -45,7 +48,7 @@ tidy_data(x, \dots)
4548
}
4649
}
4750
\details{
48-
An EconData account (http://econdata.co.za) is required to use this function. The user must provide an API token that can be found on the \emph{Account} page of the online portal, a GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret")}, when available.
51+
An \href{http://econdata.co.za/}{EconData} account is required to use this function. The user must provide an API token, which can be found on the \emph{Account} page of the online portal; a GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret")}, when available.
4952
}
5053
\value{
5154
If \code{tidy = FALSE}, a list of data frames is returned, where the names of the list are the EconData series codes, and each data frame has a single column named 'OBS_VALUE' containing the data, with corresponding dates attached as rownames. Each data frame further has a \code{"metadata"} attribute providing information about the series. The entire list of data frames also has a \code{"metadata"} attribute, providing information about the dataset. If multiple datasets (or versions of a dataset if \code{version} is specified as 'all') are being queried, a list of such lists is returned.
@@ -55,6 +58,7 @@ If \code{tidy = TRUE} and \code{wide = TRUE} (the default), a single \emph{data.
5558
If \code{tidy = TRUE} and \code{wide = FALSE} and \code{compact = FALSE} (the default), a named list of two \emph{data.table}'s is returned. The first, \code{"data"}, has columns 'code', 'date' and 'value' providing the data in a long format. The second, \code{"metadata"}, provides dataset and series-level matadata, with one row for each series. If \code{compact = TRUE}, these two datasets are combined, where all repetitive content is converted to factors for more efficient storage. If multiple datasets (or versions of a dataset if \code{version} is specified as 'all') are being queried, \code{compact = FALSE} gives a nested list, whereas \code{compact = TRUE} binds everything together to a single long frame. In general, if \code{wide = FALSE}, no attributes are attached to the tables or columns in the tables.
5659
}
5760
\seealso{
61+
\code{\line{read_dataset}}
5862
\code{\link{write_econdata}}
5963
\code{\link{read_release}}
6064
}

0 commit comments

Comments
 (0)