【发布时间】:2016-05-14 14:00:24
【问题描述】:
我目前有一个散点图,仅显示我的数据集中的一列,我是从 csv 读取的。我想同时绘制 ATI 和 BTI。
PP BTI ATI
1 9710 9660
2 10000 9900
3 10300 10100
4 10600 10400
.
.
.
99 159000 107000
我的代码如下所示:
#server.R
#Income Percentile Scatterplot
incomedata <- read.csv("/Users/mathewsayer/Documents/Work/Level 7/Shiny Flat Tax/Flat Tax App/data/incomedist.csv")
ranges <- reactiveValues(x = NULL, y = NULL)
output$plot1 <- renderPlot({
ggplot(incomedata, aes(x = BTI, y = PP)) +
geom_point() +
coord_cartesian(xlim = ranges$x, ylim = ranges$y)
})
#Brush and zoom on scatterplot
observeEvent(input$plot1_dblclick, {
brush <- input$plot1_brush
if (!is.null(brush)) {
ranges$x <- c(brush$xmin, brush$xmax)
ranges$y <- c(brush$ymin, brush$ymax)
}
else {
ranges$x <- NULL
ranges$y <- NULL
}
})
我尝试像这样添加 ATI:aes(x = BTI:ATI, y = PP),但我收到错误消息 Aesthetics must be either length 1 or the same as the data (99): x, y
将我的数据称为框架或表格会更好吗?任何帮助将不胜感激。
【问题讨论】: