Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Nov 4, 2024
1 parent 2946f9f commit b05a281
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 6 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ knitr::opts_chunk$set(
# rdantic

<!-- badges: start -->
[![R-CMD-check](https://github.com/eodaGmbH/rdantic/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eodaGmbH/rdantic/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check](https://github.com/eoda-dev/rdantic/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eoda-dev/rdantic/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of rdantic is to add type safety to your R code.
Expand All @@ -42,7 +42,10 @@ my_model <- base_model(
b = is_integer
)
my_model(a = 2L, b = 4L)
(m <- my_model(a = 2L, b = 4L))
try(m$a <- 10.5)
try(my_model(a = 2L, b = 4.5))
# Functions
Expand All @@ -59,7 +62,7 @@ try(f(5L, c(3L, 4L)))
# Data frames
df <- data.frame(
id = 1:3L,
id = 1:3,
letter = letters[1:3]
)
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!-- badges: start -->

[![R-CMD-check](https://github.com/eodaGmbH/rdantic/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eodaGmbH/rdantic/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check](https://github.com/eoda-dev/rdantic/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eoda-dev/rdantic/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of rdantic is to add type safety to your R code.
Expand All @@ -32,7 +32,7 @@ my_model <- base_model(
b = is_integer
)

my_model(a = 2L, b = 4L)
(m <- my_model(a = 2L, b = 4L))
#> $a
#> [1] 2
#>
Expand All @@ -41,6 +41,16 @@ my_model(a = 2L, b = 4L)
```

``` r

try(m$a <- 10.5)
#> Error in check_assignment(x, name, value) : Type check failed.
#> {
#> .Call(ffi_is_integer, x, n)
#> }
```

``` r

try(my_model(a = 2L, b = 4.5))
#> Error in my_model(a = 2L, b = 4.5) : Type check(s) failed
#> # ---
Expand Down Expand Up @@ -85,7 +95,7 @@ try(f(5L, c(3L, 4L)))

# Data frames
df <- data.frame(
id = 1:3L,
id = 1:3,
letter = letters[1:3]
)

Expand Down

0 comments on commit b05a281

Please sign in to comment.