diff --git a/articles/intro-to-interface.html b/articles/intro-to-interface.html index 41b93a4..11870f8 100644 --- a/articles/intro-to-interface.html +++ b/articles/intro-to-interface.html @@ -214,7 +214,7 @@

Nested Interfaces and Extend #> scores: Science #> scores: 95 #> scores: 88 -#> scholarship: <environment: 0x556bea032330> +#> scholarship: <environment: 0x5582316c42d8> #> street: 123 Main St #> city: Small town #> postal_code: 12345 @@ -327,8 +327,8 @@

Using Enums in Interfaces start_time = 10, duration = 1 )) -#> Error in validator(value) : -#> Invalid value. Must be one of: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday +#> Error : Errors occurred during interface creation: +#> - Invalid enum value for property 'day': Invalid value. Must be one of: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday

In-place Enum Declaration in Interfaces @@ -446,23 +446,22 @@

Typed data.frame/data.ta ) print(persons) -#> Typed data frame with the following properties: -#> Number of rows: 3 -#> Number of columns: 4 -#> Column types: -#> id: function (length = 0L) -#> id: .Internal(vector("integer", length)) -#> name: function (length = 0L) -#> name: .Internal(vector("character", length)) -#> age: function (length = 0L) -#> age: .Internal(vector("double", length)) -#> is_student: function (length = 0L) -#> is_student: .Internal(vector("logical", length)) -#> Freeze columns: Yes -#> Allow NA: Yes -#> On violation: error +#> Typed Data Frame Summary: +#> Base Frame Type: data.frame +#> Dimensions: 3 rows x 4 columns +#> +#> Column Specifications: +#> id : integer +#> name : character +#> age : numeric +#> is_student : logical #> -#> Data: +#> Frame Properties: +#> Freeze columns : Yes +#> Allow NA : Yes +#> On violation : error +#> +#> Data Preview: #> id name age is_student #> 1 1 Alice 25 TRUE #> 2 2 Bob 30 FALSE @@ -470,7 +469,8 @@

Typed data.frame/data.ta # Invalid modification (throws error) try(persons$id <- letters[1:3]) -#> Error : Property 'id' must be of type integer

+#> Error in `$<-.typed_frame`(`*tmp*`, id, value = c("a", "b", "c")) : +#> object 'col_name' not found

Additional Options

@@ -482,7 +482,7 @@

Additional Options= character, age = numeric, is_student = logical, - email = function(x) all(grepl("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", x)) + email = function(x) all(grepl("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", x)) # functions are applied to whole column ), freeze_n_cols = FALSE, row_callback = function(row) { @@ -507,51 +507,35 @@

Additional Options) print(df) -#> Typed data frame with the following properties: -#> Number of rows: 3 -#> Number of columns: 5 -#> Column types: -#> id: function (length = 0L) -#> id: .Internal(vector("integer", length)) -#> name: function (length = 0L) -#> name: .Internal(vector("character", length)) -#> age: function (length = 0L) -#> age: .Internal(vector("double", length)) -#> is_student: function (length = 0L) -#> is_student: .Internal(vector("logical", length)) -#> email: function (x) -#> email: all(grepl("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", -#> email: x)) -#> Freeze columns: No -#> Allow NA: No -#> On violation: error +#> Typed Data Frame Summary: +#> Base Frame Type: data.frame +#> Dimensions: 3 rows x 5 columns +#> +#> Column Specifications: +#> id : integer +#> name : character +#> age : numeric +#> is_student : logical +#> email : custom function +#> +#> Frame Properties: +#> Freeze columns : No +#> Allow NA : No +#> On violation : error #> -#> Data: -#> id name age is_student email -#> 1 1 Alice 25 TRUE alice@test.com -#> 2 2 Bob 35 FALSE bob_no_valid@test.com -#> 3 3 Charlie 35 TRUE charlie@example.com +#> Data Preview: +#> id name age is_student email +#> 1 1 TRUE 1 TRUE TRUE +#> 2 1 TRUE 1 TRUE TRUE +#> 3 1 TRUE 1 TRUE TRUE summary(df) -#> Typed data frame summary: -#> Number of rows: 3 -#> Number of columns: 5 -#> Column types: -#> id: function (length = 0L) -#> id: .Internal(vector("integer", length)) -#> name: function (length = 0L) -#> name: .Internal(vector("character", length)) -#> age: function (length = 0L) -#> age: .Internal(vector("double", length)) -#> is_student: function (length = 0L) -#> is_student: .Internal(vector("logical", length)) -#> email: function (x) -#> email: all(grepl("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", -#> email: x)) -#> Freeze columns: No -#> Allow NA: No -#> On violation: error -#> Validation status: -#> All rows passed validation. +#> id name age is_student email +#> Min. :1 Length:3 Min. :1 Mode:logical Length:3 +#> 1st Qu.:1 Class :character 1st Qu.:1 TRUE:3 Class :character +#> Median :1 Mode :character Median :1 Mode :character +#> Mean :1 Mean :1 +#> 3rd Qu.:1 3rd Qu.:1 +#> Max. :1 Max. :1 # Invalid row addition (throws error) try(rbind(df, data.frame( @@ -562,7 +546,7 @@

Additional Options= "d@test.com" ))) #> Error in rbind(deparse.level, ...) : -#> Row 1 failed validation: Age must be less than 40 (got 500)

+#> All data frames must be typed_frame objects diff --git a/pkgdown.yml b/pkgdown.yml index 31ce153..d78a0db 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: donate: donate.html intro-to-interface: intro-to-interface.html -last_built: 2024-07-28T22:43Z +last_built: 2024-07-29T05:35Z urls: reference: https://dereckmezquita.github.io/interface/reference article: https://dereckmezquita.github.io/interface/articles diff --git a/reference/index.html b/reference/index.html index 170af6f..b874ba0 100644 --- a/reference/index.html +++ b/reference/index.html @@ -153,12 +153,6 @@

All functionssummary(<typed_frame>) - - -
Summary method for typed data frames
-
- type.frame()
@@ -169,6 +163,12 @@

All functionswrap_fun_in_all() + + +
Modify a user-defined function to return a single logical value

diff --git a/reference/type.frame.html b/reference/type.frame.html index b01654e..f00e2de 100644 --- a/reference/type.frame.html +++ b/reference/type.frame.html @@ -119,23 +119,22 @@

Examples) print(persons) -#> Typed data frame with the following properties: -#> Number of rows: 3 -#> Number of columns: 4 -#> Column types: -#> id: function (length = 0L) -#> id: .Internal(vector("integer", length)) -#> name: function (length = 0L) -#> name: .Internal(vector("character", length)) -#> age: function (length = 0L) -#> age: .Internal(vector("double", length)) -#> is_student: function (length = 0L) -#> is_student: .Internal(vector("logical", length)) -#> Freeze columns: Yes -#> Allow NA: Yes -#> On violation: error +#> Typed Data Frame Summary: +#> Base Frame Type: data.frame +#> Dimensions: 3 rows x 4 columns #> -#> Data: +#> Column Specifications: +#> id : integer +#> name : character +#> age : numeric +#> is_student : logical +#> +#> Frame Properties: +#> Freeze columns : Yes +#> Allow NA : Yes +#> On violation : error +#> +#> Data Preview: #> id name age is_student #> 1 1 Alice 25 TRUE #> 2 2 Bob 30 FALSE @@ -143,7 +142,8 @@

Examples # Invalid modification (throws error) try(persons$id <- letters[1:3]) -#> Error : Property 'id' must be of type integer +#> Error in `$<-.typed_frame`(`*tmp*`, id, value = c("a", "b", "c")) : +#> object 'col_name' not found # Adding a column (throws error if freeze_n_cols is TRUE) try(persons$yeet <- letters[1:3]) diff --git a/reference/summary.typed_frame.html b/reference/wrap_fun_in_all.html similarity index 58% rename from reference/summary.typed_frame.html rename to reference/wrap_fun_in_all.html index 2f43711..0ce7b55 100644 --- a/reference/summary.typed_frame.html +++ b/reference/wrap_fun_in_all.html @@ -1,5 +1,11 @@ -Summary method for typed data frames — summary.typed_frame • interface +Modify a user-defined function to return a single logical value — wrap_fun_in_all • interface Skip to contents @@ -35,32 +41,34 @@
-

Provides a summary of the typed data frame, including validation status.

+

Modifies a user-defined function to wrap its body in an all() call, ensuring that it returns a single logical value instead of a vector.

+

It uses bquote() to create a new body for the function. +The .() inside bquote() inserts the original body of the function. +The all() function wraps around the original body.

Usage

-
# S3 method for class 'typed_frame'
-summary(x)
+
wrap_fun_in_all(user_fun)

Arguments

-
x
-

A typed data frame.

+
user_fun
+

A user-defined function.

Value

-

Summary information of the typed data frame.

+

The modified function.