| title | format |
|---|---|
Merging R objects like dictionaries in R |
html |
Let's explore how to merge lists, enviroments or vectors like dictionaries in R.
pak::pak(c(
"purrr",
| title | format |
|---|---|
Merging R objects like dictionaries in R |
html |
Let's explore how to merge lists, enviroments or vectors like dictionaries in R.
pak::pak(c(
"purrr",
| --- | |
| title: "Create and search image embeddings using torch, mobilenet v3, rchroma and R" | |
| --- | |
| Prepare torch, and mobilenet v3 embeddings. | |
| ```{r} | |
| if (!rlang::is_installed("torch")) { | |
| # https://torch.mlverse.org/docs/articles/installation#pre-built | |
| options(timeout = 90000) |
| { | |
| "lib": { | |
| "prefix": "lib", | |
| "body": "library(${1:package})", | |
| "description": "Attach an R package" | |
| }, | |
| "src": { | |
| "prefix": "src", | |
| "body": "source(\"${1:file.R}\")", | |
| "description": "Source an R file" |
| library(purrr) | |
| # The intial information | |
| elements <- tibble::tribble( | |
| ~key , ~values , | |
| "Barbie" , "shoes" , | |
| "Oppenheimer" , "history" | |
| ) | |
| # Aditional values we want to proces |
| library(rextendr) | |
| library(mirai) | |
| rextendr::rust_source( | |
| file = "rust/xymatch_loop.rs", | |
| module = "xymatch_loop", | |
| profile = "release" | |
| ) | |
| rextendr::rust_source( | |
| file = "rust/xymatch_binary.rs", | |
| module = "xymatch_binary", |
| library(S7) | |
| ScalarDouble <- new_class("ScalarDouble", | |
| properties = list(value = class_double), | |
| constructor = function(value) { | |
| stopifnot(is.double(value), length(value) == 1) | |
| new_object(ScalarDouble, value = value) | |
| } | |
| ) |
| stopifnot(requireNamespace("rlang")) | |
| rlang::check_installed("pak") | |
| pkgs <- rlang::chr( | |
| "tidymodels", | |
| "marginaleffects", | |
| "parameters", | |
| "modelbased", | |
| "dplyr", | |
| "stringr", | |
| "tibble", |
| stopifnot(requireNamespace("rlang")) | |
| rlang::check_installed("pak") | |
| pkgs <- rlang::chr( | |
| "rlang" = "rlang", | |
| "plumber2" = "posit-dev/plumber2", | |
| "S7", | |
| "jsonlite", | |
| "httr2", | |
| "mirai", |
# Cocktails example by Hadley in 2021: Video https://youtu.be/kHFmtKCI_F4?si=HC4S3B-RI_l96sU4&t=1810 | Code: https://gist.github.com/hadley/a892ff8f00973e3bc864851deae8315f
# Added: New version using the replace_values function.
# Installing the new branch with the new feature
pak::pak("tidyverse/dplyr@feature/case-family")
#> ℹ Loading metadata database
#> ✔ Loading metadata database ... done
#>
#>