The graph, I have down. The challenge is I have the _exact_same_code_ for graphing multiple data sets (rather, subsets of one LARGE data set), but I can't seem to get the looping code right to substitute the $ correctly.
Data sets, df1, df2, df3... of the form:
OBSDATE REGION AVG_RESP P10 P90
2012-02-01 APAC 1.276 0.78 3.45
2012-02-01 EMEA 2.341 1.23 5.67
2012-02-02 APAC 1.343 0.89 3.21
2012-02-02 EMEA 2.473 1.37 5.98
The graph is more complex, but like this:
avgMx <- quantile(df1$P90,0.95)
ggplot(df1,aes(x=OBSDATE,y=AVG_RESP))+coord_cartesian(ylim=c(0,avgMx))+geom_ribbon(aes(ymin=P10,ymax=P90),fill="gray60",alpha=0.33)+geom_line(aes(x=OBSDATE,y=AVG_RESP),color="#007DB1",size=0.5)+facet_wrap(~REGION)
if I define a vector or list (both seem to fail with the same error messages) with the data set names I can't get the loop to work to find any descriptive values (like the quantile above or even a max!)
filenames <- c("df1","df2","df3")
I would like to get something like this to work
for (i in filenames) {
quantile(i$AVG_RESP,0.95)
max(i$AVG_RESP)
}
But I get errors about $ is invalid for atomic vectors. Upon investigation, that doesn't seem to yield any usable results.
So, I can get this to work:
max(df1$AVG_RESP) or max(df1['AVG_RESP'])
they both would output 2.473 from above. However, this doesn't fly:
for (i in pagesC) max(i['AVG_RESP'])
It does nothing. Changing it to this:
for (i in pagesC) print(max(i['AVG_RESP']))
Gives instances of NA.
I'm completely stuck. Any help would be tremendously appreciated!
EDIT: I fixed the data that was causing errors - should be reproducible now.