Title: | R Interface to 'Redatam' Library |
Version: | 1.1.4 |
Maintainer: | Jaime Salvador <jaime.salvador@ideasybits.com> |
Description: | Provides an API to work with 'Redatam' (see https://redatam.org) databases in both formats: 'RXDB' (new format) and 'DICX' (old format) and running 'Redatam' programs written in 'SPC' language. It's a wrapper around 'Redatam' core and provides functions to open/close a database (redatam_open()/redatam_close()), list entities and variables from the database (redatam_entities(), redatam_variables()) and execute a 'SPC' program and gets the results as data frames (redatam_query(), redatam_run()). |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | yes |
LinkingTo: | cpp11 |
SystemRequirements: | 'Redatam' runtime engine (see https://redatam.org), The dynamic binary library is downloaded from <https://redatam-core.s3.us-west-2.amazonaws.com> during the build step. Currently supported platforms are Windows, Linux and macOS. |
Copyright: | See COPYRIGHTS for details. |
URL: | https://ideasybits.github.io/redatamx4r/, https://github.com/ideasybits/redatamx4r/ |
BugReports: | https://github.com/ideasybits/redatamx4r/issues |
Config/Needs/website: | rmarkdown |
Packaged: | 2025-06-09 15:58:08 UTC; jsalvador2024 |
Author: | Jaime Salvador |
Repository: | CRAN |
Date/Publication: | 2025-06-09 21:30:02 UTC |
redatamx: R Interface to 'Redatam' Library
Description
Provides an API to work with 'Redatam' (see https://redatam.org) databases in both formats: 'RXDB' (new format) and 'DICX' (old format) and running 'Redatam' programs written in 'SPC' language. It's a wrapper around 'Redatam' core and provides functions to open/close a database (redatam_open()/redatam_close()), list entities and variables from the database (redatam_entities(), redatam_variables()) and execute a 'SPC' program and gets the results as data frames (redatam_query(), redatam_run()).
Author(s)
Maintainer: Jaime Salvador jaime.salvador@ideasybits.com (ORCID)
Other contributors:
CELADE [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/ideasybits/redatamx4r/issues
Environment for Outputs Tables
Description
This environment is created to store the outputs generated by a Redatam program execution. The environment contains TABLES (Redatam outputs) generated from FREQ, AREALIST, MATOP, TABLIST commands. You can't modify objects contained in this environment.
Usage
outputs
Format
An object of class environment
of length 0.
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
df<-redatam_query(dic,"tbl1<-freq person.sexo")
# Accessing the tbl1 object from environment
redatamx::outputs$tbl1
# Accessing the output from Global Environment
print(df)
## End(Not run)
Close dictionary
Description
Close a REDATAM database.
Usage
redatam_close(dic)
Arguments
dic |
Dictionary identifier (returned by redatam_open()) |
Value
No return value.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
# run some queries using 'redatam_query' or 'redatam_run'
# close de dictionary
redatam_close(dic);
## End(Not run)
Create Redatam database
Description
Create a new Redatam database.
Usage
redatam_create(schema_name, config_name)
Arguments
schema_name |
Dictionary schema in json format |
config_name |
Configuration in json format |
Value
No return value.
Author(s)
Jaime Salvador
Examples
## Not run:
redatam_create("path/to/schema.json","path/to/config.json")
## End(Not run)
Destroy engine
Description
Destroy the Redatam engine. This function is automatically called when the package is unloaded.
Usage
redatam_destroy_()
Value
No return value.
Author(s)
Jaime Salvador
Examples
## Not run:
redatam_destroy_();
## End(Not run)
List entities
Description
List the entities in a databse.
Usage
redatam_entities(dic)
Arguments
dic |
Dictionary identifier (returned by redatam_open()) |
Value
Data frame that contains all the entities in the database.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
redatam_entities(dic);
## End(Not run)
Get extended Redatam API information
Description
Returns extended information about datasources and datasets available.
Usage
redatam_info()
Value
String with the Redatam extended information.
Author(s)
Jaime Salvador
Examples
redatam_info()
Initialize engine
Description
Initialize the Redatam engine. This function is automatically called when the package is loaded.
Usage
redatam_init_(pachageDir)
Arguments
pachageDir |
Relative path to Redatam runtime (dll, so or dynlib) |
Value
No return value.
Author(s)
Jaime Salvador
Examples
## Not run:
redatam_init_("/engine");
## End(Not run)
Execute a Redatam command from text
Description
Execute a Redatam command: TABLE or AREALIST.
Usage
redatam_internal_query(dic, spc)
Arguments
dic |
Dictionary identifier (returned by redatam_open()) |
spc |
Program text in SPC format |
Value
Raw dataset with al values: tot, na, mv, values.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
df<-redatam_internal_query(dic,"freq person.sexo")
## End(Not run)
Execute a Redatam command from file
Description
Execute a Redatam command: TABLE or AREALIST.
Usage
redatam_internal_run(dic, file_name)
Arguments
dic |
Dictionary identifier (returned by redatam_open()) |
file_name |
Program file name |
Value
Raw dataset with all values: tot, na, mv, values.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam.open("path/to/rxdb")
df<-redatam.internal_run(dic,"/path/to/program.spc")
## End(Not run)
Load a custom plugin
Description
Load a custom plugin into internal registry. This function is used to add a custom plugin that implements a data source (to create database from custom format) or data set (to save outputs in custom format).
Usage
redatam_load_plugin(filePath)
Arguments
filePath |
Full path to .dll (windows), .so (linux) or .dynlib (macOs) |
Value
no return.
Author(s)
Jaime Salvador
Examples
## Not run:
redatam_load_plugin("path/to/custom/plugin")
## End(Not run)
Open dictionary
Description
Open a REDATAM database. This function returns an ID than can be used in functions to query data.
Usage
redatam_open(dictionary_name)
Arguments
dictionary_name |
Dictionary file name |
Value
ID than can be used in functions to query data.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
## End(Not run)
Execute a Redatam command from text
Description
Execute a Redatam command: TABLE or AREALIST. This function removes all the rows that contain total, na or mv values. Additionally, this function removes the "mask" columns.
Usage
redatam_query(dic, spc, tot.omit = TRUE)
Arguments
dic |
Dictionary identifier |
spc |
Program text in SPC format |
tot.omit |
Omit rows containing total, na y mv values |
Value
If the program contains more than one table, the method returns the last table (in the SPC program) as a data frame. All the tables are registered (as data frames) in a custom environment called ‘redatam::outputs’.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
df<-redatam_query(dic,"freq person.sexo")
print(df)
## End(Not run)
Execute a Redatam command from file
Description
Execute a Redatam command: TABLE or AREALIST. This function removes all the rows that contain total, na or mv values. Additionally, this function removes the "mask" columns.
Usage
redatam_run(dic, file_name, tot.omit = TRUE)
Arguments
dic |
Dictionary identifier |
file_name |
Program file name |
tot.omit |
Omit rows containing total, na y mv values |
Value
If the program contains more than one table, the method returns the last table (in the SPC program) as a data frame. All the tables are registered (as data frames) in a custom environment called ‘redatam::outputs’.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
df<-redatam_run(dic,"/path/to/nmir_test.spc")
print(df)
## End(Not run)
Save dictionary
Description
Save a REDATAM database. This function can be used to save a dictionary.
Usage
redatam_save(dic, name = "")
Arguments
dic |
Dictionary identifier (returned by redatam_open()) |
name |
Dictionary file name |
Value
No return value.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
...
redatam_save(dic,"path/to/new/dictionary.rxdb")
## End(Not run)
List variables for entity
Description
List the variables in an entity.
Usage
redatam_variables(dic, entity_name)
Arguments
dic |
Dictionary identifier (returned by redatam_open()) |
entity_name |
Entity's name |
Value
Data frame that contains all the variables from the ‘entity_name’.
Author(s)
Jaime Salvador
Examples
## Not run:
dic<-redatam_open("path/to/rxdb")
redatam_variables(dic, "person")
## End(Not run)
Get the Redatam API version
Description
Returns the current version of the native Redatam API.
Usage
redatam_version()
Value
String with the Redatam Engine version.
Author(s)
Jaime Salvador
Examples
redatam_version()