I recently used Markdown and Shiny in R Studio v1.1.456 (R version 3.4.3) to create an output html file. The html file simply produces a plot which the user can update by changing some basic inputs. I created a simple R Markdown (.rmd) script below for testing purposes. I simply want to add a prompt (checkbox?) to the html file that allows the user (i.e. me!) to save certain plots locally as a jpeg.
NOTE: This is just a simple local application that I run on my machine. I do not want to host a Shiny app or use servers etc.
---
title: "Example"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r Libraries and Data, include=FALSE}
library(ggplot2)
x <- c(1,3,4,5,8,9,12,12,13,17)
y <- c(30,32,35,36,38,38,40,41,44,47)
z <- rep(0,10)
DF <- data.frame(x,y,z)
```
```{r model, echo=FALSE}
numericInput("coef1","input coefficient 1:",1.5)
numericInput("coef2","input coefficient 2:",3)
renderPlot({
coef1 <- input$coef1
coef2 <- input$coef2
for (i in 1:10){
DF$z[i] <- sqrt((coef1*(DF$x[i])+coef2*(DF$y[i])))
}
plot <- ggplot(data=DF,aes(x=x,y=y)) + geom_point()
plot + geom_line(aes(x=x,y=z),colour="red")
})
```