26 lines
589 B
R
26 lines
589 B
R
|
# Rely on the 'WorldPhones' dataset in the datasets
|
||
|
# package (which generally comes preloaded).
|
||
|
library(datasets)
|
||
|
|
||
|
# Define a server for the Shiny app
|
||
|
function(input, output, session) {
|
||
|
|
||
|
# Fill in the spot we created for a plot
|
||
|
output$phonePlot <- renderPlot({
|
||
|
|
||
|
# Render a barplot
|
||
|
barplot(WorldPhones[,input$region]*1000,
|
||
|
main=input$region,
|
||
|
ylab="Number of Telephones",
|
||
|
xlab="Year")
|
||
|
})
|
||
|
|
||
|
# Close the app when the session completes
|
||
|
if(!interactive()) {
|
||
|
session$onSessionEnded(function() {
|
||
|
stopApp()
|
||
|
q("no")
|
||
|
})
|
||
|
}
|
||
|
}
|