From 0317876a3772e4708f89e519e2579795470b3506 Mon Sep 17 00:00:00 2001 From: Patrick Brown Date: Fri, 12 Nov 2021 01:22:11 -0500 Subject: [PATCH] Exercise 8 Submit--Pat Brown --- .gitignore | 4 ++++ Biocomp_tutorial10.Rproj | 13 +++++++++++++ Exercise08.R | 41 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .gitignore create mode 100644 Biocomp_tutorial10.Rproj create mode 100644 Exercise08.R 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