{"action":"created","issue":{"url":"https://api.github.com/repos/rabutler/RWDataPlot/issues/13","repository_url":"https://api.github.com/repos/rabutler/RWDataPlot","labels_url":"https://api.github.com/repos/rabutler/RWDataPlot/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/rabutler/RWDataPlot/issues/13/comments","events_url":"https://api.github.com/repos/rabutler/RWDataPlot/issues/13/events","html_url":"https://github.com/rabutler/RWDataPlot/issues/13","id":142774085,"number":13,"title":"Propose having an xts array as an output option for RWDataPlot.","user":{"login":"tjrocha","id":8174126,"avatar_url":"https://avatars.githubusercontent.com/u/8174126?v=3","gravatar_id":"","url":"https://api.github.com/users/tjrocha","html_url":"https://github.com/tjrocha","followers_url":"https://api.github.com/users/tjrocha/followers","following_url":"https://api.github.com/users/tjrocha/following{/other_user}","gists_url":"https://api.github.com/users/tjrocha/gists{/gist_id}","starred_url":"https://api.github.com/users/tjrocha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjrocha/subscriptions","organizations_url":"https://api.github.com/users/tjrocha/orgs","repos_url":"https://api.github.com/users/tjrocha/repos","events_url":"https://api.github.com/users/tjrocha/events{/privacy}","received_events_url":"https://api.github.com/users/tjrocha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-22T20:43:07Z","updated_at":"2016-03-23T01:07:14Z","closed_at":null,"body":"Hey Alan! I've found that working with the xts package works really well for rdf outputs. I've implemented it in [this project](https://jrocha.shinyapps.io/rdfModelOutputDashboard/) and it works ok. Having it as an xts object also makes it work out of the box for a lot of graphing and analysis packages.\r\n\r\n``\r\n- library(xts)\r\n- library(zoo)\r\n- library(RWDataPlot)\r\n- rawRDF <- read.rdf(rdfFileName)\r\n- tArray <- rawRDF$runs[[1]]$times\r\n-  # OPERATIONS IN ORDER OF EXECUTION\r\n-  # 1. rdfSlotToMatrix - read data for 'ithSlotName' string given 'rdf' file\r\n-  # 2. cbind - combine datetime and data series arrays\r\n-  # 3. data.frame - define R dataframe for conversion to XTS\r\n-  # 4. read.zoo - convert dataframe to zoo matrix\r\n-  # 5. as.xts - convert zoo matrix to XTS\r\n-  # 6. Storage.mode() - convert char values in the XTS matrix to numeric\r\n- rdf <- as.xts(read.zoo(data.frame(cbind(tArray,rdfSlotToMatrix(rawRDF, \"Mead.Inflow\")))))\r\n- storage.mode(rdf) <- \"numeric\"\r\n\r\n``\r\n\r\nAs an xts object, we can easily perform lots of other functions relatively easier such as getting percentile levels for the entire array via a custom function\r\n\r\n``\r\n-  # DEFINE PERCENTILE VALUES OF INTEREST\r\n-  toPctls <- function(rdfRawData) quantile(rdfRawData, c(.10,.25,.50,.75,.90))\r\n-  # GET PERCENTILE VALUES OF ENTIRE ARRAY BY EOCY\r\n-  eocyPctlXts <- apply.yearly(rdfRawData()[endpoints(rdfRawData(), on=\"years\", k=1)],toPctls)\r\n-  # GET PERCENTILE VALUES OF ENTIRE ARRAY BY MONTH\r\n-  montPctlXts <- apply.monthly(rdfRawData(),toPctls)\r\n\r\n``\r\n\r\nor get an annual sum via the built in mean function\r\n\r\n``\r\n-  # GET CY ANNUAL SUMS BY TRACE \r\n-  annlSumsXts <- apply.yearly(rdfRawData(),mean)*12\r\n\r\n``\r\n\r\nplotting is relatively easy also via a sample graphing library such as DyGraphs\r\n\r\n``\r\n-  library(dygraphs)\r\n-  plotTsRawData <- dygraph(rdf)\r\n\r\n``\r\n\r\nJust wanted to get your opinion on it. I will commit it to my local branch and do a pull request if you think its worthwhile."},"comment":{"url":"https://api.github.com/repos/rabutler/RWDataPlot/issues/comments/200100394","html_url":"https://github.com/rabutler/RWDataPlot/issues/13#issuecomment-200100394","issue_url":"https://api.github.com/repos/rabutler/RWDataPlot/issues/13","id":200100394,"user":{"login":"rabutler","id":7244282,"avatar_url":"https://avatars.githubusercontent.com/u/7244282?v=3","gravatar_id":"","url":"https://api.github.com/users/rabutler","html_url":"https://github.com/rabutler","followers_url":"https://api.github.com/users/rabutler/followers","following_url":"https://api.github.com/users/rabutler/following{/other_user}","gists_url":"https://api.github.com/users/rabutler/gists{/gist_id}","starred_url":"https://api.github.com/users/rabutler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rabutler/subscriptions","organizations_url":"https://api.github.com/users/rabutler/orgs","repos_url":"https://api.github.com/users/rabutler/repos","events_url":"https://api.github.com/users/rabutler/events{/privacy}","received_events_url":"https://api.github.com/users/rabutler/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T01:07:14Z","updated_at":"2016-03-23T01:07:14Z","body":"Hey @tjrocha! This seems like a great idea! Looks like it has the potential to simplify a lot of the code and make it much easier to deal with computations, so I'm all for it. So I'm clear, are you proposing adding a new function, similar to rdfSlotToMatrix? My only concern/preference is that we do it in such a way that any old scripts will still correctly run without having to be modified.\r\n\r\nAlso, I like the results viewer! Looks great!"}}