-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.R
52 lines (39 loc) · 1.04 KB
/
main.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
library(tercen)
library(dplyr)
source("./utils.R")
ctx <- tercenCtx()
n_bins <- 30
if(!is.null(ctx$op.value("n_bins"))) n_bins <- as.integer(ctx$op.value("n_bins"))
if(length(ctx$labels) > 0) {
if(length(ctx$labels) > 1) stop("A single label factor must be provided.")
if(ctx$hasXAxis | ctx$isPairwise) {
df <- ctx$select(c(".x", ".y", ".ci", ".ri", ctx$labels))
df2 <- df %>%
group_by(.ci, .ri) %>%
do(get2D_labs(., n_bins))
} else {
df <- ctx$select(c(".y", ".ci", ".ri", ctx$labels))
df2 <- df %>%
group_by(.ci, .ri) %>%
do(get1D_labs(., n_bins))
}
df2 %>%
ctx$addNamespace() %>%
ctx$save()
} else {
if(ctx$hasXAxis | ctx$isPairwise) {
df <- ctx %>%
select(.x, .y, .ci, .ri) %>%
group_by(.ci, .ri) %>%
do(get2D(., n_bins)) %>%
ctx$addNamespace() %>%
ctx$save()
} else {
df <- ctx %>%
select(.y, .ci, .ri) %>%
group_by(.ci, .ri) %>%
do(get1D(., n_bins)) %>%
ctx$addNamespace() %>%
ctx$save()
}
}