31
31
# ' @seealso \code{\link{column}}, \code{\link{sidebarLayout}}
32
32
# '
33
33
# ' @examples
34
- # ' fluidPage(
34
+ # ' ## Only run examples in interactive R sessions
35
+ # ' if (interactive()) {
36
+ # '
37
+ # ' # Example of UI with fluidPage
38
+ # ' ui <- fluidPage(
35
39
# '
36
40
# ' # Application title
37
41
# ' titlePanel("Hello Shiny!"),
54
58
# ' )
55
59
# ' )
56
60
# '
57
- # ' fluidPage(
61
+ # ' # Server logic
62
+ # ' server <- function(input, output) {
63
+ # ' output$distPlot <- renderPlot({
64
+ # ' hist(rnorm(input$obs))
65
+ # ' })
66
+ # ' }
67
+ # '
68
+ # ' # Complete app with UI and server components
69
+ # ' shinyApp(ui, server)
70
+ # '
71
+ # '
72
+ # ' # UI demonstrating column layouts
73
+ # ' ui <- fluidPage(
58
74
# ' title = "Hello Shiny!",
59
75
# ' fluidRow(
60
76
# ' column(width = 4,
66
82
# ' )
67
83
# ' )
68
84
# '
85
+ # ' shinyApp(ui, server = function(input, output) { })
86
+ # ' }
69
87
# ' @rdname fluidPage
70
88
# ' @export
71
89
fluidPage <- function (... , title = NULL , responsive = NULL , theme = NULL ) {
@@ -115,7 +133,10 @@ fluidRow <- function(...) {
115
133
# ' @seealso \code{\link{column}}
116
134
# '
117
135
# ' @examples
118
- # ' fixedPage(
136
+ # ' ## Only run examples in interactive R sessions
137
+ # ' if (interactive()) {
138
+ # '
139
+ # ' ui <- fixedPage(
119
140
# ' title = "Hello, Shiny!",
120
141
# ' fixedRow(
121
142
# ' column(width = 4,
@@ -127,6 +148,9 @@ fluidRow <- function(...) {
127
148
# ' )
128
149
# ' )
129
150
# '
151
+ # ' shinyApp(ui, server = function(input, output) { })
152
+ # ' }
153
+ # '
130
154
# ' @rdname fixedPage
131
155
# ' @export
132
156
fixedPage <- function (... , title = NULL , responsive = NULL , theme = NULL ) {
@@ -160,24 +184,43 @@ fixedRow <- function(...) {
160
184
# ' @seealso \code{\link{fluidRow}}, \code{\link{fixedRow}}.
161
185
# '
162
186
# ' @examples
163
- # ' fluidRow(
164
- # ' column(4,
165
- # ' sliderInput("obs", "Number of observations:",
166
- # ' min = 1, max = 1000, value = 500)
167
- # ' ),
168
- # ' column(8,
169
- # ' plotOutput("distPlot")
187
+ # ' ## Only run examples in interactive R sessions
188
+ # ' if (interactive()) {
189
+ # '
190
+ # ' ui <- fluidPage(
191
+ # ' fluidRow(
192
+ # ' column(4,
193
+ # ' sliderInput("obs", "Number of observations:",
194
+ # ' min = 1, max = 1000, value = 500)
195
+ # ' ),
196
+ # ' column(8,
197
+ # ' plotOutput("distPlot")
198
+ # ' )
170
199
# ' )
171
200
# ' )
172
201
# '
173
- # ' fluidRow(
174
- # ' column(width = 4,
175
- # ' "4"
176
- # ' ),
177
- # ' column(width = 3, offset = 2,
178
- # ' "3 offset 2"
202
+ # ' server <- function(input, output) {
203
+ # ' output$distPlot <- renderPlot({
204
+ # ' hist(rnorm(input$obs))
205
+ # ' })
206
+ # ' }
207
+ # '
208
+ # ' shinyApp(ui, server)
209
+ # '
210
+ # '
211
+ # '
212
+ # ' ui <- fluidPage(
213
+ # ' fluidRow(
214
+ # ' column(width = 4,
215
+ # ' "4"
216
+ # ' ),
217
+ # ' column(width = 3, offset = 2,
218
+ # ' "3 offset 2"
219
+ # ' )
179
220
# ' )
180
221
# ' )
222
+ # ' shinyApp(ui, server = function(input, output) { })
223
+ # ' }
181
224
# ' @export
182
225
column <- function (width , ... , offset = 0 ) {
183
226
@@ -202,8 +245,14 @@ column <- function(width, ..., offset = 0) {
202
245
# '
203
246
# '
204
247
# ' @examples
205
- # ' titlePanel("Hello Shiny!")
248
+ # ' ## Only run examples in interactive R sessions
249
+ # ' if (interactive()) {
206
250
# '
251
+ # ' ui <- fluidPage(
252
+ # ' titlePanel("Hello Shiny!")
253
+ # ' )
254
+ # ' shinyApp(ui, server = function(input, output) { })
255
+ # ' }
207
256
# ' @export
208
257
titlePanel <- function (title , windowTitle = title ) {
209
258
tagList(
@@ -226,8 +275,11 @@ titlePanel <- function(title, windowTitle=title) {
226
275
# ' layout.
227
276
# '
228
277
# ' @examples
278
+ # ' ## Only run examples in interactive R sessions
279
+ # ' if (interactive()) {
280
+ # '
229
281
# ' # Define UI
230
- # ' fluidPage(
282
+ # ' ui <- fluidPage(
231
283
# '
232
284
# ' # Application title
233
285
# ' titlePanel("Hello Shiny!"),
@@ -250,6 +302,16 @@ titlePanel <- function(title, windowTitle=title) {
250
302
# ' )
251
303
# ' )
252
304
# '
305
+ # ' # Server logic
306
+ # ' server <- function(input, output) {
307
+ # ' output$distPlot <- renderPlot({
308
+ # ' hist(rnorm(input$obs))
309
+ # ' })
310
+ # ' }
311
+ # '
312
+ # ' # Complete app with UI and server components
313
+ # ' shinyApp(ui, server)
314
+ # ' }
253
315
# ' @export
254
316
sidebarLayout <- function (sidebarPanel ,
255
317
mainPanel ,
@@ -286,13 +348,18 @@ sidebarLayout <- function(sidebarPanel,
286
348
# ' @seealso \code{\link{fluidPage}}, \code{\link{flowLayout}}
287
349
# '
288
350
# ' @examples
289
- # ' fluidPage(
351
+ # ' ## Only run examples in interactive R sessions
352
+ # ' if (interactive()) {
353
+ # '
354
+ # ' ui <- fluidPage(
290
355
# ' verticalLayout(
291
356
# ' a(href="http://example.com/link1", "Link One"),
292
357
# ' a(href="http://example.com/link2", "Link Two"),
293
358
# ' a(href="http://example.com/link3", "Link Three")
294
359
# ' )
295
360
# ' )
361
+ # ' shinyApp(ui, server = function(input, output) { })
362
+ # ' }
296
363
# ' @export
297
364
verticalLayout <- function (... , fluid = TRUE ) {
298
365
lapply(list (... ), function (row ) {
@@ -319,11 +386,16 @@ verticalLayout <- function(..., fluid = TRUE) {
319
386
# ' @seealso \code{\link{verticalLayout}}
320
387
# '
321
388
# ' @examples
322
- # ' flowLayout(
389
+ # ' ## Only run examples in interactive R sessions
390
+ # ' if (interactive()) {
391
+ # '
392
+ # ' ui <- flowLayout(
323
393
# ' numericInput("rows", "How many rows?", 5),
324
394
# ' selectInput("letter", "Which letter?", LETTERS),
325
395
# ' sliderInput("value", "What value?", 0, 100, 50)
326
396
# ' )
397
+ # ' shinyApp(ui, server = function(input, output) { })
398
+ # ' }
327
399
# ' @export
328
400
flowLayout <- function (... , cellArgs = list ()) {
329
401
@@ -369,28 +441,42 @@ inputPanel <- function(...) {
369
441
# ' of the layout.
370
442
# '
371
443
# ' @examples
444
+ # ' ## Only run examples in interactive R sessions
445
+ # ' if (interactive()) {
446
+ # '
447
+ # ' # Server code used for all examples
448
+ # ' server <- function(input, output) {
449
+ # ' output$plot1 <- renderPlot(plot(cars))
450
+ # ' output$plot2 <- renderPlot(plot(pressure))
451
+ # ' output$plot3 <- renderPlot(plot(AirPassengers))
452
+ # ' }
453
+ # '
372
454
# ' # Equal sizing
373
- # ' splitLayout(
455
+ # ' ui <- splitLayout(
374
456
# ' plotOutput("plot1"),
375
457
# ' plotOutput("plot2")
376
458
# ' )
459
+ # ' shinyApp(ui, server)
377
460
# '
378
461
# ' # Custom widths
379
- # ' splitLayout(cellWidths = c("25%", "75%"),
462
+ # ' ui <- splitLayout(cellWidths = c("25%", "75%"),
380
463
# ' plotOutput("plot1"),
381
464
# ' plotOutput("plot2")
382
465
# ' )
466
+ # ' shinyApp(ui, server)
383
467
# '
384
468
# ' # All cells at 300 pixels wide, with cell padding
385
469
# ' # and a border around everything
386
- # ' splitLayout(
470
+ # ' ui <- splitLayout(
387
471
# ' style = "border: 1px solid silver;",
388
472
# ' cellWidths = 300,
389
473
# ' cellArgs = list(style = "padding: 6px"),
390
474
# ' plotOutput("plot1"),
391
475
# ' plotOutput("plot2"),
392
476
# ' plotOutput("plot3")
393
477
# ' )
478
+ # ' shinyApp(ui, server)
479
+ # ' }
394
480
# ' @export
395
481
splitLayout <- function (... , cellWidths = NULL , cellArgs = list ()) {
396
482
@@ -460,10 +546,7 @@ splitLayout <- function(..., cellWidths = NULL, cellArgs = list()) {
460
546
# ' not determined by the height of its contents.
461
547
# '
462
548
# ' @examples
463
- # ' \donttest{
464
549
# ' # Only run this example in interactive R sessions.
465
- # ' # NOTE: This example should be run with example(fillRow, ask = FALSE) to
466
- # ' # avoid being prompted to hit Enter during plot rendering.
467
550
# ' if (interactive()) {
468
551
# '
469
552
# ' ui <- fillPage(fillRow(
@@ -483,7 +566,6 @@ splitLayout <- function(..., cellWidths = NULL, cellArgs = list()) {
483
566
# ' shinyApp(ui, server)
484
567
# '
485
568
# ' }
486
- # ' }
487
569
# ' @export
488
570
fillRow <- function (... , flex = 1 , width = " 100%" , height = " 100%" ) {
489
571
flexfill(... , direction = " row" , flex = flex , width = width , height = height )
0 commit comments