-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathserver.R
More file actions
84 lines (49 loc) · 1.84 KB
/
server.R
File metadata and controls
84 lines (49 loc) · 1.84 KB
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
shinyServer(function(input, output,session) {
# create industry select based on company range
output$industries <- renderUI({
fortune %>%
filter(rank>=input$count[1]&rank<=input$count[2]) %>%
group_by(industry) %>%
summarize(count=n()) %>%
ungroup() %>%
arrange(desc(count)) -> topIndustries
topIndustries$industry <- as.character(topIndustries$industry)
industryChoice <- c("All",topIndustries$industry)
selectInput("industry","Select Industry - ordered by count",industryChoice)
})
# create data used by all
theData <- reactive({
# create a ranking
if (input$industry=="All") {
df <-fortune %>%
filter(rank>=input$count[1]&rank<=input$count[2])
} else {
df <-fortune %>%
filter(rank>=input$count[1]&rank<=input$count[2]&industry==input$industry)
}
## several companies are located in same city so we need to
## separate them out for visual identification
df$lon <- jitter(df$lon,amount=.1)
df$lat <- jitter(df$lat,amount =.1)
## create a value useful for circlMarker size
df <- df %>%
mutate(marker=ceiling(sqrt(revRank)/3))
# create by state info
summary<-df %>%
group_by(state) %>%
summarize(total=n())
## neeed to create value for all states and set NA to zero
summary <- allStates %>%
left_join(summary)
summary[is.na(summary$total),]$total <- 0
summary <- summary %>%
mutate(rank=min_rank(desc(total)))
info=list(df=df,summary=summary)
return(info)
})
# links to outputs
source("code/locations.R", local=TRUE)
source("code/statebins.R", local=TRUE)
source("code/choropleth.R", local=TRUE)
source("code/data.R", local=TRUE)
})