Created
September 14, 2013 20:09
-
-
Save zemadi/6565210 to your computer and use it in GitHub Desktop.
This was a partially successful attempt to use the R package Shiny, which creates interactive web applications. The data is from sfdata.org, and is a list of trees planted in San Francisco. I got the data points up but couldn't get a map to display on the main panel. Apparently, Shiny can't handle certain types of maps, so I'm looking at other o…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggmap) | |
library(ggplot2) | |
SFTrees <- read.csv("~/R/win-library/3.0/Projects/SF Trees/SFTrees.csv") | |
na.omit(SFTrees$PlantDate) | |
na.omit(SFTrees$Longitude) | |
na.omit(SFTrees$Latitude) | |
# Define server logic required to plot various variables | |
shinyServer(function(input, output) { | |
output$caption <- renderText({ | |
paste("Records of trees planted in San Francisco in", year()) | |
}) | |
year.df <- reactive({ | |
subset(SFTrees, date2 == input$year) | |
}) | |
output$map <- renderPlot({ | |
year <- year.df() | |
output$map <- renderPlot({ | |
print((ggplot(year, aes(x = Longitude, y=Latitude)) + geom_point()) | |
) | |
}) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggmap) | |
library(ggplot2) | |
shinyUI(pageWithSidebar( | |
# Application title | |
headerPanel("Explore the data"), | |
sidebarPanel( | |
# Animation with custom interval (in ms) to control speed, plus looping | |
sliderInput("year", "Plant Date:", | |
min=1955, max=2013, value=2013, step=4, | |
format="###0",animate=TRUE) | |
), | |
mainPanel( | |
h3(textOutput("year")), | |
plotOutput("map") | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment