Open kingo55 opened 9 years ago
It's a great idea. When all of the batch problems existed, I built a function that does something similar.
getdata <- function(dateTF){
dateSequence <- seq(from = as.Date(startDate, "%Y-%m-%d"), to = as.Date(endDate,"%Y-%m-%d"), by = "day")
dateSequenceLength <- length(dateSequence)
outputList <<- vector("list", dateSequenceLength)
for (i in 1:length(dateSequence)){
print(paste("Pulling observations for date ",dateSequence[i]," (Day ",i,"/",dateSequenceLength,")",sep=""),quote=FALSE)
outputTemp <- try(ga$getData(
profile,
batch = TRUE,
walk = FALSE,
dateSequence[i],
dateSequence[i],
dimensions = dimensionsInput,
metrics = metricsInput,
segment = segmentIDInput,
sort = sortInput,
filters = filtersInput,
start = 1))
numObs <- nrow(outputTemp)
if (!(is.null(numObs))){
if(dateTF){outputTemp <- cbind(date=dateSequence[i],outputTemp)}
outputList[[i]] <<- outputTemp
message(paste("Received: ",numObs," observation(s) for date ",dateSequence[i]," (Day ",i,"/",dateSequenceLength,")",sep=""))
}
}
return(rbindlist(outputList))
}
With input:
startDate <- ""
endDate <- ""
dimensionsInput <- ""
metricsInput <- ""
segmentIDInput <- ""
filtersInput <- ""
sortInput <- ""
And call getdata(TRUE)
to prepend each row with the observation date, or getdata(FALSE)
to do the standard day-by-day walk without any date.
Now that the batch error is fixed, this is really only useful for when you've used all 7 dimension slots, but still need ga:date included.
OR you could do it the right way and just edit the getDataInWalks
function as you described haha.
Hi guys,
Rather than extracting ga:date as a dimension in a query, @jdeboer had an excellent idea with his plugin to include date in the output of a Walk query. That allows you to extract more dimensions when date is inferred by the parameters of the walk function.
Would it be as simple as the following change?