-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.R
More file actions
48 lines (43 loc) · 1.71 KB
/
server.R
File metadata and controls
48 lines (43 loc) · 1.71 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
# Define a server for the Shiny app
function(input, output) {
dataState = reactive({
count = sort(colSums(jobData[jobData$state == input$state,-1]))
data = data.frame(
"count"=as.integer(as.vector(count)),
"skill"=names(count))
})
dataSkill = reactive({
name = input$skill
skill = jobData[,c("state",name)]
agg = aggregate(skill[,name]~skill[,"state"],data=skill,sum)
names(agg) = c("state","count")
data = agg
})
# Fill in the spot we created for a plot
output$skillPlot <- renderPlot({
output$statePlot <- renderPlot({
# Render a barplot
ggplot(dataSkill(), aes(x=reorder(state,-count), y=count)) +
geom_bar(stat="identity", fill="lightblue", colour="black") +
coord_cartesian(ylim=c(0,max(dataSkill()$count)+5)) +
theme(axis.title = element_text(size = 15),
axis.text.x = element_text(size = 10),
plot.title = element_text(size=22,hjust = 0.5)) +
scale_y_continuous(breaks= pretty_breaks()) +
xlab("State") +
ylab("Count") +
ggtitle(paste(capitalize(input$skill),"counts in states"))
},height = 220)
# Render a barplot
ggplot(dataState(), aes(x=reorder(skill,-count), y=count)) +
geom_bar(stat="identity", fill="lightblue", colour="black") +
coord_cartesian(ylim=c(0,max(dataState()$count)+5)) +
scale_y_continuous(breaks= pretty_breaks()) +
theme(axis.text.x = element_text(angle = 70, hjust = 1,size = 15),
axis.title= element_text(size = 15),
plot.title = element_text(size=22,hjust = 0.5)) +
xlab("Skill") +
ylab("Count")+
ggtitle(paste("Skills at",input$state))
}, height = 270)
}