- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 nearPoints
函数在鼠标点击附近的 ggplot
中找到点,但它不起作用。我使用下面的代码为 diamonds
data.frame 创建了带有两个图的 Shiny 应用程序:
library(shiny)
library(ggplot2)
ui <- fluidPage(
mainPanel(
uiOutput("tb")
)
)
server <- function(input,output){
output$diamonds1 <- renderPlot({
print(ggplot(diamonds, aes(x=carat, y=price, col=clarity)) +
geom_point(alpha=0.5)+ facet_wrap(~color, scales="free"))
})
output$diamonds2 <- renderPlot({
print(ggplot(diamonds, aes(x=carat, y=price, col=clarity)) +
geom_point(alpha=0.5)+ facet_wrap(~cut, scales="free"))
})
output$info <- renderPrint({
nearPoints(diamonds, input$plot_click, threshold = 10, maxpoints = 1,
addDist = TRUE)
})
output$tb <- renderUI({
tabsetPanel(tabPanel("First plot",
plotOutput("diamonds1")),
tabPanel("Second plot",
plotOutput("diamonds2", click = "plot_click"),
verbatimTextOutput("info")))
})
}
shinyApp(ui = ui, server = server)
我在第二个情节中不断收到这个错误
Error: nearPoints: not able to automatically infer
xvar
from coordinfo
有什么建议吗?
最佳答案
这就是你想要我想的。您正在“打印”ggplot,这显然混淆了 nearPoints
:
library(shiny)
library(ggplot2)
ui <- fluidPage(
mainPanel(
uiOutput("tb")
)
)
server <- function(input,output){
output$diamonds1 <- renderPlot({
print(ggplot(diamonds, aes(x=carat, y=price, col=clarity)) +
geom_point(alpha=0.5)+ facet_wrap(~color, scales="free"))
})
output$diamonds2 <- renderPlot({
ggplot(diamonds, aes(x=carat, y=price, col=clarity)) +
geom_point(alpha=0.5)+ facet_wrap(~cut, scales="free")
})
output$info <- renderPrint({
nearPoints(diamonds,input$plot_click,threshold = 10, maxpoints = 1,addDist = TRUE)
})
output$tb <- renderUI({
tabsetPanel(tabPanel("First plot",
plotOutput("diamonds1")),
tabPanel("Second plot",
plotOutput("diamonds2", click = "plot_click"),
verbatimTextOutput("info")))
})
}
shinyApp(ui = ui, server = server)
产生这个 - 注意 data.frame 输出是 diamonds
中靠近鼠标点击的点:
关于r - nearPoints 无法从 Shiny 的坐标信息中自动推断出 `xvar`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35570553/
基础问题 我要解决的基本问题是: 我有一个模板参数包 ArgTypes,我需要用包装在 std::optional 中的每个类型创建一个元组。例如:make_optional_tuple应该返回 st
我使用 createEntityAdapter 设置了一个简单的 redux store。初始状态包含实体、ID、状态、错误设置等 const carouselEventAdapter = creat
我有一些(遗留)代码,如下所示: void castFoo(string type, void* foo) { FooA* foo_a = NULL; FooB* foo_b = NULL;
我的代码是 const int *const ptrA = nullptr; auto *ptrB = &ptrA; 我对 const int *const ptrA 的看法是: (*
我目前正在尝试用 C++ 实现 XOR 链表。我尝试使用模板使其通用。编译时会弹出此错误,我无法解决这个问题。 我尝试使用模板在谷歌上搜索 XOR 链表,但到目前为止似乎还没有实现它。 异或链表.h:
我正在尝试找到一种方法来调用多个类成员函数,每个函数都有不同的参数,并且在调用前后会发生某些已知功能。 这个包装函数是我试过的,但是例如对它的最终调用不会编译错误: 'bool Wrapper(Wor
此代码在 上编译成功g++ ( Coliru ) ,但不是 Visual C++ ( rextester ) - 在线和我的桌面。 它是一个更大的 Visual Studio 2015 项目的简化版本
我正在尝试编写一个通用类,它传递一个键 key 对应于一组已知接口(interface)中的一个的键,稍后可以传递一个对象 thing 并类型安全地访问 thing[key]。这是我得到的: inte
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我是一名优秀的程序员,十分优秀!