This function converts a data.frame or a tibble into a safeframe
object, where data are tagged and validated. The output will seem to be the
same data.frame, but safeframe-aware packages will then be able to
automatically use tagged fields for further data cleaning and analysis.
Arguments
- .data
a
data.frameor atibble- ...
<
dynamic-dots> A series of tags provided astag_name = "column_name"
See also
An overview of the safeframe package
tags(): for a list of tagged variables in asafeframeset_tags(): for modifying tagstags_df(): for selecting variables by tags
Examples
x <- make_safeframe(cars,
mph = "speed",
distance = "dist"
)
## print result - just first few entries
head(x)
#>
#> // safeframe object
#> speed dist
#> 1 4 2
#> 2 4 10
#> 3 7 4
#> 4 7 22
#> 5 8 16
#> 6 9 10
#>
#> tagged variables:
#> mph - speed
#> distance - dist
## check tags
tags(x)
#> $mph
#> [1] "speed"
#>
#> $distance
#> [1] "dist"
#>
## tags can also be passed as a list with the splice operator (!!!)
my_tags <- list(
mph = "speed",
distance = "dist"
)
new_x <- make_safeframe(cars, !!!my_tags)
## The output is strictly equivalent to the previous one
identical(x, new_x)
#> [1] TRUE