I have two different CSV files that have the same amount of rows and the same column headings. Although one is for population and the other is for income. I am trying to make a shiny app that lets the user select the country and it will update the scatter plot to show the population and income for each year. They have 194 rows and 252 columns so assigning them individually would take a good bit of time so wondering if there is an easier way of going about it?
incomeTotal = read.csv("Income.csv", header = T, sep = ",")
popTotal = read.csv("Population.csv", header = T, sep = ",")
fullData = merge(popTotal, incomeTotal)
UI:
ui <- dashboardPage(
dashboardHeader(title = "Country Income and Population"),
dashboardSidebar(
sidebarMenu(
selectInput("nation", "Select a Country: ", choices = sort(unique(fullData))
)
)
),
dashboardBody(
fluidRow(
box(width = 6, solidHeader = TRUE, status = "primary",
title = "Total",
plotlyOutput("popIncome", width = '750px', height = '300px')
)
)
)
)
Server:
server <- function(input, output, session) {
output$popIncome <- renderPlotly({
ggplot(fullData, mapping = aes(x = popTotal, y = incomeTotal)) + geom_point()
})
}
Thanks