te_datastore_duckdb, functions and methods
Source:R/te_datastore_duckdb.R
te_datastore_duckdb-class.Rd
This method is used internally by expand_trials to save the data to the "datastore" defined in set_expansion_options.
Usage
# S4 method for class 'te_datastore_duckdb'
save_expanded_data(object, data)
# S4 method for class 'te_datastore_duckdb'
read_expanded_data(object, period = NULL, subset_condition = NULL)
# S4 method for class 'te_datastore_duckdb'
sample_expanded_data(
object,
p_control,
period = NULL,
subset_condition = NULL,
seed
)
Arguments
- object
An object of class te_datastore or a child class.
- data
A data frame containing the expanded trial data. The columns
trial_period
andid
are present, which may be used in methods to save the data in an optimal way, such as with indexes, keys or separate files.- period
An integerish vector of non-zero length to select trial period(s) or
NULL
(default) to select all files.- subset_condition
A string of length 1 or
NULL
(default).- p_control
Probability of selecting a control.
- seed
An integer seed or
NULL
(default).
Slots
path
Path to the duckdb file containing the data.
table
.
con
S4 object of class duckdb_connection.
Examples
temp_dir <- tempfile("csv_dir_")
dir.create(temp_dir)
datastore <- save_to_csv(temp_dir)
data(vignette_switch_data)
save_expanded_data(datastore, vignette_switch_data[1:200, ])
#> A TE Datastore CSV object
#> N: 200 observations
#> Periods: 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
#> Path: /tmp/RtmpRXqWy2/csv_dir_1721a0f6247
#> Columns: id, trial_period, followup_time, outcome, weight, treatment, catvarA, catvarB, catvarC, nvarA, nvarB, nvarC, assigned_treatment
# delete after use
unlink(temp_dir, recursive = TRUE)