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_tutorial10.Rproj b/Biocomp_tutorial10.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/Biocomp_tutorial10.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/Exercise08.R b/Exercise08.R new file mode 100644 index 0000000..ed4554d --- /dev/null +++ b/Exercise08.R @@ -0,0 +1,41 @@ +#Question 1 +#Read the table of scores +Scores<-read.table(file="UWvMSU_1-22-13.txt",header=TRUE,stringsAsFactors = FALSE) +GameSummary<-data.frame(matrix(ncol=3, nrow =50)) +x<-c("time","UWscore", "MSUscore") +colnames(GameSummary)=x +GameSummary$time=Scores$time +sumMSU<-0 +sumUW<-0 +for (i in 1:nrow(Scores)) { + if(Scores[i,2]=="UW"){ + sumUW<-sumUW+Scores$score[i] + GameSummary[i,2]=sumUW + GameSummary[i,3]=sumMSU + }else if(Scores[i,2]=="MSU"){ + sumMSU<-sumMSU+Scores$score[i] + GameSummary[i,2]=sumUW + GameSummary[i,3]=sumMSU + } +} +x<-GameSummary$time +y<-GameSummary$UWscore +z<-GameSummary$MSUscore +plot(x,y, type = 'l', col= "Red", xlab = "Time", ylab = "Score", main = "Game Summary") +lines(x,z, type = 'l', col= "Green") + +#Question 2 +w<-sample(1:100,1) +for (i in 1:10) { + print("Guess My Number:") + t<-strtoi(readline()) + if(w>t){ + print("Higher") + }else if(w