-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmk_histo_plotlys.R
More file actions
75 lines (62 loc) · 2.12 KB
/
Copy pathmk_histo_plotlys.R
File metadata and controls
75 lines (62 loc) · 2.12 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# script that generates plotly histograms and cat bars of all variables in input file
args = commandArgs(trailingOnly = TRUE)
if (length(args) != 1) {
stop("the mk_histo_plotlys.R script requires exactly one argument: name of run config file ... thank you. goodbye.")
}
library(parallel)
library(dplyr)
source(args[1])
run_name = gsub(".R", "", args[1])
source(file.path("utilities",
"auto_histo_plotly.R"))
source(file.path("utilities",
"auto_cat_bars_plotly.R"))
# histos for numeric variables
d = read.csv(file.path(data_base_dir,
"flat_w_composites.csv"),
stringsAsFactors = FALSE) %>%
select(order(colnames(.)))
d$entity_label = NULL
d = d[order(get_pretty_name_simple(names(d)))]
names_orig = names(d)
print("names orig")
print(names_orig)
print("names now")
print(names(d))
colors = get_pretty_colors(data.frame(var = names(d)),
col_name = "var",
match_col = "item")
d_ = d[, which(sapply(names(d), function(v) is.numeric(d[,v])))]
print(head(d_))
print(dim(d_))
print(names(d_))
print(colors)
print(filter(colors, var %in% names(d_))$color)
mcmapply(auto_histo_plotly,
d_,
names(d_),
filter(colors, var %in% names(d_))$color,
file.path(getwd(),
results_base_dir,
run_name,
"dashboard",
"histos",
paste0(names(d_),
".html")),
mc.cores = 1)
d_ = d[, which(sapply(names(d), function(v) !(is.numeric(d[,v]) | all(is.na(d[,v])))))] %>%
as.data.frame(stringsAsFactors = FALSE)
names(d_) = names(d)[which(sapply(names(d), function(v) !(is.numeric(d[,v]) | all(is.na(d[,v])))))]
head(d_)
mcmapply(auto_cat_bars_plotly,
d_,
names(d_),
filter(colors, var %in% names(d_))$color,
file.path(getwd(),
results_base_dir,
run_name,
"dashboard",
"histos",
paste0(names(d_),
".html")),
mc.cores = 1)