Skip to content
Snippets Groups Projects
Commit abcc0e1a authored by Berinda van Dijk's avatar Berinda van Dijk
Browse files

Tried multiple configurations for the barplots.

Trying to use functions of ggplotly (i.e. dragmode=FALSE).
made a small change in the code around the 'separate'-function, to make a warning not appearing anymore.
parent 1823901f
Branches
No related tags found
1 merge request!8Tried multiple configurations for the barplots.
......@@ -30,20 +30,19 @@ doId <- function(input) {
bron <- read.csv(paste0("https://swimrankings.rubend.nl/csv?id=", id), encoding = "UTF-8")
bron$AfstandSlag <- gsub(" Lap", "", bron$stroke)
bron <- separate(bron, col = stroke, into = c("distance", "stroke", "Lap"), sep = " ")
bron <- separate(bron, col = stroke, into = c("distance", "stroke", "Lap"), sep = " ", fill='right')
bron$stroke <- as.factor(bron$stroke)
bron$distance <- as.numeric(str_sub(bron$distance, end = -2))
bron$distance <- factor(bron$distance, ordered = TRUE, levels = sort(unique(bron$distance)))
bron$poolType <- as.factor(bron$poolType)
bron=bron[order(bron$stroke, bron$distance),]
bron$AfstandSlag<-factor(bron$AfstandSlag, ordered=TRUE, levels=unique(bron$AfstandSlag))
#Wat als iets niet in kleurenset_afstanden valt?
kleurenset_afstanden=c('25'='red', '50'='orange', '100'='yellow', '200'='green', '400'='blue', '800'='purple', '500'='black')
kleurenset_strokes=c('Backstroke'='red', "Breaststroke"='orange', "Butterfly"="purple", "Freestyle"="green", "Medley"="blue")
bron <- separate(bron, col = heatType, into = c("hoofdafstand", "heatType"), sep = ", ")
bron$heatType[is.na(bron$heatType)] <- bron$hoofdafstand[is.na(bron$heatType)]
bron$hoofdafstand[bron$hoofdafstand == bron$heatType] <- NA
bron=separate(bron, col = heatType, into = c("hoofdafstand", "heatType"), sep = ", ", fill='left')
bron$heatType <- as.factor(bron$heatType)
bron$date <- str_sub(bron$date, -11) #alleen laatste dag van wedstrijd van meerdere dagen weergeven
......@@ -78,6 +77,9 @@ doId <- function(input) {
tabel_LastEntrys<-zonder_split%>%
group_by(distance, stroke) %>%
filter(date == max(date, na.rm=TRUE))
tabel_LastEntrys_beide<-zonder_split %>%
group_by(distance, stroke, poolType) %>%
filter(date==max(date, na.rm=TRUE))
tijdlijn_alles<-ggplot(zonder_split, aes(x=date, y=stroke, shape=poolType))+
geom_point()+
......@@ -86,7 +88,13 @@ doId <- function(input) {
geom_point(data = tabel_Prs, color="green", alpha=0.7, size=2, show.legend=FALSE)+
labs(title="Datum van alle gezwommen slagen per afstand")+guides(color='none')+
facet_grid(vars(distance), scales='free_y')
appendPlot(tijdlijn_alles)
tijdlijn_alles<-ggplotly(tijdlijn_alles, tooltip=c('x', 'shape', 'color'))
appendPlotly(tijdlijn_alles)
andere_tijdlijn<-ggplot(tabel_LastEntrys_beide,
aes(x=date, y=poolType, color=AfstandSlag, group=AfstandSlag))+
geom_point()+geom_line()+labs(title='Andere tijdlijn laatst gezwommen')
appendPlot(andere_tijdlijn)
kleurentabel_prs <- ggplot(tabel_Prs, aes(distance, stroke)) +
geom_tile(aes(fill = points)) +
......@@ -107,58 +115,100 @@ doId <- function(input) {
filter(points == max(points, na.rm = TRUE)) %>%
filter(time == min(time, na.rm=TRUE))
norm_barplot <- ggplot(tabel_Prs, aes(fill = distance, y = points, x = stroke)) +
norm_barplot <- ggplot(tabel_Prs, aes(fill = distance, y = points, x = stroke,
label=poolType, text=date)) +
geom_col(position = position_dodge2(preserve = "single")) +
scale_fill_manual(values=kleurenset_afstanden, limits=force)+
labs(title = "Prs: Punten per afstand per slag. Zowel lange - als kortebaan.")
appendPlot(norm_barplot)
norm_barplot<-ggplotly(norm_barplot, tooltip=c('label', 'text', 'y'))%>%
layout(legend=list(orientation='h'), dragmode=FALSE)
appendPlotly(norm_barplot)
norm_barplot2<-ggplot(tabel_Prs, aes(fill=distance, y=points, x=AfstandSlag, label=poolType, text=date))+
geom_col(position=position_dodge2(preserve='single'))+
scale_fill_manual(values=kleurenset_afstanden, limits=force)+
labs(title = "Prs: Punten per afstand per slag. Zowel lange - als kortebaan.")
norm_barplot2<-ggplotly(norm_barplot2, tooltip=c('label', 'text', 'y'))%>%layout(legend=list(orientation='h'), dragmode=FALSE)
appendPlotly(norm_barplot2)
norm_barplot3<-ggplot(tabel_Prs, aes(fill=distance, y=points, x=distance, label=poolType, text=date))+
geom_col(position=position_dodge2(preserve='single'))+
scale_fill_manual(values=kleurenset_afstanden, limits=force)+
labs(title = "Prs: Punten per afstand per slag. Zowel lange - als kortebaan.")+
facet_grid(cols=vars(stroke), space ='free_x')
norm_barplot3<-ggplotly(norm_barplot3, tooltip=c('label', 'text', 'y'))%>%layout(legend=list(orientation='h'), dragmode=FALSE)
appendPlotly(norm_barplot3)
norm_barplot4<- ggplot(tabel_Prs, aes(fill=distance, y=points, x=distance, label=poolType, text=date))+
geom_col(position=position_dodge2(preserve='single'))+
scale_fill_manual(values=kleurenset_afstanden, limits=force)+
labs(title = "Prs: Punten per afstand per slag. Zowel lange - als kortebaan.")+
facet_grid(cols=vars(stroke), scales='free_x')
norm_barplot4<-ggplotly(norm_barplot4, tooltip=c('label', 'text', 'y'))%>%layout(dragmode=FALSE)
appendPlotly(norm_barplot4)
tabel_LastEntrys<-zonder_split%>%
group_by(distance, stroke, poolType) %>%
filter(date == max(date, na.rm=TRUE))
norm_barplot_last <- ggplot(tabel_LastEntrys[tabel_LastEntrys$points!=0, ],
aes(fill = distance, y = points, x = stroke)) +
aes(fill = distance, y = points, x = stroke, text=date, label=poolType)) +
geom_col(position = position_dodge2(preserve = "single")) +
labs(title = "Laatste tijden: Punten >0 per afstand per slag", fill = "afstand")+
scale_fill_manual(values=kleurenset_afstanden, drop=TRUE, limits=force)
appendPlot(norm_barplot_last)
norm_barplot_last<-ggplotly(norm_barplot_last, tooltip=c('y', 'label', 'text')) %>%
layout(dragmode=FALSE, legend=list(orientation='h'))
appendPlotly(norm_barplot_last)
bovennul_sorted=bovennul[order(bovennul$distance, decreasing=TRUE),]
afstandEnslag=interaction(bovennul$distance, bovennul$stroke, sep='m ', drop=TRUE)
bovennul_50m=bovennul %>% filter(poolType=='50m')
stippenplot_plotly<-plot_ly(data=bovennul_sorted, x=~date, y=~points, type='scatter', mode='markers', color=~stroke)
appendPlotly(stippenplot_plotly)
stippenplot_alles<-ggplot(bovennul_sorted, aes(x=date, y=points, color=stroke, size=distance))+
stippenplot_alles<-ggplot(bovennul_sorted, aes(x=date, y=points, color=stroke,
size=distance, group=AfstandSlag))+
geom_point() +
scale_color_manual(values=kleurenset_strokes)+
labs(title = "Punten >0 per datum per afstand")
appendPlot(stippenplot_alles)
lijnenplot_ineen <- ggplot(bovennul, aes(x = date, y = points, color = afstandEnslag)) +
labs(title = "Punten per afstand, slag en datum") +
geom_line()
appendPlot(lijnenplot_ineen)
stippenplot_alles<-ggplotly(stippenplot_alles, tooltip=c('x', 'y'))
appendPlotly(stippenplot_alles)
lijnenplot_ineen2 <- lijnenplot_ineen+
geom_point(data=bovennul_50m, shape=17, color='black', alpha=0.5)
appendPlot(lijnenplot_ineen2)
lijnenplot_ineen_25m <- ggplot(bovennul[bovennul$poolType=='25m',],
aes(x = date, y = points, text=AfstandSlag,
color = interaction(distance, stroke, sep='m '))) +
labs(title = "Points - 25m pool") +
geom_line()+geom_point()+labs(color = "Distance & stroke")
lijnenplot_ineen_25m=ggplotly(lijnenplot_ineen_25m, dynamicTicks=TRUE, tooltip=c('x','y', 'text'))
appendPlotly(lijnenplot_ineen_25m)
tabel=zonder_split%>% count(distance, stroke)
tabel=tabel[tabel$n>1,]
tabel=tabel%>%count(distance)
lijnenplot_ineen_50m <- ggplot(bovennul[bovennul$poolType=='50m',],
aes(x = date, y = points, text=AfstandSlag,
color = interaction(distance, stroke, sep='m '))) +
labs(title = "Points - 50m pool") +
geom_line()+geom_point()+labs(color = "Distance & stroke")
lijnenplot_ineen_50m=ggplotly(lijnenplot_ineen_50m, dynamicTicks=TRUE, tooltip=c('x', 'y', 'text'))
appendPlotly(lijnenplot_ineen_50m)
AfstandGefilterd<-zonder_split[zonder_split$distance %in% tabel$distance, ]
lijnenplot_gesplitst_25m <- ggplot(zonder_split[zonder_split$poolType=='25m',],
aes(x = date, y = tijdsduur, color = stroke)) +
labs(y = "Tijd in seconden", title = "Times - 25meter pool") +
geom_line() + geom_point(size=1)+
scale_y_continuous(breaks=seq(0,15*60,30), minor_breaks=seq(0,15*60,10))+
scale_colour_manual(values=kleurenset_strokes)+
facet_wrap(vars(distance), scales = 'free_y')
lijnenplot_gesplitst_25m=ggplotly(lijnenplot_gesplitst_25m, tooltip=c('x', 'y')) %>%
layout(dragmode=FALSE, legend=list(orientation='h'))
appendPlotly(lijnenplot_gesplitst_25m)
lijnenplot_gesplitst <- ggplot(AfstandGefilterd,
aes(x = date, y = tijdsduur, color = stroke, group=AfstandSlag)) +
labs(y = "Tijd in seconden", title = "Tijden per datum en slag") +
geom_line() +
geom_point(size=1)+
theme(legend.position = "bottom")+
lijnenplot_gesplitst_50m <- ggplot(zonder_split[zonder_split$poolType=='50m',],
aes(x = date, y = tijdsduur, color = stroke)) +
labs(y = "Tijd in seconden", title = "Times - 50meter pool") +
geom_line() + geom_point(size=1)+
scale_y_continuous(breaks=seq(0,15*60,30), minor_breaks=seq(0,15*60,10))+
scale_colour_manual(values=kleurenset_strokes)+
facet_wrap(vars(distance), scales = 'free_y')
appendPlot(lijnenplot_gesplitst)
lijnenplot_gesplitst_50m=ggplotly(lijnenplot_gesplitst_50m, tooltip=c('x', 'y')) %>%
layout(dragmode=FALSE, legend=list(orientation='h'))
appendPlotly(lijnenplot_gesplitst_50m)
return(response)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment