我正在尝试构建一个有光泽的Web应用程序,我想在弹出窗口而不是在mainPanel中显示R函数的结果图.例如,对于以下示例(来自http://shiny.rstudio.com/articles/action-buttons.html),单击"开始"按钮将在弹出窗口中显示相同的图.
我试着添加一些javascript,但我还没有成功......有人可以帮忙吗?
先感谢您 !
library(shiny)
ui <- fluidPage(
actionButton("go", "Go"),
numericInput("n", "n", 50),
plotOutput("plot")
)
server <- function(input, output) {
randomVals <- eventReactive(input$go, {
runif(input$n)
})
output$plot <- renderPlot({
hist(randomVals())
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud) 当然是一个天真的问题,但我在R,我有表达
v <- "gastrula:75%"
Run Code Online (Sandbox Code Playgroud)
我想替换 "gastrula0.75"
我尝试过这样的事情:
v <- sub("\\.(\\d+)%","0.\\1",v)
v <- sub("[:punct:](\\d)\\1+[:punct:]","0.\\1",v)
Run Code Online (Sandbox Code Playgroud)
但我没有找到任何有用的东西.
我理解下面这段代码的一般目标(即总结字符串的数字部分,例如对于 currstr="3S47M" 然后 seqlength=50)。
但是有人可以逐行解释我发生了什么吗?
特别是,我很难理解where每回合持有什么价值。更准确地说,我不明白scalar函数的部分("scalar($RLENGTH = length($&), $RSTART = length($`)+1)") ?
里面的赋值RLENGTH和RSTART发生是否正确scalar?
为什么在 内使用逗号分隔的赋值scalar?这是什么意思 ?那么它的评估结果是什么?
如果有人可以提供帮助,我将非常感激!
谢谢
埃丽卡
my $seqlength=0;
my $currstr="3S47M";
my $where = $currstr =~ /[0-9]+[M|D|N|X|=|S|H|N]/
? scalar($RLENGTH = length($&), $RSTART = length($`)+1) : 0;
while ($where > 0) {
$seqlength += substr($currstr, ($where)-1, $RLENGTH - 1) + 0;
$currstr = substr($currstr, ($where + $RLENGTH)-1);
$where = $currstr =~ /[0-9]+[M|D|N|X|=|S|H|N]/
? scalar($RLENGTH = length($&), $RSTART …Run Code Online (Sandbox Code Playgroud)