Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.
Become a Premium Member and unlock a new, free course in leading technologies each month.
# ------- bar plot for STD, 95%CI and SEM ------
a <- c(25, 30, 34, 38, 43, 43, 46, 46, 49, 49, 52, 52, 55, 55, 58, 58, 62, 64,
66, 75)
b <- c(5, 5, 35, 44, 44, 47, 51, 55, 55, 58, 58, 62, 64, 64, 67, 67, 71, 74,
79, 85)
## Convert data vectors to dataframes
adf <- data.frame(Group = " Group A ", Measure = a)
bdf <- data.frame(Group = " Group B ", Measure = b)
## Combine into a dataframe using rbind
abData <- rbind(adf, bdf)
attach(abData)
tmp = split(Measure, Group)
means = sapply(tmp, mean)
medians = sapply(tmp, median)
stdev = sapply(tmp, sd)
# to calculate SE
require(sciplot)
se = sapply(tmp, se)
n <- sapply(tmp, length)
ciw <- qt(0.975, n) * stdev / sqrt(n)
# to make the 3 graphs in one row...
# however they actually don't look nice :-(
# maybe by controlling the "ylim" part things get better
par(mfrow=c(1,3))
# typeface set to Serif (or Times)
par(family="serif")
# ----- bar plot with SD
require(gplots)
plotCI(barcol="blue", pch=16, col="blue", barplot(means, col=c("white",
"gray90"),
ylim=c(0,max(means + stdev)), xlab = "Error bars: ±1SD", ylab="Measure")
, means, stdev,
add=TRUE)
# --------- bar plot with 95%CI
plotCI(barcol="red", pch=16, col="red", barplot(means, col=c("white", "grey90"),
ylim=c(0,max(means + ciw)), xlab = "Error bars: 95% CI", ylab="Measure"),
means, uiw=ciw,
add=TRUE)
justearth-data-ee.xls
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
df <- read.csv("justearth-data-ee.txt",sep="\t",dec = ",",header=TRUE,as.is=TRUE)
df$scape.f <- as.factor( df$scape )
df$Pri_No.f <- as.factor( df$Pri_No )
df$scape.Pri_No.f <- as.factor( paste(df$scape,df$Pri_No,sep="_" ) )
df.result <- data.frame( bbED.mean = tapply( df$bbED, df$scape.Pri_No.f, function(x){mean(x)} ) )
df.result$bbED.sd <- tapply( df$bbED, df$scape.Pri_No.f, function(x){sd(x)} )
require(sciplot)
df.result$bbED.se <- tapply( df$bbED, df$scape.Pri_No.f, function(x){se(x)} )
df.result$scape <- tapply( df$scape, df$scape.Pri_No.f, function(x){x[1]})
df.result$Pri_No <- tapply( df$Pri_No, df$scape.Pri_No.f, function(x){x[1]})
means <- df.result$bbED.mean[which(df.result$scape==2&df.result$Pri_No<=2)]
stdev <- df.result$bbED.sd[which(df.result$scape==2&df.result$Pri_No<=2)]
xlabel <- c("",rownames(df.result$bbED.mean[which(df.result$scape==2&df.result$Pri_No<=2)]),"")
require(gplots)
plotCI(x=means,uiw=stdev,ylab="mean",xlab="scape_Pri_No",xlim=c(0,3),xaxt="n")
axis(side=1,at=0:3,labels=xlabel)
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.