# Data input
> x<-c(28,27,30,32,29,32,33,27,23,22,26,20)
> y<-c(29,37,34,37,29,28,33,36,33,32,26,31)
# Data output
> x
[1] 28 27 30 32 29 32 33 27 23 22 26 20
> y
[1] 29 37 34 37 29 28 33 36 33 32 26 31
# Calculate means
> mean(x)
[1] 27.41667
> mean(y)
[1] 32.08333
# Put x and y data into "Osaka" and "Tokyo", respectively
> Osaka<-mean(x)
> Tokyo<-mean(y)
# Make data column
> b<-c(Osaka, Tokyo)
# Bar-plot with names.
> barplot(b, names=c("Osaka", "Tokyo"))
# Calcurate SD
> sd(x)
[1] 4.144182
> sd(y)
[1] 3.604501
# Make SD column
sdxy<-c(sd(x), sd(y))
# Calculate max and minimum of bar
> (ci.l<-b+sdxy)
[1] 31.56085 35.68783
> (ci.u<-b-sdxy)
[1] 23.27248 28.47883
# Put error bar
# * gplots package is required to make a graph with error bar.
> install.packages("gplots")
# Open "gplots" pakage
> library(gplots)
# Draw graph with error bar (SD)
> barplot2(b, beside=TRUE, names=c("Osaka", "Tokyo"), ylim = c(0,40), plot.ci=TRUE, ci.l=ci.l, ci.u=ci.u, plot.grid=TRUE)
# Calcurate SE
> sex=sd(x)/sqrt(length(x))
> sey=sd(y)/sqrt(length(y))
# SE output
> sex
[1] 1.196322
> sey
[1] 1.040530
# Make SE column
sexy<-c(sex, sey)
# Confirm SE column
> sexy
[1] 1.196322 1.040530
# Calculate max and minimum of bar (SE)
> (ci.l<-b+sexy)
[1] 28.61299 33.12386
> (ci.u<-b-sexy)
[1] 26.22034 31.04280
# Open "gplots" pakage
> library(gplots)
# Draw graph with error bar (SD)
> barplot2(b, beside=TRUE, names=c("Osaka", "Tokyo"), ylim = c(0,40), plot.ci=TRUE, ci.l=ci.l, ci.u=ci.u, plot.grid=TRUE)