Skip to content

Commit 53da6a5

Browse files
committed
wip
1 parent d05d134 commit 53da6a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+689
-3683
lines changed

NAMESPACE

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ export(tm_g_scatterplot)
4141
export(tm_g_scatterplotmatrix)
4242
export(tm_missing_data)
4343
export(tm_outliers)
44-
export(tm_p_bargraph)
45-
export(tm_p_lineplot)
46-
export(tm_p_scatterplot)
47-
export(tm_p_spaghetti)
48-
export(tm_p_spiderplot)
49-
export(tm_p_swimlane)
50-
export(tm_p_waterfall)
51-
export(tm_rmarkdown)
5244
export(tm_t_crosstable)
5345
export(tm_t_reactables)
5446
export(tm_variable_browser)

R/picks-datanames.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.picks_datanames <- function(x) {
2+
checkmate::assert_list(x, c("picks", "NULL"))
3+
datanames_list <- lapply(x, function(x) {
4+
if (is.character(x$datasets$choices)) {
5+
x$datasets$choices
6+
} else {
7+
NULL
8+
}
9+
})
10+
11+
if (any(vapply(datanames_list, is.null, logical(1)))) {
12+
"all"
13+
} else {
14+
unique(unlist(datanames_list))
15+
}
16+
}

R/tm_a_pca.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
#' modules = modules(
6767
#' tm_a_pca(
6868
#' "PCA",
69-
#' dat = picks(
69+
#' dat = teal.transform::picks(
7070
#' datasets("USArrests"),
71-
#' variables(
71+
#' teal.transform::variables(
7272
#' choices = c("Murder", "Assault", "UrbanPop", "Rape"),
7373
#' selected = c("Murder", "Assault"),
7474
#' multiple = TRUE
@@ -99,9 +99,9 @@
9999
#' data = data,
100100
#' modules = modules(
101101
#' tm_a_pca(
102-
#' dat = picks(
102+
#' dat = teal.transform::picks(
103103
#' datasets("ADSL"),
104-
#' variables(
104+
#' teal.transform::variables(
105105
#' choices = c("BMRKR1", "AGE", "EOSDY"),
106106
#' selected = c("BMRKR1", "AGE"),
107107
#' multiple = TRUE
@@ -117,7 +117,14 @@
117117
#' @export
118118
#'
119119
tm_a_pca <- function(label = "Principal Component Analysis",
120-
dat,
120+
dat = teal.transform::picks(
121+
teal.transform::datasets(),
122+
teal.transform::variables(
123+
choices = tidyselect::where(~ is.numeric(.x) && all(!is.na(.x))),
124+
selected = tidyselect::everything(),
125+
multiple = TRUE
126+
)
127+
),
121128
plot_height = c(600, 200, 2000),
122129
plot_width = NULL,
123130
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),

R/tm_a_pca_picks.R

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#' @export
22
tm_a_pca.picks <- function(label = "Principal Component Analysis",
3-
dat = picks(
4-
datasets(),
5-
variables(
3+
dat = teal.transform::picks(
4+
teal.transform::datasets(),
5+
teal.transform::variables(
66
choices = tidyselect::where(~ is.numeric(.x) && all(!is.na(.x))),
77
selected = tidyselect::everything(),
88
multiple = TRUE
@@ -82,10 +82,7 @@ tm_a_pca.picks <- function(label = "Principal Component Analysis",
8282
ui_args = args[names(args) %in% names(formals(ui_a_pca.picks))],
8383
server_args = args[names(args) %in% names(formals(srv_a_pca.picks))],
8484
transformators = transformators,
85-
datanames = {
86-
datanames <- datanames(list(dat))
87-
if (length(datanames)) datanames else "all"
88-
}
85+
datanames = .picks_datanames(list(dat))
8986
)
9087
attr(ans, "teal_bookmarkable") <- FALSE
9188
ans
@@ -125,8 +122,8 @@ ui_a_pca.picks <- function(id,
125122
),
126123
encoding = tags$div(
127124
tags$label("Encodings", class = "text-primary"),
128-
teal::teal_nav_item(
129-
label = tags$strong("Data selection"),
125+
tags$div(
126+
tags$strong("Data selection"),
130127
teal.transform::picks_ui(id = ns("dat"), picks = dat)
131128
),
132129
bslib::accordion(

R/tm_a_regression.R

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#' @inheritParams shared_params
1313
#' @param regressor (`picks`) Specification for regressor variables selection.
1414
#' Created using [teal.transform::picks()], which allows selecting variables
15-
#' to use as regressors in the regression model. `variables(multiple = TRUE)` allowed.
15+
#' to use as regressors in the regression model. `teal.transform::variables(multiple = TRUE)` allowed.
1616
#' @param response (`picks`) Specification for response variable selection.
1717
#' Created using [teal.transform::picks()], which allows selecting a single numeric variable
18-
#' to use as the response in the regression model. `variables(multiple = TRUE)` not allowed.
18+
#' to use as the response in the regression model. `teal.transform::variables(multiple = TRUE)` not allowed.
1919
#' @param outlier (`picks`) Optional specification for outlier label variable selection.
2020
#' Created using [teal.transform::picks()], which allows selecting a factor or character variable
2121
#' to label outlier points on the plots.
@@ -91,13 +91,13 @@
9191
#' modules = modules(
9292
#' tm_a_regression(
9393
#' label = "Regression",
94-
#' response = picks(
94+
#' response = teal.transform::picks(
9595
#' datasets("CO2"),
96-
#' variables(choices = "uptake", selected = "uptake")
96+
#' teal.transform::variables(choices = "uptake", selected = "uptake")
9797
#' ),
98-
#' regressor = picks(
98+
#' regressor = teal.transform::picks(
9999
#' datasets("CO2"),
100-
#' variables(choices = c("conc", "Treatment"), selected = "conc", multiple = TRUE)
100+
#' teal.transform::variables(choices = c("conc", "Treatment"), selected = "conc", multiple = TRUE)
101101
#' )
102102
#' )
103103
#' )
@@ -124,13 +124,13 @@
124124
#' modules = modules(
125125
#' tm_a_regression(
126126
#' label = "Regression",
127-
#' response = picks(
127+
#' response = teal.transform::picks(
128128
#' datasets("ADSL"),
129-
#' variables(choices = "BMRKR1", selected = "BMRKR1")
129+
#' teal.transform::variables(choices = "BMRKR1", selected = "BMRKR1")
130130
#' ),
131-
#' regressor = picks(
131+
#' regressor = teal.transform::picks(
132132
#' datasets("ADSL"),
133-
#' variables(choices = c("AGE", "SEX", "RACE"), selected = "AGE", multiple = TRUE)
133+
#' teal.transform::variables(choices = c("AGE", "SEX", "RACE"), selected = "AGE", multiple = TRUE)
134134
#' )
135135
#' )
136136
#' )
@@ -142,7 +142,15 @@
142142
#' @export
143143
#'
144144
tm_a_regression <- function(label = "Regression Analysis",
145-
regressor,
145+
regressor = teal.transform::picks(
146+
teal.transform::datasets(),
147+
teal.transform::variables(
148+
choices = is.numeric,
149+
selected = tidyselect::last_col(),
150+
multiple = TRUE
151+
),
152+
teal.transform::values()
153+
),
146154
response,
147155
plot_height = c(600, 200, 2000),
148156
plot_width = NULL,

R/tm_a_regression_picks.R

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#' @export
22
tm_a_regression.picks <- function(label = "Regression Analysis",
3-
regressor = picks(
4-
datasets(),
5-
variables(
6-
choices = tidyselect::where(is.numeric),
3+
regressor = teal.transform::picks(
4+
teal.transform::datasets(),
5+
teal.transform::variables(
6+
choices = is.numeric,
77
selected = tidyselect::last_col(),
88
multiple = TRUE
99
),
10-
values()
10+
teal.transform::values()
1111
),
12-
response = picks(
13-
datasets(),
14-
variables(choices = tidyselect::where(is.numeric)),
15-
values()
12+
response = teal.transform::picks(
13+
teal.transform::datasets(),
14+
teal.transform::variables(choices = is.numeric),
15+
teal.transform::values()
1616
),
17-
outlier = picks(
17+
outlier = teal.transform::picks(
1818
regressor$datasets,
19-
variables(choices = where(~ is.factor(.) || is.character(.))),
20-
values()
21-
), # default should be picks(datasets(), variables(primary_keys())
19+
teal.transform::variables(choices = tidyselect::where(~ is.factor(.) || is.character(.))),
20+
teal.transform::values()
21+
), # default should be teal.transform::picks(datasets(), teal.transform::variables(primary_keys())
2222
plot_height = c(600, 200, 2000),
2323
plot_width = NULL,
2424
alpha = c(1, 0, 1),
@@ -40,12 +40,12 @@ tm_a_regression.picks <- function(label = "Regression Analysis",
4040

4141
checkmate::assert_class(response, "picks")
4242
if (isTRUE(attr(response$variables, "multiple"))) {
43-
warning("`response` accepts only a single variable selection. Forcing `variables(multiple) to FALSE`")
43+
warning("`response` accepts only a single variable selection. Forcing `teal.transform::variables(multiple) to FALSE`")
4444
attr(response$variables, "multiple") <- FALSE
4545
}
4646
checkmate::assert_class(outlier, "picks", null.ok = TRUE)
4747
if (isTRUE(attr(outlier$variables, "multiple"))) {
48-
warning("`outlier` accepts only a single variable selection. Forcing `variables(multiple) to FALSE`")
48+
warning("`outlier` accepts only a single variable selection. Forcing `teal.transform::variables(multiple) to FALSE`")
4949
attr(outlier$variables, "multiple") <- FALSE
5050
}
5151

@@ -117,10 +117,7 @@ tm_a_regression.picks <- function(label = "Regression Analysis",
117117
ui_args = args[names(args) %in% names(formals(ui_a_regression.picks))],
118118
server_args = args[names(args) %in% names(formals(srv_a_regression.picks))], ,
119119
transformators = transformators,
120-
datanames = {
121-
datanames <- datanames(list(regressor, response))
122-
if (length(datanames)) datanames else "all"
123-
}
120+
datanames = .picks_datanames(list(regressor, response))
124121
)
125122
attr(ans, "teal_bookmarkable") <- FALSE
126123
ans
@@ -148,12 +145,12 @@ ui_a_regression.picks <- function(id,
148145
)),
149146
encoding = tags$div(
150147
tags$label("Encodings", class = "text-primary"), tags$br(),
151-
teal::teal_nav_item(
152-
label = tags$strong("Response variable"),
148+
tags$div(
149+
tags$strong("Response variable"),
153150
teal.transform::picks_ui(id = ns("response"), picks = response)
154151
),
155-
teal::teal_nav_item(
156-
label = tags$strong("Regressor variables"),
152+
tags$div(
153+
tags$strong("Regressor variables"),
157154
teal.transform::picks_ui(id = ns("regressor"), picks = regressor)
158155
),
159156
radioButtons(

R/tm_g_association.R

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#' @inheritParams teal::module
1212
#' @inheritParams shared_params
1313
#' @param ref (`picks`)
14-
#' Reference variable specification created using `picks()`.
14+
#' Reference variable specification created using `teal.transform::picks()`.
1515
#' @param vars (`picks`)
16-
#' Variables to be associated with the reference variable, specified using `picks()`.
16+
#' Variables to be associated with the reference variable, specified using `teal.transform::picks()`.
1717
#' @param show_association (`logical`) optional, whether show association of `vars`
1818
#' with reference variable. Defaults to `TRUE`.
1919
#' @param distribution_theme,association_theme (`character`) optional, `ggplot2` themes to be used by default.
@@ -67,16 +67,16 @@
6767
#' data = data,
6868
#' modules = modules(
6969
#' tm_g_association(
70-
#' ref = picks(
70+
#' ref = teal.transform::picks(
7171
#' datasets("CO2"),
72-
#' variables(
72+
#' teal.transform::variables(
7373
#' choices = c("Plant", "Type", "Treatment"),
7474
#' selected = "Plant"
7575
#' )
7676
#' ),
77-
#' vars = picks(
77+
#' vars = teal.transform::picks(
7878
#' datasets("CO2"),
79-
#' variables(
79+
#' teal.transform::variables(
8080
#' choices = c("Plant", "Type", "Treatment"),
8181
#' selected = "Treatment",
8282
#' multiple = TRUE
@@ -106,16 +106,16 @@
106106
#' data = data,
107107
#' modules = modules(
108108
#' tm_g_association(
109-
#' ref = picks(
109+
#' ref = teal.transform::picks(
110110
#' datasets("ADSL"),
111-
#' variables(
111+
#' teal.transform::variables(
112112
#' choices = c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2"),
113113
#' selected = "RACE"
114114
#' )
115115
#' ),
116-
#' vars = picks(
116+
#' vars = teal.transform::picks(
117117
#' datasets("ADSL"),
118-
#' variables(
118+
#' teal.transform::variables(
119119
#' choices = c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2"),
120120
#' selected = "BMRKR2",
121121
#' multiple = TRUE
@@ -130,25 +130,16 @@
130130
#'
131131
#' @export
132132
tm_g_association <- function(label = "Association",
133-
ref = picks(
134-
datasets(),
135-
variables(
136-
choices = tidyselect::where(is.numeric) |
133+
ref = teal.transform::picks(
134+
teal.transform::datasets(),
135+
teal.transform::variables(
136+
choices = is.numeric |
137137
teal.transform::is_categorical(min.len = 2, max.len = 10),
138138
selected = 1L
139139
),
140-
values()
141-
),
142-
vars = picks(
143-
datasets(),
144-
variables(
145-
choices = tidyselect::where(is.numeric) |
146-
teal.transform::is_categorical(min.len = 2, max.len = 10),
147-
selected = 2L, # todo: make sure that is doesn't fail in teal.transform
148-
multiple = TRUE
149-
),
150-
values()
140+
teal.transform::values()
151141
),
142+
vars,
152143
show_association = TRUE,
153144
plot_height = c(600, 400, 5000),
154145
plot_width = NULL,

0 commit comments

Comments
 (0)