-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmedsums.R
More file actions
29 lines (19 loc) · 751 Bytes
/
Copy pathmedsums.R
File metadata and controls
29 lines (19 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
gettotals <- function(data, sortby="Country") {
totalcount <- with(data, tapply(TotalAdj, list(Country.Name, GameType), sum))
dim(totalcount)
totalcount <- data.frame(lapply(1:2, function(i) totalcount[,i]))
colnames(totalcount) <- c("summer.medcount", "winter.medcount")
totalcount["Country.Name"] <- rownames(totalcount)
totalcount <- totalcount[c(3,1,2)]
row.names(totalcount) <- NULL
if(sortby == "Summer") {
totalcount <- totalcount[with(totalcount, order(-totalcount[,2])),]
}
if(sortby == "Winter") {
totalcount <- totalcount[with(totalcount, order(-totalcount[,3])),]
}
if(sortby == "Country") {
}
print(head(totalcount))
assign('totalcount',totalcount,envir=.GlobalEnv)
}