-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0d26a2
commit 5a242bb
Showing
13 changed files
with
270 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
*.prj | ||
.lsp | ||
.lsp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
\name{read_database} | ||
\alias{read_database} | ||
\alias{tidy_data.eds_database} | ||
\title{ | ||
read_database | ||
} | ||
\description{ | ||
Returns the data sets for the given reference - agencyid:id(version), as a list, or as a tidy \emph{data.table}. A collection of data sets in \emph{econdatar} is referred to as a database. Tidying can be done directly within \code{read_database()}, or ex-post using \code{tidy_data()}. | ||
} | ||
\usage{ | ||
read_database(id, include_series = FALSE, tidy = FALSE, \dots) | ||
|
||
\method{tidy_data}{eds_database}(x, \dots) | ||
} | ||
\arguments{ | ||
\item{id}{Data set identifier. May be \code{"all"}} | ||
\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}).} | ||
\item{x}{A raw API return object to be tidied. Can also be done directly in \code{read_database()} by setting \code{tidy = TRUE}}. | ||
|
||
\item{\dots}{Further \emph{Optional} arguments: | ||
\tabular{llll}{ | ||
\code{agencyid} \tab\tab character. Defaults to \code{ECONDATA}. Agency responsible for the metadata creation/maintenance. \cr | ||
\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 | ||
\code{username} \tab\tab character. Web username. \cr | ||
\code{password} \tab\tab character. Web password. \cr | ||
} | ||
} | ||
|
||
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}.} | ||
} | ||
\details{ | ||
An EconData account (http://econdata.co.za) is required to use this function. The user must provide their credentials either through the function arguments, or by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "username;password", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="username;password")}. If credentials are not supplied by the aforementioned methods a GUI dialog will prompt the user for credentials. | ||
} | ||
\value{ | ||
%% ~Describe the value returned | ||
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. | ||
If \code{tidy = TRUE} a single \emph{data.table} is returned with columns for \code{"agencyid"}, \code{"id"}, \code{"version"}, \code{"name"}, and \code{"description"}. | ||
%% \item{comp1 }{Description of 'comp1'} | ||
%% \item{comp2 }{Description of 'comp2'} | ||
%% ... | ||
} | ||
\seealso{ | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
\code{\link{write_database}} | ||
} | ||
\examples{ | ||
\dontrun{ | ||
# library(econdatar) | ||
# Sys.setenv(ECONDATA_CREDENTIALS="username;password") | ||
# Mining production and sales | ||
MINING <- read_database(id = "MINING") | ||
# Include previous versions | ||
MINING <- read_database(id = "MINING", versions = "all") | ||
# Return series without obervations (empty data set) | ||
MINING <- read_database(id = "MINING", include_series = TRUE) | ||
# Return all data sets (useful for browsing available data) | ||
MINING <- read_database(id = "all") | ||
tidy_data(MINING) | ||
} | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory. | ||
\keyword{ load }% use one of RShowDoc("KEYWORDS") | ||
\keyword{ download }% __ONLY ONE__ keyword per line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
\name{read_registry} | ||
\alias{read_registry} | ||
\alias{tidy_data.eds_registry} | ||
\title{ | ||
read_registry | ||
} | ||
\description{ | ||
Returns the data for the given registry structure - agencyid:id(version). | ||
} | ||
\usage{ | ||
read_registry(structure, tidy = FALSE, \dots) | ||
|
||
\method{tidy_data}{eds_registry}(x, \dots) | ||
} | ||
\arguments{ | ||
\item{structure}{structure type. One of \code{category-scheme}, \code{codelist}, \code{concept-scheme}, \code{dataflow}, \code{data-structure}, \code{memberlist}, \code{consumption-agreement}, or \code{provision-agreement}} | ||
\item{x}{A raw API return object to be tidied. Can also be done directly in \code{read_registry()} by setting \code{tidy = TRUE}. See \code{tidy} below for tidying options.} | ||
|
||
\item{\dots}{Further \emph{Optional} arguments: | ||
\tabular{llll}{ | ||
\code{agencyid} \tab\tab character. Defaults to \code{ECONDATA}. Agency responsible for the metadata creation/maintenance. \cr | ||
\code{version} \tab\tab character. Version(s) of the data (different versions will have different metadata), or 'all' to return all available versions. \cr | ||
\code{file} \tab\tab character. File name for retrieving structures stored as JSON data from disk (output of \code{read_registry()}). \cr | ||
\code{username} \tab\tab character. Web username. \cr | ||
\code{password} \tab\tab character. Web password. \cr | ||
} | ||
} | ||
|
||
\item{tidy}{logical. Return data and metadata in tidy \emph{data.table}'s (see Value), by passing the result through \code{tidy_data}. Currently not used. | ||
} | ||
} | ||
\details{ | ||
An EconData account (http://econdata.co.za) is required to use this function. The user must provide their credentials either through the function arguments, or by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "username;password", e.g. \code{Sys.setenv(ECONDATA_CREDENTIALS="username;password")}. If credentials are not supplied by the aforementioned methods a GUI dialog will prompt the user for credentials. | ||
} | ||
\value{ | ||
%% ~Describe the value returned | ||
If \code{tidy = FALSE}, a list detailing at a minimum the structure's agencyid, id, version, name, and description, as well as a data.frame with rows containing the data of any child structures. | ||
|
||
%% \item{comp1 }{Description of 'comp1'} | ||
%% \item{comp2 }{Description of 'comp2'} | ||
%% ... | ||
} | ||
|
||
\seealso{ | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
\code{\link{write_registry}} | ||
} | ||
\examples{ | ||
\dontrun{ | ||
# library(econdatar) | ||
# Sys.setenv(ECONDATA_CREDENTIALS="username;password") | ||
|
||
# Frequency codelist | ||
CL_FREQ <- read_registry("codelist", id = "CL_FREQ") | ||
} | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory. | ||
\keyword{ load }% use one of RShowDoc("KEYWORDS") | ||
\keyword{ download }% __ONLY ONE__ keyword per line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
\name{write_database} | ||
\alias{write_database} | ||
\title{ | ||
write_database | ||
} | ||
\description{ | ||
Create or update a data set (metadata including series and their metadata). | ||
} | ||
\usage{ | ||
write_database(x, method = "update", \dots) | ||
} | ||
\arguments{ | ||
\item{x}{Data set to upload.} | ||
\item{method}{Desired method. One of \code{create} or \code{update}. \code{create} will create a new data set with the provided metadata. \code{update} (default) will update an existing data set in the database.} | ||
|
||
\item{\dots}{Further \emph{Optional} arguments: | ||
\tabular{llll}{ | ||
\code{file} \tab\tab character. File name for saving data set as JSON data to disk. \cr | ||
\code{username} \tab\tab character. EconData username. \cr | ||
\code{password} \tab\tab character. EconData password. \cr | ||
} | ||
} | ||
} | ||
\details{ | ||
An EconData account (http://econdata.co.za) is required to use this function. The user must provide their credentials either through the function arguments, or by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "username;password". If credentials are not supplied by the aforementioned methods a GUI dialog will prompt the user for credentials. | ||
|
||
The functionality provided by \emph{write_database} is to save the data set according to the function arguments. As this makes modifications to the database the user calling this function requires higher privileges than needed for other \emph{econdatar} functions - the user requires \emph{membership} with the relevant data provider. | ||
} | ||
|
||
%% ~Make other sections like Warning with \section{Warning }{....} ~ | ||
|
||
\seealso{ | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
\code{\link{read_database}} | ||
} | ||
\examples{ | ||
\dontrun{ | ||
x <- read_database("MINING") | ||
|
||
write_database(x) | ||
} | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory. | ||
\keyword{ save }% use one of RShowDoc("KEYWORDS") | ||
\keyword{ upload }% __ONLY ONE__ keyword per line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.