-
Notifications
You must be signed in to change notification settings - Fork 1
/
M_action_box.R
81 lines (57 loc) · 1.24 KB
/
M_action_box.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
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
76
77
78
##### UI #####
action_box_UI <- function(id, df) {
ns <- NS(id)
div(class = "well",
drag = id,
fluidRow(
column(6,
selectizeInput(
ns("verb"),
label = "verb",
c("select",
"pull",
"arrange",
"group_by",
"count",
"add_count"
)
)
),
column(6,
selectizeInput(
ns("cols"),
label = "cols",
names(df),
selected = NULL,
multiple = TRUE
)
)
),
uiOutput(
ns("description")
)
)
}
##### server #####
action_box <- function(input, output, session) {
verb <- input$verb
cols <- input$cols
if (verb == "select"){
cols <- glue("c({edit})", edit = glue("'{cols}'") %>% glue_collapse(", "))
}
if (verb == "arrange"){
cols <- glue("{cols}") %>% glue_collapse(", ")
}
glue("{verb}({cols})")
}
input_verb <- function(input, output, session) {
input$verb
}
input_cols <- function(input, output, session) {
input$cols
}
update_action_box <- function(input, output, session, string) {
output$description <- renderUI({
span(strong("code: "), string())
})
}