I currently have a scatterplot showing only one column from my data set, which I'm reading from a csv. I want to plot both ATI and BTI.
PP BTI ATI
1 9710 9660
2 10000 9900
3 10300 10100
4 10600 10400
.
.
.
99 159000 107000
My code looks like this:
#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
}
})
I've tried adding ATI like this: aes(x = BTI:ATI, y = PP) but I get the error message Aesthetics must be either length 1 or the same as the data (99): x, y
Would I be better calling my data as a frame or table? Any help would be greatly appreciated.
EDIT: The black plot points are BTI, I want to the data from ATI to appear similar to this photo-mock up I just done. 