Make biplot using ggplot.

Principal Component Analysis (PCA) is a statistical procedure that uses an orthogonal transformation to convert a set of observations of possibly correlated variables into set of values of linearly un correlated variables. (from wiki)
R can preform PCA very simple command “prcomp”.
The result can visualise using biplot function.
ggplot2 is a plotting system for R, it can make very rich graphs using simple command.
I want to draw biplot using ggplot2, and found good package “ggbiplot”.
If you interested in that, you can install following command :-).
From R command prompt.

install.packages("devtools")  # also need install ggplot2
install_github("ggbiplot", "vqv")

OK, let’s draw biplot

> library("ggbiplot")
> data(wine)
> wine.pca <- prcomp(wine,scale.=TRUE)
> g<-ggbiplot(wine.pca, obs.scale=1, var.scale=1, groups=wine.class, ellipse=TRUE, circle=TRUE)
> g<-g+scale_color_discrete(name="")
> g<-opts(legend.discription="horiz",legend.posion="top")
Error: 'opts' is deprecated. Use 'theme' instead. (Defunct; last used in version 0.9.1) # opps! I got error
> print(g)

I got biplot.

Good job!

statistics in python

T-test uses a statistical examination of two population means.
To perform t-test in python, scipy package is good tool to do that.
For example
I have data, that collected two times.
1st time [54.3, 55.2, 55.0, 56.4, 53.1, 53.1]
2nd time [56.5, 54.8, 58.2, 57.8, 59.0, 60.7]
Is there the difference in means of two data ?
in python…

import scipy.stats as stats
a = [54.3, 55.2, 55.0, 56.4, 53.1, 53.1]
b = [56.5, 54.8, 58.2, 57.8, 59.0, 60.7]
res = stats.ttest_rel(a,b)

res has two data, 1. t-value, 2. provability. Like this.

In [10]: stats.ttest_rel(a,b)
Out[10]: (array(-2.7458856580188598), 0.040507701177115191)

Easy to do it. ;-)