-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
91 lines (50 loc) · 2.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
library(shiny)
library(googleVis)
library(ggplot2)
OmarSesiones <- read.csv("D:\\RCoursera\\OmarApp\\OmarSesiones_1415.csv",
header = T)
OmarSesiones$Mes <- factor(OmarSesiones$Mes,
levels = c("Enero", "Febrero",
"Marzo", "Abril", "Mayo",
"Junio", "Julio",
"Agosto", "Setiembre","Octubre",
"Noviembre",
"Diciembre"), ordered =T)
#colnames(OmarSesiones)
#choose.files()
#rownames(OmarSesiones) <- OmarSesiones$Fuentes
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
myData <- reactive({
# Filter the data based on user selection month
#date_seq <- seq(input$dates[1], input$dates[2], by = "day")
OmarSesiones <- filter(OmarSesiones, Fuentes %in% input$fuentes)
OmarSesiones <- filter(OmarSesiones, Mes %in% input$meses)
OmarSesiones <- filter(OmarSesiones, Ano %in% input$años)
return(OmarSesiones)
})
output$barrasfuentes <- renderPlot({
library(ggplot2)
#OmarSesiones <- filter(OmarSesiones, Fuentes %in% input$fuentes)
ggplot(myData(), aes(Mes, Visitas, fill=Fuentes)) +
stat_summary(fun.y=sum, geom="bar", position="stack") #+
#stat_summary(fun.y=sum, geom="text", aes(label=..y..))
})
output$tablafuentes <- renderDataTable({
library(ggplot2)
library(dplyr)
#OmarSesiones <- filter(OmarSesiones, Fuentes %in% input$fuentes)
myData2 <- myData() %>%
group_by(Mes, Fuentes) %>%
summarise(Visitas = prettyNum(sum(Visitas),big.mark = ",",
decimal.mark ="."))
myData2
})
###
# Expression that generates a histogram. The expression is
# wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should re-execute automatically
# when inputs change
# 2) Its output type is a plot
})