r - 分辨率变化时如何避免重复渲染ggplot
问题描述
我在更改屏幕分辨率时遇到了 ggplot 渲染本身的问题,尤其是当我处理大文件时,这使得我的 shinyApp 每次分辨率更改时都很忙。有没有办法避免这种情况?
library(shiny)
library(ggplot2)
ui <- fluidPage(
plotOutput("plot")
)
server <- function(input, output, session) {
data<-mtcars
for(i in 1:15){
data<-rbind(data,data)
}
output$plot<-renderPlot({
ggplot(aa,aes(x = cyl, y = mpg))+geom_point()
})
}
shinyApp(ui, server)
解决方案
我想说的是在更改屏幕分辨率时(例如放大/缩小),我可以看到我们从头开始运行 renderPlot 而 renderTable dosent 这样做。您可以运行代码并在控制台中查看打印结果
library(shiny)
library(ggplot2)
ui <- fluidPage(
plotOutput("plot"),
tableOutput("table")
)
server <- function(input, output, session) {
data<-mtcars
for(i in 1:5){
data<-rbind(data,data)
}
output$plot<-renderPlot({
print("plot")
ggplot(data,aes(x = cyl, y = mpg))+geom_point()
})
output$table<-renderTable({
print("table")
head(data)
})
}
shinyApp(ui, server)
推荐阅读
- c# - 有没有办法通过 < 运算符加入 linq 的 1 个值大于另一个值?
- angular - 将文件上传到 S3 但返回 observable
- jsf - p:消息显示但几乎立即消失
- php - 是否可以将 akeneo 与我的非 cms PHP 网站集成?
- powerbi - 如何在powerbi中按计数进行分组
- sql - 使用所有不同的值更新多行
- c - Deadlock when using fork, exec and pipes in a parallel environment
- excel - 从excel VBA复制到word时范围有限
- ios - iOS(swift)退出/关闭共享扩展中的预选文本视图
- ios - 将 int 数据从一个视图控制器传递到另一个视图控制器时遇到问题(segue)