Instantly share code, notes, and snippets.

Embed
What would you like to do?
cs_476_data_script.r
library(readr)
data <- read_csv("data.csv",
col_types = cols(date = col_datetime(format = "%FT%T")))
# costs <- read_csv("Cloud Provider Costs - Sheet1.csv")
normz <- function(column) { ( column - mean(column) ) / sd(column) }
# data <- merge(data, costs)
data[,c("nginx")] <- normz(getElement(data,"nginx"))
data[,c("sha256sum")] <- normz(getElement(data,"sha256sum"))
data[,c("sysbench/memory")] <- normz(getElement(data,"sysbench/memory"))
data[,c("sysbench/cpu")] <- normz(getElement(data,"sysbench/cpu"))
data[,c("sorting")] <- normz(getElement(data,"sorting"))
data[,c("ffmpeg")] <- normz(getElement(data,"ffmpeg"))
data$hour = as.double(format(data$date, "%H"))
data$weekday = format(data$date, "%A")
data$total = rowMeans(data[,3:8])
aggregate(data, by=list(name=data$name), FUN=mean)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment