Last data update: 2014.03.03

R: Get variable groups of reduced results.
getResultVarsR Documentation

Get variable groups of reduced results.

Description

Useful helper for e.g. package plyr and such.

Usage

getResultVars(data, type = "group")

Arguments

data

[ReducedResultsExperiments]
Result data.frame from reduceResultsExperiments.

type

[character(1)]
Can be “prob” (prob + pars), “prob.pars” (only problem pars), “algo” (algo + pars), “algo.pars” (only algo pars), “group” (prob + problem pars + algo + algo pars), “result” (result column names). Default is “group”.

Value

[character]. Names of of columns.

Examples

reg = makeExperimentRegistry("BatchExample", seed = 123, file.dir = tempfile())
addProblem(reg, "p1", static = 1)
addProblem(reg, "p2", static = 2)
addAlgorithm(reg, id = "a1",
  fun = function(static, dynamic, alpha) c(y = static*alpha))
addAlgorithm(reg, id = "a2",
  fun = function(static, dynamic, alpha, beta) c(y = static*alpha+beta))
ad1 = makeDesign("a1", exhaustive = list(alpha = 1:2))
ad2 = makeDesign("a2", exhaustive = list(alpha = 1:2, beta = 5:6))
addExperiments(reg, algo.designs = list(ad1, ad2), repls = 2)
submitJobs(reg)
data = reduceResultsExperiments(reg)
library(plyr)
ddply(data, getResultVars(data, "group"), summarise, mean_y = mean(y))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BatchExperiments)
Loading required package: BatchJobs
Loading required package: BBmisc
Sourcing configuration file: '/home/ddbj/local/lib64/R/library/BatchJobs/etc/BatchJobs_global_config.R'
BatchJobs configuration:
  cluster functions: Interactive
  mail.from: 
  mail.to: 
  mail.start: none
  mail.done: none
  mail.error: none
  default.resources: 
  debug: FALSE
  raise.warnings: FALSE
  staged.queries: TRUE
  max.concurrent.jobs: Inf
  fs.timeout: NA

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BatchExperiments/getResultVars.Rd_%03d_medium.png", width=480, height=480)
> ### Name: getResultVars
> ### Title: Get variable groups of reduced results.
> ### Aliases: getResultVars
> 
> ### ** Examples
> 
> reg = makeExperimentRegistry("BatchExample", seed = 123, file.dir = tempfile())
Creating dir: /tmp/RtmpXmViiM/file39a65deb5214
Saving registry: /tmp/RtmpXmViiM/file39a65deb5214/registry.RData
> addProblem(reg, "p1", static = 1)
Writing problem files: /tmp/RtmpXmViiM/file39a65deb5214/problems/p1_static.RData, /tmp/RtmpXmViiM/file39a65deb5214/problems/p1_dynamic.RData
> addProblem(reg, "p2", static = 2)
Writing problem files: /tmp/RtmpXmViiM/file39a65deb5214/problems/p2_static.RData, /tmp/RtmpXmViiM/file39a65deb5214/problems/p2_dynamic.RData
> addAlgorithm(reg, id = "a1",
+   fun = function(static, dynamic, alpha) c(y = static*alpha))
Writing algorithm file: /tmp/RtmpXmViiM/file39a65deb5214/algorithms/a1.RData
> addAlgorithm(reg, id = "a2",
+   fun = function(static, dynamic, alpha, beta) c(y = static*alpha+beta))
Writing algorithm file: /tmp/RtmpXmViiM/file39a65deb5214/algorithms/a2.RData
> ad1 = makeDesign("a1", exhaustive = list(alpha = 1:2))
> ad2 = makeDesign("a2", exhaustive = list(alpha = 1:2, beta = 5:6))
> addExperiments(reg, algo.designs = list(ad1, ad2), repls = 2)
Adding 12 experiments / 24 jobs to DB.
> submitJobs(reg)
Saving conf: /tmp/RtmpXmViiM/file39a65deb5214/conf.RData
Submitting 24 chunks / 24 jobs.
Cluster functions: Interactive.
Auto-mailer settings: start=none, done=none, error=none.
Writing 24 R scripts...
 SubmitJobs |+                                                |   0% (00:00:00) SubmitJobs |+                                                |   0% (00:00:00) SubmitJobs |++                                               |   4% (00:00:00) SubmitJobs |++++                                             |   8% (00:00:00) SubmitJobs |++++++                                           |  12% (00:00:00) SubmitJobs |++++++++                                         |  17% (00:00:00) SubmitJobs |++++++++++                                       |  21% (00:00:03) SubmitJobs |++++++++++++                                     |  25% (00:00:03) SubmitJobs |++++++++++++++                                   |  29% (00:00:02) SubmitJobs |++++++++++++++++                                 |  33% (00:00:02) SubmitJobs |++++++++++++++++++                               |  38% (00:00:01) SubmitJobs |++++++++++++++++++++                             |  42% (00:00:01) SubmitJobs |++++++++++++++++++++++                           |  46% (00:00:01) SubmitJobs |++++++++++++++++++++++++                         |  50% (00:00:02) SubmitJobs |+++++++++++++++++++++++++++                      |  54% (00:00:01) SubmitJobs |+++++++++++++++++++++++++++++                    |  58% (00:00:01) SubmitJobs |+++++++++++++++++++++++++++++++                  |  62% (00:00:01) SubmitJobs |+++++++++++++++++++++++++++++++++                |  67% (00:00:01) SubmitJobs |+++++++++++++++++++++++++++++++++++              |  71% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++            |  75% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++++          |  79% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++++++        |  83% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++++++++      |  88% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++++++++++    |  92% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++++++++++++  |  96% (00:00:00) SubmitJobs |+++++++++++++++++++++++++++++++++++++++++++++++++| 100% (00:00:00)
Sending 24 submit messages...
Might take some time, do not interrupt this!
> data = reduceResultsExperiments(reg)
Syncing registry ...
Reducing 24 results...
 reduceResultsExperiments |+                                  |   0% (00:00:00) reduceResultsExperiments |+++++++++++++++++++++++++++++++++++| 100% (00:00:00)
> library(plyr)
> ddply(data, getResultVars(data, "group"), summarise, mean_y = mean(y))
   prob algo alpha beta mean_y
1    p1   a1     1   NA      1
2    p1   a1     2   NA      2
3    p1   a2     1    5      6
4    p1   a2     1    6      7
5    p1   a2     2    5      7
6    p1   a2     2    6      8
7    p2   a1     1   NA      2
8    p2   a1     2   NA      4
9    p2   a2     1    5      7
10   p2   a2     1    6      8
11   p2   a2     2    5      9
12   p2   a2     2    6     10
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>