Sydney Harris Exercise10 submission#3
Open
sydneyharris wants to merge 2 commits into
Open
Conversation
qtran4
reviewed
Dec 3, 2022
|
|
||
| #creates 2 columns in UW_MSU called UW_Total and MSU_Total with the cumulative sum of each team when a basket is scored regardless of team | ||
| UW_MSU$UW_Total <- c(cumsum(UW_scores)) | ||
| UW_MSU$MSU_Total <- c(cumsum(MSU_scores)) |
Owner
There was a problem hiding this comment.
You can use the for loops for cumulative sum as well. Checking this code:
load table of scoring
scoring=read.table("UWvMSU_1-22-13.txt",header=TRUE,sep="\t",stringsAsFactors=FALSE)
look at data
dim(scoring)
head(scoring)
preallocating matrix to store cumulative scores
cum_scores=matrix(NA,nrow(scoring)+1,3)
cum_scores[,1]=c(0,scoring[,1])
cum_scores[1,2:3]=0
colnames(cum_scores)=c("time","UW","MSU")
looping through individual scoring events
for(i in 1:nrow(scoring)){
if(scoring[i,2]=="UW"){
cum_scores[(i+1),2]=cum_scores[i,2]+scoring[i,3]
cum_scores[(i+1),3]=cum_scores[i,3]
}else{
cum_scores[(i+1),2]=cum_scores[i,2]
cum_scores[(i+1),3]=cum_scores[i,3]+scoring[i,3]
}
}
qtran4
reviewed
Dec 3, 2022
| print(number) | ||
| return('end of game') | ||
| }} | ||
| } |
Owner
There was a problem hiding this comment.
There should be a condition when i > 10 then the console will print out that this is out of guesses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.