R闪亮的错误:";找不到函数“;shinyServer“;
新到R闪亮。模拟在but上找到的闪亮服务器,用于逻辑分布,而不是所示的二次、线性和线性分布。在我的代码中,复选框被去掉,y变量是一个分类变量。在控制台中以})结尾之前,R不会显示错误。R声明“找不到函数”shinyServer。我没有使用runApp()尝试应用程序,因为发生了错误 我的代码:R闪亮的错误:";找不到函数“;shinyServer“;,r,R,新到R闪亮。模拟在but上找到的闪亮服务器,用于逻辑分布,而不是所示的二次、线性和线性分布。在我的代码中,复选框被去掉,y变量是一个分类变量。在控制台中以})结尾之前,R不会显示错误。R声明“找不到函数”shinyServer。我没有使用runApp()尝试应用程序,因为发生了错误 我的代码: library(ggplot2) hw <- read.csv("LogitTV.csv") in_range <- function(x, range) { x >= min(r
library(ggplot2)
hw <- read.csv("LogitTV.csv")
in_range <- function(x, range) {
x >= min(range) & x <= max(range)
}
shinyServer(function(input, output) {
limit_data_range <- function() {
if (is.null(input$x_range) || is.null(input$y_range)) {
return(NULL)
}
hw_sub <- hw[in_range(hw[[input$x_var]], input$x_range) &
in_range(hw[[input$y_var]], input$y_range), ]
hw_sub
}
output$main_plot <- renderPlot({
hw_sub <- limit_data_range()
if (is.null(hw_sub))
return()
xdat <- hw[[input$x_var]]
ydat <- hw[[input$y_var]]
if(input$mod_logistic)
point_alpha <- 0.5
else
point_alpha <- 1
p <- ggplot(hw_sub, mapping = aes_mapping) +
points +
theme_bw() +
scale_colour_hue(l = 40) +
scale_shape(solid = FALSE) +
scale_x_continuous(limits = range(xdat)) +
scale_y_continuous(limits = range(ydat))
if (max(input$x_range) != max(xdat)) {
p <- p + geom_vline(xintercept = max(input$x_range), linetype = "dashed",
alpha = 0.3)
}
if (min(input$x_range) != min(xdat)) {
p <- p + geom_vline(xintercept = min(input$x_range), linetype = "dashed",
alpha = 0.3)
}
if (max(input$y_range) != max(ydat)) {
p <- p + geom_hline(yintercept = max(input$y_range), linetype = "dashed",
alpha = 0.3)
}
if (min(input$y_range) != min(ydat)) {
p <- p + geom_hline(yintercept = min(input$y_range), linetype = "dashed",
alpha = 0.3)
}
if (input$mod_logistic) {
p <- p + geom_smooth(method = lm, se = FALSE, size = 0.75,
linetype = "dotdash")
}
print
})
output$x_range_slider <- renderUI({
xmin <- floor(min(hw[[input$x_var]]))
xmax <- ceiling(max(hw[[input$x_var]]))
sliderInput(inputId = "x_range",
label = paste("Limit range"),
min = xmin, max = xmax, value = c(xmin, xmax))
})
output$y_range_slider <- renderUI({
ymin <- floor(min(hw[[input$y_var]]))
ymax <- ceiling(max(hw[[input$y_var]]))
sliderInput(inputId = "y_range",
label = paste("Limit range"),
min = ymin, max = ymax, value = c(ymin, ymax))
})
make_model <- function(model_type, formula, ...) {
hw_sub <- limit_data_range()
if (is.null(hw_sub))
return()
do.call(model_type, args = list(formula = formula, data = quote(hw_sub), ...))
}
output$mod_logistic_text <- renderPrint({
formula <- paste(input$y_var, "~", input$x_var)
})
库(ggplot2)
hw您不应该在脚本顶部说require(shinny)
吗?这看起来像一个服务器.R文件。您还应该有一个ui.R文件。将它们都放在一个目录中,然后在R中调用runApp
并将其传递到目录的路径。如果目录名为“myApp”,那么在R中您将运行library(shinny);runApp(“myApp”)“,port=8100)
@GSee我将把ui.R文件放在服务器脚本上方的同一目录中。“myApp”指的是工作目录的名称还是ui.r和服务器所在目录的名称(窗口左上角的选项卡)?我用setwd(“~/Home Automation”)设置工作目录,执行runApp(“~/Home Automation/”,port=8100),但在startAppDir(port=port)中出错:在/Users/scdavis6/Home Automation中找不到ui.R或www子目录。“myApp”指的是包含ui.R和server.R的目录的名称。我建议你完成这项工作。谢谢你指出这一点,我在顶部加入了require(闪亮)。