1. Preprocessing.R 805 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

#importing following packages
library(tidyverse)
library(lubridate)
library(dplyr)
library(ggplot2)
library(leaflet)

#Packages can be installed using the code below:
#install.packages('leaflet')

#importing data file 'crime.csv'
df <- read.csv(file = "crime.csv", header = TRUE, sep=",")
#view first few rows
head(df)

Sanjay Pant committed
17 18
#remove missing values
df <- na.omit(df)
19 20 21
#view number of rows and columns
dim(df)

Sanjay Pant committed
22

23 24 25 26 27 28 29 30 31
#view data types
str(df)

#Preprocessing
df$YEAR <- as.factor(df$YEAR)
df$HOUR <- as.factor(df$HOUR)
df$MONTH <- as.factor(df$MONTH)
df$OCCURRED_ON_DATE <- as.POSIXct(df$OCCURRED_ON_DATE, format = "%Y-%m-%d %H:%M:%OS")

Sanjay Pant committed
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
str(df)






#Shiny App

#importing shiny library
library(shiny)


ui <- basicPage("My first Shiny App")

server <- function(input, output){}

shinyApp(ui = ui, server = server)