add get/set inst environment variables
continuous-integration/drone/push Build is passing Details

This allows the internal instrument to be handled as a regular
environment object. It can be saved, exported, directly modified (not
recommended), whatever.
This commit is contained in:
Brian Albert Monroe 2020-07-31 14:41:11 +02:00
parent 76ad9b7659
commit 8b9215d9c0
Signed by: bam
GPG Key ID: ACB52939BF87F222
5 changed files with 48 additions and 2 deletions

View File

@ -1,6 +1,6 @@
Package: rcgen
Title: Generate Chocies for Popular Experimental Economics Instruments
Version: 0.12.3
Version: 0.13.0
Authors@R: person("Brian", "Monroe", email = "brianalbertmonroe@gmail.com", role = c("aut", "cre"))
Description: Generates chocies from popular experimental economics instruments. This package makes simulated data that can then be used to test various estimation techniques.
Depends:
@ -11,4 +11,4 @@ Encoding: UTF-8
LazyData: true
Imports:
rcest
RoxygenNote: 7.0.2
RoxygenNote: 7.1.1

View File

@ -4,4 +4,6 @@ export(avail_inst)
export(gen_choice)
export(gen_inst)
export(get_inst)
export(get_instenv)
export(set_inst)
export(set_instenv)

View File

@ -42,3 +42,22 @@ get_inst <- function(names) {
avail_inst <- function() {
ls(envir = premade_inst_env)
}
#' @title Get the Private Inst Environment
#'
#' @export get_instenv
get_instenv <- function() {
return(premade_inst_env)
}
#' @title Set the Private Inst Environment
#'
#' @param instenv the environment containing premade insts
#' @export set_instenv
set_instenv <- function(instenv) {
# remove everything from the environment
rm(list = ls(envir = premade_inst_env), envir = premade_inst_env)
for (e in ls(envir = instenv)) {
assign(e, instenv[[e]], envir = premade_inst_env)
}
}

11
man/get_instenv.Rd Normal file
View File

@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/inst_set.R
\name{get_instenv}
\alias{get_instenv}
\title{Get the Private Inst Environment}
\usage{
get_instenv()
}
\description{
Get the Private Inst Environment
}

14
man/set_instenv.Rd Normal file
View File

@ -0,0 +1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/inst_set.R
\name{set_instenv}
\alias{set_instenv}
\title{Set the Private Inst Environment}
\usage{
set_instenv(instenv)
}
\arguments{
\item{instenv}{the environment containing premade insts}
}
\description{
Set the Private Inst Environment
}