Skip to content

Instantly share code, notes, and snippets.

View kazutan's full-sized avatar
🍺

Kazuhiro Maeda kazutan

🍺
View GitHub Profile
@kazutan
kazutan / ubuntu_setup
Last active August 29, 2015 14:19
ubuntu_setup
$ LANG=C xdg-user-dirs-gtk-update
$ sudo apt-get update
$ sudo apt-get upgrade
$ dconf reset /org/gnome/settings-daemon/plugins/keyboard/active
$ dconf write /org/gnome/desktop/input-sources/xkb-options "['ctrl:swapcaps']"
add repos:
$ sudo vim /etc/apt/sources.list
# lapplyでgeom_segment()を繰り返し記述
p <- ggplot(iris, aes(y=Sepal.Width, x=Species)) +
stat_summary(fun.y=mean, geom = "bar") +
ylim(0,6) +
lapply(1:3, function(i) geom_segment(x=i-0.4, y=7-i, xend=i+0.4, yend=7-i))
p
# あと教えてもらったmapply使ったサンプルコードメモ
q = ggplot(data.frame(x = c(-10, 10)), aes(x)) +
mapply(function(m, s, co) stat_function(fun = dnorm, args = list(mean = m, sd = s), colour = co),
# 台風情報
library("dplyr")
library("rvest")
library("stringr")
library("leaflet")
trg <- html("http://www.jma.go.jp/jp/typh/") %>% html_table
tbl1 <- trg[[4]] # テーブルは4番目以降が台風に関するもので今回は台風15号と16号があるので4を指定
res <- data.frame(
timing = tbl1$X1 %>% str_subset("[0-9][0-9]日[0-9][0-9]時"),
@kazutan
kazutan / dygraphs_xts.r
Created August 27, 2015 02:27
dygraphs_xts
library(dygraphs)
library(xts)
daylab <- seq(as.Date("2010-07-29"), as.Date("2010-8-10"), by="days")
val1 <- runif(length(daylab))
val2 <- runif(length(daylab))
vals <- data.frame(value1 = val1, value2 =val2)
rownames(vals) <- daylab
series <- xts(vals, order.by = daylab, tx="GMT")
dygraph(series)
---
title: "revealjsのテスト"
author: "kazutan"
date: "2015年9月18日"
output:
revealjs::revealjs_presentation:
theme: sky
center: true
css: "test.css"
---
/* for {revealjs} */
.reveal section.slide>h1 {
color: blue;
}
.reveal .progress {
height: 15px;
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS
locale:
[1] LC_CTYPE=ja_JP.UTF-8 LC_NUMERIC=C LC_TIME=ja_JP.UTF-8
[4] LC_COLLATE=ja_JP.UTF-8 LC_MONETARY=ja_JP.UTF-8 LC_MESSAGES=ja_JP.UTF-8
[7] LC_PAPER=ja_JP.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=ja_JP.UTF-8 LC_IDENTIFICATION=C
@kazutan
kazutan / gist:51140da3eda1d6d7ca38
Last active February 1, 2016 05:45
uvtools and kvm
# 以下のリンクを参考にすること
# http://gihyo.jp/admin/serial/01/ubuntu-recipe/0344
# 事前にRSA鍵を作っとく
# uvtoolsのインストール
$ sudo apt install uvtool
# 14.04のイメージダウンロード
# 結構時間かかる
# パッケージ読込
library(dplyr)
library(ggplot2)
# 水準ごとの平均値を算出
xx <- iris %>%
group_by(Species) %>%
summarise(a=mean(Sepal.Width))
# ボックスプロット(ベース)作成
path <- getwd()
write.csv(iris, "iris-tan.csv")
write.csv(iris, "iris-tan2.csv")
write.csv(iris, "iris-tan3.csv")
ss <- list.files(path,pattern = "iris-")
iristan <- data.frame()
for (i in 1:length(ss)) {
d <- read.csv(ss[i])