Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
13 changes: 13 additions & 0 deletions R-Test-Project.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
42 changes: 42 additions & 0 deletions server.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#


library(shiny)
library(leaflet)
library(data.table)
library(lubridate)
library(DT)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

d <- fread("/Volumes/Nifty/Cloudstation/_Uni/Master/actual/FS2018/R-NonTechnicalIntroduction/02_Exercises/data/demographics.csv")
d[, JoinDate:=dmy(JoinDate, tz="UTC")]
#zips <- as.matrix(d[1:10000, list(zip_longitude, zip_latitude, Gender)])

d.shiny <- reactive({
d[Gender %in% input$genderWidget & JoinDate >= input$date[1] & JoinDate <= input$date[2]]
})

# Define map and fill map with data points
output$mymap <- renderLeaflet({
map <- leaflet();
map <- addTiles(map);
map <- addMarkers(map, lng = d.shiny()[,zip_longitude],
lat =d.shiny()[,zip_latitude],
clusterOptions = markerClusterOptions());
map <- setView(map, lat= 43, lng= -79, zoom = 4); # North America
})

# Table Output for Tab
output$mydata <- DT::renderDataTable(d.shiny())


})
46 changes: 46 additions & 0 deletions ui.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# This is the user-interface definition of a Shiny web application. You can
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#


library(shiny)
library(leaflet)
library(data.table)
library(shinythemes)
library(lubridate)


# Define UI for application that draws a histogram
shinyUI(fluidPage(

theme = shinytheme("simplex"),
# Application title
titlePanel("Customer map"),

sidebarLayout(position = "left",
sidebarPanel("Inputs",
checkboxGroupInput("genderWidget",
label ="Gender Choice",
choices = list("Male" = "m",
"Female" = "f",
"Alien" = "alien"),
selected = c("f","m", "alien")
),
sliderInput("date",
label = "Dates:",
min = dmy("01.01.1965"),
max = dmy("31.12.2011"),
value=c(dmy("01.01.1965"), dmy("31.12.2011"))
)),
mainPanel(
tabsetPanel(
tabPanel("Map", leafletOutput("mymap", height = "800px")),
tabPanel("Data", DT::dataTableOutput('mydata'))
)
))
))