0
我試圖設置一個閃亮的滑塊,從0.01到100的日誌基準10比例。我一直在using this Q/A嘗試解決我的問題。然而,我似乎無法得到圖上的水平線根據滑塊閾值作出反應。R閃亮 - 從0.01到100的值使用日誌比例滑塊
我錯過了什麼嗎?
該圖顯示了我的滑塊和繪圖上的線條;底部或頂部閾值都不符合水平線位置。如果我恢復到線性比例,則線條與滑塊位置匹配。
我可重複碼
# Set libraries
library(shiny)
library(ggplot2)
# Global variables
from <- seq(1, 100, 1)
data <- (rexp(100, 0.05))
df1 <- as.data.frame(cbind(from, data))
JScode <-
"$(function() {
setTimeout(function(){
var vals = [0];
var powStart = -2;
var powStop = 2;
for (i = powStart; i <= powStop; i++) {
var val = Math.pow(10, i);
val = parseFloat(val.toFixed(8));
vals.push(val);
}
$('#slider1').data('ionRangeSlider').update({'values':vals})
}, 10)})"
ui <-
shinyUI(fluidPage(tabsetPanel(tabPanel(
"", " ",
fluidRow(
column(
width = 6,
tags$head(tags$script(HTML(JScode))),
sliderInput(
"slider1",
"bounds",
min = 0,
max = 100,
value = c(0, 100)
)
),
column(width = 6, " ",
plotOutput("plot7"))
)
))))
server <- function(input, output) {
filedata <- reactive({
infile <- input$datafile
if (is.null(infile)) {
return(df1) # this returns the default .Rds - see global variables
}
temp <- read.csv(infile$datapath)
#return
temp[order(temp[, 1]),]
})
output$plot7 <- renderPlot({
ggplot(df1, aes(sample = data)) +
stat_qq() +
scale_y_log10() +
geom_hline(aes(yintercept = input$slider1[1])) + # low bound
geom_hline(aes(yintercept = input$slider1[2])) + # high bound
labs(title = "Q-Q Plot", x = "Normal Theoretical Quantiles", y = "Normal Data Quantiles")
})
}
shinyApp(ui = ui, server = server)
無法重現你的榜樣。您可以在擦除'scale_y_log10()'命令時嘗試記錄數據。 – Jimbou
@Jimbou:增加了repr。碼。 – val
你可以試試嗎? 'geom_hline(aes(yintercept = c(0,10^seq(-2,2))[input $ slider1 [1] +1]))' – Jimbou