This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
data <- iris %>% filter(Species != "setosa") %>% | |
select(Petal.Width, Sepal.Length, Species) %>% | |
sample_frac(1) | |
ggplot(data, aes(Petal.Width, Sepal.Length)) + | |
geom_point(aes(color = Species), size=4) + xlab("") + ylab("") + | |
scale_x_continuous(label=NULL) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rvest) | |
qiita_get_organization_member <- function(organization) { | |
target_url <- str_glue("https://qiita.com/organizations/{organization}/members") | |
sess <- html_session(target_url) | |
member_ids <- c() | |
while (!is.null(sess)) { | |
ids <- sess %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(DT) | |
library(sparkline) | |
library(tidyverse) | |
ui <- fluidPage( | |
titlePanel("Sparkline in DT"), | |
sidebarLayout(NULL, | |
mainPanel( | |
dataTableOutput("table_with_sparkline") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
head.mcmc <- function(x, n = 6L, ...) { | |
mcpar <- attr(x, "mcpar") | |
start <- mcpar[1] | |
max_end <- mcpar[2] | |
thin <- mcpar[3] | |
niter <- nrow(x) | |
end <- start + niter - 1 | |
attr(x, "mcpar")[2:3] <- c(end, 1) | |
out <- window(x, end = min(start + n - 1, end)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(purrr) | |
library(furrr) | |
plan(multiprocess) | |
x <- iris$Sepal.Length | |
n_cores <- parallel::detectCores() - 1 | |
N <- length(x) | |
k <- ceiling(N / n_cores) | |
split_factor <- gl(n_cores, k) %>% head(N) | |
x_list <- split(x, split_factor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iter_index_matrix <- function(dims, chunk_size = 1L) { | |
f_split <- cumprod(dims) <= chunk_size | |
has_next <- TRUE | |
if (all(f_split)) { | |
next_element <- function() { | |
if (!has_next) stop("StopIteration") | |
has_next <<- FALSE | |
expand.grid(lapply(dims, seq_len)) | |
} | |
} else { |
OlderNewer