Case Studies: створення вебзастосунків із Shiny в R
Dean Attali
Shiny Consultant
Графіки — типовий перший крок під час вивчення нового набору даних
plotOutput("my_plot")
output$my_plot <- renderPlot({
# code for a plot
})
Завантаження підтримується через кнопку завантаження

Comma Separated Values
Зберігають малі й середні набори даних
CSV для gapminder:
country,continent,year,lifeExp,pop,gdpPercap
Afghanistan,Asia,1952,28.801,8425333,779.4453145
Afghanistan,Asia,1957,30.332,9240934,820.8530296
Afghanistan,Asia,1962,31.997,10267083,853.10071
Afghanistan,Asia,1967,34.02,11537966,836.1971382
Створення CSV-файлу:
write.csv(gapminder, "myfile.csv")
Кнопка завантаження розглядається як вивід
downloadButton(outputId = "download_data",
label = "Download data")
output$download_data <- downloadHandler(
filename = "data.csv",
content = function(file) {
# Code that creates a file in the path <file>
write.csv(gapminder, file)
}
)
output$download_data <- downloadHandler(
filename = "data.csv",
content = function(file) {
# code that creates a file in the path <file>
write.csv(gapminder, file)
}
)
downloadHandler() має два аргументиfilenamecontent(file)Case Studies: створення вебзастосунків із Shiny в R