Skip to content

Instantly share code, notes, and snippets.

View yutannihilation's full-sized avatar
🍣
Nobody loves you

Hiroaki Yutani yutannihilation

🍣
Nobody loves you
View GitHub Profile
library(string2path)
library(ggplot2)
d <- string2path("?", "/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-BoldItalic.ttf")
f <- function(d, theta) {
d <- dplyr::mutate(d, x = x + 0.02 * cos(theta * 3.2), y = y + 0.02 * sin(theta * 2.1))
d2 <- dplyr::bind_rows(
@yutannihilation
yutannihilation / current.md
Last active September 20, 2021 00:48
Check the behaviours around manual scales (current.md: the current dev version, pr4619.md: https://github.com/tidyverse/ggplot2/pull/4619)
library(tidyverse)
library(patchwork)

excel_file <- tempfile(fileext = ".xlsx")
curl::curl_download("https://www.fukushihoken.metro.tokyo.lg.jp/iryo/kansen/kensa/kensuu.files/syousaisenryakukensa.xlsx", excel_file)

d_raw <- readxl::read_excel(excel_file, skip = 2)
d_raw
#> # A tibble: 18 × 4

(Draft) extendr's conversion specs and semantics

Scope of this document

To implement a Rust function for R with extendr, users can choose to use either (or both) of the following:

  1. Rust types (e.g. i32, and &str)
  2. Proxy types (e.g. Integer, and Character)

For Rust types, we need to consider how to handle the case where the types are incompatible between R and Rust.

Based on the example code on https://www.tidymodels.org/learn/models/parsnip-nnet/

library(tidymodels)
#> ─ Attaching packages ──────────────────────────────────────────── tidymodels 0.1.0 ─
#> ✓ broom     0.5.6          ✓ recipes   0.1.12    
#> ✓ dials     0.0.6          ✓ rsample   0.0.6     
#> ✓ dplyr     0.8.5          ✓ tibble    3.0.1     
#> ✓ ggplot2   3.3.0.9000     ✓ tune      0.1.0     
#> ✓ infer     0.5.1          ✓ workflows 0.1.1     
@yutannihilation
yutannihilation / grafana-playbook.yml
Last active March 12, 2021 13:39
Ansible Playbook to install Grafana
---
- hosts: HOST
vars:
grafana_version: 2.5.0
arch: amd64
grafana_filename: grafana_{{ grafana_version }}_{{ arch }}.deb
tasks:
- name: Verify version
command: dpkg-query -W --showformat='${version}' grafana
library(stringr)
library(ggplot2)
library(rr4r)

ptn <- r"([\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?)"
url <- "https://mail.google.com/mail/u/0/"

res1 <- bench::press(
 x = c(1, 1e3, 1e5),
Rcpp::cppFunction('
void foo() {
// works fine if I change the pattern to one without []
std::regex reg("[0-9]");
}
', includes = "#include <regex>")
# works
Sys.setlocale("LC_ALL", 'English')
foo()
PS C:\Users\...\Documents\tmp> C:\rtools40\mingw64\bin\g++ -std=gnu++11 -O3 .\main.cpp
PS C:\Users\...\Documents\tmp> .\a.exe
PS C:\Users\...\Documents\tmp>