【发布时间】:2016-09-07 19:56:48
【问题描述】:
我想绘制 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
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)
})
})
您将看到该图出现在需要输入值的行下方。 我怎样才能让那个情节更偏向右侧呢? 我的目标确实是在最终代码中包含许多输入行,将绘图放在右侧会使页面更紧凑。
【问题讨论】: