This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reticulate) | |
use_python("<PYTHONPATH>") | |
Connect Amazon Elasticsearch Service | |
py_awsauth <- import("requests_aws4auth") | |
credentials <- data.frame(list('<key>', '<secret>', '<region>', '<service>')) | |
authr <- py_awsauth$AWS4Auth(credentials$key, credentials$secret, credentials$region, credentials$service) | |
colnames(credentials) <- c("key", "secret", "region", "service") | |
hosts = c("<domain>:<port>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box( | |
title = "Airline Flight Destination Weather", | |
sliderInput("wordcloud_size", "Size of the Wordcloud:", | |
min=0.1, | |
max=0.6, | |
value=0.6 | |
), | |
wordcloud2Output("dest_weather", height = 200), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output$dest_weather <- renderWordcloud2({ | |
data <- setNames(annotate_agg1_es_result((es$search("kibana_sample_data_flights", dest_weather_query))), | |
c("weather", "ndest")) | |
wordcloud2(data, size = input$wordcloud_size) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output$delay_time <- renderPlot({ | |
data <- setNames(annotate_agg2_es_result((es$search("kibana_sample_data_flights", delay_type_query))), | |
c("time", "airline", "ndelays")) | |
data$time <- as.POSIXct(data$time, format="%Y-%m-%dT%H:%M:%S") | |
data <- data[(data$time >= input$delay_time_range[1]) & (data$time <= input$delay_time_range[2]), ] | |
ggplot(data, aes(x=time, y=ndelays, fill=airline)) + geom_bar(stat="identity") + theme_minimal() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output$airline_flights <- renderPlotly({ | |
data <- setNames(annotate_agg1_es_result((es$search("kibana_sample_data_flights", airline_carrier_query))), | |
c("airline", "nflights")) | |
colors <- c('rgb(211,94,96)', 'rgb(128,133,133)', 'rgb(144,103,167)', 'rgb(171,104,87)', 'rgb(114,147,203)') | |
plot_ly(data, labels = ~airline, values = ~nflights, type = 'pie', | |
textposition = 'inside', | |
textinfo = 'label+percent', | |
insidetextfont = list(color = '#FFFFFF'), | |
marker = list(colors = colors, | |
line = list(color = '#FFFFFF', width = 1)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
annotate_agg1_es_result <- function(result, include_others=FALSE) { | |
name <- c() | |
count <- c() | |
aggregation_result <- result$aggregations[[1]] | |
if (include_others){ | |
if ("key_as_string" %in% names(aggregation_result)) name <- c(name, aggregation_result$key_as_string) | |
else name <- c(name, aggregation_result$key) | |
name <- c(name, "Others") | |
count <- c(count, aggregation_result$sum_other_doc_count) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(DBI) | |
library(reticulate) | |
use_python("<PYTHONPATH>") | |
# Connect Amazon Elasticsearch Service | |
# py_awsauth <- import("requests_aws4auth") | |
# credentials <- data.frame(list('<key>', '<secret>', '<region>', '<service>')) | |
# authr <- py_awsauth$AWS4Auth(credentials$key, credentials$secret, credentials$region, credentials$service) | |
# colnames(credentials) <- c("key", "secret", "region", "service") |