From 6389dc04b507e182fc9e716822028386451c6636 Mon Sep 17 00:00:00 2001 From: avivalund Date: Tue, 29 Nov 2022 17:50:56 -0500 Subject: [PATCH 1/3] some progress --- RScript_Ex10_Lund.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 RScript_Ex10_Lund.R diff --git a/RScript_Ex10_Lund.R b/RScript_Ex10_Lund.R new file mode 100644 index 0000000..a09ff60 --- /dev/null +++ b/RScript_Ex10_Lund.R @@ -0,0 +1,31 @@ +# Set working directory +setwd("/Users/avivalund/Desktop/Biocomputing/Exercise10") + +# Read data and assign to variable +GoBadgers<-read.csv("UWvMSU_1-22-13.txt") + +# make a dataframe with a cumulative score +# for each team whenever either team scores + #isolate one team at a time +grep("UW", team) # how do I isolate a team? +UWisconsin<- data.frame(time, team, score) + + #cumulative score thing -how do i properly do this? + +#isolate one team at a time +grep("MSU", team) # how do I isolate a team? +MSU<- data.frame(time, team, score) + #cumulative score thing -how do i properly do this? + +# load a package every time you wish to use it +library(ggplot2) +library(cowplot) + + +#Make plot without grey background and gridlines + +ggplot(data = GoBadgers, + aes(x = time, y = cumscore)) + + geom_point() + + stat_smooth(method="loess") + + theme_classic() From 98dfa89be4930e47958a63b3873930de37b19ac4 Mon Sep 17 00:00:00 2001 From: avivalund Date: Wed, 30 Nov 2022 13:31:09 -0500 Subject: [PATCH 2/3] some more progress --- RScript_Ex10_Lund.R | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/RScript_Ex10_Lund.R b/RScript_Ex10_Lund.R index a09ff60..ae93b89 100644 --- a/RScript_Ex10_Lund.R +++ b/RScript_Ex10_Lund.R @@ -2,18 +2,34 @@ setwd("/Users/avivalund/Desktop/Biocomputing/Exercise10") # Read data and assign to variable -GoBadgers<-read.csv("UWvMSU_1-22-13.txt") +GoBadgers<-read.table("UWvMSU_1-22-13.txt", header=TRUE) # make a dataframe with a cumulative score # for each team whenever either team scores #isolate one team at a time + +cumUW = c(0) +for(file in 1:nrow(GoBadgers)){ + one_row_data = GoBadgers[file,] + if(one_row_data$team[file] == "UW"){ + currentcumUW = cumUW[file] + one_row_data$score + }else{ + currentcumUW = cumUW[file] + 0 + } + cumUW = c(cumUW, currentcumUW) + +} grep("UW", team) # how do I isolate a team? +df$csum <- ave(time, team, score=cumsum) +#OR UWisconsin<- data.frame(time, team, score) #cumulative score thing -how do i properly do this? #isolate one team at a time grep("MSU", team) # how do I isolate a team? +df$csum <- ave(time, team, score=cumsum) +#OR MSU<- data.frame(time, team, score) #cumulative score thing -how do i properly do this? From 1a2b4a32d483d71593ef90871ba91f724739f4d4 Mon Sep 17 00:00:00 2001 From: avivalund Date: Wed, 30 Nov 2022 14:24:53 -0500 Subject: [PATCH 3/3] done --- RScript_Ex10_Lund.R | 53 +++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/RScript_Ex10_Lund.R b/RScript_Ex10_Lund.R index ae93b89..b7eefca 100644 --- a/RScript_Ex10_Lund.R +++ b/RScript_Ex10_Lund.R @@ -1,3 +1,5 @@ +##Question 1 + # Set working directory setwd("/Users/avivalund/Desktop/Biocomputing/Exercise10") @@ -6,42 +8,55 @@ GoBadgers<-read.table("UWvMSU_1-22-13.txt", header=TRUE) # make a dataframe with a cumulative score # for each team whenever either team scores - #isolate one team at a time +#UW cumUW = c(0) +cumMSU = c(0) for(file in 1:nrow(GoBadgers)){ one_row_data = GoBadgers[file,] - if(one_row_data$team[file] == "UW"){ + if(one_row_data$team == "UW"){ currentcumUW = cumUW[file] + one_row_data$score + currentcumMSU = cumMSU[file] + 0 }else{ + currentcumMSU = cumMSU[file] + one_row_data$score currentcumUW = cumUW[file] + 0 } cumUW = c(cumUW, currentcumUW) + cumMSU = c(cumMSU, currentcumMSU) } -grep("UW", team) # how do I isolate a team? -df$csum <- ave(time, team, score=cumsum) -#OR -UWisconsin<- data.frame(time, team, score) - - #cumulative score thing -how do i properly do this? - -#isolate one team at a time -grep("MSU", team) # how do I isolate a team? -df$csum <- ave(time, team, score=cumsum) -#OR -MSU<- data.frame(time, team, score) - #cumulative score thing -how do i properly do this? # load a package every time you wish to use it library(ggplot2) library(cowplot) +#create a dataframe with adjusted time +basketball <-data.frame(time = c(0, GoBadgers$time), cumUW, cumMSU) #Make plot without grey background and gridlines -ggplot(data = GoBadgers, - aes(x = time, y = cumscore)) + - geom_point() + - stat_smooth(method="loess") + +ggplot(data = basketball, + aes(x = time)) + + geom_line(aes(y=cumUW), color="blue") + + geom_line(aes(y=cumMSU), color="pink") + theme_classic() + + +## Question 2 +randomnumber<-sample(1:100, 1) + +for(file in 1:11){ + if(file==11){ + print("GAME OVER!") + break + } + input=readline(prompt="Guess:") + if(inputrandomnumber){ + print("this is higher than actual value") + } else { + print("Correct!") + break + } +} \ No newline at end of file