├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── 001-hello ├── DESCRIPTION ├── Readme.md └── app.R ├── 002-text ├── DESCRIPTION ├── Readme.md └── app.R ├── 003-reactivity ├── DESCRIPTION ├── Readme.md └── app.R ├── 004-mpg ├── DESCRIPTION ├── Readme.md └── app.R ├── 005-sliders ├── DESCRIPTION ├── Readme.md └── app.R ├── 006-tabsets ├── DESCRIPTION ├── Readme.md └── app.R ├── 007-widgets ├── DESCRIPTION ├── Readme.md └── app.R ├── 008-html ├── DESCRIPTION ├── Readme.md ├── app.R └── www │ └── index.html ├── 009-upload ├── DESCRIPTION ├── Readme.md └── app.R ├── 010-download ├── DESCRIPTION ├── Readme.md └── app.R ├── 011-timer ├── DESCRIPTION ├── Readme.md └── app.R ├── 012-datatables ├── DESCRIPTION ├── Readme.md └── app.R ├── 013-selectize ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 014-onflushed ├── DESCRIPTION ├── server.R └── ui.R ├── 015-layout-navbar ├── DESCRIPTION ├── server.R └── ui.R ├── 015-layout-sidebar ├── DESCRIPTION ├── server.R └── ui.R ├── 016-knitr-pdf ├── DESCRIPTION ├── Readme.md ├── report.Rmd ├── server.R └── ui.R ├── 017-select-vs-selectize ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 018-datatable-options ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 019-mathjax ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 020-knit-html ├── DESCRIPTION ├── Readme.md ├── report.Rmd ├── server.R └── ui.R ├── 021-selectize-plot ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 022-unicode-chinese ├── DESCRIPTION ├── Readme.md ├── global.R ├── server.R └── ui.R ├── 023-optgroup-server ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 024-optgroup-selectize ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 025-loop-ui ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 026-shiny-inline ├── DESCRIPTION └── index.Rmd ├── 027-absolutely-positioned-panels ├── DESCRIPTION ├── server.R └── ui.R ├── 028-actionbutton-demo ├── DESCRIPTION ├── README.md ├── server.r └── ui.r ├── 030-basic-datatable ├── DESCRIPTION ├── server.R └── ui.R ├── 032-client-data-and-query-string ├── DESCRIPTION ├── README.md ├── server.r └── ui.r ├── 033-conditionalpanel-demo ├── DESCRIPTION ├── server.R └── ui.R ├── 034-current-time ├── DESCRIPTION ├── server.R └── ui.R ├── 035-custom-input-bindings ├── DESCRIPTION ├── README.md ├── server.R ├── ui.R ├── url-input.R └── www │ └── url-input-binding.js ├── 036-custom-input-control ├── DESCRIPTION ├── README.md ├── chooser.R ├── server.R ├── ui.R └── www │ └── chooser-binding.js ├── 037-date-and-date-range ├── DESCRIPTION ├── server.R └── ui.R ├── 039-download-file ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 040-dynamic-clustering ├── DESCRIPTION ├── server.R └── ui.R ├── 041-dynamic-ui ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 047-image-output ├── DESCRIPTION ├── README.md ├── images │ ├── chainring.jpg │ └── face.png ├── server.R └── ui.R ├── 048-including-html-text-and-markdown-files ├── DESCRIPTION ├── README.md ├── include.html ├── include.md ├── include.txt ├── server.r └── ui.r ├── 049-isolate-demo ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 050-kmeans-example ├── DESCRIPTION ├── server.R └── ui.R ├── 051-movie-explorer ├── .Renviron ├── DESCRIPTION ├── README.md ├── global.R ├── movies.db ├── server.R └── ui.R ├── 052-navbar-example ├── DESCRIPTION ├── about.md ├── server.R └── ui.R ├── 053-navlistpanel-example ├── DESCRIPTION ├── README.md ├── server.r └── ui.r ├── 054-nvd3-line-chart-output ├── DESCRIPTION ├── README.md ├── global.R ├── linechart.R ├── output.Rproj ├── server.R ├── ui.R └── www │ ├── d3 │ └── d3.v3.min.js │ ├── linechart-binding.js │ └── nvd3 │ ├── .gitignore │ ├── .jshintrc │ ├── GruntFile.js │ ├── LICENSE.md │ ├── Makefile │ ├── README.md │ ├── bower.json │ ├── build.bat │ ├── deprecated │ ├── bar.html │ ├── bar.js │ ├── charts │ │ ├── cumulativeLineChart.js │ │ ├── discreteBarChart.js │ │ ├── lineChart.js │ │ ├── lineChartDaily.js │ │ └── stackedAreaChart.js │ ├── cumulativeLine.html │ ├── cumulativeLine.js │ ├── discreteBarChartWithEnabledTooltip.html │ ├── discreteBarChartWithEnabledTooltip.js │ ├── discreteBarWithAxes.html │ ├── discreteBarWithAxes.js │ ├── lineChart-old.html │ ├── lineChartDaily.html │ ├── linePlusBar.html │ ├── linePlusBar.js │ ├── lineWithFocus.html │ ├── lineWithFocus.js │ ├── lineWithFourAxes.html │ ├── lineWithFourAxes.js │ ├── lineWithLegend.html │ ├── lineWithLegend.js │ ├── monthendAxis.html │ ├── multiBarHorizontalWithLegend.html │ ├── multiBarHorizontalWithLegend.js │ ├── multiBarWithLegend.html │ ├── multiBarWithLegend.js │ ├── pie.js │ ├── scatterChart.html │ ├── scatterChart.js │ ├── scatterFisheyeChart.js │ ├── scatterWithLegend.html │ ├── scatterWithLegend.js │ ├── stackedArea.js │ ├── stackedAreaChart.html │ ├── stackedAreaChart_old.html │ ├── stackedAreaWithLegend.html │ └── stackedAreaWithLegend.js │ ├── examples │ ├── bullet.html │ ├── bulletChart.html │ ├── crossfilter.html │ ├── crossfilterWithDimentions.html │ ├── crossfilterWithTables.html │ ├── cumulativeLineChart.html │ ├── discreteBarChart.html │ ├── historicalBar.html │ ├── historicalBarChart.html │ ├── horizon.html │ ├── images │ │ ├── grey-minus.png │ │ ├── grey-plus.png │ │ └── nvd3_sampleLineChart1.png │ ├── indentedtree.html │ ├── index.html │ ├── legend.html │ ├── line.html │ ├── lineChart.html │ ├── lineChartSVGResize.html │ ├── linePlusBarChart.html │ ├── linePlusBarWithFocusChart.html │ ├── lineWithFisheyeChart.html │ ├── lineWithFocusChart.html │ ├── multiBar.html │ ├── multiBarChart.html │ ├── multiBarHorizontalChart.html │ ├── multiChart.html │ ├── nations.json │ ├── parallelCoordinates.html │ ├── pie.html │ ├── pieChart.html │ ├── scatter.html │ ├── scatterChart.html │ ├── scatterPlusLineChart.html │ ├── sparkline.html │ ├── sparklinePlus.html │ ├── stackedArea.html │ ├── stackedAreaChart.html │ └── stream_layers.js │ ├── lib │ ├── cie.js │ ├── colorbrewer.js │ ├── crossfilter.js │ ├── crossfilter.min.js │ ├── d3.v2.js │ ├── d3.v2.min.js │ ├── d3.v3.js │ ├── fisheye.js │ ├── hive.js │ ├── horizon.js │ └── sankey.js │ ├── nv.d3.css │ ├── nv.d3.js │ ├── nv.d3.min.css │ ├── nv.d3.min.js │ ├── package.json │ ├── src │ ├── core.js │ ├── interactiveLayer.js │ ├── intro.js │ ├── models │ │ ├── axis.js │ │ ├── backup │ │ │ ├── bullet.js │ │ │ └── bulletChart.js │ │ ├── boilerplate.js │ │ ├── bullet.js │ │ ├── bulletChart.js │ │ ├── cumulativeLineChart.js │ │ ├── discreteBar.js │ │ ├── discreteBarChart.js │ │ ├── distribution.js │ │ ├── historicalBar.js │ │ ├── historicalBarChart.js │ │ ├── indentedTree.js │ │ ├── legend.js │ │ ├── line.js │ │ ├── lineChart.js │ │ ├── linePlusBarChart.js │ │ ├── linePlusBarWithFocusChart.js │ │ ├── lineWithFisheye.js │ │ ├── lineWithFisheyeChart.js │ │ ├── lineWithFocusChart.js │ │ ├── multiBar.js │ │ ├── multiBarChart.js │ │ ├── multiBarHorizontal.js │ │ ├── multiBarHorizontalChart.js │ │ ├── multiBarTimeSeries.js │ │ ├── multiBarTimeSeriesChart.js │ │ ├── multiChart.js │ │ ├── ohlcBar.js │ │ ├── parallelCoordinates.js │ │ ├── pie.js │ │ ├── pieChart.js │ │ ├── scatter.js │ │ ├── scatterChart.js │ │ ├── scatterPlusLineChart.js │ │ ├── sparkline.js │ │ ├── sparklinePlus.js │ │ ├── stackedArea.js │ │ └── stackedAreaChart.js │ ├── nv.d3.css │ ├── outro.js │ ├── tooltip.js │ └── utils.js │ └── test │ ├── ScatterChartTest.html │ ├── interactiveBisectTest.html │ ├── lineChartTest.html │ ├── multiBarChartTest.html │ ├── pieChartTest.html │ ├── polylinearTest.html │ ├── realTimeChartTest.html │ ├── stackedAreaChartTest.html │ ├── testScript.js │ └── teststyle.css ├── 055-observer-demo ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 057-plot-plus-three-columns ├── DESCRIPTION ├── server.R └── ui.R ├── 059-reactive-poll-and-file-reader ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 060-retirement-simulation ├── DESCRIPTION ├── server.r ├── ui.r └── www │ └── simplex.min.css ├── 061-server-to-client-custom-messages ├── DESCRIPTION ├── README.md ├── server.R ├── ui.R └── www │ └── message-handler.js ├── 062-submitbutton-demo ├── DESCRIPTION ├── README.md ├── server.r └── ui.r ├── 063-superzip-example ├── DESCRIPTION ├── README.md ├── data │ ├── -revisedmurrayfile_111952895138.xls │ ├── deps.sh │ ├── superzip.csv │ ├── superzip.rds │ └── zip_codes_states.csv ├── global.R ├── gomap.js ├── server.R ├── styles.css └── ui.R ├── 064-telephones-by-region ├── DESCRIPTION ├── server.R └── ui.R ├── 065-update-input-demo ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 066-upload-file ├── DESCRIPTION ├── README.md ├── server.R ├── ui.R └── www │ ├── mtcars.csv │ └── pressure.tsv ├── 067-vertical-layout ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 068-widget-action-button ├── .RData ├── DESCRIPTION ├── README.md ├── action-button.Rproj ├── server.R └── ui.R ├── 069-widget-check-group ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 070-widget-checkbox ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 071-widget-date ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 072-widget-date-range ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 073-widget-file ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 074-widget-numeric ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 075-widget-radio ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 076-widget-select ├── DESCRIPTION ├── Readme.md ├── server.R └── ui.R ├── 077-widget-slider ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 078-widget-slider-range ├── DESCRIPTION ├── server.R └── ui.R ├── 079-widget-submit ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 080-widget-text ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 081-widgets-gallery ├── .RData ├── DESCRIPTION ├── server.R ├── ui.R ├── widgets.Rproj └── www │ └── texturebg.png ├── 082-word-cloud ├── DESCRIPTION ├── README.md ├── global.R ├── merchant.txt.gz ├── romeo.txt.gz ├── screenshot.png ├── server.R ├── summer.txt.gz └── ui.R ├── 083-front-page ├── DESCRIPTION ├── README.md ├── front-page.Rproj ├── server.R └── ui.R ├── 084-single-file ├── DESCRIPTION ├── README.md └── app.R ├── 085-progress ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 086-bus-dashboard ├── DESCRIPTION ├── R │ ├── gtfs.R │ ├── realtime.R │ └── utils.R ├── README.md ├── server.R └── ui.R ├── 087-crandash ├── DESCRIPTION ├── README.md ├── bloomfilter.R ├── global.R ├── server.R └── ui.R ├── 088-action-pattern1 ├── 088-action-pattern1.Rproj ├── DESCRIPTION ├── app.R └── www │ └── message-handler.js ├── 089-action-pattern2 ├── 089-action-pattern2.Rproj ├── DESCRIPTION └── app.R ├── 090-action-pattern3 ├── 090-action-pattern3.Rproj ├── DESCRIPTION └── app.R ├── 091-action-pattern4 ├── 091-action-pattern4.Rproj ├── DESCRIPTION └── app.R ├── 092-action-pattern5 ├── 092-action-pattern5.Rproj ├── DESCRIPTION └── app.R ├── 093-plot-interaction-basic ├── DESCRIPTION ├── README.md └── app.R ├── 094-image-interaction-basic ├── DESCRIPTION ├── README.md └── app.R ├── 095-plot-interaction-advanced ├── DESCRIPTION ├── README.md └── app.R ├── 096-plot-interaction-article-1 ├── app.R └── deps.R ├── 097-plot-interaction-article-2 ├── app.R └── deps.R ├── 098-plot-interaction-article-3 ├── app.R └── deps.R ├── 099-plot-interaction-article-4 ├── app.R └── deps.R ├── 100-plot-interaction-article-5 ├── app.R └── deps.R ├── 101-plot-interaction-article-6 ├── app.R └── deps.R ├── 102-plot-interaction-article-7 ├── app.R └── deps.R ├── 103-plot-interaction-article-8 ├── app.R └── deps.R ├── 104-plot-interaction-select ├── DESCRIPTION ├── README.md └── app.R ├── 105-plot-interaction-zoom ├── DESCRIPTION ├── README.md └── app.R ├── 106-plot-interaction-exclude ├── DESCRIPTION ├── README.md └── app.R ├── 107-events ├── DESCRIPTION ├── Readme.md ├── server.R ├── ui.R └── www │ └── events.js ├── 108-module-output ├── DESCRIPTION ├── Readme.md ├── app.R └── linked_scatter.R ├── 109-render-table ├── DESCRIPTION ├── Readme.md ├── check_valid.R ├── code_printing.R ├── server.R └── ui.R ├── 110-error-sanitization ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 111-insert-ui ├── DESCRIPTION ├── README.md ├── server.R └── ui.R ├── 112-generate-report ├── DESCRIPTION ├── README.md ├── app.R └── report.Rmd ├── 113-bookmarking-url ├── DESCRIPTION ├── README.md └── app.R ├── 114-modal-dialog ├── DESCRIPTION ├── README.md └── app.R ├── 115-bookmarking-updatequerystring ├── DESCRIPTION ├── README.md └── app.R ├── 116-notifications ├── DESCRIPTION ├── README.md └── app.R ├── 117-shinythemes ├── DESCRIPTION ├── README.md └── app.R ├── 118-highcharter-births ├── DESCRIPTION ├── README.md ├── app.R └── data │ └── births.csv ├── 119-namespaced-conditionalpanel-demo ├── DESCRIPTION └── app.R ├── 120-goog-index ├── DESCRIPTION ├── README.md ├── app.R └── data │ ├── trend_data.csv │ └── trend_description.csv ├── 121-async-timer └── app.R ├── 122-async-outputs └── app.R ├── 123-async-renderprint └── app.R ├── 124-async-download └── app.R ├── 125-async-req └── app.R ├── 126-async-ticks └── app.R ├── 127-async-flush └── app.R ├── 128-plot-dim-error └── app.R ├── 129-async-perf └── app.R ├── 130-output-null └── app.R ├── 131-renderplot-args └── app.R ├── 132-async-events └── app.R ├── 133-async-hold-inputs └── app.R ├── 134-async-hold-timers └── app.R ├── 135-bookmark-uioutput └── app.R ├── 136-plot-cache ├── DESCRIPTION ├── README.md └── app.R ├── 137-plot-cache-key ├── DESCRIPTION ├── README.md └── app.R ├── 138-icon-fontawesome ├── DESCRIPTION ├── README.md └── app.R ├── 139-plot-brush-scaling └── app.R ├── 140-selectize-inputs └── app.R ├── 141-radiant ├── README.md └── app.R ├── 142-reactive-timer └── app.R ├── 143-async-plot-caching └── app.R ├── 144-colors ├── app.R ├── countries.R ├── countries.geojson └── countries.rds ├── 145-dt-replacedata └── app.R ├── 146-ames-explorer ├── README.md ├── app.R ├── helpers │ ├── data_functions.R │ └── plot_functions.R └── modules │ ├── data_modules.R │ └── plot_modules.R ├── 147-websocket └── app.R ├── 148-addresourcepath-deleted └── app.R ├── 149-onRender └── app.R ├── 150-networkD3-sankey └── app.R ├── 151-reactr-input ├── app.R └── js │ └── input.js ├── 152-set-reactivevalue └── app.R ├── 153-connection-header └── app.R ├── 154-index-html-server-r ├── server.R └── www │ └── index.html ├── 155-index-html-app-r ├── app.R └── www │ └── index.html ├── 156-subapps ├── README.md ├── app2 │ ├── app.R │ └── www │ │ ├── app2_styles.css │ │ └── index.html ├── app3 │ ├── server.R │ └── ui.R └── index.Rmd ├── 157-date-format └── app.R ├── 158-input-labels └── app.R ├── 159-rate-policy └── app.R ├── 160-select-input └── app.R ├── 161-discrete-limits └── app.R ├── 162-plot-dragging └── app.R ├── 163-select-factor └── app.R ├── 164-no-whitespace ├── DESCRIPTION ├── Readme.md └── app.R ├── 165-trailing-comma ├── DESCRIPTION ├── Readme.md └── app.R ├── 166-dynamic-hosted-tab ├── app.R └── app.js ├── 167-resource-warnings ├── app.R └── www │ └── images │ └── rstudio.png ├── 168-supporting-r-dir ├── DESCRIPTION ├── R │ └── counter.R ├── Readme.md ├── server.R └── ui.R ├── 169-prerender-a ├── index.Rmd └── js │ └── log-rmd.js ├── 169-prerender-b ├── app.R └── www │ └── js │ └── run-test.js ├── 170-date-range-max └── app.R ├── 171-path-traversal └── app.R ├── 173-invalidatelater-leak └── app.R ├── 174-throttle-debounce └── app.R ├── 175-setInputValue ├── app.R └── script.js ├── 176-jquery-3 └── app.R ├── 177-jquery-1 └── app.R ├── 178-delayed-widget └── app.R ├── 179-nondelayed-widget └── app.R ├── 180-delayed-staticwidget └── app.R ├── 181-google-analytics ├── app.R ├── cerulean.css ├── google-analytics.html └── sunshine.RDS ├── 182-google-charts ├── DESCRIPTION ├── README.md ├── app.R └── healthexp.Rds ├── 183-sv-simple ├── DESCRIPTION ├── README.md └── app.R ├── 184-sv-deferred ├── DESCRIPTION ├── README.md └── app.R ├── 185-sv-custom-inputs ├── DESCRIPTION ├── R │ └── camera_input.R ├── README.md ├── app.R └── www │ ├── camera_input.css │ └── camera_input.js ├── 186-sv-module-1 ├── DESCRIPTION ├── README.md └── app.R ├── 187-sv-module-2 ├── DESCRIPTION ├── README.md └── app.R ├── 188-sv-module-3 ├── DESCRIPTION ├── README.md └── app.R ├── 500-movie-browser ├── app.R └── movies.RData ├── 501-movie-browser-nav ├── app.R └── movies.RData ├── 502-random-number └── app.R ├── 503-server-function └── app.R ├── LICENSE ├── README.md ├── deploy ├── docker-rsc-deployer ├── .gitignore ├── Applist.Rmd ├── Dockerfile ├── README.md ├── deployApp.R └── set_public.sh ├── docker ├── Dockerfile ├── README.md └── shiny-server.sh ├── gallery-URLs.txt ├── install_deps.R ├── linux-devel-init.sh ├── run_apps.R └── shiny-examples.Rproj /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .RData 4 | 5 | # Example code in package build process 6 | *-Ex.R 7 | .Rproj.user 8 | 9 | # ShinyApps manifest 10 | *.dcf 11 | 12 | # Fonts 13 | *.ttc 14 | 15 | # DS Store 16 | .DS_Store 17 | 18 | 19 | # Log Files 20 | logfile*.txt 21 | 22 | # Packrat lockfiles generated during RSC deploy 23 | packrat.lock 24 | 25 | 169-prerender-a/index.html 26 | -------------------------------------------------------------------------------- /001-hello/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Hello Shiny! 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /001-hello/Readme.md: -------------------------------------------------------------------------------- 1 | This small Shiny application demonstrates Shiny's automatic UI updates. 2 | 3 | Move the *Number of bins* slider and notice how the `renderPlot` expression is automatically re-evaluated when its dependant, `input$bins`, changes, causing a histogram with a new number of bins to be rendered. 4 | -------------------------------------------------------------------------------- /002-text/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Shiny Text 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | 9 | -------------------------------------------------------------------------------- /002-text/Readme.md: -------------------------------------------------------------------------------- 1 | This example demonstrates output of raw text from R using the `renderPrint` function in `server` and the `verbatimTextOutput` function in `ui`. In this case, a textual summary of the data is shown using R's built-in `summary` function. 2 | -------------------------------------------------------------------------------- /003-reactivity/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Reactivity 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /003-reactivity/Readme.md: -------------------------------------------------------------------------------- 1 | This example demonstrates a core feature of Shiny: **reactivity**. In the `server` function, a reactive called `datasetInput` is declared. 2 | 3 | Notice that the reactive expression depends on the input expression `input$dataset`, and that it's used by two output expressions: `output$summary` and `output$view`. Try changing the dataset (using *Choose a dataset*) while looking at the reactive and then at the outputs; you will see first the reactive and then its dependencies flash. 4 | 5 | Notice also that the reactive expression doesn't just update whenever anything changes--only the inputs it depends on will trigger an update. Change the "Caption" field and notice how only the `output$caption` expression is re-evaluated; the reactive and its dependents are left alone. 6 | -------------------------------------------------------------------------------- /004-mpg/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Miles Per Gallon 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /004-mpg/Readme.md: -------------------------------------------------------------------------------- 1 | This example demonstrates the following concepts: 2 | 3 | - **Global variables**: The `mpgData` variable is declared outside of the `ui` and `server` function definitions. This makes it available anywhere inside `app.R`. The code in `app.R` outside of `ui` and `server` function definitions is only run once when the app starts up, so it can't contain user input. 4 | - **Reactive expressions**: `formulaText` is a reactive expression. Note how it re-evaluates when the Variable field is changed, but not when the Show Outliers box is unchecked. 5 | -------------------------------------------------------------------------------- /005-sliders/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Sliders 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /005-sliders/Readme.md: -------------------------------------------------------------------------------- 1 | This example demonstrates Shiny's versatile `sliderInput` widget. 2 | 3 | Slider inputs can be used to select single values, to select a continuous range of values, and even to animate over a range. 4 | -------------------------------------------------------------------------------- /006-tabsets/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Tabsets 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /006-tabsets/Readme.md: -------------------------------------------------------------------------------- 1 | This example demonstrates the `tabsetPanel` and `tabPanel` widgets. 2 | 3 | Notice that outputs that are not visible are not re-evaluated until they become visible. Try this: 4 | 5 | 1. Scroll to the bottom of the `server` function. You might need to use the *show with app* option so you can easily view the code and interact with the app at the same time. 6 | 2. Change the number of observations, and observe that only `output$plot` is evaluated. 7 | 3. Click the Summary tab, and observe that `output$summary` is evaluated. 8 | 4. Change the number of observations again, and observe that now only `output$summary` is evaluated. 9 | 10 | -------------------------------------------------------------------------------- /007-widgets/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Widgets 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /007-widgets/Readme.md: -------------------------------------------------------------------------------- 1 | This example demonstrates some additional widgets included in Shiny, such as `helpText` and `actionButton`. The latter is used to delay rendering output until the user explicitly requests it (a construct which also introduces two important server functions, `eventReactive` and `isolate`). 2 | -------------------------------------------------------------------------------- /008-html/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Custom HTML UI 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /008-html/Readme.md: -------------------------------------------------------------------------------- 1 | Normally we use the built-in functions, such as `textInput()`, to generate the HTML UI in the R script `ui.R`. Actually **shiny** also works with a custom HTML page `www/index.html`. See [the tutorial](http://shiny.rstudio.com/tutorial/) for more details. 2 | -------------------------------------------------------------------------------- /009-upload/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: File Upload 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /009-upload/Readme.md: -------------------------------------------------------------------------------- 1 | We can add a file upload input in the UI using the function `fileInput()`, 2 | e.g. `fileInput('foo')`. In the `server` function, we can access the 3 | uploaded files via `input$foo`. 4 | -------------------------------------------------------------------------------- /010-download/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: File Download 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /010-download/Readme.md: -------------------------------------------------------------------------------- 1 | We can add a download button to the UI using `downloadButton()`, and write 2 | the content of the file in `downloadHandler()` in the `server` function. 3 | -------------------------------------------------------------------------------- /011-timer/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Timer 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: getting-started 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /011-timer/Readme.md: -------------------------------------------------------------------------------- 1 | The function `invalidateLater()` can be used to invalidate an observer or 2 | reactive expression in a given number of milliseconds. In this example, the 3 | output `currentTime` is updated every second, so it shows the current time 4 | on a second basis. 5 | -------------------------------------------------------------------------------- /011-timer/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | # Define UI for displaying current time ---- 4 | ui <- fluidPage( 5 | 6 | h2(textOutput("currentTime")) 7 | 8 | ) 9 | 10 | # Define server logic to show current time, update every second ---- 11 | server <- function(input, output, session) { 12 | 13 | output$currentTime <- renderText({ 14 | invalidateLater(1000, session) 15 | paste("The current time is", Sys.time()) 16 | }) 17 | 18 | } 19 | 20 | # Create Shiny app ---- 21 | shinyApp(ui, server) 22 | -------------------------------------------------------------------------------- /012-datatables/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: DataTables Demo 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: datatables 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /012-datatables/Readme.md: -------------------------------------------------------------------------------- 1 | We have three tables in this example: 2 | 3 | - For the `diamonds` data, we can select variables to show in the table. 4 | 5 | - For the `mtcars` example, we use `orderClasses = TRUE` so that sorted 6 | columns are colored since they have special CSS classes attached. 7 | 8 | - For the `iris` data, we customize the length menu so we can display 5 rows 9 | per page. 10 | -------------------------------------------------------------------------------- /013-selectize/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Selectize Examples 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: selectize 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /013-selectize/Readme.md: -------------------------------------------------------------------------------- 1 | The function `selectizeInput()` creates a select input extended by 2 | [selectize.js](https://github.com/brianreavis/selectize.js). You can type and 3 | search in the input box, delete selected items, set placeholders, and add new 4 | options by typing in the input box, etc. 5 | -------------------------------------------------------------------------------- /013-selectize/server.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | function(input, output) { 4 | output$ex_out <- renderPrint({ 5 | str(sapply(sprintf('e%d', 0:7), function(id) { 6 | input[[id]] 7 | }, simplify = FALSE)) 8 | }) 9 | output$github <- renderText({ 10 | paste('You selected', if (input$github == '') 'nothing' else input$github, 11 | 'in the Github example.') 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /014-onflushed/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: onFlush Example 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: flush 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /014-onflushed/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | values <- reactiveValues(starting = TRUE) 4 | 5 | session$onFlushed(function() { 6 | values$starting <- FALSE 7 | }) 8 | 9 | output$fast <- renderText({ "This happens right away" }) 10 | output$slow <- renderText({ 11 | if (values$starting) { 12 | invalidateLater(0, session) 13 | return("Please wait for 5 seconds") 14 | } 15 | Sys.sleep(5) # pretend this is time-consuming 16 | "This happens later" 17 | }) 18 | output$slow_plot <- renderPlot({ 19 | if (values$starting) { 20 | invalidateLater(0, session) 21 | return(plot(cars, main = "Please wait for a while")) 22 | } 23 | plot(rnorm(100000), main = "A slow plot") 24 | }) 25 | 26 | } 27 | -------------------------------------------------------------------------------- /014-onflushed/ui.R: -------------------------------------------------------------------------------- 1 | basicPage( 2 | h2('Immediate output here'), 3 | verbatimTextOutput('fast'), 4 | h2('Delayed output comes after the page is ready'), 5 | verbatimTextOutput('slow'), 6 | plotOutput('slow_plot') 7 | ) 8 | -------------------------------------------------------------------------------- /015-layout-navbar/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Navbar Layout 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: layout navbar 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /015-layout-navbar/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /015-layout-navbar/ui.R: -------------------------------------------------------------------------------- 1 | navbarPage( 2 | "My Application", 3 | tabPanel("Component 1"), 4 | tabPanel("Component 2"), 5 | tabPanel("Component 3") 6 | ) 7 | -------------------------------------------------------------------------------- /015-layout-sidebar/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Sidebar Layout 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: layout sidebar 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /015-layout-sidebar/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | output$distPlot <- renderPlot({ 4 | x <- faithful[, 2] # Old Faithful Geyser data 5 | bins <- seq(min(x), max(x), length.out = input$bins + 1) 6 | 7 | # draw the histogram with the specified number of bins 8 | hist(x, breaks = bins, col = 'darkgray', border = 'white') 9 | }) 10 | 11 | } 12 | -------------------------------------------------------------------------------- /015-layout-sidebar/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | titlePanel("Hello Shiny!"), 4 | 5 | # put the side bar on the right 6 | sidebarLayout(position = "right", 7 | 8 | sidebarPanel( 9 | sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30) 10 | ), 11 | 12 | mainPanel( 13 | plotOutput("distPlot") 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /016-knitr-pdf/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Download knitr Reports 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: download knitr rmarkdown 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /016-knitr-pdf/Readme.md: -------------------------------------------------------------------------------- 1 | This app uses the **rmarkdown** package to compile a report template to PDF/HTML/Word, 2 | which we can download by clicking a button. Note we switched the working dir 3 | to a temporary dir, to avoid the possibility that we do not have write 4 | permission on the server. 5 | -------------------------------------------------------------------------------- /016-knitr-pdf/report.Rmd: -------------------------------------------------------------------------------- 1 | Here is my regression model: 2 | 3 | ```{r model, collapse=TRUE} 4 | options(digits = 4) 5 | fit <- lm(regFormula(), data = mtcars) 6 | b <- coef(fit) 7 | summary(fit) 8 | ``` 9 | 10 | The fitting result is $mpg = `r b[1]` + `r b[2]``r input$x`$. 11 | Below is a scatter plot with the regression line. 12 | 13 | ```{r plot, fig.height=5} 14 | par(mar = c(4, 4, 1, 1)) 15 | plot(regFormula(), data = mtcars, pch = 19, col = 'gray') 16 | abline(fit, col = 'red', lwd = 2) 17 | ``` 18 | -------------------------------------------------------------------------------- /016-knitr-pdf/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | regFormula <- reactive({ 4 | as.formula(paste('mpg ~', input$x)) 5 | }) 6 | 7 | output$regPlot <- renderPlot({ 8 | par(mar = c(4, 4, .1, .1)) 9 | plot(regFormula(), data = mtcars, pch = 19) 10 | }) 11 | 12 | output$downloadReport <- downloadHandler( 13 | filename = function() { 14 | paste('my-report', sep = '.', switch( 15 | input$format, PDF = 'pdf', HTML = 'html', Word = 'docx' 16 | )) 17 | }, 18 | 19 | content = function(file) { 20 | src <- normalizePath('report.Rmd') 21 | 22 | # temporarily switch to the temp dir, in case you do not have write 23 | # permission to the current working directory 24 | owd <- setwd(tempdir()) 25 | on.exit(setwd(owd)) 26 | file.copy(src, 'report.Rmd', overwrite = TRUE) 27 | 28 | library(rmarkdown) 29 | out <- render('report.Rmd', switch( 30 | input$format, 31 | PDF = pdf_document(), HTML = html_document(), Word = word_document() 32 | )) 33 | file.rename(out, file) 34 | } 35 | ) 36 | 37 | } 38 | -------------------------------------------------------------------------------- /016-knitr-pdf/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | title = 'Download a PDF report', 3 | sidebarLayout( 4 | sidebarPanel( 5 | helpText(), 6 | selectInput('x', 'Build a regression model of mpg against:', 7 | choices = names(mtcars)[-1]), 8 | radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'), 9 | inline = TRUE), 10 | downloadButton('downloadReport') 11 | ), 12 | mainPanel( 13 | plotOutput('regPlot') 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /017-select-vs-selectize/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Selectize vs. Select 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: selectinput selectize 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /017-select-vs-selectize/Readme.md: -------------------------------------------------------------------------------- 1 | This app shows a side-by-side comparison of select and selectize input 2 | elements, i.e. `selectInput(..., selectize = FALSE)` vs `selectizeInput(...)`. 3 | -------------------------------------------------------------------------------- /017-select-vs-selectize/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | output$out1 <- renderPrint(input$in1) 3 | output$out2 <- renderPrint(input$in2) 4 | output$out3 <- renderPrint(input$in3) 5 | output$out4 <- renderPrint(input$in4) 6 | output$out5 <- renderPrint(input$in5) 7 | output$out6 <- renderPrint(input$in6) 8 | } 9 | -------------------------------------------------------------------------------- /018-datatable-options/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: DataTables Options 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: DataTables 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /018-datatable-options/Readme.md: -------------------------------------------------------------------------------- 1 | We can customize DataTables through the `options` argument of 2 | `DT::datatable()`. Below is a brief explanation of the examples 3 | above: 4 | 5 | 1. the option `pageLength = 25` changes the default number of rows to 6 | display from 10 to 25; 7 | 8 | 1. the option `lengthMenu = list(c(5, 15, -1), c('5', '15', 'All'))` sets 9 | the length menu items (in the top left corner); it can be either a numeric 10 | vector (e.g. `c(5, 10, 30, 100)`), or a list of length 2 -- in the latter 11 | case, the first element is the length options, and the second element 12 | contains their labels to be shown in the menu; 13 | 14 | 1. `paging = FALSE` disables pagination, i.e. all records in the data are 15 | shown at once; alternatively, you can set `pageLength = -1`; 16 | 17 | 1. `searching = FALSE` disables searching, and no searching boxes will be shown; 18 | 19 | 1. any character strings wrapped in `JS()` will be treated as literal JavaScript 20 | code, and evaluated using `eval()` in JavaScript, so we can pass, for 21 | example, JS functions to DataTables; 22 | -------------------------------------------------------------------------------- /018-datatable-options/ui.R: -------------------------------------------------------------------------------- 1 | navbarPage( 2 | title = 'DataTable Options', 3 | tabPanel('Display length', DT::dataTableOutput('ex1')), 4 | tabPanel('Length menu', DT::dataTableOutput('ex2')), 5 | tabPanel('No pagination', DT::dataTableOutput('ex3')), 6 | tabPanel('No filtering', DT::dataTableOutput('ex4')), 7 | tabPanel('Function callback', DT::dataTableOutput('ex5')) 8 | ) 9 | -------------------------------------------------------------------------------- /019-mathjax/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: MathJax 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: MathJax 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /019-mathjax/Readme.md: -------------------------------------------------------------------------------- 1 | The function `withMathJax()` is a wrapper function to load the 2 | [MathJax](http://www.mathjax.org) library in a shiny app. For static HTML 3 | content, we only need to call `withMathJax()` once. However, for dynamic UI 4 | output via `renderUI()`, we must wrap the content that contains math 5 | expressions in `withMathJax()`, because we have to call the MathJax function 6 | `MathJax.Hub.Queue(["Typeset", MathJax.Hub])` to render math manually, which is 7 | what `withMathJax()` does. 8 | -------------------------------------------------------------------------------- /019-mathjax/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | output$ex1 <- renderUI({ 3 | withMathJax(helpText('Dynamic output 1: $$\\alpha^2$$')) 4 | }) 5 | output$ex2 <- renderUI({ 6 | withMathJax( 7 | helpText('and output 2 $$3^2+4^2=5^2$$'), 8 | helpText('and output 3 $$\\sin^2(\\theta)+\\cos^2(\\theta)=1$$') 9 | ) 10 | }) 11 | output$ex3 <- renderUI({ 12 | withMathJax( 13 | helpText('The busy Cauchy distribution 14 | $$\\frac{1}{\\pi\\gamma\\,\\left[1 + 15 | \\left(\\frac{x-x_0}{\\gamma}\\right)^2\\right]}\\!$$')) 16 | }) 17 | output$ex4 <- renderUI({ 18 | invalidateLater(5000, session) 19 | x <- round(rcauchy(1), 3) 20 | withMathJax(sprintf("If \\(X\\) is a Cauchy random variable, then 21 | $$P(X \\leq %.03f ) = %.03f$$", x, pcauchy(x))) 22 | }) 23 | output$ex5 <- renderUI({ 24 | if (!input$ex5_visible) return() 25 | withMathJax( 26 | helpText('You do not see me initially: $$e^{i \\pi} + 1 = 0$$') 27 | ) 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /019-mathjax/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | title = 'MathJax Examples', 3 | withMathJax(), 4 | helpText('An irrational number \\(\\sqrt{2}\\) 5 | and a fraction $$1-\\frac{1}{2}$$'), 6 | helpText('and a fact about \\(\\pi\\): 7 | $$\\frac2\\pi = \\frac{\\sqrt2}2 \\cdot 8 | \\frac{\\sqrt{2+\\sqrt2}}2 \\cdot 9 | \\frac{\\sqrt{2+\\sqrt{2+\\sqrt2}}}2 \\cdots$$'), 10 | uiOutput('ex1'), 11 | uiOutput('ex2'), 12 | uiOutput('ex3'), 13 | uiOutput('ex4'), 14 | checkboxInput('ex5_visible', 'Show Example 5', FALSE), 15 | uiOutput('ex5') 16 | ) 17 | -------------------------------------------------------------------------------- /020-knit-html/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: knit html 2 | Author: Yihui Xie 3 | AuthorUrl: http://yihui.name 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: knitr 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /020-knit-html/Readme.md: -------------------------------------------------------------------------------- 1 | This example shows you how to knit an R Markdown document using the two packages **knitr** and **markdown**, and include the HTML output in a shiny app. Note we are using [R Markdown v1](http://rmarkdown.rstudio.com/authoring_migrating_from_v1.html) here, which has a couple of differences with [v2](http://rmarkdown.rstudio.com). The basic idea is to call `knitr::knit2html()` with the argument `template = FALSE` to generate a fragment of HTML code. 2 | -------------------------------------------------------------------------------- /020-knit-html/report.Rmd: -------------------------------------------------------------------------------- 1 | Here is my regression model: 2 | 3 | ```{r model, collapse=TRUE} 4 | options(digits = 4) 5 | fit <- lm(regFormula(), data = mtcars) 6 | b <- coef(fit) 7 | summary(fit) 8 | ``` 9 | 10 | The fitting result is $mpg = `r b[1]` + `r b[2]``r input$x`$. 11 | Below is a scatter plot with the regression line. 12 | 13 | ```{r plot, fig.height=5} 14 | par(mar = c(4, 4, 1, 1)) 15 | plot(regFormula(), data = mtcars, pch = 19, col = 'gray') 16 | abline(fit, col = 'red', lwd = 2) 17 | ``` 18 | -------------------------------------------------------------------------------- /020-knit-html/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | title = 'Embed an HTML report from R Markdown/knitr', 3 | sidebarLayout( 4 | sidebarPanel( 5 | withMathJax(), # include the MathJax library 6 | selectInput('x', 'Build a regression model of mpg against:', 7 | choices = names(mtcars)[-1]) 8 | ), 9 | mainPanel( 10 | uiOutput('report') 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /021-selectize-plot/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Selectize rendering methods 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: selectize 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /021-selectize-plot/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | title = 'Create plots in selectize input', 3 | fluidRow( 4 | column( 5 | 5, 6 | plotOutput('parcoord'), 7 | hr(), 8 | selectizeInput('state', label = NULL, choices = NULL, options = list( 9 | placeholder = 'Type a state name, e.g. Iowa', maxOptions = 5) 10 | ) 11 | ), 12 | column( 13 | 7, 14 | DT::dataTableOutput('rawdata') 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /022-unicode-chinese/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Unicode characters 2 | Author: 谢益辉 3 | AuthorUrl: http://yihui.name 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: unicode 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /022-unicode-chinese/Readme.md: -------------------------------------------------------------------------------- 1 | 这个例子展示了Shiny应用中的中文字符。多字节字符在Windows上一直都是让人头疼的问题,因为Windows不像Linux或苹果系统那样统一使用UTF-8编码,而是有自己的成百上千种编码,不同的系统语言环境有不同的默认字符编码,每次涉及到多字节字符的读写问题的时候,开发者或用户都要问自己一个问题:我应该用什么编码?从shiny版本0.10.1开始,我们强制跟shiny应用有关的文件都使用UTF-8编码,包括ui.R / server.R / global.R / DESCRIPTION / README.md文件(不是所有文件都是shiny应用必需的)。如果你使用RStudio编辑器,你可以从菜单File -> Save with Encoding选择UTF-8编码保存你的shiny应用文件。 2 | 3 | If you do not understand Chinese, please take a look at [this article](http://shiny.rstudio.com/articles/unicode.html). 4 | -------------------------------------------------------------------------------- /022-unicode-chinese/server.R: -------------------------------------------------------------------------------- 1 | library(datasets) 2 | 3 | # 定义服务器逻辑 4 | function(input, output) { 5 | 6 | cars2 <- cars 7 | cars2$random <- sample( 8 | strsplit("随意放一些中文字符", "")[[1]], nrow(cars2), replace = TRUE 9 | ) 10 | 11 | # 返回数据集,注意input$dataset返回的结果可能是中文“岩石” 12 | datasetInput <- reactive({ 13 | if (input$dataset == "岩石") return(rock2) 14 | if (input$dataset == "pressure") return(pressure) 15 | if (input$dataset == "cars") return(cars2) 16 | }) 17 | 18 | output$rockvars <- renderUI({ 19 | if (input$dataset != "岩石") return() 20 | selectInput("vars", "从岩石数据中选择一列作为自变量", names(rock2)[-1]) 21 | }) 22 | 23 | output$rockplot <- renderPlot({ 24 | validate(need(input$vars, "")) 25 | par(mar = c(4, 4, .1, .1)) 26 | plot(as.formula(paste("面积 ~ ", input$vars)), data = rock2) 27 | }) 28 | 29 | # 数据概要信息 30 | output[['summary这里也可以用中文']] <- renderPrint({ 31 | if (!input$summary) return(cat("数据概要信息被隐藏了!")) 32 | dataset <- datasetInput() 33 | summary(dataset) 34 | }) 35 | 36 | # 显示前"n"行数据 37 | output$view <- renderTable({ 38 | head(datasetInput(), n = input$obs) 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /022-unicode-chinese/ui.R: -------------------------------------------------------------------------------- 1 | # 定义用户界面 2 | fluidPage( 3 | 4 | # 标题 5 | titlePanel("麻麻再也不用担心我的Shiny应用不能显示中文了"), 6 | 7 | # 侧边栏布局 8 | sidebarLayout( 9 | sidebarPanel( 10 | selectInput("dataset", "请选一个数据:", 11 | choices = c("岩石", "pressure", "cars")), 12 | 13 | uiOutput("rockvars"), 14 | 15 | numericInput("obs", "查看多少行数据?", 5), 16 | 17 | checkboxInput("summary", "显示概要", TRUE) 18 | ), 19 | 20 | # 展示一个HTML表格 21 | mainPanel( 22 | conditionalPanel("input.dataset === '岩石'", plotOutput("rockplot")), 23 | 24 | verbatimTextOutput("summary这里也可以用中文"), 25 | 26 | tableOutput("view") 27 | ) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /023-optgroup-server/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Option groups for server-side selectize 2 | Author: Yihui Xie 3 | AuthorUrl: http://yihui.name 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: selectize 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /023-optgroup-server/Readme.md: -------------------------------------------------------------------------------- 1 | We can use `updateSelectizeInput(server = TRUE)` to make use of the server-side selectize input, but it is not straightforward to obtain the `` info from the server side dynamically. In this case, we just predefine the option groups in the initialization configurations. 2 | 3 | Note this feature requires **shiny** >= 0.10.1. 4 | -------------------------------------------------------------------------------- /023-optgroup-server/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | Titanic2 <- as.data.frame(Titanic, stringsAsFactors = FALSE) 4 | Titanic2 <- cbind(Titanic2, value = seq_len(nrow(Titanic2))) 5 | Titanic2$label <- apply(Titanic2[, 2:4], 1, paste, collapse = ', ') 6 | updateSelectizeInput(session, 'group', choices = Titanic2, server = TRUE) 7 | 8 | output$row <- renderPrint({ 9 | validate(need( 10 | input$group, 'Please type and search (e.g. Female)' 11 | )) 12 | Titanic2[as.integer(input$group), -(6:7)] 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /024-optgroup-selectize/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Option groups for selectize input 2 | Author: Yihui Xie 3 | AuthorUrl: http://yihui.name 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: selectize 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /024-optgroup-selectize/Readme.md: -------------------------------------------------------------------------------- 1 | Sometimes it is more convenient to group all options into a few categories for the select/selectize input. To enable option groups, just use a nested list as the value of the `choices` argument of `selectInput()` / `selectizeInput()`. At least one of the child elements of the list must be of length >= 2, in other words, at least one option group should contain more than one option. 2 | 3 | Note this feature requires **shiny** >= 0.10.1. 4 | -------------------------------------------------------------------------------- /024-optgroup-selectize/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | updateSelectizeInput(session, 'x2', choices = list( 4 | Eastern = list(`Rhode Island` = 'RI', `New Jersey` = 'NJ'), 5 | Western = list(`Oregon` = 'OR', `Washington` = 'WA'), 6 | Middle = list(Iowa = 'IA') 7 | ), selected = 'IA') 8 | 9 | output$values <- renderPrint({ 10 | list(x1 = input$x1, x2 = input$x2, x3 = input$x3, x4 = input$x4) 11 | }) 12 | } 13 | -------------------------------------------------------------------------------- /024-optgroup-selectize/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage(sidebarLayout( 2 | sidebarPanel( 3 | # use regions as option groups 4 | selectizeInput("x1", "X1", choices = list( 5 | Eastern = list(`New York` = "NY", `New Jersey` = "NJ"), 6 | Western = list(`California` = "CA", `Washington` = "WA") 7 | ), multiple = TRUE), 8 | 9 | # use updateSelectizeInput() to generate options later 10 | selectizeInput("x2", "X2", choices = NULL), 11 | 12 | # an ordinary selectize input without option groups 13 | selectizeInput("x3", "X3", choices = setNames(state.abb, state.name)), 14 | 15 | # a select input 16 | selectInput("x4", "X4", choices = list( 17 | Eastern = list(`New York` = "NY", `New Jersey` = "NJ"), 18 | Western = list(`California` = "CA", `Washington` = "WA") 19 | ), selectize = FALSE) 20 | ), 21 | mainPanel( 22 | verbatimTextOutput("values") 23 | ) 24 | ), title = "Options groups for select(ize) input") 25 | -------------------------------------------------------------------------------- /025-loop-ui/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Creating a UI from a loop 2 | Author: Yihui Xie 3 | AuthorUrl: http://yihui.name 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: dynamic-ui 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /025-loop-ui/Readme.md: -------------------------------------------------------------------------------- 1 | When you want to create some UI elements from a loop, it is tempting to use the dark power `eval(parse())`, e.g. `for (i in 1:10)` `eval(parse(text = paste0("uiOutput('id", i, "'"))))`, but this is almost always the wrong way to go in shiny. It makes the code obscure and insecure. This example shows you how to express the logic more naturally and securely without manually constructing the program code and evaluating it using the `eval(parse())` trick. 2 | -------------------------------------------------------------------------------- /025-loop-ui/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | # note we use the syntax input[['foo']] instead of input$foo, because we have 4 | # to construct the id as a character string, then use it to access the value; 5 | # same thing applies to the output object below 6 | output$a_out <- renderPrint({ 7 | res <- lapply(1:5, function(i) input[[paste0('a', i)]]) 8 | str(setNames(res, paste0('a', 1:5))) 9 | }) 10 | 11 | lapply(1:10, function(i) { 12 | output[[paste0('b', i)]] <- renderUI({ 13 | strong(paste0('Hi, this is output B#', i)) 14 | }) 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /025-loop-ui/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | title = 'Creating a UI from a loop', 3 | 4 | sidebarLayout( 5 | sidebarPanel( 6 | # create some select inputs 7 | lapply(1:5, function(i) { 8 | selectInput(paste0('a', i), paste0('SelectA', i), 9 | choices = sample(LETTERS, 5)) 10 | }) 11 | ), 12 | 13 | mainPanel( 14 | verbatimTextOutput('a_out'), 15 | 16 | # UI output 17 | lapply(1:10, function(i) { 18 | uiOutput(paste0('b', i)) 19 | }) 20 | ) 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /026-shiny-inline/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Inline Output 2 | Author: Yihui Xie 3 | AuthorUrl: http://yihui.name 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: inline 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /027-absolutely-positioned-panels/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Absolutely-positioned panels 2 | Type: Shiny 3 | Author: Joe Cheng 4 | AuthorUrl: http://www.rstudio.com/ 5 | Tags: absolutePanel css markdown 6 | License: MIT 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /027-absolutely-positioned-panels/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | output$plot <- renderPlot({ 3 | mtscaled <- as.matrix(scale(mtcars)) 4 | heatmap(mtscaled, 5 | col = topo.colors(200, alpha=0.5), 6 | Colv=F, scale="none") 7 | }) 8 | 9 | output$plot2 <- renderPlot({ 10 | plot(head(cars, input$n), main="Foo") 11 | }, bg = "#F5F5F5") 12 | } 13 | -------------------------------------------------------------------------------- /028-actionbutton-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: actionButton demo 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: actionbutton 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /028-actionbutton-demo/README.md: -------------------------------------------------------------------------------- 1 | Action buttons should always be used with one of `eventReactive()` or `observeEvent()`. See the article [Using Action Buttons](http://shiny.rstudio.com/articles/action-buttons.html) for details. -------------------------------------------------------------------------------- /028-actionbutton-demo/server.r: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # builds a reactive expression that only invalidates 4 | # when the value of input$goButton becomes out of date 5 | # (i.e., when the button is pressed) 6 | ntext <- eventReactive(input$goButton, { 7 | input$n 8 | }) 9 | 10 | output$nText <- renderText({ 11 | ntext() 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /028-actionbutton-demo/ui.r: -------------------------------------------------------------------------------- 1 | pageWithSidebar( 2 | headerPanel("actionButton test"), 3 | sidebarPanel( 4 | numericInput("n", "N:", min = 0, max = 100, value = 50), 5 | br(), 6 | actionButton("goButton", "Go!"), 7 | p("Click the button to update the value displayed in the main panel.") 8 | ), 9 | mainPanel( 10 | verbatimTextOutput("nText") 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /030-basic-datatable/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Basic DataTable 2 | Author: Jeff Allen 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: mtcars selectinput datatables 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /030-basic-datatable/server.R: -------------------------------------------------------------------------------- 1 | # Load the ggplot2 package which provides 2 | # the 'mpg' dataset. 3 | library(ggplot2) 4 | 5 | function(input, output) { 6 | 7 | # Filter data based on selections 8 | output$table <- DT::renderDataTable(DT::datatable({ 9 | data <- mpg 10 | if (input$man != "All") { 11 | data <- data[data$manufacturer == input$man,] 12 | } 13 | if (input$cyl != "All") { 14 | data <- data[data$cyl == input$cyl,] 15 | } 16 | if (input$trans != "All") { 17 | data <- data[data$trans == input$trans,] 18 | } 19 | data 20 | })) 21 | 22 | } 23 | -------------------------------------------------------------------------------- /030-basic-datatable/ui.R: -------------------------------------------------------------------------------- 1 | # Load the ggplot2 package which provides 2 | # the 'mpg' dataset. 3 | library(ggplot2) 4 | 5 | fluidPage( 6 | titlePanel("Basic DataTable"), 7 | 8 | # Create a new Row in the UI for selectInputs 9 | fluidRow( 10 | column(4, 11 | selectInput("man", 12 | "Manufacturer:", 13 | c("All", 14 | unique(as.character(mpg$manufacturer)))) 15 | ), 16 | column(4, 17 | selectInput("trans", 18 | "Transmission:", 19 | c("All", 20 | unique(as.character(mpg$trans)))) 21 | ), 22 | column(4, 23 | selectInput("cyl", 24 | "Cylinders:", 25 | c("All", 26 | unique(as.character(mpg$cyl)))) 27 | ) 28 | ), 29 | # Create a new row for the table. 30 | DT::dataTableOutput("table") 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /032-client-data-and-query-string/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Client data and query string 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: clientdata query-string 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /032-client-data-and-query-string/README.md: -------------------------------------------------------------------------------- 1 | The `session$clientdata` object provides the server with some information about the client. 2 | 3 | If the client is visiting a URL with a query string or hash (such as http://localhost:8100/?a=xxx&b=yyy#zzz), there will be values for `url_search` and `url_hash_initial`. This app will also display the parsed query string. 4 | 5 | This app in the Shiny gallery is displayed without a query string. To see the query string, follow [this link](https://gallery.shinyapps.io/032-client-data-and-query-string/?a=xxx&b=yyy#zzz). 6 | -------------------------------------------------------------------------------- /032-client-data-and-query-string/ui.r: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("Client data and query string example"), 3 | 4 | fluidRow( 5 | column(8, 6 | h3("session$clientdata values"), 7 | verbatimTextOutput("summary"), 8 | h3("Parsed URL query string"), 9 | verbatimTextOutput("queryText", placeholder = TRUE) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /033-conditionalpanel-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: conditionalPanel demo 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: conditionalpanel 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /033-conditionalpanel-demo/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | output$scatterPlot <- renderPlot({ 4 | x <- rnorm(input$n) 5 | y <- rnorm(input$n) 6 | plot(x, y) 7 | }) 8 | 9 | } 10 | -------------------------------------------------------------------------------- /033-conditionalpanel-demo/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | titlePanel("Conditional panels"), 4 | 5 | column(4, wellPanel( 6 | sliderInput("n", "Number of points:", 7 | min = 10, max = 200, value = 50, step = 10) 8 | )), 9 | 10 | column(5, 11 | "The plot below will be not displayed when the slider value", 12 | "is less than 50.", 13 | 14 | # With the conditionalPanel, the condition is a JavaScript 15 | # expression. In these expressions, input values like 16 | # input$n are accessed with dots, as in input.n 17 | conditionalPanel("input.n >= 50", 18 | plotOutput("scatterPlot", height = 300) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /034-current-time/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Current Time 2 | Author: Joe Cheng 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: invalidatelater 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /034-current-time/server.R: -------------------------------------------------------------------------------- 1 | options(digits.secs = 3) # Include milliseconds in time display 2 | 3 | function(input, output, session) { 4 | 5 | output$currentTime <- renderText({ 6 | # invalidateLater causes this output to automatically 7 | # become invalidated when input$interval milliseconds 8 | # have elapsed 9 | invalidateLater(as.integer(input$interval), session) 10 | 11 | format(Sys.time()) 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /034-current-time/ui.R: -------------------------------------------------------------------------------- 1 | basicPage( 2 | h4( 3 | "The time is ", 4 | # We give textOutput a span container to make it appear 5 | # right in the h4, without starting a new line. 6 | textOutput("currentTime", container = span) 7 | ), 8 | selectInput("interval", "Update every:", c( 9 | "5 seconds" = "5000", 10 | "1 second" = "1000", 11 | "0.5 second" = "500" 12 | ), selected = 1000, selectize = FALSE) 13 | ) 14 | -------------------------------------------------------------------------------- /035-custom-input-bindings/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Custom input bindings 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: custom-input-binding 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /035-custom-input-bindings/README.md: -------------------------------------------------------------------------------- 1 | Shiny comes with several types of inputs out of the box. You may find time when it would be useful to implement your own input bindings. 2 | 3 | In this example, we've created an input binding for inputs with `type=url` (which requires a modern browser). This input binding is based on Shiny's built-in textInputBinding. URL behave very similary to regular text inputs, so you won't see any new features over and above what a textInputBinding will do. Still, the code demonstrates what's needed for writing your own input bindings. 4 | 5 | This example application has files other than server.R and ui.R. To see them, make sure to see the full source code. 6 | -------------------------------------------------------------------------------- /035-custom-input-bindings/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | output$urlText <- renderText({ 4 | as.character(input$my_url) 5 | }) 6 | 7 | observe({ 8 | # Run whenever reset button is pressed 9 | input$reset 10 | 11 | # Send an update to my_url, resetting its value 12 | updateUrlInput(session, "my_url", value = "http://www.r-project.org/") 13 | }) 14 | } 15 | -------------------------------------------------------------------------------- /035-custom-input-bindings/ui.R: -------------------------------------------------------------------------------- 1 | source("url-input.R") 2 | 3 | fluidPage( 4 | titlePanel("Custom input example"), 5 | 6 | fluidRow( 7 | column(4, wellPanel( 8 | urlInput("my_url", "URL: ", "http://www.r-project.org/"), 9 | actionButton("reset", "Reset URL") 10 | )), 11 | column(8, wellPanel( 12 | verbatimTextOutput("urlText") 13 | )) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /035-custom-input-bindings/url-input.R: -------------------------------------------------------------------------------- 1 | # This function generates the client-side HTML for a URL input 2 | urlInput <- function(inputId, label, value = "") { 3 | tagList( 4 | # This makes web page load the JS file in the HTML head. 5 | # The call to singleton ensures it's only included once 6 | # in a page. 7 | shiny::singleton( 8 | shiny::tags$head( 9 | shiny::tags$script(src = "url-input-binding.js") 10 | ) 11 | ), 12 | shiny::tags$label(label, `for` = inputId), 13 | shiny::tags$input(id = inputId, type = "url", value = value) 14 | ) 15 | } 16 | 17 | 18 | # Send an update message to a URL input on the client. 19 | # This update message can change the value and/or label. 20 | updateUrlInput <- function(session, inputId, 21 | label = NULL, value = NULL) { 22 | 23 | message <- dropNulls(list(label = label, value = value)) 24 | session$sendInputMessage(inputId, message) 25 | } 26 | 27 | 28 | # Given a vector or list, drop all the NULL items in it 29 | dropNulls <- function(x) { 30 | x[!vapply(x, is.null, FUN.VALUE=logical(1))] 31 | } 32 | -------------------------------------------------------------------------------- /036-custom-input-control/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Custom input control 2 | Author: Joe Cheng 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Type: Shiny 6 | Tags: javascript custom-input 7 | DisplayMode: Normal 8 | -------------------------------------------------------------------------------- /036-custom-input-control/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | output$selection <- renderPrint( 4 | input$mychooser 5 | ) 6 | 7 | } 8 | -------------------------------------------------------------------------------- /036-custom-input-control/ui.R: -------------------------------------------------------------------------------- 1 | source("chooser.R") 2 | 3 | fluidPage( 4 | chooserInput("mychooser", "Available frobs", "Selected frobs", 5 | row.names(USArrests), c(), size = 10, multiple = TRUE 6 | ), 7 | verbatimTextOutput("selection") 8 | ) -------------------------------------------------------------------------------- /037-date-and-date-range/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Date and date range 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: date, daterange 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /037-date-and-date-range/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | # input$date and others are Date objects. When outputting 4 | # text, we need to convert to character; otherwise it will 5 | # print an integer rather than a date. 6 | output$dateText <- renderText({ 7 | paste("input$date is", as.character(input$date)) 8 | }) 9 | 10 | output$dateText2 <- renderText({ 11 | paste("input$date2 is", as.character(input$date2)) 12 | }) 13 | 14 | output$dateRangeText <- renderText({ 15 | paste("input$dateRange is", 16 | paste(as.character(input$dateRange), collapse = " to ") 17 | ) 18 | }) 19 | 20 | output$dateRangeText2 <- renderText({ 21 | paste("input$dateRange2 is", 22 | paste(as.character(input$dateRange2), collapse = " to ") 23 | ) 24 | }) 25 | } 26 | -------------------------------------------------------------------------------- /039-download-file/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Download File 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: file-download 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /039-download-file/README.md: -------------------------------------------------------------------------------- 1 | To create file download button, there should be a `downloadButton` on the client side, and a corresponding `downloadHandler` on the server side. 2 | -------------------------------------------------------------------------------- /039-download-file/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel('File download'), 3 | sidebarLayout( 4 | sidebarPanel( 5 | selectInput("dataset", "Choose a dataset:", 6 | choices = c("Rock", "Pressure", "Cars")), 7 | radioButtons("filetype", "File type:", 8 | choices = c("csv", "tsv")), 9 | downloadButton('downloadData', 'Download') 10 | ), 11 | mainPanel( 12 | tableOutput('table') 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /040-dynamic-clustering/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Dynamic Clustering 2 | Author: Jeff Allen 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: mclust clustering clickid observe isolate 7 | Type: Shiny -------------------------------------------------------------------------------- /040-dynamic-clustering/ui.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | # Create a bootstrap fluid layout 4 | fluidPage( 5 | 6 | # Add a title 7 | titlePanel("Dynamic Clustering in Shiny"), 8 | 9 | # Add a row for the main content 10 | fluidRow( 11 | 12 | # Create a space for the plot output 13 | plotOutput( 14 | "clusterPlot", "100%", "500px", click="clusterClick" 15 | ) 16 | ), 17 | 18 | # Create a row for additional information 19 | fluidRow( 20 | # Take up 2/3 of the width with this element 21 | mainPanel("Points: ", verbatimTextOutput("numPoints")), 22 | 23 | # And the remaining 1/3 with this one 24 | sidebarPanel(actionButton("clear", "Clear Points")) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /041-dynamic-ui/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Dynamic UI 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: dynamic-ui renderui uioutput 7 | DisplayMode: Showcase 8 | 9 | -------------------------------------------------------------------------------- /041-dynamic-ui/README.md: -------------------------------------------------------------------------------- 1 | The user interface components in this example are generated as HTML on the server inside a `renderUI()` block and sent to the client, which displays them with `uiOutput()`. Each time a new component is sent to the client, it completely replaces the previous component. This is different from the udpate input demo app, where the value of an existing input component is changed with a command from the server, but the component itself is not replaced with a new one. 2 | -------------------------------------------------------------------------------- /041-dynamic-ui/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("Dynamically generated user interface components"), 3 | fluidRow( 4 | 5 | column(3, wellPanel( 6 | selectInput("input_type", "Input type", 7 | c("slider", "text", "numeric", "checkbox", 8 | "checkboxGroup", "radioButtons", "selectInput", 9 | "selectInput (multi)", "date", "daterange" 10 | ) 11 | ) 12 | )), 13 | 14 | column(3, wellPanel( 15 | # This outputs the dynamic UI component 16 | uiOutput("ui") 17 | )), 18 | 19 | column(3, 20 | tags$p("Input type:"), 21 | verbatimTextOutput("input_type_text"), 22 | tags$p("Dynamic input value:"), 23 | verbatimTextOutput("dynamic_value") 24 | ) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /047-image-output/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Image output 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: image-output 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /047-image-output/README.md: -------------------------------------------------------------------------------- 1 | The `renderImage()` and `imageOutput()` functions can be used to display any image files on the client. This is in contrast to the `renderPlot()` and `plotOutput()` functions, which are used for images created by R's usual plot rendering device. 2 | 3 | In the upper image, `image1`, a new image file is created each time the slider changes, and the `deleteFile=TRUE` argument tells the server to delete the temporary iamge file after it's sent to the client. 4 | 5 | This technique can be also used for pre-rendered images. The lower image, `image2` sends pre-rendered images to the client. In this case the `deleteFile=FALSE` argument is used so that the image files aren't deleted after being sent to the client. 6 | -------------------------------------------------------------------------------- /047-image-output/images/chainring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/047-image-output/images/chainring.jpg -------------------------------------------------------------------------------- /047-image-output/images/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/047-image-output/images/face.png -------------------------------------------------------------------------------- /047-image-output/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("Image output"), 3 | 4 | fluidRow( 5 | column(4, wellPanel( 6 | sliderInput("r", "Radius :", min = 0.05, max = 1, 7 | value = 0.2, step = 0.05), 8 | radioButtons("picture", "Picture:", 9 | c("chainring", "face")) 10 | )), 11 | column(4, 12 | imageOutput("image1", height = 300), 13 | imageOutput("image2") 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Including HTML, text, and Markdown files 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: include 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/README.md: -------------------------------------------------------------------------------- 1 | It's possible to include files with HTML, text, or Markdown content in a Shiny app. 2 | 3 | HTML files will be included as-is, text files will have characters escaped, and Markdown files will be processed into HTML with the markdown package before inclusion. 4 | 5 | Be sure to look at the full source code for this app, since it has files other than ui.R and server.R. 6 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/include.html: -------------------------------------------------------------------------------- 1 |

This file is include.html.

2 | 3 |

The content of this file is included as-is in the web page.

4 | 5 |
6 | This is a div with a light red background. 7 |
8 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/include.md: -------------------------------------------------------------------------------- 1 | This file is include.md 2 | ======================= 3 | 4 | The content of this file is: 5 | 6 | * Processed with the markdown package, which transforms it into HTML. 7 | * The output is included in the web page. 8 | 9 | ## Including code 10 | 11 | In the .md file, R code is highlighted, and code can be included inline with backticks, as in `sum(1:10)`. However, this is *not* an .Rmd file, and the code will not be executed by knitr. 12 | 13 | ```{r} 14 | # Some example code 15 | x <- 12 16 | x + 1 17 | ``` 18 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/include.txt: -------------------------------------------------------------------------------- 1 | This file is include.txt. 2 | 3 | The content of this file is escaped, so special characters like & and
will display correctly in the web page. However, no other processing is done, so hard breaks and multiple spaces will be rendered as usual in HTML. 4 | 5 | If you want to display preformatted text, wrap the text in pre(). 6 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/server.r: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /048-including-html-text-and-markdown-files/ui.r: -------------------------------------------------------------------------------- 1 | library(markdown) 2 | 3 | fluidPage( 4 | 5 | titlePanel("includeText, includeHTML, and includeMarkdown"), 6 | 7 | fluidRow( 8 | column(4, 9 | includeText("include.txt"), 10 | br(), 11 | pre(includeText("include.txt")) 12 | ), 13 | column(4, 14 | includeHTML("include.html") 15 | ), 16 | column(4, 17 | includeMarkdown("include.md") 18 | ) 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /049-isolate-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: isolate demo 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: isolate 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /049-isolate-demo/README.md: -------------------------------------------------------------------------------- 1 | In this example, changing `n` will not result in an update to the summary text, because it is always used within `isolate()` on the server side. 2 | 3 | However, changing `text` or clicking on the button will result in the summary text updating, because when `input$text` and `input$goButton` are accessed it is **not** inside `isolate()`. 4 | -------------------------------------------------------------------------------- /049-isolate-demo/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("isolate example"), 3 | fluidRow( 4 | column(4, wellPanel( 5 | sliderInput("n", "n (isolated):", 6 | min = 10, max = 1000, value = 200, step = 10), 7 | 8 | textInput("text", "text (not isolated):", "input text"), 9 | 10 | br(), 11 | actionButton("goButton", "Go!") 12 | )), 13 | column(8, 14 | h4("summary"), 15 | textOutput("summary"), 16 | h4("summary2"), 17 | textOutput("summary2") 18 | ) 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /050-kmeans-example/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Kmeans example 2 | License: MIT 3 | Author: Joe Cheng 4 | AuthorUrl: http://www.rstudio.com/ 5 | Tags: getting-started kmeans plotoutput sliderinput numericinput reactivity 6 | DisplayMode: Showcase 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /050-kmeans-example/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | # Combine the selected variables into a new data frame 4 | selectedData <- reactive({ 5 | iris[, c(input$xcol, input$ycol)] 6 | }) 7 | 8 | clusters <- reactive({ 9 | kmeans(selectedData(), input$clusters) 10 | }) 11 | 12 | output$plot1 <- renderPlot({ 13 | palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", 14 | "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999")) 15 | 16 | par(mar = c(5.1, 4.1, 0, 1)) 17 | plot(selectedData(), 18 | col = clusters()$cluster, 19 | pch = 20, cex = 3) 20 | points(clusters()$centers, pch = 4, cex = 4, lwd = 4) 21 | }) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /050-kmeans-example/ui.R: -------------------------------------------------------------------------------- 1 | # k-means only works with numerical variables, 2 | # so don't give the user the option to select 3 | # a categorical variable 4 | vars <- setdiff(names(iris), "Species") 5 | 6 | pageWithSidebar( 7 | headerPanel('Iris k-means clustering'), 8 | sidebarPanel( 9 | selectInput('xcol', 'X Variable', vars), 10 | selectInput('ycol', 'Y Variable', vars, selected = vars[[2]]), 11 | numericInput('clusters', 'Cluster count', 3, min = 1, max = 9) 12 | ), 13 | mainPanel( 14 | plotOutput('plot1') 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /051-movie-explorer/.Renviron: -------------------------------------------------------------------------------- 1 | LANG="C.UTF-8" 2 | -------------------------------------------------------------------------------- /051-movie-explorer/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Movie explorer 2 | Author: Winston Chang 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Type: Shiny 6 | Tags: ggvis sliderinput 7 | -------------------------------------------------------------------------------- /051-movie-explorer/README.md: -------------------------------------------------------------------------------- 1 | This is the source code for a movie explorer app which runs on R and Shiny. The data is a subset of data from [OMDb](http://www.omdbapi.com/), which in turn is from IMDb and Rotten Tomatoes. The data is saved in a SQLite database. 2 | 3 | To run it locally, you'll need to install the latest versions of [ggvis](http://ggvis.rstudio.com), [Shiny](http://shiny.rstudio.com), and [dplyr](https://github.com/hadley/dplyr), as well as [RSQLite](http://cran.r-project.org/web/packages/RSQLite/index.html). 4 | 5 | ```r 6 | install.packages(c('shiny', 'ggvis', 'dplyr', 'RSQLite')) 7 | ``` 8 | 9 | You may need to restart R to make sure the newly-installed packages work properly. 10 | 11 | After all these packages are installed, you can run this app by entering the directory, and then running the following in R: 12 | 13 | ```s 14 | shiny::runApp() 15 | ``` 16 | -------------------------------------------------------------------------------- /051-movie-explorer/global.R: -------------------------------------------------------------------------------- 1 | # Variables that can be put on the x and y axes 2 | axis_vars <- c( 3 | "Tomato Meter" = "Meter", 4 | "Numeric Rating" = "Rating", 5 | "Number of reviews" = "Reviews", 6 | "Dollars at box office" = "BoxOffice", 7 | "Year" = "Year", 8 | "Length (minutes)" = "Runtime" 9 | ) 10 | -------------------------------------------------------------------------------- /051-movie-explorer/movies.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/051-movie-explorer/movies.db -------------------------------------------------------------------------------- /052-navbar-example/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Navbar Example 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: navbar layout 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /052-navbar-example/about.md: -------------------------------------------------------------------------------- 1 | ### Speed and Stopping Distances of Cars 2 | 3 | The data give the speed of cars and the distances taken to stop. Note that the data were recorded in the 1920s. 4 | 5 | * **Speed** - speed (mph) 6 | * **Dist** - stopping distance (ft) 7 | -------------------------------------------------------------------------------- /052-navbar-example/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | output$plot <- renderPlot({ 3 | plot(cars, type=input$plotType) 4 | }) 5 | 6 | output$summary <- renderPrint({ 7 | summary(cars) 8 | }) 9 | 10 | output$table <- DT::renderDataTable({ 11 | DT::datatable(cars) 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /053-navlistpanel-example/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: navlistPanel example 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: navlistpanel 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /053-navlistpanel-example/README.md: -------------------------------------------------------------------------------- 1 | A `navlistPanel` is like a `tabPanel`, except that the navigation links are on the left instead of the top. -------------------------------------------------------------------------------- /053-navlistpanel-example/server.r: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /053-navlistpanel-example/ui.r: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | titlePanel("Navlist panel example"), 4 | 5 | navlistPanel( 6 | "Header", 7 | tabPanel("First", 8 | h3("This is the first panel") 9 | ), 10 | tabPanel("Second", 11 | h3("This is the second panel") 12 | ), 13 | tabPanel("Third", 14 | h3("This is the third panel") 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: NVD3 line chart output 2 | Author: Joe Cheng 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Type: Shiny 6 | Tags: custom-output nvd3 d3 javascript 7 | 8 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/global.R: -------------------------------------------------------------------------------- 1 | # Any code in this file is guaranteed to be called before either 2 | # ui.R or server.R 3 | 4 | source("linechart.R") 5 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/output.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | output$mychart <- renderLineChart({ 4 | # Return a data frame. Each column will be a series in the line chart. 5 | data.frame( 6 | Sine = sin(1:100/10 + input$sinePhase * pi/180) * input$sineAmplitude, 7 | Cosine = 0.5 * cos(1:100/10), 8 | "Sine 2" = sin(1:100/10) * 0.25 + 0.5 9 | ) 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | tags$h2("JavaScript output binding example"), 3 | fluidRow( 4 | column(width=6, 5 | p("This Shiny app is an adaptation of the", 6 | a(href="http://nvd3.org/examples/line.html", "Simple Line Chart"), 7 | "example for the", 8 | a(href="http://nvd3.org/", "NVD3.js"), 9 | "JavaScript charting library." 10 | ), 11 | p("Source code:", 12 | a(href="https://github.com/jcheng5/shiny-js-examples/tree/master/output", "@jcheng5/shiny-js-examples/output")) 13 | ) 14 | ), 15 | fluidRow( 16 | column(width=9, 17 | lineChartOutput("mychart") 18 | ), 19 | column(width=3, 20 | sliderInput("sinePhase", "Sine phase", -180, 180, 0, step=10, 21 | animate=animationOptions(interval=100, loop=TRUE)), 22 | sliderInput("sineAmplitude", "Sine amplitude", -2, 2, 1, step=0.1, 23 | animate=animationOptions(interval=100, loop=TRUE)) 24 | ) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Jekyll Files # 3 | ################ 4 | _site 5 | 6 | 7 | # Random Files # 8 | ################ 9 | *.swp 10 | *~ 11 | *.log 12 | 13 | 14 | # Private Test Data # 15 | ##################### 16 | *REALDATA* 17 | 18 | 19 | # OS generated files # 20 | ###################### 21 | .DS_Store* 22 | ehthumbs.db 23 | Icon? 24 | Thumbs.db 25 | # nodejs packages # 26 | ###################### 27 | node_modules 28 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "asi": true 3 | } 4 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nvd3", 3 | "version": "1.1.15-beta", 4 | "homepage": "http://www.nvd3.org", 5 | "authors": [ 6 | "Bob Monteverde", 7 | "Tyler Wolf", 8 | "Robin Hu", 9 | "Frank Shao" 10 | ], 11 | "description": "Re-usable charts and chart components for d3.", 12 | "main": ["nv.d3.js", "src/nv.d3.css"], 13 | "keywords": [ 14 | "d3", 15 | "visualization", 16 | "svg", 17 | "charts" 18 | ], 19 | "license": "Apache License, v2.0", 20 | "dependencies": { 21 | "d3": "~3.3.13" 22 | }, 23 | "ignore" : [ 24 | "**/.*", 25 | "node_modules", 26 | "bower_components", 27 | "test", 28 | "tests", 29 | "src/models/*", 30 | "src/*.js", 31 | "lib", 32 | "examples", 33 | "deprecated" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | copy src\intro.js /B + src\core.js /B + src\tooltip.js /B temp1.js /B 3 | copy src\models\*.js /B temp2.js /B 4 | copy temp1.js /B + temp2.js /B + src\outro.js /B nv.d3.js /B 5 | del temp1.js 6 | del temp2.js 7 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/examples/images/grey-minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/054-nvd3-line-chart-output/www/nvd3/examples/images/grey-minus.png -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/examples/images/grey-plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/054-nvd3-line-chart-output/www/nvd3/examples/images/grey-plus.png -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/examples/images/nvd3_sampleLineChart1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/054-nvd3-line-chart-output/www/nvd3/examples/images/nvd3_sampleLineChart1.png -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/examples/stream_layers.js: -------------------------------------------------------------------------------- 1 | 2 | /* Inspired by Lee Byron's test data generator. */ 3 | function stream_layers(n, m, o) { 4 | if (arguments.length < 3) o = 0; 5 | function bump(a) { 6 | var x = 1 / (.1 + Math.random()), 7 | y = 2 * Math.random() - .5, 8 | z = 10 / (.1 + Math.random()); 9 | for (var i = 0; i < m; i++) { 10 | var w = (i / m - y) * z; 11 | a[i] += x * Math.exp(-w * w); 12 | } 13 | } 14 | return d3.range(n).map(function() { 15 | var a = [], i; 16 | for (i = 0; i < m; i++) a[i] = o + o * Math.random(); 17 | for (i = 0; i < 5; i++) bump(a); 18 | return a.map(stream_index); 19 | }); 20 | } 21 | 22 | /* Another layer generator using gamma distributions. */ 23 | function stream_waves(n, m) { 24 | return d3.range(n).map(function(i) { 25 | return d3.range(m).map(function(j) { 26 | var x = 20 * j / m - i / 3; 27 | return 2 * x * Math.exp(-.5 * x); 28 | }).map(stream_index); 29 | }); 30 | } 31 | 32 | function stream_index(d, i) { 33 | return {x: i, y: Math.max(0, d)}; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nvd3", 3 | "version": "0.0.1", 4 | "devDependencies": { 5 | "grunt": "~0.4.1", 6 | "grunt-contrib-jshint": "~0.3.0", 7 | "grunt-contrib-watch": "~0.3.1", 8 | "grunt-contrib-uglify": "~0.2.0", 9 | "grunt-contrib-concat": "~0.2.0", 10 | "grunt-contrib-copy": "~0.4.1", 11 | "grunt-contrib-cssmin": "~0.6.2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/src/intro.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/src/outro.js: -------------------------------------------------------------------------------- 1 | })(); -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/test/testScript.js: -------------------------------------------------------------------------------- 1 | //A little snippet of D3 code that creates a button that lets you toggle whether a chart is the only one visible on a page or not. 2 | d3.selectAll(".chart button").on("click",function() { 3 | var thisId = this.parentElement.id; 4 | 5 | var chartContainer = d3.select("#" + thisId); 6 | if (chartContainer.attr("class").match("selected")) 7 | chartContainer.classed("selected",false); 8 | else 9 | chartContainer.classed("selected",true); 10 | 11 | d3.selectAll(".chart").style("display",function() { 12 | if (thisId === this.id) return "block"; 13 | 14 | if (d3.select(this).style("display") === "none") 15 | return "block"; 16 | else 17 | return "none"; 18 | }); 19 | window.onresize(); 20 | }); -------------------------------------------------------------------------------- /054-nvd3-line-chart-output/www/nvd3/test/teststyle.css: -------------------------------------------------------------------------------- 1 | body { 2 | overflow-y:scroll; 3 | font-family: arial; 4 | } 5 | 6 | text { 7 | font: 12px sans-serif; 8 | } 9 | 10 | .chart { 11 | float:left; 12 | height: 500px; 13 | text-align: center; 14 | font-weight: bold; 15 | margin-bottom: 2em; 16 | } 17 | .chart.full { 18 | width: 100%; 19 | } 20 | 21 | .chart.half { 22 | width: 50%; 23 | } 24 | 25 | .chart.third { 26 | width: 33%; 27 | } 28 | 29 | .chart.selected { 30 | width: 100% !important; 31 | } 32 | 33 | .navigation a{ 34 | margin-right: 1em; 35 | } 36 | 37 | .navigation { 38 | margin-bottom: 1em; 39 | } 40 | -------------------------------------------------------------------------------- /055-observer-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Observer demo 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: observer 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /055-observer-demo/README.md: -------------------------------------------------------------------------------- 1 | `output` variables are used to send information to client to display, and in most cases, they are all that's needed for an app. In some cases, though, you need more flexibility in what the server does in response to inputs. 2 | 3 | When you set an `output` variable to a value, that value is sent to the client to be displayed. In contrast, observers don't (by default) send anything to the client. Their purpose is simply to execute R code. For example, observers can be used to write to files or databases. They can also be used send custom messages to the client -- these are messages that don't fit into the normal `output` model. 4 | -------------------------------------------------------------------------------- /055-observer-demo/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | 3 | # Create a random name for the log file 4 | logfilename <- tempfile('logfile', fileext = '.txt') 5 | 6 | output$logfile <- renderText({ 7 | sprintf("Log file: %s", logfilename) 8 | }) 9 | 10 | # This observer adds an entry to the log file every time 11 | # input$n changes. 12 | obs <- observe({ 13 | cat(input$n, '\n', file = logfilename, append = TRUE) 14 | }) 15 | 16 | 17 | session$onSessionEnded(function() { 18 | # When the client ends the session, clean up the log file 19 | # for this session. 20 | unlink(logfilename) 21 | }) 22 | 23 | 24 | output$text <- renderText({ 25 | paste0("The value of input$n is: ", input$n) 26 | }) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /055-observer-demo/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("Observer demo"), 3 | mainPanel( 4 | p("This demo writes the value of the slider to a log file. If you can, check the file contents after moving the slider to confirm it's been appended to."), 5 | verbatimTextOutput('logfile'), 6 | fluidRow( 7 | column(4, wellPanel( 8 | sliderInput("n", "N:", 9 | min = 10, max = 1000, value = 200, step = 10) 10 | )), 11 | column(8, 12 | verbatimTextOutput("text"), 13 | br(), 14 | br(), 15 | p("In this example, what's visible in the client isn't", 16 | "what's interesting. The server is writing to a log", 17 | "file each time the slider value changes.") 18 | ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /057-plot-plus-three-columns/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot plus three columns 2 | Author: JJ Allaire 3 | AuthorUrl: http://www.rstudio.com/ 4 | Type: Shiny 5 | License: MIT 6 | DisplayMode: Showcase 7 | Tags: application-layout ggplot2 8 | -------------------------------------------------------------------------------- /057-plot-plus-three-columns/server.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | 3 | function(input, output) { 4 | 5 | dataset <- reactive({ 6 | diamonds[sample(nrow(diamonds), input$sampleSize),] 7 | }) 8 | 9 | output$plot <- renderPlot({ 10 | 11 | p <- ggplot(dataset(), aes_string(x=input$x, y=input$y)) + geom_point() 12 | 13 | if (input$color != 'None') 14 | p <- p + aes_string(color=input$color) 15 | 16 | facets <- paste(input$facet_row, '~', input$facet_col) 17 | if (facets != '. ~ .') 18 | p <- p + facet_grid(facets) 19 | 20 | if (input$jitter) 21 | p <- p + geom_jitter() 22 | if (input$smooth) 23 | p <- p + geom_smooth() 24 | 25 | print(p) 26 | 27 | }) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /057-plot-plus-three-columns/ui.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | 3 | dataset <- diamonds 4 | 5 | fluidPage( 6 | 7 | title = "Diamonds Explorer", 8 | 9 | plotOutput('plot'), 10 | 11 | hr(), 12 | 13 | fluidRow( 14 | column(3, 15 | h4("Diamonds Explorer"), 16 | sliderInput('sampleSize', 'Sample Size', 17 | min=1, max=nrow(dataset), 18 | value=min(1000, nrow(dataset)), 19 | step=500, round=0), 20 | br(), 21 | checkboxInput('jitter', 'Jitter'), 22 | checkboxInput('smooth', 'Smooth') 23 | ), 24 | column(4, offset = 1, 25 | selectInput('x', 'X', names(dataset)), 26 | selectInput('y', 'Y', names(dataset), names(dataset)[[2]]), 27 | selectInput('color', 'Color', c('None', names(dataset))) 28 | ), 29 | column(4, 30 | selectInput('facet_row', 'Facet Row', 31 | c(None='.', names(diamonds[sapply(diamonds, is.factor)]))), 32 | selectInput('facet_col', 'Facet Column', 33 | c(None='.', names(diamonds[sapply(diamonds, is.factor)]))) 34 | ) 35 | ) 36 | ) -------------------------------------------------------------------------------- /059-reactive-poll-and-file-reader/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Reactive poll and file reader 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: reactive-poll reactive-file-reader 7 | DisplayMode: Showcase 8 | 9 | -------------------------------------------------------------------------------- /059-reactive-poll-and-file-reader/README.md: -------------------------------------------------------------------------------- 1 | There are three main parts of the server code: 2 | 3 | 1. The first sets up an observer which writes to a log file once every second. This is just to make the example work; typically some external process will be writing to a file. 4 | 5 | 1. The second part uses a `reactiveFileReader` to monitor the log file for changes every 0.5 seconds. 6 | 7 | 1. The third part uses a `reactivePoll` to monitor the log file for changes every 4 seconds. The `reactivePoll` is general, and it will watch for things other than file changes. It could, for example, query a database. 8 | -------------------------------------------------------------------------------- /059-reactive-poll-and-file-reader/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("reactivePoll and reactiveFileReader"), 3 | fluidRow( 4 | column(12, 5 | p("This app has a log file which is appended to", 6 | "every second.") 7 | ) 8 | ), 9 | fluidRow( 10 | column(6, wellPanel( 11 | "This side uses a reactiveFileReader, which is monitoring", 12 | "the log file for changes every 0.5 seconds.", 13 | verbatimTextOutput("fileReaderText") 14 | )), 15 | 16 | column(6, wellPanel( 17 | "This side uses a reactivePoll, which is monitoring", 18 | "the log file for changes every 4 seconds.", 19 | verbatimTextOutput("pollText") 20 | )) 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /060-retirement-simulation/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Retirement simulation 2 | License: MIT 3 | Author: Michael Kapler , Joe Cheng 4 | AuthorUrl: http://systematicinvestor.wordpress.com/ 5 | Tags: simluation finance application-layout bootstrap-theme 6 | DisplayMode: Normal 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /061-server-to-client-custom-messages/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Server-to-client custom messages 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: send-custom-message 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /061-server-to-client-custom-messages/README.md: -------------------------------------------------------------------------------- 1 | Sometimes it's useful to send messages from the server to the client, in a way that can't easily be handled with the usual Shiny output bindings. 2 | 3 | `sendCustomMessage()` sends information from the server to the client. It's typically used inside an `observe()` statement. The message is converted from an R data structure to JSON using `RJSONIO::toJSON()`. 4 | 5 | On the client side, a message handler function must be registered to receive and do something with the message. Here, the Javascript file (in the www/ directory) which registers the handler gets included in the head of the HTML page. (Make sure to look at the full source code to see the Javascript file.) 6 | 7 | In this example, the message handler simply pops up an alert box which displays the content of the message. 8 | -------------------------------------------------------------------------------- /061-server-to-client-custom-messages/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | # An observer is used to send messages to the client. 3 | # The message is converted to JSON 4 | observe({ 5 | session$sendCustomMessage(type = 'testmessage', 6 | message = list(a = 1, b = 'text', 7 | controller = input$controller)) 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /061-server-to-client-custom-messages/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("sendCustomMessage example"), 3 | 4 | fluidRow( 5 | column(4, wellPanel( 6 | sliderInput("controller", "Controller:", 7 | min = 1, max = 20, value = 15), 8 | 9 | # This makes web page load the JS file in the HTML head. 10 | # The call to singleton ensures it's only included once 11 | # in a page. It's not strictly necessary in this case, but 12 | # it's good practice. 13 | singleton( 14 | tags$head(tags$script(src = "message-handler.js")) 15 | ) 16 | )) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /061-server-to-client-custom-messages/www/message-handler.js: -------------------------------------------------------------------------------- 1 | // This recieves messages of type "testmessage" from the server. 2 | Shiny.addCustomMessageHandler("testmessage", 3 | function(message) { 4 | alert(JSON.stringify(message)); 5 | } 6 | ); 7 | -------------------------------------------------------------------------------- /062-submitbutton-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: submitButton demo 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: submitbutton 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /062-submitbutton-demo/README.md: -------------------------------------------------------------------------------- 1 | When a `submitButton` is present in a Shiny application, it causes **all** the inputs on the page to not send updates to the server until the button is pressed. 2 | 3 | Because a `submitButton` alters the behavior of all other inputs on the page, we generally recommend **not** using `submitButton`, and using `actionButton` instead. In most cases, it is best not to use `submitButton`, but instead to use `actionButton`, since it allows finer-grained control over which inputs will trigger re-execution of code. See the `actionButton` demo in the gallery for more information. 4 | -------------------------------------------------------------------------------- /062-submitbutton-demo/server.r: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | output$plot1 <- renderPlot({ 3 | hist(rnorm(input$n)) 4 | }) 5 | 6 | output$text <- renderText({ 7 | paste("Input text is:", input$text) 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /062-submitbutton-demo/ui.r: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | titlePanel("submitButton example"), 3 | fluidRow( 4 | column(3, wellPanel( 5 | sliderInput("n", "N:", min = 10, max = 1000, value = 200, 6 | step = 10), 7 | textInput("text", "Text:", "text here"), 8 | submitButton("Submit") 9 | )), 10 | column(6, 11 | plotOutput("plot1", width = 400, height = 300), 12 | verbatimTextOutput("text") 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /063-superzip-example/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: SuperZip example 2 | License: MIT 3 | DisplayMode: Normal 4 | Author: Joe Cheng 5 | AuthorUrl: http://www.rstudio.com/ 6 | Type: Shiny 7 | Tags: leaflet selectize datatables absolutepanel 8 | -------------------------------------------------------------------------------- /063-superzip-example/README.md: -------------------------------------------------------------------------------- 1 | # SuperZIP demo 2 | 3 | See a version of it live at http://shiny.rstudio.com/gallery/superzip-example.html 4 | 5 | You can run this demo with: 6 | ``` 7 | if (!require(devtools)) 8 | install.packages("devtools") 9 | devtools::install_github("rstudio/leaflet") 10 | shiny::runGitHub("rstudio/shiny-examples", subdir="063-superzip-example") 11 | ``` 12 | 13 | Data compiled for _Coming Apart: The State of White America, 1960–2010_ by Charles Murray (Crown Forum, 2012). This app was inspired by the Washington Post's interactive feature _[Washington: A world apart](http://www.washingtonpost.com/sf/local/2013/11/09/washington-a-world-apart/)_. 14 | -------------------------------------------------------------------------------- /063-superzip-example/data/-revisedmurrayfile_111952895138.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/063-superzip-example/data/-revisedmurrayfile_111952895138.xls -------------------------------------------------------------------------------- /063-superzip-example/data/deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wget http://notebook.gaslampmedia.com/wp-content/uploads/2013/08/zip_codes_states.csv 4 | wget http://www.aei.org/files/2012/02/16/-revisedmurrayfile_111952895138.xls 5 | -------------------------------------------------------------------------------- /063-superzip-example/data/superzip.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/063-superzip-example/data/superzip.rds -------------------------------------------------------------------------------- /063-superzip-example/global.R: -------------------------------------------------------------------------------- 1 | library(dplyr) 2 | 3 | allzips <- readRDS("data/superzip.rds") 4 | allzips$latitude <- jitter(allzips$latitude) 5 | allzips$longitude <- jitter(allzips$longitude) 6 | allzips$college <- allzips$college * 100 7 | allzips$zipcode <- formatC(allzips$zipcode, width=5, format="d", flag="0") 8 | row.names(allzips) <- allzips$zipcode 9 | 10 | cleantable <- allzips %>% 11 | select( 12 | City = city.x, 13 | State = state.x, 14 | Zipcode = zipcode, 15 | Rank = rank, 16 | Score = centile, 17 | Superzip = superzip, 18 | Population = adultpop, 19 | College = college, 20 | Income = income, 21 | Lat = latitude, 22 | Long = longitude 23 | ) 24 | -------------------------------------------------------------------------------- /063-superzip-example/gomap.js: -------------------------------------------------------------------------------- 1 | // When locator icon in datatable is clicked, go to that spot on the map 2 | $(document).on("click", ".go-map", function(e) { 3 | e.preventDefault(); 4 | $el = $(this); 5 | var lat = $el.data("lat"); 6 | var long = $el.data("long"); 7 | var zip = $el.data("zip"); 8 | $($("#nav a")[0]).tab("show"); 9 | Shiny.onInputChange("goto", { 10 | lat: lat, 11 | lng: long, 12 | zip: zip, 13 | nonce: Math.random() 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /063-superzip-example/styles.css: -------------------------------------------------------------------------------- 1 | input[type="number"] { 2 | max-width: 80%; 3 | } 4 | 5 | div.outer { 6 | position: fixed; 7 | top: 41px; 8 | left: 0; 9 | right: 0; 10 | bottom: 0; 11 | overflow: hidden; 12 | padding: 0; 13 | } 14 | 15 | /* Customize fonts */ 16 | body, label, input, button, select { 17 | font-family: 'Helvetica Neue', Helvetica; 18 | font-weight: 200; 19 | } 20 | h1, h2, h3, h4 { font-weight: 400; } 21 | 22 | #controls { 23 | /* Appearance */ 24 | background-color: white; 25 | padding: 0 20px 20px 20px; 26 | cursor: move; 27 | /* Fade out while not hovering */ 28 | opacity: 0.65; 29 | zoom: 0.9; 30 | transition: opacity 500ms 1s; 31 | } 32 | #controls:hover { 33 | /* Fade in while hovering */ 34 | opacity: 0.95; 35 | transition-delay: 0; 36 | } 37 | 38 | /* Position and style citation */ 39 | #cite { 40 | position: absolute; 41 | bottom: 10px; 42 | left: 10px; 43 | font-size: 12px; 44 | } 45 | 46 | /* If not using map tiles, show a white background */ 47 | .leaflet-container { 48 | background-color: white !important; 49 | } -------------------------------------------------------------------------------- /064-telephones-by-region/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Telephones by region 2 | Author: Jeff Allen 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: sidebarlayout helptext selectinput 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /064-telephones-by-region/server.R: -------------------------------------------------------------------------------- 1 | # Rely on the 'WorldPhones' dataset in the datasets 2 | # package (which generally comes preloaded). 3 | library(datasets) 4 | 5 | # Define a server for the Shiny app 6 | function(input, output) { 7 | 8 | # Fill in the spot we created for a plot 9 | output$phonePlot <- renderPlot({ 10 | 11 | # Render a barplot 12 | barplot(WorldPhones[,input$region]*1000, 13 | main=input$region, 14 | ylab="Number of Telephones", 15 | xlab="Year") 16 | }) 17 | } 18 | -------------------------------------------------------------------------------- /064-telephones-by-region/ui.R: -------------------------------------------------------------------------------- 1 | # Rely on the 'WorldPhones' dataset in the datasets 2 | # package (which generally comes preloaded). 3 | library(datasets) 4 | 5 | # Use a fluid Bootstrap layout 6 | fluidPage( 7 | 8 | # Give the page a title 9 | titlePanel("Telephones by region"), 10 | 11 | # Generate a row with a sidebar 12 | sidebarLayout( 13 | 14 | # Define the sidebar with one input 15 | sidebarPanel( 16 | selectInput("region", "Region:", 17 | choices=colnames(WorldPhones)), 18 | hr(), 19 | helpText("Data from AT&T (1961) The World's Telephones.") 20 | ), 21 | 22 | # Create a spot for the barplot 23 | mainPanel( 24 | plotOutput("phonePlot") 25 | ) 26 | 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /065-update-input-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Update input demo 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: updateinput 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /065-update-input-demo/README.md: -------------------------------------------------------------------------------- 1 | The user interface components in this example are updated when the server sends a command to the client. This is different from the Dynamic UI example, where the user interface component is generated on the server and sent to the client, where it replaces an existing UI component. Updating an input is faster and usually preferable, but sometimes it's not powerful enough - for example, if you want to replace the UI component with one of a different type, you need to replace it. See the Dynamic UI demo for an example of this. 2 | -------------------------------------------------------------------------------- /066-upload-file/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Upload File 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: file-upload 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /066-upload-file/README.md: -------------------------------------------------------------------------------- 1 | We can add a file upload input in the UI using the function `fileInput()`, 2 | e.g. `fileInput('foo')`. In `server.R`, we can access the uploaded files via 3 | `input$foo`. See [the 4 | tutorial](http://rstudio.github.io/shiny/tutorial/#uploads) for more details. 5 | -------------------------------------------------------------------------------- /066-upload-file/server.R: -------------------------------------------------------------------------------- 1 | # By default, the file size limit is 5MB. It can be changed by 2 | # setting this option. Here we'll raise limit to 9MB. 3 | options(shiny.maxRequestSize = 9*1024^2) 4 | 5 | function(input, output) { 6 | output$contents <- renderTable({ 7 | # input$file1 will be NULL initially. After the user selects 8 | # and uploads a file, it will be a data frame with 'name', 9 | # 'size', 'type', and 'datapath' columns. The 'datapath' 10 | # column will contain the local filenames where the data can 11 | # be found. 12 | 13 | inFile <- input$file1 14 | 15 | if (is.null(inFile)) 16 | return(NULL) 17 | 18 | read.csv(inFile$datapath, header = input$header, 19 | sep = input$sep, quote = input$quote) 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /066-upload-file/www/pressure.tsv: -------------------------------------------------------------------------------- 1 | "temperature" "pressure" 2 | 0 2e-04 3 | 20 0.0012 4 | 40 0.006 5 | 60 0.03 6 | 80 0.09 7 | 100 0.27 8 | 120 0.75 9 | 140 1.85 10 | 160 4.2 11 | 180 8.8 12 | 200 17.3 13 | 220 32.1 14 | 240 57 15 | 260 96 16 | 280 157 17 | 300 247 18 | 320 376 19 | 340 558 20 | 360 806 21 | -------------------------------------------------------------------------------- /067-vertical-layout/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Vertical Layout 3 | License: MIT 4 | Author: Winston Chang 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: vertical-layout 7 | DisplayMode: Showcase 8 | 9 | -------------------------------------------------------------------------------- /067-vertical-layout/README.md: -------------------------------------------------------------------------------- 1 | Each item passed to `verticalLayout()` will occupy a row. This is similar to `fluidRow()`, except that `fluidRow()` expects there to be one or more `column()`s inside, whereas `vertcialLayout()` does not; each item takes a full row. 2 | -------------------------------------------------------------------------------- /067-vertical-layout/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | output$plot1 <- renderPlot({ 3 | plot(x = rnorm(input$n), y = rnorm(input$n)) 4 | }) 5 | } 6 | -------------------------------------------------------------------------------- /067-vertical-layout/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | verticalLayout( 3 | titlePanel("Vertical layout example"), 4 | plotOutput("plot1"), 5 | wellPanel( 6 | sliderInput("n", "Number of points", 10, 200, 7 | value = 50, step = 10) 8 | ) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /068-widget-action-button/.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/068-widget-action-button/.RData -------------------------------------------------------------------------------- /068-widget-action-button/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Action Button 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /068-widget-action-button/README.md: -------------------------------------------------------------------------------- 1 | 2 | actionButton(inputId, label, icon = NULL) 3 | 4 | Creates an action button whose value is initially zero. The value advances by one each time the button is pressed. This change can spur an action, even if your app does not directly use the value. 5 | 6 | ##### Arguments 7 | 8 | `inputId` 9 | The name to use to look up the value of the widget (as a character string) 10 | 11 | `label` 12 | The label to display in the button. This can also be an HTML element such as an image. 13 | 14 | `icon` 15 | Optional icon to appear on the button 16 | 17 | _Make this widget by copying the code in ui.R._ 18 | -------------------------------------------------------------------------------- /068-widget-action-button/action-button.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /068-widget-action-button/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$action, e.g. 4 | output$value <- renderPrint({ input$action }) 5 | 6 | } 7 | -------------------------------------------------------------------------------- /068-widget-action-button/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make an action button 4 | actionButton("action", label = "Action"), 5 | 6 | hr(), 7 | fluidRow(column(2, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /069-widget-check-group/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Checkbox Group 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /069-widget-check-group/README.md: -------------------------------------------------------------------------------- 1 | 2 | checkboxGroupInput(inputId, label, choices, selected = NULL) 3 | 4 | Creates a group of checkboxes. The widget sends the server a character vector that contains the values of the selected boxes. 5 | 6 | ##### Arguments 7 | 8 | `inputId` 9 | The name to use to look up the value of the widget (as a character string) 10 | 11 | `label` 12 | A label to display above the check boxes 13 | 14 | `choices` 15 | A list of values. The widget will build a checkbox for each value of the list. If the list has names, these will be displayed next to the checkboxes. Otherwise the values themselves will be displayed. 16 | 17 | `selected` 18 | The values that should initially be selected, if any. 19 | 20 | _Make this widget by copying the code in ui.R._ 21 | -------------------------------------------------------------------------------- /069-widget-check-group/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the values of the widget (as a vector) 4 | # with input$checkGroup, e.g. 5 | output$value <- renderPrint({ input$checkGroup }) 6 | 7 | } 8 | -------------------------------------------------------------------------------- /069-widget-check-group/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the chunk below to make a group of checkboxes 4 | checkboxGroupInput("checkGroup", label = h3("Checkbox group"), 5 | choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), 6 | selected = 1), 7 | 8 | 9 | hr(), 10 | fluidRow(column(3, verbatimTextOutput("value"))) 11 | 12 | ) 13 | -------------------------------------------------------------------------------- /070-widget-checkbox/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Checkbox 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /070-widget-checkbox/README.md: -------------------------------------------------------------------------------- 1 | 2 | checkboxInput(inputId, label, value = FALSE) 3 | 4 | Creates a single checkbox. The widget sends the server `TRUE` if the box is checked, `FALSE` otherwise. 5 | 6 | ##### Arguments 7 | 8 | `inputId` 9 | The name to use to look up the value of the widget (as a character string) 10 | 11 | `label` 12 | A label to display next to the checkbox 13 | 14 | `value` 15 | A logical value. If `TRUE`, the checkbox will begin checked. If `FALSE`, it will begin unchecked. 16 | 17 | _Make this widget by copying the code in ui.R._ 18 | -------------------------------------------------------------------------------- /070-widget-checkbox/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$checkbox, e.g. 4 | output$value <- renderPrint({ input$checkbox }) 5 | 6 | } 7 | -------------------------------------------------------------------------------- /070-widget-checkbox/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a checkbox 4 | checkboxInput("checkbox", label = "Choice A", value = TRUE), 5 | 6 | hr(), 7 | fluidRow(column(3, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /071-widget-date/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Date Selector 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /071-widget-date/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$date, e.g. 4 | output$value <- renderPrint({ input$date }) 5 | 6 | } 7 | -------------------------------------------------------------------------------- /071-widget-date/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a date selector 4 | dateInput("date", label = h3("Date input"), value = "2014-01-01"), 5 | 6 | hr(), 7 | fluidRow(column(3, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /072-widget-date-range/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Date Range Selector 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /072-widget-date-range/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the values of the widget (as a vector of Dates) 4 | # with input$dates, e.g. 5 | output$value <- renderPrint({ input$dates }) 6 | 7 | } 8 | -------------------------------------------------------------------------------- /072-widget-date-range/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a date range selector 4 | dateRangeInput("dates", label = h3("Date range")), 5 | 6 | hr(), 7 | fluidRow(column(4, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /073-widget-file/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: File Upload widget 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /073-widget-file/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$file, e.g. 4 | output$value <- renderPrint({ 5 | str(input$file) 6 | }) 7 | 8 | } 9 | -------------------------------------------------------------------------------- /073-widget-file/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a file upload manager 4 | fileInput("file", label = h3("File input")), 5 | 6 | hr(), 7 | fluidRow(column(4, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /074-widget-numeric/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Number Selector 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /074-widget-numeric/README.md: -------------------------------------------------------------------------------- 1 | 2 | numericInput(inputId, label, value, min = NA, max = NA, step = NA) 3 | 4 | 5 | Creates a box you can use to enter numeric values. You can type a number or scroll through values with the box's scroll bar. The widget will pass the value shown in the box to the server as a double (e.g. number). 6 | 7 | ##### Arguments 8 | 9 | `inputId` 10 | The name to use to look up the value of the widget (as a character string) 11 | 12 | `label` 13 | A label to display above the number field 14 | 15 | `value` 16 | The initial number to display in the number field 17 | 18 | `min` 19 | The minimum number that can be selected 20 | 21 | `max` 22 | The maximum number that can be selected 23 | 24 | `step` 25 | The amount to increment the value by when a user clicks up or down on the scroll bar. 26 | 27 | _Make this widget by copying the code in ui.R._ 28 | -------------------------------------------------------------------------------- /074-widget-numeric/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$num, e.g. 4 | output$value <- renderPrint({ input$num }) 5 | 6 | } 7 | -------------------------------------------------------------------------------- /074-widget-numeric/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a number input box into the UI. 4 | numericInput("num", label = h3("Numeric input"), value = 1), 5 | 6 | hr(), 7 | fluidRow(column(3, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /075-widget-radio/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Radio Buttons 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /075-widget-radio/README.md: -------------------------------------------------------------------------------- 1 | 2 | radioButtons(inputId, label, choices, selected = NULL) 3 | 4 | 5 | Creates a set of radio buttons, several buttons only one of which can be pressed at any time. The widget will return the value of the selected button to the server as a character string. 6 | 7 | ##### Arguments 8 | 9 | `inputId` 10 | The name to use to look up the value of the widget (as a character string) 11 | 12 | `label` 13 | A label to display above the buttons 14 | 15 | `choices` 16 | A list of values. The widget will build a button for each value of the list. If the list has names, these will be displayed next to the buttons. Otherwise the values themselves will be displayed. 17 | 18 | `selected` 19 | The value that should initially be selected, defaults to the first value. 20 | 21 | _Make this widget by copying the code in ui.R._ 22 | -------------------------------------------------------------------------------- /075-widget-radio/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the values of the widget (as a vector) 4 | # with input$radio, e.g. 5 | output$value <- renderPrint({ input$radio }) 6 | 7 | } 8 | -------------------------------------------------------------------------------- /075-widget-radio/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a set of radio buttons 4 | radioButtons("radio", label = h3("Radio buttons"), 5 | choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), 6 | selected = 1), 7 | 8 | hr(), 9 | fluidRow(column(3, verbatimTextOutput("value"))) 10 | 11 | ) 12 | -------------------------------------------------------------------------------- /076-widget-select/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Select Box 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /076-widget-select/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$select, e.g. 4 | output$value <- renderPrint({ input$select }) 5 | 6 | } 7 | -------------------------------------------------------------------------------- /076-widget-select/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a select box 4 | selectInput("select", label = h3("Select box"), 5 | choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), 6 | selected = 1), 7 | 8 | hr(), 9 | fluidRow(column(3, verbatimTextOutput("value"))) 10 | 11 | ) 12 | -------------------------------------------------------------------------------- /077-widget-slider/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Slider Bar and Slider Range 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /077-widget-slider/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$slider1, e.g. 4 | output$value <- renderPrint({ input$slider1 }) 5 | 6 | # You can access the values of the second widget with input$slider2, e.g. 7 | output$range <- renderPrint({ input$slider2 }) 8 | } 9 | -------------------------------------------------------------------------------- /077-widget-slider/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | fluidRow( 3 | column(4, 4 | 5 | # Copy the line below to make a slider bar 6 | sliderInput("slider1", label = h3("Slider"), min = 0, 7 | max = 100, value = 50) 8 | ), 9 | column(4, 10 | 11 | # Copy the line below to make a slider range 12 | sliderInput("slider2", label = h3("Slider Range"), min = 0, 13 | max = 100, value = c(40, 60)) 14 | ) 15 | ), 16 | 17 | hr(), 18 | 19 | fluidRow( 20 | column(4, verbatimTextOutput("value")), 21 | column(4, verbatimTextOutput("range")) 22 | ) 23 | 24 | ) 25 | -------------------------------------------------------------------------------- /078-widget-slider-range/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Slider Range 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: widgets slider 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /078-widget-slider-range/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget (as a vector of length 2) 4 | # with input$slider2, e.g. 5 | output$value <- renderPrint({ input$slider2 }) 6 | 7 | } 8 | -------------------------------------------------------------------------------- /078-widget-slider-range/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a slider bar with a range 4 | sliderInput("slider2", label = h3("Slider Range"), min = 0, max = 100, 5 | value = c(25, 75)), 6 | 7 | hr(), 8 | fluidRow(column(3, verbatimTextOutput("value"))) 9 | 10 | ) 11 | -------------------------------------------------------------------------------- /079-widget-submit/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Submit Button 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /079-widget-submit/README.md: -------------------------------------------------------------------------------- 1 | 2 | submitButton(text = "Apply Changes", icon = NULL) 3 | 4 | 5 | Creates a submit button. Apps that use a submit button do not update their output as soon as a user makes a change, rather they wait until the user clicks the submit button. This can be a useful way to let your user make several changes and then apply them all at once. 6 | 7 | ##### Arguments 8 | 9 | `text` 10 | A character string to display in the button 11 | 12 | `icon` 13 | An optional icon to appear in the button 14 | 15 | _Make this widget by copying the code in ui.R._ 16 | -------------------------------------------------------------------------------- /079-widget-submit/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # submit buttons do not have a value of their own, 4 | # they control when the app accesses values of other widgets. 5 | # input$num is the value of the number widget. 6 | output$value <- renderPrint({ input$num }) 7 | 8 | } 9 | -------------------------------------------------------------------------------- /079-widget-submit/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | numericInput("num", label = "Make changes", value = 1), 4 | 5 | # Copy the line below to place a submit into the UI. 6 | submitButton("Apply Changes"), 7 | 8 | hr(), 9 | fluidRow(column(3, verbatimTextOutput("value"))) 10 | 11 | ) 12 | -------------------------------------------------------------------------------- /080-widget-text/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Text Input 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | DisplayMode: Showcase 7 | Type: Shiny -------------------------------------------------------------------------------- /080-widget-text/README.md: -------------------------------------------------------------------------------- 1 | 2 | textInput(inputId, label, value = "") 3 | 4 | 5 | Create a text field to enter text in. The widget will pass the text displayed to the server as a character string. 6 | 7 | ##### Arguments 8 | 9 | `inputId` 10 | The name to use to look up the value of the widget (as a character string) 11 | 12 | `label` 13 | A label to display above the text field 14 | 15 | `value` 16 | The initial text to display in the box, if any 17 | 18 | _Make this widget by copying the code in ui.R._ 19 | -------------------------------------------------------------------------------- /080-widget-text/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | # You can access the value of the widget with input$text, e.g. 4 | output$value <- renderPrint({ input$text }) 5 | 6 | } 7 | -------------------------------------------------------------------------------- /080-widget-text/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | 3 | # Copy the line below to make a text input box 4 | textInput("text", label = h3("Text input"), value = "Enter text..."), 5 | 6 | hr(), 7 | fluidRow(column(3, verbatimTextOutput("value"))) 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /081-widgets-gallery/.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/081-widgets-gallery/.RData -------------------------------------------------------------------------------- /081-widgets-gallery/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Widget Gallery 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: widgets 6 | Type: Shiny 7 | -------------------------------------------------------------------------------- /081-widgets-gallery/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | output$actionOut <- renderPrint({ input$action }) 4 | output$checkboxOut <- renderPrint({ input$checkbox }) 5 | output$checkGroupOut <- renderPrint({ input$checkGroup }) 6 | output$dateOut <- renderPrint({ input$date }) 7 | output$datesOut <- renderPrint({ input$dates }) 8 | output$fileOut <- renderPrint({ input$file }) 9 | output$numOut <- renderPrint({ input$num }) 10 | output$radioOut <- renderPrint({ input$radio }) 11 | output$selectOut <- renderPrint({ input$select }) 12 | output$slider1Out <- renderPrint({ input$slider1 }) 13 | output$slider2Out <- renderPrint({ input$slider2 }) 14 | #output$submitOut <- renderPrint({ input$submit }) 15 | output$textOut <- renderPrint({ input$text }) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /081-widgets-gallery/widgets.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /081-widgets-gallery/www/texturebg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/081-widgets-gallery/www/texturebg.png -------------------------------------------------------------------------------- /082-word-cloud/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Word cloud 2 | Author: Fereshteh Karimeddini 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: wordcloud text-mining actionbutton 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /082-word-cloud/README.md: -------------------------------------------------------------------------------- 1 | A simple word cloud generator, based on [this blog post](http://pirategrunt.com/2013/12/11/24-days-of-r-day-11/) by PirateGrunt. -------------------------------------------------------------------------------- /082-word-cloud/merchant.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/082-word-cloud/merchant.txt.gz -------------------------------------------------------------------------------- /082-word-cloud/romeo.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/082-word-cloud/romeo.txt.gz -------------------------------------------------------------------------------- /082-word-cloud/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/082-word-cloud/screenshot.png -------------------------------------------------------------------------------- /082-word-cloud/server.R: -------------------------------------------------------------------------------- 1 | # Text of the books downloaded from: 2 | # A Mid Summer Night's Dream: 3 | # http://www.gutenberg.org/cache/epub/2242/pg2242.txt 4 | # The Merchant of Venice: 5 | # http://www.gutenberg.org/cache/epub/2243/pg2243.txt 6 | # Romeo and Juliet: 7 | # http://www.gutenberg.org/cache/epub/1112/pg1112.txt 8 | 9 | function(input, output, session) { 10 | # Define a reactive expression for the document term matrix 11 | terms <- reactive({ 12 | # Change when the "update" button is pressed... 13 | input$update 14 | # ...but not for anything else 15 | isolate({ 16 | withProgress({ 17 | setProgress(message = "Processing corpus...") 18 | getTermMatrix(input$selection) 19 | }) 20 | }) 21 | }) 22 | 23 | # Make the wordcloud drawing predictable during a session 24 | wordcloud_rep <- repeatable(wordcloud) 25 | 26 | output$plot <- renderPlot({ 27 | v <- terms() 28 | wordcloud_rep(names(v), v, scale=c(4,0.5), 29 | min.freq = input$freq, max.words=input$max, 30 | colors=brewer.pal(8, "Dark2")) 31 | }) 32 | } 33 | -------------------------------------------------------------------------------- /082-word-cloud/summer.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/082-word-cloud/summer.txt.gz -------------------------------------------------------------------------------- /082-word-cloud/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | # Application title 3 | titlePanel("Word Cloud"), 4 | 5 | sidebarLayout( 6 | # Sidebar with a slider and selection inputs 7 | sidebarPanel( 8 | selectInput("selection", "Choose a book:", 9 | choices = books), 10 | actionButton("update", "Change"), 11 | hr(), 12 | sliderInput("freq", 13 | "Minimum Frequency:", 14 | min = 1, max = 50, value = 15), 15 | sliderInput("max", 16 | "Maximum Number of Words:", 17 | min = 1, max = 300, value = 100) 18 | ), 19 | 20 | # Show Word Cloud 21 | mainPanel( 22 | plotOutput("plot") 23 | ) 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /083-front-page/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Faithful 2 | Author: RStudio 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /083-front-page/README.md: -------------------------------------------------------------------------------- 1 | A simple Shiny app that displays eruption data for the Old Faithful geyser. Featured on the front page of the [Shiny Dev Center](http://shiny.rstudio.com). -------------------------------------------------------------------------------- /083-front-page/front-page.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /083-front-page/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | output$main_plot <- renderPlot({ 4 | 5 | hist(faithful$eruptions, 6 | probability = TRUE, 7 | breaks = as.numeric(input$n_breaks), 8 | xlab = "Duration (minutes)", 9 | main = "Geyser eruption duration") 10 | 11 | if (input$individual_obs) { 12 | rug(faithful$eruptions) 13 | } 14 | 15 | if (input$density) { 16 | dens <- density(faithful$eruptions, 17 | adjust = input$bw_adjust) 18 | lines(dens, col = "blue") 19 | } 20 | 21 | }) 22 | } -------------------------------------------------------------------------------- /083-front-page/ui.R: -------------------------------------------------------------------------------- 1 | bootstrapPage( 2 | 3 | selectInput(inputId = "n_breaks", 4 | label = "Number of bins in histogram (approximate):", 5 | choices = c(10, 20, 35, 50), 6 | selected = 20), 7 | 8 | checkboxInput(inputId = "individual_obs", 9 | label = strong("Show individual observations"), 10 | value = FALSE), 11 | 12 | checkboxInput(inputId = "density", 13 | label = strong("Show density estimate"), 14 | value = FALSE), 15 | 16 | plotOutput(outputId = "main_plot", height = "300px"), 17 | 18 | # Display this only if the density is shown 19 | conditionalPanel(condition = "input.density == true", 20 | sliderInput(inputId = "bw_adjust", 21 | label = "Bandwidth adjustment:", 22 | min = 0.2, max = 2, value = 1, step = 0.2) 23 | ) 24 | 25 | ) 26 | -------------------------------------------------------------------------------- /084-single-file/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Single-file shiny app 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: single-file 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /084-single-file/README.md: -------------------------------------------------------------------------------- 1 | This example shows how to make an app with a single file, app.R, instead of using the two files server.R and ui.R. 2 | -------------------------------------------------------------------------------- /084-single-file/app.R: -------------------------------------------------------------------------------- 1 | # Global variables can go here 2 | n <- 200 3 | 4 | 5 | # Define the UI 6 | ui <- bootstrapPage( 7 | numericInput('n', 'Number of obs', n), 8 | plotOutput('plot') 9 | ) 10 | 11 | 12 | # Define the server code 13 | server <- function(input, output) { 14 | output$plot <- renderPlot({ 15 | hist(runif(input$n)) 16 | }) 17 | } 18 | 19 | # Return a Shiny app object 20 | shinyApp(ui = ui, server = server) 21 | -------------------------------------------------------------------------------- /085-progress/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | Type: Shiny 3 | Title: Progress bar example 4 | Author: RStudio, Inc. 5 | AuthorUrl: http://www.rstudio.com/ 6 | License: MIT 7 | Tags: 8 | DisplayMode: Showcase 9 | -------------------------------------------------------------------------------- /085-progress/README.md: -------------------------------------------------------------------------------- 1 | This example shows two ways to add progress bars to an app. 2 | 3 | One method is to use `withProgress()`, and another is to create a `Progress` object using `shiny::Progress$new()`. The latter allows finer control over the progress bar, but it is a bit more complicated to use. -------------------------------------------------------------------------------- /085-progress/ui.R: -------------------------------------------------------------------------------- 1 | basicPage( 2 | plotOutput('plot', width = "300px", height = "300px"), 3 | tableOutput('table'), 4 | radioButtons('style', 'Progress bar style', c('notification', 'old')), 5 | actionButton('goPlot', 'Go plot'), 6 | actionButton('goTable', 'Go table') 7 | ) 8 | -------------------------------------------------------------------------------- /086-bus-dashboard/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Version: 2.0 2 | Type: Shiny 3 | Title: Bus dashboard example 4 | Author: RStudio, Inc. 5 | AuthorUrl: http://www.rstudio.com/ 6 | License: MIT 7 | Tags: 8 | DisplayMode: Normal 9 | -------------------------------------------------------------------------------- /086-bus-dashboard/R/gtfs.R: -------------------------------------------------------------------------------- 1 | 2 | get_transit_gtfs <- memoise::memoise(function() { 3 | download_and_read( 4 | url = "https://svc.metrotransit.org/mtgtfs/gtfs.zip", 5 | # Use consistent location for caching within R session 6 | destfile = file.path(tempdir(), "gtfs.zip"), 7 | read_fn = function(x) { 8 | gtfstools::read_gtfs(x, c("trips", "shapes")) 9 | } 10 | ) 11 | }) 12 | -------------------------------------------------------------------------------- /086-bus-dashboard/R/utils.R: -------------------------------------------------------------------------------- 1 | 2 | 3 | download_file <- function(url, destfile) { 4 | download.file(url, destfile, quiet = TRUE) 5 | } 6 | 7 | download_and_read <- function(url, destfile, read_fn, clean = FALSE) { 8 | if (!file.exists(destfile)) { 9 | download_file(url, destfile) 10 | } 11 | if (clean) { 12 | on.exit(unlink(destfile), add = TRUE) 13 | } 14 | 15 | read_fn(destfile) 16 | } 17 | 18 | 19 | # Method to recursively convert proto objects to lists 20 | # Great for debugging 21 | as_list <- function(x) { 22 | if (inherits(x, "Message")) { 23 | x <- as.list(x) 24 | } 25 | if (is.list(x)) { 26 | return(lapply(x, as_list)) 27 | } 28 | x 29 | } 30 | -------------------------------------------------------------------------------- /086-bus-dashboard/README.md: -------------------------------------------------------------------------------- 1 | Information about schedule data: https://svc.metrotransit.org/ 2 | 3 | Realtime GTFS proto definition: https://gtfs.org/realtime/proto/ 4 | -------------------------------------------------------------------------------- /087-crandash/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | Type: Shiny 3 | Title: Streaming CRAN data example 4 | Author: Joe Cheng 5 | AuthorUrl: http://www.rstudio.com/ 6 | License: MIT 7 | Tags: streaming 8 | DisplayMode: Normal 9 | -------------------------------------------------------------------------------- /087-crandash/README.md: -------------------------------------------------------------------------------- 1 | # crandash 2 | 3 | Demo of dashboard with streaming updates, using [Shiny](http://shiny.rstudio.com). 4 | 5 | The streaming data is a 1-week-delayed livestream of download logs from cran.rstudio.com. The server code for that service is at [jcheng5/cransim](https://github.com/jcheng5/cransim). 6 | 7 | ## Installation 8 | 9 | ```r 10 | install.packages(c("shiny", "dplyr", "htmlwidgets", "digest", "bit")) 11 | devtools::install_github("rstudio/shinydashboard") 12 | devtools::install_github("jcheng5/bubbles") 13 | devtools::install_github("hadley/shinySignals") 14 | ``` 15 | 16 | -------------------------------------------------------------------------------- /088-action-pattern1/088-action-pattern1.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /088-action-pattern1/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Action Button - Pattern 1 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: action-button 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /088-action-pattern1/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | tags$head(tags$script(src = "message-handler.js")), 5 | actionButton("do", "Click Me") 6 | ) 7 | 8 | server <- function(input, output, session) { 9 | observeEvent(input$do, { 10 | session$sendCustomMessage(type = 'testmessage', 11 | message = 'Thank you for clicking') 12 | }) 13 | } 14 | 15 | shinyApp(ui, server) -------------------------------------------------------------------------------- /088-action-pattern1/www/message-handler.js: -------------------------------------------------------------------------------- 1 | // This recieves messages of type "testmessage" from the server. 2 | // See http://shiny.rstudio.com/gallery/server-to-client-custom-messages.html 3 | // for details 4 | Shiny.addCustomMessageHandler("testmessage", 5 | function(message) { 6 | alert(JSON.stringify(message)); 7 | } 8 | ); -------------------------------------------------------------------------------- /089-action-pattern2/089-action-pattern2.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /089-action-pattern2/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Action Button - Pattern 2 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: action-button 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /089-action-pattern2/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | actionButton("go", "Go"), 5 | numericInput("n", "n", 50), 6 | plotOutput("plot") 7 | ) 8 | 9 | server <- function(input, output) { 10 | 11 | randomVals <- eventReactive(input$go, { 12 | runif(input$n) 13 | }) 14 | 15 | output$plot <- renderPlot({ 16 | hist(randomVals()) 17 | }) 18 | } 19 | 20 | shinyApp(ui, server) 21 | -------------------------------------------------------------------------------- /090-action-pattern3/090-action-pattern3.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /090-action-pattern3/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Action Button - Pattern 3 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: action-button 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /090-action-pattern3/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | actionButton("runif", "Uniform"), 5 | actionButton("rnorm", "Normal"), 6 | hr(), 7 | plotOutput("plot") 8 | ) 9 | 10 | server <- function(input, output){ 11 | v <- reactiveValues(data = NULL) 12 | 13 | observeEvent(input$runif, { 14 | v$data <- runif(100) 15 | }) 16 | 17 | observeEvent(input$rnorm, { 18 | v$data <- rnorm(100) 19 | }) 20 | 21 | output$plot <- renderPlot({ 22 | if (is.null(v$data)) return() 23 | hist(v$data) 24 | }) 25 | } 26 | 27 | shinyApp(ui, server) -------------------------------------------------------------------------------- /091-action-pattern4/091-action-pattern4.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /091-action-pattern4/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Action Button - Pattern 4 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: action-button 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /091-action-pattern4/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | actionButton("runif", "Uniform"), 5 | actionButton("reset", "Clear"), 6 | hr(), 7 | plotOutput("plot") 8 | ) 9 | 10 | server <- function(input, output){ 11 | v <- reactiveValues(data = NULL) 12 | 13 | observeEvent(input$runif, { 14 | v$data <- runif(100) 15 | }) 16 | 17 | observeEvent(input$reset, { 18 | v$data <- NULL 19 | }) 20 | 21 | output$plot <- renderPlot({ 22 | if (is.null(v$data)) return() 23 | hist(v$data) 24 | }) 25 | } 26 | 27 | shinyApp(ui, server) -------------------------------------------------------------------------------- /092-action-pattern5/092-action-pattern5.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /092-action-pattern5/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Action Button - Pattern 5 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: action-button 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /093-plot-interaction-basic/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot interaction - basic 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-interaction 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /093-plot-interaction-basic/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates basic plot interactions, with both base graphics and ggplot2. 2 | 3 | The four types of interactions are: clicking, double-clicking, hovering, and brushing. 4 | -------------------------------------------------------------------------------- /094-image-interaction-basic/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Image interaction - basic 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-interaction 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /094-image-interaction-basic/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates basic interactions with a dynamically-generated PNG image, which has a grid of lines spaced by 10 pixels. 2 | 3 | With `imageOutput`, Shiny provides pixel coordinates. This is in contrast to `plotOutput`, for which Shiny provides coordinates that are scaled to the data values. 4 | 5 | Note that depending on your browser window's width, you may see non-integer values for `x` or `y`. This is because, although the mouse cursor always has an integer-valued position, the image itself may have a non-integer position. You can see the image position in most web browsers by opening the Javascript console and running `$('#image1').offset()`. 6 | -------------------------------------------------------------------------------- /095-plot-interaction-advanced/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot interaction - advanced 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-interaction 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /096-plot-interaction-article-1/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- basicPage( 4 | plotOutput("plot1", click = "plot_click"), 5 | verbatimTextOutput("info") 6 | ) 7 | 8 | server <- function(input, output) { 9 | output$plot1 <- renderPlot({ 10 | plot(mtcars$wt, mtcars$mpg) 11 | }) 12 | 13 | output$info <- renderText({ 14 | paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y) 15 | }) 16 | } 17 | 18 | shinyApp(ui, server) 19 | -------------------------------------------------------------------------------- /096-plot-interaction-article-1/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /097-plot-interaction-article-2/app.R: -------------------------------------------------------------------------------- 1 | ui <- basicPage( 2 | plotOutput("plot1", 3 | click = "plot_click", 4 | dblclick = "plot_dblclick", 5 | hover = "plot_hover", 6 | brush = "plot_brush" 7 | ), 8 | verbatimTextOutput("info") 9 | ) 10 | 11 | server <- function(input, output) { 12 | output$plot1 <- renderPlot({ 13 | plot(mtcars$wt, mtcars$mpg) 14 | }) 15 | 16 | output$info <- renderText({ 17 | xy_str <- function(e) { 18 | if(is.null(e)) return("NULL\n") 19 | paste0("x=", round(e$x, 1), " y=", round(e$y, 1), "\n") 20 | } 21 | xy_range_str <- function(e) { 22 | if(is.null(e)) return("NULL\n") 23 | paste0("xmin=", round(e$xmin, 1), " xmax=", round(e$xmax, 1), 24 | " ymin=", round(e$ymin, 1), " ymax=", round(e$ymax, 1)) 25 | } 26 | 27 | paste0( 28 | "click: ", xy_str(input$plot_click), 29 | "dblclick: ", xy_str(input$plot_dblclick), 30 | "hover: ", xy_str(input$plot_hover), 31 | "brush: ", xy_range_str(input$plot_brush) 32 | ) 33 | }) 34 | } 35 | 36 | shinyApp(ui, server) 37 | -------------------------------------------------------------------------------- /097-plot-interaction-article-2/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /098-plot-interaction-article-3/app.R: -------------------------------------------------------------------------------- 1 | ui <- basicPage( 2 | plotOutput("plot1", click = "plot_click"), 3 | verbatimTextOutput("info") 4 | ) 5 | 6 | server <- function(input, output) { 7 | output$plot1 <- renderPlot({ 8 | plot(mtcars$wt, mtcars$mpg) 9 | }) 10 | 11 | output$info <- renderPrint({ 12 | # With base graphics, need to tell it what the x and y variables are. 13 | nearPoints(mtcars, input$plot_click, xvar = "wt", yvar = "mpg") 14 | # nearPoints() also works with hover and dblclick events 15 | }) 16 | } 17 | 18 | shinyApp(ui, server) 19 | -------------------------------------------------------------------------------- /098-plot-interaction-article-3/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /099-plot-interaction-article-4/app.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | ui <- basicPage( 3 | plotOutput("plot1", click = "plot_click"), 4 | verbatimTextOutput("info") 5 | ) 6 | 7 | server <- function(input, output) { 8 | output$plot1 <- renderPlot({ 9 | ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() 10 | }) 11 | 12 | output$info <- renderPrint({ 13 | # With ggplot2, no need to tell it what the x and y variables are. 14 | # threshold: set max distance, in pixels 15 | # maxpoints: maximum number of rows to return 16 | # addDist: add column with distance, in pixels 17 | nearPoints(mtcars, input$plot_click, threshold = 10, maxpoints = 1, 18 | addDist = TRUE) 19 | }) 20 | } 21 | 22 | shinyApp(ui, server) 23 | -------------------------------------------------------------------------------- /099-plot-interaction-article-4/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /100-plot-interaction-article-5/app.R: -------------------------------------------------------------------------------- 1 | ui <- basicPage( 2 | plotOutput("plot1", brush = "plot_brush"), 3 | verbatimTextOutput("info") 4 | ) 5 | 6 | server <- function(input, output) { 7 | output$plot1 <- renderPlot({ 8 | plot(mtcars$wt, mtcars$mpg) 9 | }) 10 | 11 | output$info <- renderPrint({ 12 | # With base graphics, need to tell it what the x and y variables are. 13 | brushedPoints(mtcars, input$plot_brush, xvar = "wt", yvar = "mpg") 14 | }) 15 | } 16 | 17 | shinyApp(ui, server) 18 | -------------------------------------------------------------------------------- /100-plot-interaction-article-5/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /101-plot-interaction-article-6/app.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | ui <- basicPage( 3 | plotOutput("plot1", brush = "plot_brush", height = 250), 4 | verbatimTextOutput("info") 5 | ) 6 | 7 | server <- function(input, output) { 8 | output$plot1 <- renderPlot({ 9 | ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + 10 | facet_grid(. ~ cyl) + 11 | theme_bw() 12 | }) 13 | 14 | output$info <- renderPrint({ 15 | brushedPoints(mtcars, input$plot_brush) 16 | }) 17 | } 18 | 19 | shinyApp(ui, server) 20 | -------------------------------------------------------------------------------- /101-plot-interaction-article-6/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /102-plot-interaction-article-7/app.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | ui <- basicPage( 3 | plotOutput("plot1", brush = "plot_brush"), 4 | verbatimTextOutput("info") 5 | ) 6 | 7 | server <- function(input, output) { 8 | options(width = 100) # Increase text width for printing table 9 | output$plot1 <- renderPlot({ 10 | ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() 11 | }) 12 | 13 | output$info <- renderPrint({ 14 | brushedPoints(mtcars, input$plot_brush, allRows = TRUE) 15 | }) 16 | } 17 | 18 | shinyApp(ui, server) 19 | -------------------------------------------------------------------------------- /102-plot-interaction-article-7/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /103-plot-interaction-article-8/app.R: -------------------------------------------------------------------------------- 1 | library(ggplot2) 2 | ui <- basicPage( 3 | plotOutput("plot1", 4 | brush = brushOpts(id = "plot_brush", fill = "#ccc", direction = "x"), 5 | height = 250 6 | ) 7 | ) 8 | 9 | server <- function(input, output) { 10 | output$plot1 <- renderPlot({ 11 | ggplot(ChickWeight, aes(x=Time, y=weight, colour=factor(Chick))) + 12 | geom_line() + 13 | guides(colour=FALSE) + 14 | theme_bw() 15 | }) 16 | } 17 | 18 | shinyApp(ui, server) 19 | -------------------------------------------------------------------------------- /103-plot-interaction-article-8/deps.R: -------------------------------------------------------------------------------- 1 | library(Cairo) 2 | -------------------------------------------------------------------------------- /104-plot-interaction-select/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot interaction - selecting points 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-interaction 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /104-plot-interaction-select/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates two ways of selecting points. 2 | 3 | The first way is to use `nearPoints()` with the click input object. 4 | 5 | The second way is to use `brushedPoints()` with the brush input object. 6 | -------------------------------------------------------------------------------- /105-plot-interaction-zoom/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot interaction - zoom 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-interaction 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /105-plot-interaction-zoom/README.md: -------------------------------------------------------------------------------- 1 | The plot on the left can be zoomed in by drawing a brush and then double-clicking on the brush. 2 | 3 | The middle and right plots are linked: when you draw a brush on the middle plot, the right plot will automatically zoom to the brush's dimensions. 4 | -------------------------------------------------------------------------------- /106-plot-interaction-exclude/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot interaction - excluding points 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-interaction 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /106-plot-interaction-exclude/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates how to exclude points from a computation. You can exclude points from a linear model by clicking on points, or by selecting them with a brush and clicking "Toggle points". 2 | 3 | To record the state of which rows of data are kept and which are excluded, we use a `reactiveValues` object containing a logical vector, each element of which represents whether each row is kept or excluded. The reactive value is modified whenever points are clicked or toggled. 4 | -------------------------------------------------------------------------------- /107-events/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: JavaScript Events in Shiny 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: JavaScript 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /107-events/Readme.md: -------------------------------------------------------------------------------- 1 | This app demonstrates the JavaScript events in Shiny. 2 | -------------------------------------------------------------------------------- /108-module-output/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Module example 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: modules 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /108-module-output/Readme.md: -------------------------------------------------------------------------------- 1 | This small example shows a Shiny module (`linked_scatter.R`) and how it can be 2 | used within an application (`app.R`). The linked scatter module lets the caller 3 | specify the data frame (mpg) and dimensions (cty/hwy and drv/hwy) that should 4 | be plotted, and also returns a reactive expression that contains the data 5 | frame with selection info in a `selected_` column. It renders two scatter 6 | plots that can be brushed (click and drag to make a selection) with coordinated 7 | highlighting between the plots. 8 | -------------------------------------------------------------------------------- /108-module-output/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | source("linked_scatter.R") 4 | 5 | ui <- fixedPage( 6 | h2("Module example"), 7 | linkedScatterUI("scatters"), 8 | textOutput("summary") 9 | ) 10 | 11 | server <- function(input, output, session) { 12 | df <- callModule(linkedScatter, "scatters", reactive(mpg), 13 | left = reactive(c("cty", "hwy")), 14 | right = reactive(c("drv", "hwy")) 15 | ) 16 | 17 | output$summary <- renderText({ 18 | sprintf("%d observation(s) selected", nrow(dplyr::filter(df(), selected_))) 19 | }) 20 | } 21 | 22 | shinyApp(ui, server) 23 | -------------------------------------------------------------------------------- /108-module-output/linked_scatter.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(ggplot2) 3 | 4 | linkedScatterUI <- function(id) { 5 | ns <- NS(id) 6 | 7 | fluidRow( 8 | column(6, plotOutput(ns("plot1"), brush = ns("brush"))), 9 | column(6, plotOutput(ns("plot2"), brush = ns("brush"))) 10 | ) 11 | } 12 | 13 | linkedScatter <- function(input, output, session, data, left, right) { 14 | # Yields the data frame with an additional column "selected_" 15 | # that indicates whether that observation is brushed 16 | dataWithSelection <- reactive({ 17 | brushedPoints(data(), input$brush, allRows = TRUE) 18 | }) 19 | 20 | output$plot1 <- renderPlot({ 21 | scatterPlot(dataWithSelection(), left()) 22 | }) 23 | 24 | output$plot2 <- renderPlot({ 25 | scatterPlot(dataWithSelection(), right()) 26 | }) 27 | 28 | return(dataWithSelection) 29 | } 30 | 31 | scatterPlot <- function(data, cols) { 32 | ggplot(data, aes_string(x = cols[1], y = cols[2])) + 33 | geom_point(aes(color = selected_)) + 34 | scale_color_manual(values = c("black", "#66D65C"), guide = FALSE) 35 | } 36 | -------------------------------------------------------------------------------- /109-render-table/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Table Demo App 3 | Author: Bárbara Borges 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | DisplayMode: Normal 7 | Tags: outputs -------------------------------------------------------------------------------- /110-error-sanitization/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Error Hiding Demo 3 | Author: Bárbara Borges 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | DisplayMode: Normal 7 | Tags: outputs -------------------------------------------------------------------------------- /110-error-sanitization/README.md: -------------------------------------------------------------------------------- 1 | If you are worried about sensitive information leaking through to the users of your app via error messages, fret not! You now have the option of sanitizing error messages, meaning that users will only see a generic error message unless you specify otherwise. Explore the app tabs to learn more about the error hiding mechanism in Shiny. -------------------------------------------------------------------------------- /111-insert-ui/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: insertUI and removeUI - Queue demo 3 | Author: Bárbara Borges 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | DisplayMode: Showcase -------------------------------------------------------------------------------- /111-insert-ui/README.md: -------------------------------------------------------------------------------- 1 | A simple app that inserts and removes elements using a queue logic. -------------------------------------------------------------------------------- /111-insert-ui/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | 3 | ## keep track of elements inserted and not yet removed 4 | inserted <- c() 5 | 6 | observeEvent(input$insertBtn, { 7 | btn <- input$insertBtn 8 | id <- paste0('txt', btn) 9 | insertUI( 10 | selector = '#placeholder', 11 | ## wrap element in a div with id for ease of removal 12 | ui = tags$div( 13 | tags$p(paste('Element number', btn)), 14 | id = id 15 | ) 16 | ) 17 | inserted <<- c(id, inserted) 18 | }) 19 | 20 | observeEvent(input$removeBtn, { 21 | removeUI( 22 | ## pass in appropriate div id 23 | selector = paste0('#', inserted[length(inserted)]) 24 | ) 25 | inserted <<- inserted[-length(inserted)] 26 | }) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /111-insert-ui/ui.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | fluidPage( 4 | actionButton('insertBtn', 'Insert'), 5 | actionButton('removeBtn', 'Remove'), 6 | tags$div(id = 'placeholder') 7 | ) 8 | -------------------------------------------------------------------------------- /112-generate-report/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Generating reports 3 | Author: Winston Chang 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: reports 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /112-generate-report/README.md: -------------------------------------------------------------------------------- 1 | This app generates a downloadable report when the download button is clicked. It uses a .Rmd file to generate the report. [Source code](https://github.com/rstudio/shiny-examples/tree/main/112-generate-report). Note that this app uses a temporaray directory because the app directory might not be writable when deployed. 2 | -------------------------------------------------------------------------------- /112-generate-report/report.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Dynamic report" 3 | output: html_document 4 | params: 5 | n: NA 6 | --- 7 | 8 | ```{r eval = FALSE, echo = FALSE} 9 | # For PDF output, change the header to have "output: pdf_document". 10 | # 11 | # Note that due to an issue in rmarkdown, the default value of a parameter in 12 | # the header cannot be `NULL`, so I used a default of `NA` for the default value 13 | # of `n`. 14 | ``` 15 | 16 | 17 | ```{r} 18 | # The `params` object is available in the document. 19 | params$n 20 | ``` 21 | 22 | A plot of `params$n` random points. 23 | 24 | ```{r} 25 | plot(rnorm(params$n), rnorm(params$n)) 26 | ``` 27 | -------------------------------------------------------------------------------- /113-bookmarking-url/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Bookmarking - URL 3 | Author: Winston Chang 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: bookmarking 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /113-bookmarking-url/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates bookmarking with the state encoded in the URL. 2 | -------------------------------------------------------------------------------- /113-bookmarking-url/app.R: -------------------------------------------------------------------------------- 1 | ui <- function(request) { 2 | fluidPage( 3 | plotOutput("plot"), 4 | sliderInput("n", "Number of observations", 1, nrow(faithful), 100), 5 | bookmarkButton() 6 | ) 7 | } 8 | 9 | server <- function(input, output, session) { 10 | output$plot <- renderPlot({ 11 | hist(faithful$eruptions[seq_len(input$n)], breaks = 40) 12 | }) 13 | } 14 | 15 | enableBookmarking(store = "url") 16 | shinyApp(ui, server) 17 | -------------------------------------------------------------------------------- /114-modal-dialog/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Modal dialogs 3 | Author: Winston Chang 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: modal 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /114-modal-dialog/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates modal dialogs. -------------------------------------------------------------------------------- /114-modal-dialog/app.R: -------------------------------------------------------------------------------- 1 | shinyApp( 2 | ui = basicPage( 3 | actionButton("show", "Show modal dialog") 4 | ), 5 | server = function(input, output) { 6 | observeEvent(input$show, { 7 | showModal(modalDialog( 8 | title = "Important message", 9 | "This is an important message!", 10 | easyClose = TRUE 11 | )) 12 | }) 13 | } 14 | ) 15 | -------------------------------------------------------------------------------- /115-bookmarking-updatequerystring/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Bookmarking with updateQueryString 3 | Author: Winston Chang 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: bookmarking 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /115-bookmarking-updatequerystring/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates bookmarking with the state encoded in the URL, and updates the browser's location bar automatically each time an input value changes. 2 | -------------------------------------------------------------------------------- /115-bookmarking-updatequerystring/app.R: -------------------------------------------------------------------------------- 1 | ui <- function(req) { 2 | fluidPage( 3 | textInput("txt", "Text"), 4 | checkboxInput("chk", "Checkbox") 5 | ) 6 | } 7 | server <- function(input, output, session) { 8 | observe({ 9 | # Trigger this observer every time an input changes 10 | reactiveValuesToList(input) 11 | session$doBookmark() 12 | }) 13 | onBookmarked(function(url) { 14 | updateQueryString(url) 15 | }) 16 | } 17 | 18 | enableBookmarking(store = "url") 19 | shinyApp(ui, server) 20 | -------------------------------------------------------------------------------- /116-notifications/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Notifications 3 | Author: Winston Chang 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: notifications 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /116-notifications/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates Shiny's notification system. -------------------------------------------------------------------------------- /117-shinythemes/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Shiny theme selector 3 | Author: Winston Chang 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: themes 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /117-shinythemes/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates the themes available in the [shinythemes](http://rstudio.github.io/shinythemes/) package. You can select a theme by using the selector in the upper right. 2 | 3 | Once you've found a theme that you like, you can use it in your app by passing the argument `theme = shinythemes::shinytheme("theme_name")` (where you replace `theme_name` with the theme that you want) to the top-level page function in your app. The top-level page function in your app will be one of `fluidPage()`, `bootstrapPage()`, `navbarPage()`, or `fixedPage()`. 4 | -------------------------------------------------------------------------------- /118-highcharter-births/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: The Friday the 13th effect 3 | Author: Mine Cetinkaya-Rundel 4 | AuthorUrl: http://www.rstudio.com/ 5 | License: MIT 6 | Tags: highcharter, highcharts 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /119-namespaced-conditionalpanel-demo/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Namespaced conditionalPanel demo 3 | License: MIT 4 | Author: Alan Dipert 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: conditionalpanel 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /120-goog-index/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Shiny 2 | Title: Google Trend Index 3 | License: MIT 4 | Author: Mine Cetinkaya-Rundel 5 | AuthorUrl: http://www.rstudio.com/ 6 | Tags: getting-started 7 | DisplayMode: Showcase 8 | -------------------------------------------------------------------------------- /120-goog-index/README.md: -------------------------------------------------------------------------------- 1 | A simple Shiny app that displays eruption data for the Google Trend Index app. 2 | -------------------------------------------------------------------------------- /120-goog-index/data/trend_description.csv: -------------------------------------------------------------------------------- 1 | type,text 2 | advert,"The Google Advertising & Marketing Index tracks queries related to marketing, advertising, ads, adsense, constant contact, public relations, etc." 3 | educat,"The Google Education Index tracks queries related to college, education, test, academy, barnes and noble, harvard, etc." 4 | smallbiz,"The Google Small Business Index tracks queries related to small business, make money, franchise, work from home, chamber or commerce, etc." 5 | travel,"The Google Travel Index tracks queries related to airlines, hotels, beach, southwest, las vegas, flights, etc." 6 | unempl,"The Google Unemployment Index tracks queries related to unemployment, food stamps, social security, edd, disability, etc." 7 | -------------------------------------------------------------------------------- /121-async-timer/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(future) 3 | library(promises) 4 | library(magrittr) 5 | plan(multisession) 6 | 7 | ui <- fluidPage( 8 | p("This app tests that ", tags$code("invalidateLater()"), " calls are held until async operations are complete."), 9 | tags$ol( 10 | tags$li("You should see the number below increasing by 1, every 2 seconds."), 11 | tags$li("The output should be semi-transparent (i.e. recalculating state) continuously."), 12 | tags$li("You should see the word 'Flushed' in the R console, every 2 seconds.") 13 | ), 14 | verbatimTextOutput("out") 15 | ) 16 | 17 | server <- function(input, output, session) { 18 | 19 | value <- reactiveVal(0L) 20 | 21 | observe({ 22 | invalidateLater(100) 23 | isolate({ value(value() + 1L) }) 24 | }) 25 | 26 | session$onFlushed(function() { 27 | message("Flushed") 28 | }, once = FALSE) 29 | 30 | output$out <- renderText({ 31 | future(Sys.sleep(2)) %...>% 32 | { value() } 33 | }) 34 | } 35 | 36 | shinyApp(ui, server) 37 | -------------------------------------------------------------------------------- /124-async-download/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(promises) 3 | library(future) 4 | plan(multiprocess) 5 | 6 | ui <- fluidPage( 7 | h2("Async downloadHandler test"), 8 | tags$ol( 9 | tags$li("Verify that plot appears below"), 10 | tags$li("Verify that pressing Download results in 5 second delay, then rock.csv being downloaded"), 11 | tags$li("Check 'Throw on download?' checkbox and verify that pressing Download results in 5 second delay, then error, as well as stack traces in console") 12 | ), 13 | hr(), 14 | checkboxInput("throw", "Throw on download?"), 15 | downloadButton("download", "Download (wait 5 seconds)"), 16 | plotOutput("plot") 17 | ) 18 | 19 | server <- function(input, output, session) { 20 | output$download <- downloadHandler("rock.csv", function(file) { 21 | future({Sys.sleep(5)}) %...>% 22 | { 23 | if (input$throw) { 24 | stop("boom") 25 | } else { 26 | write.csv(rock, file) 27 | } 28 | } 29 | }) 30 | 31 | output$plot <- renderPlot({ 32 | plot(cars) 33 | }) 34 | } 35 | 36 | shinyApp(ui, server) 37 | -------------------------------------------------------------------------------- /128-plot-dim-error/app.R: -------------------------------------------------------------------------------- 1 | # Test for https://github.com/rstudio/shiny/issues/1964 2 | 3 | library(shiny) 4 | 5 | ui <- fluidPage( 6 | p("Verify that this app doesn't crash on startup, and that Go draws a plot."), 7 | actionButton("go", "Go"), 8 | plotOutput("plot") 9 | ) 10 | 11 | server <- function(input, output, session) { 12 | w <- eventReactive(input$go, { 400 }) 13 | h <- eventReactive(input$go, { 400 }) 14 | 15 | output$plot <- renderPlot({ 16 | plot(cars) 17 | }, width = w, height = h) 18 | } 19 | 20 | shinyApp(ui, server) 21 | 22 | -------------------------------------------------------------------------------- /130-output-null/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | h3("Pressing \"Clear\" should clear the plot."), 5 | plotOutput("plot"), 6 | actionButton("clear", "Clear") 7 | ) 8 | 9 | server <- function(input, output, session) { 10 | output$plot <- renderPlot({ plot(cars) }) 11 | 12 | observeEvent(input$clear, { 13 | output$plot <- NULL 14 | }) 15 | } 16 | 17 | shinyApp(ui, server) 18 | -------------------------------------------------------------------------------- /131-renderplot-args/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- withTags(fluidPage( 4 | h3("Test of additional renderPlot args"), 5 | ol( 6 | li("The background of the plot should be the same color as the page background."), 7 | li("Try resizing the browser's width, make sure it's transparent even after redraw.") 8 | ), 9 | style("body { background-color: #A3E4D7; }"), 10 | plotOutput("plot") 11 | )) 12 | 13 | server <- function(input, output, session) { 14 | output$plot <- renderPlot({ 15 | par(bg = NA) 16 | plot(cars) 17 | }, bg = NA) 18 | } 19 | 20 | shinyApp(ui, server) 21 | -------------------------------------------------------------------------------- /134-async-hold-timers/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(promises) 3 | 4 | wait <- function(secs) { 5 | force(secs) 6 | promise(~{later::later(~resolve(TRUE), secs)}) 7 | } 8 | 9 | ui <- fluidPage( 10 | h2("Verify timers don't run until async tasks are complete"), 11 | "If this app runs for about 10 seconds without killing the session, that's success!" 12 | ) 13 | 14 | server <- function(input, output, session) { 15 | timer <- reactiveTimer(500) 16 | 17 | in_task <- FALSE 18 | 19 | observe({ 20 | invalidateLater(500) 21 | if (in_task) { 22 | stop("invalidateLater fired while async observer was active!") 23 | } 24 | }, priority = 1) 25 | 26 | observe({ 27 | timer() 28 | if (in_task) { 29 | stop("reactiveTimer fired while async observer was active!") 30 | } 31 | }, priority = 1) 32 | 33 | observe({ 34 | timer() 35 | in_task <<- TRUE 36 | wait(1300) %...>% { 37 | in_task <<- FALSE 38 | } 39 | }) 40 | } 41 | 42 | shinyApp(ui, server) 43 | 44 | -------------------------------------------------------------------------------- /136-plot-cache/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot caching - basic 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-cache 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /136-plot-cache/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates basic plot caching. 2 | -------------------------------------------------------------------------------- /136-plot-cache/app.R: -------------------------------------------------------------------------------- 1 | shinyApp( 2 | 3 | fluidPage( 4 | sidebarLayout( 5 | sidebarPanel( 6 | sliderInput("n", "Number of points", 4, 32, value = 8, step = 4) 7 | ), 8 | mainPanel(plotOutput("plot")) 9 | ) 10 | ), 11 | 12 | function(input, output, session) { 13 | output$plot <- renderCachedPlot( 14 | { 15 | Sys.sleep(2) # Add an artificial delay 16 | 17 | rownums <- seq_len(input$n) 18 | plot(cars$speed[rownums], cars$dist[rownums], 19 | xlim = range(cars$speed), ylim = range(cars$dist)) 20 | }, 21 | cacheKeyExpr = {input$n } 22 | ) 23 | } 24 | ) 25 | -------------------------------------------------------------------------------- /137-plot-cache-key/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Plot caching - data key 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: plot-cache 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /137-plot-cache-key/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates using multiple items in the plot cache key. 2 | -------------------------------------------------------------------------------- /137-plot-cache-key/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | randomData <- function() data.frame(x = rnorm(400), y = rnorm(400)) 3 | dataset <- reactiveVal(randomData()) 4 | 5 | ui <- fluidPage( 6 | sidebarLayout( 7 | sidebarPanel( 8 | sliderInput("n", "Number of points to display", 50, 400, 100, step = 50), 9 | actionButton("newdata", "Generate new data") 10 | ), 11 | mainPanel( 12 | plotOutput("plot") 13 | ) 14 | ) 15 | ) 16 | 17 | server <- function(input, output, session) { 18 | # When the newdata button is clicked, change the data set to new random data 19 | observeEvent(input$newdata, { 20 | dataset(randomData()) 21 | }) 22 | 23 | output$plot <- renderCachedPlot( 24 | { 25 | Sys.sleep(2) # Add an artificial delay 26 | d <- dataset() 27 | rownums <- seq_len(input$n) 28 | plot(d$x[rownums], d$y[rownums], xlim = range(d$x), ylim = range(d$y)) 29 | }, 30 | cacheKeyExpr = { 31 | list(input$n, dataset()) 32 | } 33 | ) 34 | } 35 | 36 | shinyApp(ui, server) 37 | -------------------------------------------------------------------------------- /138-icon-fontawesome/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: FontAwesome icons 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: fontawesome 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /138-icon-fontawesome/README.md: -------------------------------------------------------------------------------- 1 | This app demonstrates using `icon` to create [FontAwesome](https://fontawesome.com/) icons. 2 | -------------------------------------------------------------------------------- /141-radiant/README.md: -------------------------------------------------------------------------------- 1 | # [Radiant](https://github.com/radiant-rstats/radiant) 2 | 3 | Radiant is an open-source platform-independent browser-based interface for business analytics in [R](https://www.r-project.org/). The application is based on the [Shiny](https://www.rstudio.com/shiny/) package and can be run locally or on a server. Radiant was developed by Vincent Nijs. Please use the issue tracker on GitHub to suggest enhancements or report problems: https://github.com/radiant-rstats/radiant/issues. For other questions and comments please use radiant@rady.ucsd.edu. 4 | 5 | 6 | # Testing 7 | 8 | Make sure this package loads. Click on multiple tabs to launch their modules 9 | -------------------------------------------------------------------------------- /141-radiant/app.R: -------------------------------------------------------------------------------- 1 | ## CRAN 2 | # install.packages("radiant") 3 | 4 | ## Github instructions 5 | # install.packages("radiant", repos = "https://radiant-rstats.github.io/minicran/") 6 | 7 | library(radiant) 8 | 9 | ## Regular execution 10 | # radiant::radiant() 11 | 12 | # Retrieve the underlying shinyapp in radiant 13 | shiny::shinyAppDir(system.file("app", package = "radiant")) 14 | -------------------------------------------------------------------------------- /144-colors/countries.R: -------------------------------------------------------------------------------- 1 | # Converts countries.geojson to sf file and saves as RDS. This is 2 | # to spare people from needing to have rgdal installed just to 3 | # run the app. 4 | 5 | library(rgdal) 6 | library(sf) 7 | 8 | download.file("https://raw.githubusercontent.com/rstudio/leaflet/main/docs/json/countries.geojson", "countries.geojson") 9 | countries <- readOGR("countries.geojson", "OGRGeoJSON") 10 | saveRDS(st_as_sf(countries), "countries.rds") 11 | message("Saved countries.rds") 12 | -------------------------------------------------------------------------------- /144-colors/countries.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/144-colors/countries.rds -------------------------------------------------------------------------------- /146-ames-explorer/README.md: -------------------------------------------------------------------------------- 1 | This is the Ames Housing Explorer Shiny application discussed in the 2019 `rstudio::conf` presentation entitled __Effective use of Shiny modules__ created by [Eric Nantz](https://github.com/rpodcast). You can view the application at [gallery.shinyapps.io/ames-explorer](https://gallery.shinyapps.io/ames-explorer/) This application requires the following packages (each available on CRAN): 2 | * shiny 3 | * dplyr 4 | * ggplot2 5 | * scales 6 | * gghighlight 7 | * DT 8 | * AmesHousing 9 | -------------------------------------------------------------------------------- /146-ames-explorer/helpers/data_functions.R: -------------------------------------------------------------------------------- 1 | highlight_prep <- function(data, highlight_rows) { 2 | # assumes data set has a "selected_" column 3 | res_filtered <- data %>% 4 | filter(selected_) %>% 5 | mutate(label_ind = row_number() %in% highlight_rows) 6 | 7 | res_unfiltered <- data %>% 8 | filter(!selected_) %>% 9 | mutate(label_ind = FALSE) 10 | 11 | res <- bind_rows(res_filtered, res_unfiltered) 12 | 13 | return(res) 14 | } 15 | -------------------------------------------------------------------------------- /148-addresourcepath-deleted/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | tempdir <- tempfile("test") 4 | dir.create(tempdir) 5 | addResourcePath("my_test_prefix", tempdir) 6 | unlink(tempdir, recursive = TRUE) 7 | 8 | ui <- HTML("This app tests whether deleting a directory pointed to by addResourcePath breaks Shiny. If you're reading this, the test passed!") 9 | 10 | server <- function(input, output, session) { 11 | } 12 | 13 | shinyApp(ui, server) 14 | 15 | -------------------------------------------------------------------------------- /151-reactr-input/js/input.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | function SimpleTextInput(props) { 3 | return React.createElement('input', { 4 | value: props.value, 5 | onChange: function(e) { 6 | props.setValue(e.target.value); 7 | } 8 | }); 9 | } 10 | reactR.reactShinyInput('.simple-text-input', 'shiny.examples', SimpleTextInput); 11 | })(); 12 | -------------------------------------------------------------------------------- /152-set-reactivevalue/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | # Create a nested list, which is slow to print with str() 4 | obj <- lapply(1:60, function(i) { 5 | lapply(1:60, function(j) { 6 | list(i, j) 7 | }) 8 | }) 9 | 10 | 11 | shinyApp( 12 | ui = fluidPage( 13 | p("This is a test for ", a("#2375",href = "https://github.com/rstudio/shiny/issues/2375"), 14 | ". The elapsed time should be small, less than 0.5 seconds."), 15 | htmlOutput("txt") 16 | ), 17 | 18 | server = function(input, output) { 19 | start <- as.numeric(Sys.time()) 20 | r <- reactiveValues(x = 1) 21 | 22 | observe({ 23 | r$x <- obj 24 | }) 25 | 26 | compute_time <- reactive({ 27 | r$x 28 | round(as.numeric(Sys.time()) - start, 2) 29 | }) 30 | 31 | output$txt <- renderUI({ 32 | if (compute_time() < 0.5) 33 | status <- tags$b("Pass: ", style = "color: green;") 34 | else 35 | status <- tags$b("Fail: ", style = "color: red;") 36 | 37 | p( 38 | status, 39 | paste("Finished in", compute_time(), "seconds.") 40 | ) 41 | }) 42 | } 43 | ) 44 | -------------------------------------------------------------------------------- /154-index-html-server-r/server.R: -------------------------------------------------------------------------------- 1 | function(input, output) { 2 | output$status <- renderPrint({ 3 | tags$b("pass", style = "color: green;") 4 | }) 5 | } 6 | -------------------------------------------------------------------------------- /154-index-html-server-r/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

www/index.html with app.R

12 | 13 |

This app tests whether a www/index.html is served when used with app.R, for #2380. It should say "Status: pass" below.

14 | 15 |

16 | Status: 17 | fail 18 |

19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /155-index-html-app-r/app.R: -------------------------------------------------------------------------------- 1 | server <- function(input, output) { 2 | output$status <- renderPrint({ 3 | tags$b("pass", style = "color: green;") 4 | }) 5 | } 6 | 7 | shinyApp(NULL, server) 8 | -------------------------------------------------------------------------------- /155-index-html-app-r/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

www/index.html with app.R

12 | 13 |

This app tests whether a www/index.html is served when used with app.R, for #2380. It should say "Status: pass" below.

14 | 15 |

16 | Status: 17 | fail 18 |

19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /156-subapps/README.md: -------------------------------------------------------------------------------- 1 | Test for https://github.com/rstudio/shiny/issues/2385 2 | 3 | Run this test using `rmarkdown::run("index.Rmd")`. If you're running R from the terminal (not RStudio), you'll need to make sure that the `RSTUDIO_PANDOC` environment variable is defined, or that pandoc is on your system path. On Mac, it's like this: 4 | 5 | ``` 6 | RSTUDIO_PANDOC=/Applications/RStudio.app/Contents/MacOS/pandoc R --quiet -e 'rmarkdown::run("index.Rmd", shiny_args = list(launch.browser=TRUE))' 7 | ``` 8 | -------------------------------------------------------------------------------- /156-subapps/app2/app.R: -------------------------------------------------------------------------------- 1 | server <- function(input, output, session) { 2 | } 3 | 4 | shinyApp(NULL, server) 5 | -------------------------------------------------------------------------------- /156-subapps/app2/www/app2_styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: pink; 3 | } 4 | -------------------------------------------------------------------------------- /156-subapps/app2/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Hello, world! 13 | 14 | 15 | -------------------------------------------------------------------------------- /156-subapps/app3/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | } 3 | -------------------------------------------------------------------------------- /156-subapps/app3/ui.R: -------------------------------------------------------------------------------- 1 | library(leaflet) 2 | 3 | tagList( 4 | leaflet(width="100%", height="100%") %>% addTiles(), 5 | tags$style("html, body { width: 100%; height: 100%; }") 6 | ) 7 | -------------------------------------------------------------------------------- /156-subapps/index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Subapp test" 3 | output: html_document 4 | runtime: shiny 5 | --- 6 | 7 | Check the 3 items below. Also, verify that the page survives three reloads. 8 | 9 | (1 of 3) Verify that a selectize input and summary output appear below. 10 | 11 | ```{r echo=FALSE} 12 | ui <- fluidPage( 13 | selectInput("select", "Select dataset", ls("package:datasets")), 14 | verbatimTextOutput("summary") 15 | ) 16 | 17 | server <- function(input, output, session) { 18 | output$summary <- renderPrint({ 19 | summary(get(input$select, pos = "package:datasets", inherits = FALSE)) 20 | }) 21 | } 22 | 23 | shinyApp(ui, server) 24 | ``` 25 | 26 | (2 of 3) Verify that "Hello World" appears on a pink background. 27 | 28 | ```{r} 29 | shinyAppDir("app2") 30 | ``` 31 | 32 | (3 of 3) Verify that you see a leaflet map. 33 | 34 | ```{r} 35 | shinyAppDir("app3") 36 | ``` 37 | -------------------------------------------------------------------------------- /160-select-input/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | shinyApp( 4 | ui = fluidPage( 5 | p( 6 | "This test ensures that", code("selectInput()"), "doesn't introduce extra input variable(s).", 7 | a("Issue #2396", href = "https://github.com/rstudio/shiny/issues/2396"), "/", 8 | a("PR #2418", href = "https://github.com/rstudio/shiny/pull/2418") 9 | ), 10 | selectInput("variable", "Variable:", 11 | c("Cylinders" = "cyl", "Transmission" = "am", "Gears" = "gear") 12 | ), 13 | uiOutput("testResult") 14 | ), 15 | server = function(input, output, session) { 16 | 17 | output$testResult <- renderUI({ 18 | input$variable 19 | 20 | nInputs <- length(.subset2(input, "impl")$toList()) 21 | if (nInputs == 1) { 22 | tags$b("Test passed, move along", style = "color: green") 23 | } else { 24 | p( 25 | tags$b("Test failed: ", style = "color: red"), 26 | "expected one input value, but got ", 27 | nInputs 28 | ) 29 | } 30 | }) 31 | } 32 | 33 | ) 34 | -------------------------------------------------------------------------------- /163-select-factor/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | # Regression test for https://github.com/rstudio/shiny/pull/2524/ 4 | choices <- factor(setNames(letters, LETTERS)) 5 | 6 | ui <- fluidPage( 7 | title = "Select from Factor", 8 | tags$ol( 9 | tags$li("Select any capital letter from the input below."), 10 | tags$li("You should see your selection reflected, in lower case, in the output area.") 11 | ), 12 | selectInput("letter", "Letters", choices = choices), 13 | tags$h3("Output"), 14 | verbatimTextOutput("selected") 15 | ) 16 | 17 | server <- function(input, output, session) { 18 | output$selected <- renderText({ 19 | sprintf("You selected: %s", input$letter) 20 | }) 21 | } 22 | 23 | shinyApp(ui, server) 24 | -------------------------------------------------------------------------------- /164-no-whitespace/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: No Whitespace 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Type: Shiny 7 | -------------------------------------------------------------------------------- /164-no-whitespace/Readme.md: -------------------------------------------------------------------------------- 1 | This small Shiny application demonstrates how to suppress whitespace between HTML tags. 2 | 3 | The .noWS argument can be specified when specifying a tag to suppress whitespace in or around it. 4 | 5 | Note this feature requires **htmltools** >= 0.3.6.9004. 6 | -------------------------------------------------------------------------------- /165-trailing-comma/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Trailing commas in the UI 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Type: Shiny 7 | -------------------------------------------------------------------------------- /165-trailing-comma/Readme.md: -------------------------------------------------------------------------------- 1 | This app has a trailing comma in the UI. Historically, that would have crashed the app. But as of htmltools `0.3.6.9004`, that's now allowed. 2 | -------------------------------------------------------------------------------- /165-trailing-comma/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | 5 | titlePanel("Hello Shiny!"), 6 | 7 | # NOTE THE TRAILING COMMA 8 | textOutput(outputId = "text"), 9 | ) 10 | 11 | server <- function(input, output) { 12 | 13 | output$text <- renderText({ 14 | "If you're seeing this, things are fine." 15 | }) 16 | } 17 | 18 | # Create Shiny app ---- 19 | shinyApp(ui = ui, server = server) 20 | -------------------------------------------------------------------------------- /167-resource-warnings/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | addResourcePath("session", system.file(package = "httpuv")) 4 | addResourcePath("images", system.file(package = "shiny")) 5 | 6 | onStop(function() { 7 | removeResourcePath("session") 8 | removeResourcePath("images") 9 | }) 10 | 11 | ui <- fluidPage( 12 | "You should see two warnings about resource paths in your R console.", 13 | # This image is here to ensure that addResourcePath("images", ...) 14 | # throws a warning when your app has a www/images directory. 15 | img(src = "images/rstudio.png", style = "display:none") 16 | ) 17 | 18 | server <- function(input, output, session) { 19 | 20 | } 21 | 22 | shinyApp(ui, server) 23 | 24 | 25 | -------------------------------------------------------------------------------- /167-resource-warnings/www/images/rstudio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/167-resource-warnings/www/images/rstudio.png -------------------------------------------------------------------------------- /168-supporting-r-dir/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Automatically Load Supporting R files 2 | Author: RStudio, Inc. 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Type: Shiny 7 | -------------------------------------------------------------------------------- /168-supporting-r-dir/R/counter.R: -------------------------------------------------------------------------------- 1 | counterButton <- function(id, label = "Counter") { 2 | ns <- NS(id) 3 | tagList( 4 | actionButton(ns("button"), label = label), 5 | verbatimTextOutput(ns("out")) 6 | ) 7 | } 8 | 9 | counter <- function(input, output, session) { 10 | count <- reactiveVal(0) 11 | observeEvent(input$button, { 12 | count(count() + 1) 13 | }) 14 | output$out <- renderText({ 15 | count() 16 | }) 17 | count 18 | } 19 | -------------------------------------------------------------------------------- /168-supporting-r-dir/Readme.md: -------------------------------------------------------------------------------- 1 | Demonstrates that `.R` files in the `R/` directory are automatically loaded at runtime. 2 | 3 | At the moment, this functionality is opt-in so this app requires setting the following option in order to work: 4 | 5 | ``` 6 | options(shiny.autoload.r = TRUE) 7 | ``` 8 | 9 | Without setting that option, the example will fail. 10 | 11 | Requires Shiny with the change in https://github.com/rstudio/shiny/pull/2547. This requires Shiny v1.3.2.9001. 12 | -------------------------------------------------------------------------------- /168-supporting-r-dir/server.R: -------------------------------------------------------------------------------- 1 | function(input, output, session) { 2 | callModule(counter, "counter1") 3 | } 4 | -------------------------------------------------------------------------------- /168-supporting-r-dir/ui.R: -------------------------------------------------------------------------------- 1 | fluidPage( 2 | counterButton("counter1", "Counter #1") 3 | ) 4 | -------------------------------------------------------------------------------- /169-prerender-a/index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Test passed, move along!" 3 | output: html_document 4 | runtime: shiny_prerendered 5 | --- 6 | 7 | ```{r, echo = FALSE} 8 | tags$script(src = "js/log-rmd.js") 9 | ``` 10 | -------------------------------------------------------------------------------- /169-prerender-a/js/log-rmd.js: -------------------------------------------------------------------------------- 1 | console.log("file 1") 2 | -------------------------------------------------------------------------------- /169-prerender-b/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | ui <- fluidPage( 4 | "Below is a test for behavior described ", 5 | a("here", href = "https://github.com/rstudio/rmarkdown/pull/1631"), 6 | br(), 7 | span( 8 | id = "test-message", 9 | style = "color: red", 10 | "Test failed :(" 11 | ), 12 | tags$script(src = "js/run-test.js") 13 | ) 14 | 15 | server <- function(input, output) {} 16 | 17 | shinyApp(ui, server) 18 | -------------------------------------------------------------------------------- /169-prerender-b/www/js/run-test.js: -------------------------------------------------------------------------------- 1 | $("#test-message") 2 | .text("Test passed :)") 3 | .css("color", "green"); 4 | -------------------------------------------------------------------------------- /170-date-range-max/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | ui <- fluidPage( 3 | dateInput("val", "Date Input", max = Sys.Date()), 4 | "Below is a test for ", 5 | a("#2355", href = "https://github.com/rstudio/shiny/issues/2335"), 6 | verbatimTextOutput("res") 7 | ) 8 | server <- function(input, output, session) { 9 | output$res <- renderPrint({ 10 | if (length(input$val) > 0) "Test passed!" else "Test didn't pass :(" 11 | }) 12 | } 13 | shinyApp(ui, server) 14 | -------------------------------------------------------------------------------- /171-path-traversal/app.R: -------------------------------------------------------------------------------- 1 | shinyApp( 2 | fluidPage( 3 | p( 4 | "Click on each of the links below. They should report that the file is not found, or is forbidden.", 5 | "(For issues ", a("httpuv#235", href = "https://github.com/rstudio/httpuv/pull/235"), 6 | "and ", a("shiny#2566", href = "https://github.com/rstudio/shiny/pull/2566", .noWS = "after"), ")", 7 | ), 8 | a("Link 1", href = "/shared/..%5c..%5c..%5c..%5c..%5c..%5c..%5c..%5c..%5cwindows%5cwin.ini"), 9 | br(), 10 | a("Link 2", href = "/shared/../../../../../../../../etc/passwd") 11 | ), 12 | function(input, output) {} 13 | ) 14 | -------------------------------------------------------------------------------- /175-setInputValue/script.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | setTimeout(function() { 3 | Shiny.setInputValue("test_evt", 1, {priority: "event"}); 4 | Shiny.setInputValue("test_evt", 1, {priority: "event"}); 5 | Shiny.setInputValue("test_evt", 1, {priority: "event"}); 6 | Shiny.setInputValue("test_evt", 1, {priority: "event"}); 7 | Shiny.setInputValue("test_evt", 1, {priority: "event"}); 8 | 9 | Shiny.setInputValue("test_val", 1, {priority: "immediate"}); 10 | Shiny.setInputValue("test_val", 1, {priority: "deferred"}); 11 | Shiny.setInputValue("test_val", 1, {priority: "immediate"}); 12 | Shiny.setInputValue("test_val", 1); 13 | Shiny.setInputValue("test_val", 1); 14 | }, 1000); 15 | }); 16 | -------------------------------------------------------------------------------- /176-jquery-3/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | options(shiny.jquery.version = NULL) 4 | 5 | ui <- fluidPage( 6 | p("This test verifies the default jQuery version."), 7 | p("The number below is the jQuery version number. It should begin with a 3."), 8 | tags$script(HTML(" 9 | document.write(jQuery.fn.jquery); 10 | ")) 11 | ) 12 | 13 | server <- function(input, output, session) { 14 | 15 | } 16 | 17 | shinyApp(ui, server) 18 | -------------------------------------------------------------------------------- /177-jquery-1/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | 3 | options(shiny.jquery.version = 1) 4 | onStop(function() { 5 | options(shiny.jquery.version = NULL) 6 | }) 7 | 8 | ui <- fluidPage( 9 | p(HTML("This test verifies that app authors can opt into using jQuery 1 using options(shiny.jquery.version).")), 10 | p("The number below is the jQuery version number. It should begin with a 1."), 11 | tags$script(HTML(" 12 | document.write(jQuery.fn.jquery); 13 | ")) 14 | ) 15 | 16 | server <- function(input, output, session) { 17 | 18 | } 19 | 20 | shinyApp(ui, server) 21 | -------------------------------------------------------------------------------- /178-delayed-widget/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(leaflet) 3 | 4 | ui <- fluidPage( 5 | p("This app checks whether htmlwidgets can be loaded if the htmlwidgets dependency isn't part of the initial page load. ", 6 | "See ", 7 | a(href = "https://github.com/ramnathv/htmlwidgets/issues/349", "htmlwidgets#349"), 8 | " for more details." 9 | ), 10 | p("Verify the following:"), 11 | tags$ol( 12 | tags$li("A 'Static render complete' alert DOES NOT appear."), 13 | tags$li("An 'onRender called' alert appears."), 14 | tags$li("The map appears, with background tiles and markers."), 15 | ), 16 | uiOutput("ui"), 17 | ) 18 | 19 | server <- function(input, output, session) { 20 | output$ui <- renderUI({ 21 | tagList( 22 | leafletOutput("map"), 23 | htmlwidgets::onStaticRenderComplete("alert('Static render complete');") 24 | ) 25 | }) 26 | 27 | output$map <- renderLeaflet({ 28 | leaflet(quakes) %>% 29 | addTiles() %>% 30 | addMarkers() %>% 31 | htmlwidgets::onRender("function(el, x) { alert('onRender called'); }") 32 | }) 33 | } 34 | 35 | shinyApp(ui, server) 36 | -------------------------------------------------------------------------------- /179-nondelayed-widget/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(leaflet) 3 | 4 | ui <- fluidPage( 5 | p("This is similar to 178-delayed-widget, except the htmlwidget dependency is present right from the beginning."), 6 | p("Verify the following:"), 7 | tags$ol( 8 | tags$li("A 'Static render complete' alert appears."), 9 | tags$li("An 'onRender called' alert appears."), 10 | tags$li("The map appears, with background tiles and markers."), 11 | ), 12 | tagList( 13 | leafletOutput("map"), 14 | htmlwidgets::onStaticRenderComplete("alert('Static render complete');") 15 | ) 16 | ) 17 | 18 | server <- function(input, output, session) { 19 | output$map <- renderLeaflet({ 20 | leaflet(quakes) %>% 21 | addTiles() %>% 22 | addMarkers() %>% 23 | htmlwidgets::onRender("function(el, x) { alert('onRender called'); }") 24 | }) 25 | } 26 | 27 | shinyApp(ui, server) 28 | -------------------------------------------------------------------------------- /180-delayed-staticwidget/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(leaflet) 3 | 4 | ui <- fluidPage( 5 | p("This app checks whether htmlwidgets can be loaded if the htmlwidgets dependency isn't part of the initial page load. ", 6 | "See ", 7 | a(href = "https://github.com/ramnathv/htmlwidgets/issues/349", "htmlwidgets#349"), 8 | " for more details." 9 | ), 10 | p("Verify the following:"), 11 | tags$ol( 12 | tags$li("An 'onRender called' alert appears."), 13 | tags$li("A 'Static render complete' alert appears."), 14 | tags$li("The map appears, with background tiles and markers."), 15 | ), 16 | uiOutput("ui"), 17 | ) 18 | 19 | server <- function(input, output, session) { 20 | output$ui <- renderUI({ 21 | tagList( 22 | leaflet(quakes) %>% 23 | addTiles() %>% 24 | addMarkers() %>% 25 | htmlwidgets::onRender("function(el, x) { alert('onRender called'); }"), 26 | htmlwidgets::onStaticRenderComplete("alert('Static render complete');") 27 | ) 28 | }) 29 | } 30 | 31 | shinyApp(ui, server) 32 | -------------------------------------------------------------------------------- /181-google-analytics/google-analytics.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | -------------------------------------------------------------------------------- /181-google-analytics/sunshine.RDS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/181-google-analytics/sunshine.RDS -------------------------------------------------------------------------------- /182-google-charts/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Google Charts 2 | Author: Joe Cheng 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | Tags: google-charts google-fonts bubble-chart 6 | Type: Shiny 7 | DisplayMode: Showcase 8 | Imports: 9 | googleCharts 10 | Remotes: 11 | jcheng5/googleCharts 12 | -------------------------------------------------------------------------------- /182-google-charts/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Source: [World Bank](http://databank.worldbank.org/) 4 | -------------------------------------------------------------------------------- /182-google-charts/healthexp.Rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/182-google-charts/healthexp.Rds -------------------------------------------------------------------------------- /183-sv-simple/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Simple example of validation with shinyvalidate 2 | Author: RStudio, PBC 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: validation 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /183-sv-simple/README.md: -------------------------------------------------------------------------------- 1 | ## Simple example of validation with shinyvalidate 2 | 3 | Demonstrates simple usage of `InputValidator`. 4 | 5 | The `iv$enable()` method is called at the top level, so validation feedback is displayed immediately upon starting the session. 6 | 7 | The `output$valid` output displays the overall success/failure of validation, using `iv$is_valid()`. 8 | -------------------------------------------------------------------------------- /183-sv-simple/app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(shinyvalidate) 3 | library(markdown) 4 | 5 | ui <- fluidPage( 6 | textInput("name", "Name"), 7 | textInput("email", "Email"), 8 | textOutput("greeting") 9 | ) 10 | 11 | server <- function(input, output, session) { 12 | 13 | # Create an InputValidator object 14 | iv <- InputValidator$new() 15 | 16 | # Add validation rules 17 | iv$add_rule("name", sv_required()) 18 | iv$add_rule("email", sv_required()) 19 | iv$add_rule("email", sv_email()) 20 | 21 | # Start displaying errors in the UI 22 | iv$enable() 23 | 24 | output$greeting <- renderText({ 25 | 26 | # Don't proceed if any input is invalid 27 | req(iv$is_valid()) 28 | 29 | paste0("Nice to meet you, ", input$name, " <", input$email, ">!") 30 | }) 31 | } 32 | 33 | shinyApp(ui, server) 34 | -------------------------------------------------------------------------------- /184-sv-deferred/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Deferred validation with shinyvalidate 2 | Author: RStudio, PBC 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: validation 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /184-sv-deferred/README.md: -------------------------------------------------------------------------------- 1 | ## Deferred validation 2 | 3 | This example app shows that input validation feedback can be deferred until after the user presses Submit. 4 | 5 | Note also that the email input is not required, but if provided, it must be valid. 6 | -------------------------------------------------------------------------------- /185-sv-custom-inputs/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Using custom inputs with shinyvalidate 2 | Author: RStudio, PBC 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: validation 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /185-sv-custom-inputs/README.md: -------------------------------------------------------------------------------- 1 | ## Custom inputs 2 | 3 | In this example, the picture-taking control is a custom input control. shinyvalidate lets custom input controls decide where and how to display their input validation feedback. 4 | 5 | **Note: As of this writing, this app doesn't work in RStudio; view it in an external browser like Chrome or Firefox instead.** 6 | 7 | Try pressing the Submit button without taking a picture first; notice that the validation feedback message appears within the input control. This is because the [custom input binding](https://shiny.rstudio.com/articles/building-inputs.html) code for this control contains `setInvalid()` and `clearInvalid()` methods. 8 | 9 | (If you'd like a packaged camera input widget for your actual Shiny app, consider the [`shinyviewr` function from the `shinysense` package](https://livefreeordichotomize.com/2018/07/22/shinyviewr-camera-input-for-shiny/).) 10 | -------------------------------------------------------------------------------- /186-sv-module-1/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Shiny module with self-contained validation logic 2 | Author: RStudio, PBC 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: validation 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /186-sv-module-1/README.md: -------------------------------------------------------------------------------- 1 | # Shiny module with self-contained validation logic 2 | 3 | This example demonstrates the usage of `InputValidator` inside of a module. In this example, the validation is entirely self-contained, meaning that the inputs to be validated, the rules used to validate them, and the actions that need to guard against invalid inputs are all entirely contained within the module. 4 | 5 | In this simple case, the caller of the module does not even need to be aware that validation is being used by the module; it is just an implementation detail of the module itself. 6 | -------------------------------------------------------------------------------- /187-sv-module-2/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Validation within a Shiny module 2 | Author: RStudio, PBC 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: validation 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /187-sv-module-2/README.md: -------------------------------------------------------------------------------- 1 | ## Validation within Shiny module 2 | 3 | This example demonstrates how `InputValidator` is used within a Shiny module. The module server function creates an `InputValidator` and populates it with rules, then returns it to the caller (the app server function in this case). The caller then calls `enable()`. 4 | -------------------------------------------------------------------------------- /188-sv-module-3/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Passing validation rules to a Shiny module 2 | Author: RStudio, PBC 3 | AuthorUrl: http://www.rstudio.com/ 4 | License: MIT 5 | DisplayMode: Showcase 6 | Tags: validation 7 | Type: Shiny 8 | -------------------------------------------------------------------------------- /188-sv-module-3/README.md: -------------------------------------------------------------------------------- 1 | # Passing validation rule to Shiny module 2 | 3 | In this example, the `password_input` module server function allows the caller to customize the module's validation logic by providing a `password_rule` argument. 4 | 5 | In this case, the customize rule enforces the presence of a number and upper-case letter, as well as a minimum password length of 8. -------------------------------------------------------------------------------- /500-movie-browser/movies.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/500-movie-browser/movies.RData -------------------------------------------------------------------------------- /501-movie-browser-nav/movies.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/shiny-examples/8d558967d65e00dbb1f17ed18c46b1d4c4722016/501-movie-browser-nav/movies.RData -------------------------------------------------------------------------------- /503-server-function/app.R: -------------------------------------------------------------------------------- 1 | # Hello Shiny: Server function 2 | # Shiny app 3 | # Practice: Matching inputs and outputs 4 | 5 | library(shiny) 6 | 7 | ui <- fluidPage( 8 | 9 | textInput( 10 | inputId = "custom_text", 11 | label = "Input some text here:" 12 | ), 13 | 14 | strong("Text is shown below:"), 15 | 16 | textOutput(outputId = "user_text") 17 | 18 | ) 19 | 20 | server <- function(input, output, session){ 21 | 22 | output$user_text <- renderText({ input$custom_text }) 23 | 24 | } 25 | 26 | shinyApp(ui = ui, server = server) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | shiny-examples 2 | ============== 3 | 4 | This is a collection of Shiny examples. You can see them in action on 5 | `http://gallery.shinyapps.io/example-name` where `example-name` is the directory 6 | name of an example here, e.g. http://gallery.shinyapps.io/001-hello 7 | 8 | To run the examples locally, you can install the **shiny** package in R, and 9 | use the function `runGitHub()`. For example, to run the example `001-hello`: 10 | 11 | ```R 12 | if (!require('shiny')) install.packages("shiny") 13 | shiny::runGitHub("shiny-examples", "rstudio", subdir = "001-hello") 14 | ``` 15 | 16 | Or you can clone or download this repository, and use run 17 | `shiny::runApp("001-hello")`. 18 | 19 | Note the examples listed below depend on the [development 20 | version](https://github.com/rstudio/shiny) of **shiny** to show some new 21 | features under development. Please be cautious that such features may or may 22 | not end up in the final release, or they may also change according to the 23 | feedback. 24 | 25 | * [None] 26 | -------------------------------------------------------------------------------- /docker-rsc-deployer/.gitignore: -------------------------------------------------------------------------------- 1 | Applist.html -------------------------------------------------------------------------------- /docker-rsc-deployer/Applist.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Shiny Example Apps on Connect" 3 | output: html_document 4 | params: 5 | account: "alan" 6 | server: "rsc.radixu.com" 7 | api_key: "" 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | library(httr) 12 | library(magrittr) 13 | library(jsonlite) 14 | 15 | account <- params$account 16 | server <- params$server 17 | api_key <- params$api_key 18 | 19 | user <- GET(paste0("https://", server, "/__api__/me"), add_headers(authorization = paste0("Key ", api_key))) %>% 20 | `[[`("content") %>% 21 | rawToChar() %>% 22 | jsonlite::fromJSON() 23 | 24 | # TODO paginate 25 | apps <- GET(paste0("https://", server, "/__api__/applications?count=1000"), add_headers(authorization = paste0("Key ", api_key))) %>% 26 | `[[`("content") %>% 27 | rawToChar() %>% 28 | jsonlite::fromJSON() %>% 29 | `[[`("applications") 30 | apps <- subset(apps, apps$owner_guid == user$guid & grepl("^[0-9]{3}", apps$name)) 31 | apps <- apps[,c("name", "url")] 32 | apps <- apps[order(apps$name),] 33 | ``` 34 | 35 | ```{r df, echo=FALSE} 36 | knitr::kable(apps, row.names = FALSE) 37 | ``` 38 | -------------------------------------------------------------------------------- /docker-rsc-deployer/deployApp.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | 3 | args <- commandArgs(TRUE) 4 | 5 | if (length(args) == 0) { 6 | cat(sep = "\n", 7 | "Usage: deployApp account server appdir", 8 | "", 9 | "Examples:", 10 | " ./deployApp.R alan rsc.radixu.com 001-hello", 11 | "" 12 | ) 13 | 14 | q() 15 | } 16 | 17 | library(rsconnect) 18 | library(packrat) 19 | 20 | deps <- packrat:::dirDependencies(args[[3]]) 21 | deps <- deps[!"shiny" %in% deps] 22 | if (length(deps) > 0) install.packages(deps) 23 | 24 | packrat::.snapshotImpl(args[[3]], snapshot.sources = FALSE) 25 | 26 | rsconnect::deployApp( 27 | appDir = args[[3]], 28 | appName = args[[3]], 29 | account = args[[1]], 30 | server = args[[2]], 31 | logLevel = 'verbose', 32 | launch.browser = FALSE, 33 | forceUpdate = TRUE 34 | ) 35 | -------------------------------------------------------------------------------- /docker/shiny-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Make sure the directory for individual app logs exists 4 | mkdir -p /var/log/shiny-server 5 | chown shiny.shiny /var/log/shiny-server 6 | 7 | exec shiny-server >> /var/log/shiny-server.log 2>&1 8 | -------------------------------------------------------------------------------- /shiny-examples.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | --------------------------------------------------------------------------------