<!--head
meta:
  title: Analyze Wizard template
  author: Daniel Nagy, Gergely Daróczi
  description: In this template Rapporter will present you an analyzing wizard template, where we will show you the most important statistics between any kind of variables.
  email: ~
  packages: ~
  example:
  - rapport('AnalyzeWizard', data=ius2008, variables = c('edu', 'game'))
  - rapport('AnalyzeWizard', data=ius2008, variables = c('gender', 'game'))
  - rapport('AnalyzeWizard', data=ius2008, variables = c('edu', 'age'))
inputs:
- name: variables
  label: Used Variables
  description: These are the variables which Wizard will use
  length:
    min: 2.0
    max: 2.0
  required: yes
  standalone: no
head-->

<%=
v  <- na.omit(variables)
vc <- sapply(v, class, USE.NAMES = FALSE)

## force levels of measurement
vc <- sapply(vc, function(x) {
    if (any(x %in% c('character', 'factor', 'logical')))
        return('factor')
    if (any(x %in% c('integer', 'numeric', 'complex')))
        return('numeric')
})

if ('factor' %in% vc && 'numeric' %in% vc) {
    rapport("ANOVA", data = rapport.data, resp = variables.name[which(vc == 'numeric')], fac = variables.name[which(vc == 'factor')])
} else {
    if ('factor' %in% vc) {
        rapport('Crosstable', data = rapport.data, row = variables.name[1], col = variables.name[2])
    } else {
        rapport('Correlation', data = rapport.data, vars = variables.name)
    }
}
%>


