These functions are aimed at developers who wish to extend causal_tbl
functionality.
Usage
causal_cols(data)
causal_cols(data) <- value
set_causal_cols(data, ...)
add_causal_col(data, what, ..., ptype = NULL)
get_causal_col(data, what)
Arguments
- data
A causal_tbl.
- value
New value for
causal_cols
.- ...
Named attributes to add to
data
's causal attributes.- what
The causal column to get or add.
- ptype
A type to coerce a single added column to.
Functions
causal_cols(data) <- value
: Setcausal_cols
set_causal_cols()
: Set column(s) for acausal_col
add_causal_col()
: Add a single column to acausal_col
get_causal_col()
: Get the column name of the requested variable
Examples
data <- data.frame(
milk_first = c(0, 1, 0, 1, 1, 0, 0, 1),
guess = c(0, 1, 0, 1, 1, 0, 0, 1)
) |>
set_causal_cols(outcomes=guess, treatments=c(guess=milk_first))
print(data)
#> # A <causal_tbl> [8 × 2]
#> [trt] [out]
#> milk_first guess
#> <dbl> <dbl>
#> 1 0 0
#> 2 1 1
#> 3 0 0
#> 4 1 1
#> 5 1 1
#> 6 0 0
#> 7 0 0
#> 8 1 1
get_causal_col(data, "treatments")
#> guess
#> "milk_first"
get_causal_col(data, "outcomes")
#> [1] "guess"
causal_cols(data)
#> $outcomes
#> [1] "guess"
#>
#> $treatments
#> guess
#> "milk_first"
#>