This file contains hidden or 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) | |
randomwalk2D <- function(){cbind(x=cumsum(rnorm(100)), y=cumsum(rnorm(100)))} | |
library(foreach) | |
library(doParallel) | |
registerDoParallel(detectCores()) | |
res_df = foreach(i = 1:10, .combine = rbind) %dopar% | |
data.frame(randomwalk2D(), group=LETTERS[i]) | |
This file contains hidden or 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(cowsay) | |
> say("進捗どうですか") | |
----- | |
進捗どうですか | |
------ | |
\ ^__^ | |
\ (oo)\ ________ | |
(__)\ )\ /\ | |
||------w| |
This file contains hidden or 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
#!/bin/bash | |
dir=$(dirname $1) | |
[ "$dir" = "" ] && exit 1 | |
pandoc -f markdown -t html $1 -o $dir/html |
This file contains hidden or 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
RmdFileName=$1 | |
FileName=`basename $1 .Rmd` | |
echo -e "library(knitr) \n purl(\"$RmdFileName\") \n source(\"$FileName.R\")"\ | |
| R --no-save | |
rm $FileName".R" |
This file contains hidden or 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(data.table) | |
library(dplyr) | |
dt1 = data.table(x = 1, y = 1) | |
dt2 = data.table(x = 1, z = 1) | |
dt1 %>% inner_join(dt2, by = "x") | |
# x y z | |
#1 1 1 1 |
This file contains hidden or 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(Rcpp) | |
sourceCpp("timesTwo.cpp") | |
x = matrix(1:9, nrow = 3, ncol= 3) | |
timesTwo(x) |
This file contains hidden or 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
# 関数定義 | |
func = function(hoge){ | |
return(hoge*hoge) | |
} | |
# 1から10までの整数のベクトルに対して関数を適用したい | |
x = 1:10 | |
# 絶対殺す | |
fx = as.numeric() |
This file contains hidden or 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
\documentclass{article} | |
\usepackage[round]{natbib} | |
\usepackage{filecontents} | |
\begin{filecontents}{\jobname.bib} | |
@article {Schimd1993, | |
author = {Schmid, Hans-Peter and McNeal, John E. and Stamey, Thomas A.}, | |
title = {Observations on the doubling time of prostate cancer. The use of serial prostate-specific antigen in patients with untreated disease as a measure of increasing cancer volume}, | |
journal = {Cancer}, | |
volume = {71}, |
This file contains hidden or 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
for dir in `ls | grep [0-9]` | |
do | |
mv $dir"/"*.pdf $dir".pdf" | |
done | |
join.py --output out.pdf *.pdf |
This file contains hidden or 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(data.table) | |
library(dplyr) | |
library(magrittr) | |
makedata = function(year = 2013){ | |
# set the path of data file | |
filename = paste("../../../data/all", year, ".csv", sep="") | |
dat = fread(filename, header=FALSE) | |
colnames = fread("names.csv", header = FALSE) %>% unlist | |
setnames(dat, colnames) |