-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
158 lines (113 loc) · 3.2 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# load the required packages
library(shiny)
require(shinydashboard)
library(ggplot2)
library(dplyr)
# library(MASS) # to access Animals data sets
# library(scales) # to access break formatting functions
#library(ggthemes)
library(editheme)
library(RColorBrewer)
###
#++
library(viridis) # Color palette
library(lubridate)
library(tibble)
library(DT)
##
#pal <- get_pal(theme = "Dracula")
####
source('load.R', local = TRUE)
source('waffle.R', local = TRUE)
#source('dataTables.R', local = TRUE)
#######-------------------
# create the server functions for the dashboard
server <- function(input, output) {
Year <- reactive({
yr <-input$variable
as.numeric(yr)
})
### total number of application in the year
yrApp <- reactive({
d1 <- df %>%
group_by(y) %>%
summarise(tot=n()) %>%
filter(y==Year())
Tot1 <- d1$tot
Tot1
})
### total number of application in the month
monthApp <- reactive({
d2 <- df %>%
group_by(y,mon) %>%
summarise(tot=n()) %>%
filter(y==Year()) %>%
top_n(tot,n=1)
Tot2 <- as.character(d2$mon)
Tot2
})
### total number of application in the month
dayApp <- reactive({
d3 <- df %>%
group_by(y,day) %>%
summarise(tot=n()) %>%
filter(y==Year()) %>%
top_n(tot,n=1)
Tot3 <- as.character(d3$day)
Tot3
})
############################
#creeating the valueBoxOutput content
output$value1 <- renderValueBox({
valueBox(
formatC(yrApp(), format="d", big.mark=',')
,paste('Number of Applications')
,icon = icon("globe",lib='glyphicon')
,color = "purple")
})
output$value2 <- renderValueBox({
valueBox(
formatC(monthApp(), format="d", big.mark=',')
,paste('Best performing month')
,icon = icon("heart-empty",lib='glyphicon')
,color = "green")
})
output$value3 <- renderValueBox({
valueBox(
formatC(dayApp(), format="d", big.mark=',')
,paste('Most releases')
,icon = icon("fire",lib='glyphicon')
,color = "yellow")
})
## ggplot2
output$yrRelPlot <- renderPlot({
P1 <- pl.git(Year())
P1
})
## data table: Year 2016
inYr <- reactive({
year(input$date)
})
inMon <- reactive({
month(input$date)
})
inDay <- reactive({
day(input$date)
})
## data.table
selDate <- reactive({
d4 <- app_df %>%
filter(y==inYr() & m==inMon() & d==inDay()) %>%
mutate(date=ymd(date)) %>%
dplyr::select(-c(y,m,d, free_download)) %>%
dplyr::select(date,app_id:Cost)
d4
})
output$tbl1 <- DT::renderDataTable({
#funApp_DT(inYr(),inMon(),inDay())
dfRank <- selDate()
datatable(dfRank,class = 'cell-border stripe')%>%formatStyle(1, color = "#f7f7f7", backgroundColor = "#282a36", target = "row") %>%
formatStyle('Cost',
backgroundColor = styleEqual(c("Paid", "Free"), c('#FF6A71', '#96C275')))
})
}