问题描述
当我运行我的服务器函数时收到一条错误消息,内容为:**“错误:在没有活动响应上下文的情况下不允许操作。
- 您试图做一些只能从反应性消费者内部完成的事情。"**
这是我的非响应式服务器:
server <- function(input,output){
reactivedata <- reactive({PC
})
x <- reactive({reactivedata() %>% drop_na() %>% pull(plotdate)})
y <- reactive({
reactivedata() %>% pull(Value) %>% na.omit()
})
###Non-reactive code
for (d in 1:c){
tempval <- val[which(!is.na(val[,d])),d] #omit not filled rows na
tempdate <- rollingdates[,d]
se <- sd(tempval)
mean <- mean(tempval)
movrang <- diff(tempval)
rbar <- mean(abs(movrang))
d2constant <- 1.1283791671
sigmacalc <- rbar/d2constant
if (percent1 >= 0.02){
rc <- rc + 1
if (!is.na(usl) && !is.na(lsl) == TRUE){
ppkcalc <- c(((usl-mean)/(3*sigmacalc)),((mean-lsl)/(3*sigmacalc)))
ppk <- min(ppkcalc)
}else if (is.na(usl) == TRUE){
ppk <- ((mean-lsl)/(3*sigmacalc))
}else if (is.na(lsl) == TRUE){
ppk <- ((usl-mean)/(3*sigmacalc))
}
PC$Parameter[rc] <- param
PC$Calculation[rc] <- "ppk"
PC$Value[rc] <- ppk
PC$DaterangeBeg[rc] <- as.character(tempdate[length(which(!is.na(tempdate)))])
PC$DaterangeEnd[rc] <- as.character(rollingdates[1,d])
PC$plotdate <- paste(PC$DaterangeBeg,PC$DaterangeEnd,sep=" ")
}
}
PC = na.omit(PC)
}
这里有几乎相同的代码,但以反应形式制作(我正在反应地提取 usl、lsl、ucl 和 lcl 值。 这是我的响应式服务器:
server <- function(input,output){
reactivedata <- reactive({PC
})
x <- reactive({reactivedata() %>% drop_na() %>% pull(plotdate)})
y <- reactive({
reactivedata() %>% pull(Value) %>% na.omit()
})
###Reactive Code
ucl =reactive({excel[excel$Quality.Attributes == input$select,"UCL"]})
lcl =reactive({excel[excel$Quality.Attributes == input$select,"LCL"]})
usl =reactive({excel[excel$Quality.Attributes == input$select,"USL"]})
lsl =reactive({excel[excel$Quality.Attributes == input$select,"LSL"]})
# #
#
#
for (d in 1:c){
tempval <- val[which(!is.na(val[,d] #omit not filled rows na
tempdate <- rollingdates[,d]
se <- sd(tempval)
mean <- mean(tempval)
movrang <- diff(tempval)
rbar <- mean(abs(movrang))
d2constant <- 1.1283791671
sigmacalc <- rbar/d2constant
if (percent1 >= 0.02){
rc <- rc + 1
if (!is.na(usl()) && !is.na(lsl()) == TRUE){
ppkcalc <- c((usl()-mean/(3*sigmacalc)),((mean-lsl())/(3*sigmacalc)))
ppk <- min(cpkcalc)
}else if (is.na(usl()) == TRUE){
ppk <- ((mean-lsl())/(3*sigmacalc))
}else if (is.na(lsl()) == TRUE){
ppk <- ((usl()-mean)/(3*sigmacalc))
}
#
#
PC$Parameter[rc] <- param
PC$Calculation[rc] <- "ppk"
PC$Value[rc] <- ppk
PC$DaterangeBeg[rc] <- as.character(tempdate[length(which(!is.na(tempdate)))])
PC$DaterangeEnd[rc] <- as.character(rollingdates[1,d])
PC$plotdate <- paste(PC$DaterangeBeg,sep=" ")
}
}
PC = na.omit(PC)
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)