2016-09-07 91 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 

和服務器代碼,其中每個測量被繪製爲橫: 我使用以下代碼創建A 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")) 

請記住,屏幕的寬度是12個單位,所以如果你打算把一個8單元的UI元素,最右邊的位置,使用offset = 4

編輯:在這種情況下,你可以指定列的高度。 (I改變了numericInput的寬度爲1,從而使3個輸入+輸出寬度是< = 12。否則它們會分裂成2行)

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

改變偏移移動陰謀右側,但仍位於第一行下面,我想三個輸入標籤和情節是同一行 –

+0

可以作爲一個魅力(儘可能) ,謝謝GyD –

0

通過閃亮Bootstrap使用的CSS framewok是基於一個響應網格佈局:

Bootstrap包括一個響應式的移動式第一流體網格系統,可隨着設備或視口尺寸的增加適當擴展至12列。

每行中的列僅可具有一個12最大寬度在您的例子,你的總是2 + 2 + 2 + 8,其是14.這意味着你的最後一列將出現在下面他人。您可以更改width=8width=6解決您的問題。