Categories
status

Slopegraph in R Slopegraph shows the change of…

slopegraph

Slopegraph in R. Slopegraph shows the change of the quantity or rank.

Beautiful slopegraph example. http://www.drewconway.com/zia/

Theory of slopegraph. http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk

An R and ggplot2 code example of slopegraph https://github.com/leondutoit/slopegraph/blob/master/slopegraph.

R Example code.

Generate sample data

a <- data.frame(go = LETTERS[1:10], enrich = runif(10, 0, 10))
b <- data.frame(go = LETTERS[1:10], enrich = runif(10, 0, 10))
a <- cbind(a, status ='before')

b <- cbind(b, status = 'after')
ab.melt <- rbind(a, b)

Add an offset column for label positioning

ab.melt <- transform(ab.melt, offset = c(rep(2, times = 10), rep(-2, times = 10)))

library(ggplot2)
ggplot(data = ab.melt, aes(x = status, y = enrich)) + geom_line(aes(group = go, colour = go)) + geom_text(aes(label = go, hjust = offset, colour = factor(go)))
Categories
status

R function matching a function argument against candidate…

R function matching a function argument against candidate values.

match.arg(arg, choices, several.ok = FALSE)

arg = match.arg(arg)
Categories
status

How to rank data in R rank a…

How to rank data in R.

rank(a)

Then how to rank the data in reverse order?

rand(-a)
Categories
status

Vim folding tips zf create a manual fold…

Vim folding tips.
zf: create a manual fold
zd: remove a manual fold
zM: overview
zR: detail
zo: open fold
zc: close fold

:mkview save fold
:loadview load fold

http://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun

Categories
status

View very large images http zoom it

View very large images.

http://zoom.it/

Categories
status

Select random contents from a file Sort sort…

Select random contents from a file

Sort

sort -R infile | head -n 3000

Perl

perl -n -e 'print if (rand > 0.1)' infile
Categories
status

Process multiple files in a directory by Makefile…

Process multiple files in a directory by Makefile.

SOURCES := $(wildcard *_conversion.txt)
TARGETS := $(patsubst %_conversion.txt, %_uniq.txt, $(SOURCES))

.PHONY: all
all: $(TARGETS)

%_uniq.txt: %_conversion.txt
>    command $< > $@

Categories
status

scatter plot equivalent to pairs by ggplot http…

scatter plot equivalent to pairs() by ggplot.

http://stackoverflow.com/questions/3735286/pairs-equivalent-in-ggplot2

Hadley recommends using the GGally package instead. It has a function, ggpairs that is a vastly improved pairs plot (lets you use non-continuous variables in your data frames). It plots different plots in each square, depending on the variable types:

Categories
status

Probability density function in R http www cyclismo…

Probability density function in R

http://www.cyclismo.org/tutorial/R/probability.html

Chi square goodness-of-fit test in R
http://ww2.coastal.edu/kingw/statistics/R-tutorials/goodness.html

Chi square independence test in R
http://ww2.coastal.edu/kingw/statistics/R-tutorials/independ.html

ANOVA in R
http://personality-project.org/r/r.anova.html

Categories
status

Use Inkscape as a command line tool to…

Use Inkscape as a command line tool to batch convert svg to pdf files.

ls *svg | xargs -I{} inkscape -z -f {} -A {}.pdf