diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/Biocomp_tutorial11.Rproj b/Biocomp_tutorial11.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/Biocomp_tutorial11.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/Exercise9.R b/Exercise9.R new file mode 100644 index 0000000..791d373 --- /dev/null +++ b/Exercise9.R @@ -0,0 +1,29 @@ +#Where x is a specified column in the files in dir +path=("~/Desktop/Dir") +DirFiles=list.files(path=path, pattern="*.csv") +for (i in 1:DirFiles) { + read.csv(i,header=TRUE,stringsAsFactors = FALSE, sep = ",") +} +varianceFunction<-function(dir,x){ + CoefVector<-vector() + a=0 + b=0 + for (i in dir) { + if(i[,x]<50){ + print("Warning! Less than 50 columns. If you wish to continue, type Yes") + if (readline()=="Yes"){ + a<-mean(i[,x]) + b<-sd(i[,x]) + varianceCoef=b/a + append(CoefVector, varianceCoef, after=length(CoefVector)) + }else{ + break + } + }else{ + a<-mean(i[,x]) + b<-sd(i[,x]) + varianceCoef=b/a + append(CoefVector, varianceCoef, after=length(CoefVector)) + } + } + }