I want to generate a R markdown page with an interactive shiny app. It works fine but the output is in a really small area with scrollbars. I want to get rid of the scrollbars and show the 2 figures with full width and height without scrollbars. How can I achieve that?
I have already tried:
options(width = 800)
Currently it looks like this:
---
title: "Spielercluster"
output: html_document
runtime: shiny
---
```{r,echo=FALSE}
library(ggplot2)
library(shiny)
data<-read.csv2('data.csv',header=T,sep=",")
rawData<-read.csv2('rawData.csv',header=T,sep=",")
cluster<-read.csv2('cluster.csv',header=T,sep=",")
colors<-c("green","red","black")
ui<-fluidPage(plotOutput("plot1", hover = "plot_hover"),
plotOutput("plot2", hover = "plot_hover"),
verbatimTextOutput("info")
)
server <- function(input, output) {
output$plot1 <- renderPlot({
ggplot(rawData, aes(koerpergewicht, groesse, color = factor(data$gruppe))) +
geom_point() + labs(title = paste(nlevels(factor(colors))))+geom_point(size=8)+geom_text(aes(label=position),vjust=-1.5)+scale_color_manual(name = "Gruppe",
labels = c("1 schwer", "2 leicht","3 Zwischengruppe"),
values = c(rgb(0.9725490196078431,0.4627450980392157,0.4274509803921569,1),rgb(0,0.7294117647058824,0.2196078431372549,1),rgb(0.3803921568627451,0.6117647058823529,1,1)))+ggtitle("Original")
})
output$plot2 <- renderPlot({
ggplot(rawData, aes(koerpergewicht, groesse, color = factor(cluster$x))) +
geom_point() + labs(title = paste(nlevels(factor(colors))))+geom_point(size=8)+geom_text(aes(label=position),vjust=-1.5)+scale_color_manual(name = "Gruppe",
labels = c("1 schwer", "2 leicht","3 Zwischengruppe"),
values = c(rgb(0.9725490196078431,0.4627450980392157,0.4274509803921569,1),rgb(0,0.7294117647058824,0.2196078431372549,1),rgb(0.3803921568627451,0.6117647058823529,1,1)))+ggtitle("Berechnet")
})
output$info <- renderPrint({
nearPoints(rawData, input$plot_hover, , threshold = 10, maxpoints = 1,
addDist = TRUE)
})
}
shinyApp(ui, server)
```
To change the output size you can use the corresponding LaTeX commands, set just before the code junk. The smallest option would be \tiny . For a full overview consider e.g. this. After the code junk it's important to set back to the size you used before, e.g. \normalsize .
The default value is 1. To reduce the text size, use a cex value of less than 1; to increase the text size, use a cex value greater than 1. To change the size of other plot parameters, use the following: cex.
If you prefer to use the console by default for all your R Markdown documents (restoring the behavior in previous versions of RStudio), you can make Chunk Output in Console the default: Tools -> Options -> R Markdown -> Show output inline for all R Markdown documents .
I achieved it by adding my own css file. You can include it like this:
---
title: "Spielercluster"
output:
html_document:
css: style.css
runtime: shiny
---
Then you have to adjust the sizes of the class shiny-frame
.shiny-frame{
width: 1400px;
height: 1200px;
}
shinyApp(ui, server, options = list(height = 1000)
Note the use of the height parameter to determine how much vertical space the embedded application should occupy. (http://rmarkdown.rstudio.com/authoring_embedded_shiny.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With