Example of Error Bars in R – read in data and format for finding CI
# error in distance difference in scans 2 and 3 (both trials):
# normal distribution
# error difference from expected
errorbars1 <- function() (create simple function)
{
library(gplots)
expected1 <- read.csv(file="Hip-phantom-scan-procedure-series-1-2-3a.csv",header=TRUE,sep=",");
phant2 <- read.csv(file="hip_stats2.csv",header=TRUE,sep=",");
phant2a <- read.csv(file="hip_stats2a.csv",header=TRUE,sep=",");
phant3 <- read.csv(file="hip_stats3.csv",header=TRUE,sep=",");
phant3a <- read.csv(file="hip_stats3a.csv",header=TRUE,sep=",");
x1 <- expected1[3:15,9] - phant2[3:15, 20]
x2 <- expected1[3:15,9] - phant2a[3:15, 20]
x3 <- expected1[3:15,9] - phant3[3:15, 20]
x4 <- expected1[3:15,9] - phant3a[3:15, 20]
# First make an x5 that exists as a vector
x5<-c(1:28)
x5[1:7] <- x1[1:7]
x5[8:14] <- x2[1:7]
x5[15:21] <- x3[1:7]
x5[22:28] <- x4[1:7]
print(x5)
Transcript
So what can we do? Okay. So, in this case, we're going to create a function. We load our gplots library; we read the data, then we say here the expected values for our different sets. We do the computations. We now say, "aha!" Now that we have the data in the vector, we can compute these particular portions of it, and we can now print the values that we just put into this data frame. And what do we see?