我在使用UI中的selectInput通过用户输入的变量在dplyr :: mutate中创建新变量时遇到了麻烦。
gwrdata <- eventReactive(input$rungwr, {
sp_shape <- as(data(), "Spatial")
bwG <- gwr.sel(formula(), data = sp_shape, gweight = gwr.Gauss, verbose = FALSE)
gwrG <- gwr(formula(), data = sp_shape, bandwidth = bwG,
gweight = gwr.Gauss, hatmatrix = TRUE)
sf_gwr <- st_as_sf(gwrG$SDF)
bins <- 3
browser()
sf_gwr <- mutate(sf_gwr, parBin = cut2(sf_gwr[, input$inVar],
g = bins, levels.mean = TRUE))
sf_gwr <- mutate(sf_gwr, sigBin = cut2(localR2, g = bins, levels.mean = TRUE))
bvColors = c("#e8e8e8", "#dfb0d6", "#be64ac", "#ace4e4",
"#a5add3", "#8c62aa", "#5ac8c8", "#5698b9", "#3b4994")
levels(sf_gwr$parBin) <- 1:bins
levels(sf_gwr$sigBin) <- 1:bins
sf_gwr <- mutate(sf_gwr, value = paste(parBin, '-', sigBin, sep = ''))
sf_gwr
})
有两个mutate函数。如果它与localR2
一样硬编码,则该过程可以正常工作。但是,使用sf_gwr[,input$inVar]
时会出现以下错误。
评估错误:没有适用于&#39; st_geometry&lt; - &#39;应用于类&#34;列表&#34;。
的对象这是否与mutate函数中的子集有关?