FitWeibull <- function(data, xinf, xsup){
sub.data <- data[(data$X >= log(xinf) & data$X <= log(xsup),]
my.lm <- lm(Y~X, data = sub.data)
return(my.lm)
}

Xinf and xsup is the limit of my linear regression, on shiny people will moove a slider ( and choose a range), the question is how can i identify the two slider by xinf and xsup ?

Thank you.

有帮助吗?

解决方案

Try this:

in ui.R

sliderInput(inputId=XValues, label="This slider determines Xinf and Xsup or 
    whatever", min=0, max=1000, value=c(0,1000))

And in your server.R:

FitWeibull <- function(data, xinf, xsup){
sub.data <- data[(data$X >= log(input$XValues[1]) & data$X <= log(input$XValues[2]),]
my.lm <- lm(Y~X, data = sub.data)
return(my.lm)
}

I just put in 0 and 1000 as example values for min and max, you should put in /calculate something reasonable. This will make a slider that returns two values, you can access them using XValues[1] and XValues[2]

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top