Skip to contents

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.

Usage

make_safeframe(x, ...)

Arguments

x

a data.frame or a tibble

...

<dynamic-dots> A series of tags provided as tag_name = "column_name"

Value

The function returns a safeframe object.

See also

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