Created
April 30, 2015 00:18
-
-
Save saptarshiguha/456a99a631aa2aaf48c2 to your computer and use it in GitHub Desktop.
Tagging Days with Version Infomation
This file contains 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
tagDaysByVersion <- function(d){ | |
## takes $data$days and returns a modified data$days | |
## with versioninfo attached as a field | |
## i've not done much error checking with this | |
## if you get errors notify me | |
if(length(d$data$days)==0) return(d$data$days) | |
days <- d$data$days [ order(names(d$data$days)) ] | |
dates <- names(days) | |
dversion <- rep(NA, length(dates)) | |
iversion <- NA | |
verupdate <- rep(FALSE,length(dates)) | |
for(i in 1:length(dates)){ | |
vs <- days[[i]]$org.mozilla.appInfo.versions | |
if(is.null(vs$appVersion)){ | |
dversion[i] <- iversion | |
}else{ | |
iversion <- dversion[i] <- max(vs$appVersion) ## there can be several on a day | |
verupdate[i] <- TRUE | |
} | |
} | |
## If alll of dversion is NA, there was never an update | |
## Force them to be equal to gecko values | |
if(all(is.na(dversion))) dversion <- rep(d$geckoAppInfo$platformVersion, length(dates)) | |
days <- mapply(function(dc, dv, vu){ | |
dc$versioninfo <- list(version=dv,vup=vu) | |
dc | |
}, days, dversion,verupdate, SIMPLIFY=FALSE) | |
return(days) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment