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
@yutannihilation
yutannihilation / dev_version_testthat_result.txt
Created July 5, 2020 14:06
Test result of ggplot2 with the dev version of testthat
==> devtools::test()
Loading ggplot2
Testing ggplot2
✓ | OK F W S | Context
✓ | 1 | Adding plot elements
✓ | 17 | test-aes-calculated.r
✓ | 11 | Aesthetics (grouping) [0.4 s]
✓ | 10 | Aes - setting values [0.6 s]
✓ | 45 | Creating aesthetic mappings [1.3 s]
@yutannihilation
yutannihilation / Are_mutate_and_summarise_different.md
Created June 27, 2020 23:22
Are mutate() and summarise() different?
library(dplyr, warn.conflicts = FALSE)

g <- starwars %>%
  select(name, mass, species) %>%
  group_by(species)

# usual usage of mutate()
d1 <- g %>% 
  mutate(mass_norm = mass / mean(mass, na.rm = TRUE))

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     
sudo pacman -S libutf8proc
cd cpp
mkdir build
cd build
ARROW_BUILD_TOOLCHAIN=/usr ORC_HOME=/usr DOUBLE_CONVERSION_HOME=/usr cmake \
.. -DARROW_DEPENDENCY_SOURCE=SYSTEM \
-DARROW_PYTHON=ON \
-DCMAKE_BUILD_TYPE=Release \
library(estatapi)
#> このサービスは、政府統計総合窓口(e-Stat)のAPI機能を使用していますが、サービスの内容は国によって保証されたものではありません。
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)

d <- estat_getStatsData(appId = keyring::key_get("estatapi"), statsDataId = "0003368797")
#> Fetching record 1-2120... (total: 2120 records)

d %&gt;% 
library(readr)

bad_df1 <- readr::read_csv("a,b\n1,2\n-,2", col_types = "nn")
#> Warning: 1 parsing failure.
#> row col expected actual         file
#>   2   a a number      - literal data
bad_df2 <- readr::read_csv("a,b\n1,2\n2,-", col_types = "nn")
#> Warning: 1 parsing failure.
#&gt; row col expected actual file
library(httr)

delika_new_jwt <- function() {
  # TODO
  browseURL("https://api.delika.io/v1/auth/token")
}

delika_verb <- function(verb, path, ...) {
  secret <- jsonlite::fromJSON("~/.delika/token.json")
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Moved to: https://github.com/yutannihilation/covid19-tokyo-daily-de-facto-population
library(chromote)

Sys.setenv(CHROMOTE_CHROME="/usr/bin/chromium")

b <- ChromoteSession$new()
b$Page$navigate("https://www.instagram.com/")
#> $frameId
#> [1] "7A4B060856C628A9F30A449F9F443F42"
#&gt; 
library(ggplot2)
library(rlang)

ggplot <- function(...) {
  f <- function(...) list(clone = f)
  structure(
    list(
      call = sys.call()
 ),