Clone an stobject

st_clone(x)

Arguments

x

an stobject object.

Value

A copy (y) of x such that y can be modified without modifying x.

Examples

x <- st_new(stdata())
y <- st_clone(x)

y$data$STUDY <- NULL
x$data
#> # A tibble: 13 × 9
#>    STUDY       DOSE   FORM    N     WT    CRCL  AGE   ALB   SCR  
#>    <chr>       <chr>  <chr>   <chr> <chr> <chr> <chr> <chr> <chr>
#>  1 12-DEMO-001 100 mg tablet  80    71.4  104   33.7  4.20  1.06 
#>  2 12-DEMO-001 150 mg capsule 16    89.4  122   24.4  4.63  1.12 
#>  3 12-DEMO-001 150 mg tablet  48    81.7  104   34.4  3.83  0.910
#>  4 12-DEMO-001 150 mg troche  16    94.0  93.2  27.4  4.94  1.25 
#>  5 12-DEMO-001 200 mg tablet  64    67.9  100   27.5  4.25  1.10 
#>  6 12-DEMO-001 200 mg troche  16    76.6  99.2  22.8  4.54  1.15 
#>  7 12-DEMO-002 100 mg capsule 36    61.3  113   38.3  4.04  1.28 
#>  8 12-DEMO-002 100 mg tablet  324   77.6  106   29.9  4.31  0.981
#>  9 12-DEMO-002 50 mg  capsule 36    74.1  112   37.1  4.44  0.900
#> 10 12-DEMO-002 50 mg  tablet  324   71.2  106   34.1  4.63  0.868
#> 11 12-DEMO-002 75 mg  capsule 36    72.4  105   38.2  3.89  0.900
#> 12 12-DEMO-002 75 mg  tablet  288   71.6  98.9  34.2  4.49  0.991
#> 13 12-DEMO-002 75 mg  troche  36    73.6  103   49.2  4.52  0.930
y$data
#> # A tibble: 13 × 8
#>    DOSE   FORM    N     WT    CRCL  AGE   ALB   SCR  
#>    <chr>  <chr>   <chr> <chr> <chr> <chr> <chr> <chr>
#>  1 100 mg tablet  80    71.4  104   33.7  4.20  1.06 
#>  2 150 mg capsule 16    89.4  122   24.4  4.63  1.12 
#>  3 150 mg tablet  48    81.7  104   34.4  3.83  0.910
#>  4 150 mg troche  16    94.0  93.2  27.4  4.94  1.25 
#>  5 200 mg tablet  64    67.9  100   27.5  4.25  1.10 
#>  6 200 mg troche  16    76.6  99.2  22.8  4.54  1.15 
#>  7 100 mg capsule 36    61.3  113   38.3  4.04  1.28 
#>  8 100 mg tablet  324   77.6  106   29.9  4.31  0.981
#>  9 50 mg  capsule 36    74.1  112   37.1  4.44  0.900
#> 10 50 mg  tablet  324   71.2  106   34.1  4.63  0.868
#> 11 75 mg  capsule 36    72.4  105   38.2  3.89  0.900
#> 12 75 mg  tablet  288   71.6  98.9  34.2  4.49  0.991
#> 13 75 mg  troche  36    73.6  103   49.2  4.52  0.930

# Get back to a regular environment
class(x) <- "environment"
class(y) <- "environment"

x
#> <environment: 0x55afc7116108>
#> attr(,"argnames")
#>  [1] "data"               "panel"              "notes"             
#>  [4] "align"              "r_file"             "output_file"       
#>  [7] "output_dir"         "span"               "span_split"        
#> [10] "cols_rename"        "cols_blank"         "sumrows"           
#> [13] "note_config"        "clear_reps"         "clear_grouped_reps"
#> [16] "hline_at"           "hline_from"         "sizes"             
#> [19] "units"              "drop"               "lt_cap_text"       
#> [22] "lt_cap_macro"       "lt_cap_label"       "lt_cap_short"      
#> [25] "lt_continue"        "caption"            "path.type"         
#> [28] "args"              
y
#> <environment: 0x55afc6e2a410>
#> attr(,"argnames")
#>  [1] "data"               "panel"              "notes"             
#>  [4] "align"              "r_file"             "output_file"       
#>  [7] "output_dir"         "span"               "span_split"        
#> [10] "cols_rename"        "cols_blank"         "sumrows"           
#> [13] "note_config"        "clear_reps"         "clear_grouped_reps"
#> [16] "hline_at"           "hline_from"         "sizes"             
#> [19] "units"              "drop"               "lt_cap_text"       
#> [22] "lt_cap_macro"       "lt_cap_label"       "lt_cap_short"      
#> [25] "lt_continue"        "caption"            "path.type"         
#> [28] "args"