
Here's one version that does what you want...
#ui.R
library(shiny)
shinyUI(fluidPage(
fluidRow(h1("Old Faithful Geyser Data")),
fluidRow(
column(2,
sliderInput("bins","Number of bins:",min = 1,max = 50,value = 30),
# generate and plot a rnorm distribution with the requested number of observations and number of bins
hist( rnorm(input$obs), breaks = input$bins)
})
})
The boiler plate functions like
titlePanel,
sidebarLayout and
sidebarPanel etc are easy, but restrictive. More advanced layouts, however, can be made quite easily using the
fluidRow and
column helper functions. There is also a
layout guide about this:
https://github.com/rstudio/shiny/wiki/Shiny-Application-Layout-Guide Combined with div and css you have much more control over what you want.
A valuable tool in understanding the structure of webpages and their layouts is by using the
element inspector avalaible in modern browsers. They tell you a lot about the css classes and styles used to obtain a specific layout. For Firefox for instance you can activate it via the F12 key, see also here:
https://addons.mozilla.org/en-US/firefox/addon/element-inspector/ Finally, setting a width past 100% (as in your code) doesn't do anything (I think). 100% just means the element can use 100% of the available space. The avaliable space depends on other elements surrounding it. As you can see the figure now fits in the frame and the frame extends to the outer right edge. Let's say the div holding the figure has only 1000 pixels, yet you squeeze in a figure of 1200px i.e. it doesn't fit ;-) Now what happens depends on the css set for the div.
You can use the css overflow property to indicate what should happen i.e. should a scroll bar appear, should the figure be clipped or be allowed to extend over it's normal region? This is further explained here:
http://www.w3schools.com/cssref/pr_pos_overflow.aspFor instance, setting the css property overflow to scroll for a div (say with id = myDiv)
#myDiv{
overflow:scroll;
}
would add a scroll bar to your tab if the figure doesn't fit.
Hope this helps, best Herman
Op zondag 4 mei 2014 00:48:10 UTC+2 schreef
claymore...@gmail.com: