2016-09-07 5 views
0

私は3つの測定値をプロットして、ユーザーが分散感を得るようにしたいと思います。各測定は、クロスとしてプロットされるR輝く、列にプロットを追加する方法

ui.R

shinyUI(fluidPage(

fluidRow(
h2("Enter 3 values"), 
column(width=2,offset=0, numericInput("triceps.sf1", label = "1.", value = 0)), 
column(width=2,offset=0, numericInput("triceps.sf2", label = "2.", value = 0)), 
column(width=2,offset=0, numericInput("triceps.sf3", label = "3.", value = 0)), 
column(width=8,offset=0, plotOutput("sfTricepsPlot")) 
) 
)#fluidpage 
)#shinyUI 

とサーバコード: 私は次のコードを使用して、R光沢のあるアプリケーションを作成

server.Rを

library(graphics) 
shinyServer(function(input, output) { 

################################### 
## Plot the values of sf measured 
sfPlot <- function(m1, m2, m3){ 

par(mai = c(0.8, 0.8, 0.3, 0.8)) 
plot(1, axes=F, xaxt = "n", xlab = "Mesures", ylab = "sf (mm)", xlim = c(0.8, 3.2), ylim=c(0.8*m1, 1.2*m1)) 
axis(1, at=1:3) 
axis(2, at=seq(from=0.8*m1, to=1.2*m1, by=10)) 
points(x=1, y=m1, pch=4, lwd=2, cex=1.5) 
points(x=2, y=m2, pch=4, lwd=2, cex=1.5) 
points(x=3, y=m3, pch=4, lwd=2, cex=1.5) 
} 

###################################### 
## Plot the triceps sf 
output$sfTricepsPlot <- renderPlot({ 
sfPlot(input$triceps.sf1, input$triceps.sf2, input$triceps.sf3) 
}) 
}) 

入力値が必要な行の下にプロットが表示されます。 どうすればそのプロットを右側に置くことができますか? 最終的なコードに多くの入力行があり、右側にプロットするとページがコンパクトになります。

答えて

1

column機能のoffsetパラメータを使用します。

column(width=8,offset=4, plotOutput("sfTricepsPlot")) 

あなたは右端の位置に8単位のUI要素を置くつもりので、もしoffset = 4

Editを使用し、画面の幅は12個の単位であることに注意してください。その場合は、あなただけ指定することができます列の高さ。

column(width=1,offset=0, div(style = "height:150px;"), numericInput("triceps.sf1", label = "1.", value = 0)), 
column(width=1,offset=0, div(style = "height:150px;"), numericInput("triceps.sf2", label = "2.", value = 0)), 
column(width=1,offset=0, div(style = "height:150px;"), numericInput("triceps.sf3", label = "3.", value = 0)), 
column(width=8,offset=0, plotOutput("sfTricepsPlot")) 
+0

オフセットを変更すると、プロットが右側に移動しますが、それでもまだ最初の行の下にあります。同じ行に3つの入力タブとプロットを(できるだけ)表示します。 –

+0

魅力として動作します、ありがとうGyD –

0

シャイニーBootstrapで使用されるCSSのframewokが応答グリッドに基づいています(3つの入力+出力幅は、そうでなければ、彼らが2行に分かれます< = 12となるように、私は、1にnumericInputの幅を変更しました)レイアウト:

ブートストラップが適切デバイスまたはビューポートのサイズが増加するにつれて、12列までスケール応答して、モバイル第一流体グリッドシステムを含みます。

例では、合計は2 + 2 + 2 + 8、つまり14です。つまり、最後の列が他の列の下に表示されます。問題を解決するにはwidth=8width=6に変更できます。

関連する問題