Commit 226d9203 authored by Я's avatar Я

add News: Data all item

parent 027f9326
...@@ -47,6 +47,19 @@ load_web_db <- function(){ ...@@ -47,6 +47,19 @@ load_web_db <- function(){
df_tag_entity <- db_table_load("wp_esi_tag_entity") df_tag_entity <- db_table_load("wp_esi_tag_entity")
df_investment <- db_table_load("wp_esi_investment") df_investment <- db_table_load("wp_esi_investment")
# basic for cross
df_technology <- db_table_load("wp_esi_technology")
df_industry <- db_table_load("wp_esi_industry")
df_function <- db_table_load("wp_esi_function")
df_media <- db_table_load("wp_esi_media")
df_region <- db_table_load("wp_esi_region")
df_type <- db_table_load("wp_esi_type")
# news tables
df_news <- db_table_load("wp_esi_news")
df_news_entity <- db_table_load("wp_esi_news_entity")
# 1.1.4. disconnect # 1.1.4. disconnect
dbDisconnect(db) dbDisconnect(db)
...@@ -72,6 +85,19 @@ if (exist_cash()){ ...@@ -72,6 +85,19 @@ if (exist_cash()){
df_tag_entity <- read_df("wp_esi_tag_entity") df_tag_entity <- read_df("wp_esi_tag_entity")
df_investment <- read_df("wp_esi_investment") df_investment <- read_df("wp_esi_investment")
# basic for cross
df_technology <- read_df("wp_esi_technology")
df_industry <- read_df("wp_esi_industry")
df_function <- read_df("wp_esi_function")
df_media <- read_df("wp_esi_media")
df_region <- read_df("wp_esi_region")
df_type <- read_df("wp_esi_type")
# news tables
df_news <- read_df("wp_esi_news")
df_news_entity <- read_df("wp_esi_news_entity")
# packages management # packages management
detach("package:RMySQL", unload=TRUE) detach("package:RMySQL", unload=TRUE)
library(sqldf) library(sqldf)
...@@ -131,10 +157,12 @@ body <- dashboardBody( ...@@ -131,10 +157,12 @@ body <- dashboardBody(
tabItem(tabName = "company_data_all", tabItem(tabName = "company_data_all",
fluidPage( fluidPage(
fluidRow(h2("All data about companies")),
fluidRow(DT::dataTableOutput("company_data_all_table")) fluidRow(DT::dataTableOutput("company_data_all_table"))
)), )),
tabItem(tabName = "company_data_tags", tabItem(tabName = "company_data_tags",
fluidPage( fluidPage(
fluidRow(h2("Data about companies by tags")),
fluidRow(selectizeInput('company_data_tags_tags', 'Tags', choices = df_tag$name, multiple = TRUE)), fluidRow(selectizeInput('company_data_tags_tags', 'Tags', choices = df_tag$name, multiple = TRUE)),
fluidRow(radioButtons("company_data_tags_tags_filter", "Tags filter", fluidRow(radioButtons("company_data_tags_tags_filter", "Tags filter",
choices = list("OR" = 1, "AND" = 2), selected = 1, inline = T)), choices = list("OR" = 1, "AND" = 2), selected = 1, inline = T)),
...@@ -143,7 +171,7 @@ body <- dashboardBody( ...@@ -143,7 +171,7 @@ body <- dashboardBody(
)), )),
tabItem(tabName = "company_analysis_countries", tabItem(tabName = "company_analysis_countries",
fluidPage( fluidPage(
fluidRow(h2("Distribution of AI companies by countries")), fluidRow(h2("Analysis of companies by countries")),
fluidRow(p(tags$b("Number of companies"))), fluidRow(p(tags$b("Number of companies"))),
fluidRow( fluidRow(
column(3, textInput("company_analysis_countries_entities_min", "Min", "100")), column(3, textInput("company_analysis_countries_entities_min", "Min", "100")),
...@@ -156,7 +184,7 @@ body <- dashboardBody( ...@@ -156,7 +184,7 @@ body <- dashboardBody(
), ),
tabItem(tabName = "company_analysis_tags", tabItem(tabName = "company_analysis_tags",
fluidPage( fluidPage(
fluidRow(h2("Number of companies per tags")), fluidRow(h2("Analysis of companies by tags")),
fluidRow(selectInput("company_analysis_tags_choice", "Number of tags", fluidRow(selectInput("company_analysis_tags_choice", "Number of tags",
c("> 100", "50:100", "10:50", "5:10", "3:5", "1:3", "1: Max"))), c("> 100", "50:100", "10:50", "5:10", "3:5", "1:3", "1: Max"))),
fluidRow(plotlyOutput("company_analysis_tags")), fluidRow(plotlyOutput("company_analysis_tags")),
...@@ -166,7 +194,7 @@ body <- dashboardBody( ...@@ -166,7 +194,7 @@ body <- dashboardBody(
), ),
tabItem(tabName = "company_analysis_size_tags", tabItem(tabName = "company_analysis_size_tags",
fluidPage( fluidPage(
fluidRow(h2("Average size of company per tags")), fluidRow(h2("Analysis of companies by average size per tags")),
fluidRow(selectInput("company_analysis_size_tags_choice", "Average size", fluidRow(selectInput("company_analysis_size_tags_choice", "Average size",
c("> 1000", "500 : 1000", "250 : 500", "100 : 250", "50 : 100", "25 : 50", "1 : 25", "1 : Max"))), c("> 1000", "500 : 1000", "250 : 500", "100 : 250", "50 : 100", "25 : 50", "1 : 25", "1 : Max"))),
fluidRow(plotlyOutput("company_analysis_size_tags")), fluidRow(plotlyOutput("company_analysis_size_tags")),
...@@ -175,7 +203,7 @@ body <- dashboardBody( ...@@ -175,7 +203,7 @@ body <- dashboardBody(
)), )),
tabItem(tabName = "company_analysis_age_tags", tabItem(tabName = "company_analysis_age_tags",
fluidPage( fluidPage(
fluidRow(h2("Average age of company per tags")), fluidRow(h2("Analysis of companies by average age per tags")),
fluidRow(selectInput("company_analysis_age_tags_choice", "Average age", fluidRow(selectInput("company_analysis_age_tags_choice", "Average age",
c("> 20", "15 : 20", "10 : 15", "7 : 10", "5 : 7", "3 : 5", "1 : 3", "1 : Max"))), c("> 20", "15 : 20", "10 : 15", "7 : 10", "5 : 7", "3 : 5", "1 : 3", "1 : Max"))),
fluidRow(plotlyOutput("company_analysis_age_tags")), fluidRow(plotlyOutput("company_analysis_age_tags")),
...@@ -187,13 +215,14 @@ body <- dashboardBody( ...@@ -187,13 +215,14 @@ body <- dashboardBody(
tabItem(tabName = "invest_data_all", tabItem(tabName = "invest_data_all",
fluidPage( fluidPage(
fluidRow(h2("All investments")), fluidRow(h2("Data about all investments")),
fluidRow(DT::dataTableOutput("dt_invest_data_all")) fluidRow(DT::dataTableOutput("dt_invest_data_all"))
) )
), ),
tabItem(tabName = "invest_data_tags", tabItem(tabName = "invest_data_tags",
fluidPage( fluidPage(
fluidRow(h2("Data about investments by tags")),
fluidRow(selectizeInput('invest_data_tags_tags', 'Tags', choices = df_tag$name, multiple = TRUE)), fluidRow(selectizeInput('invest_data_tags_tags', 'Tags', choices = df_tag$name, multiple = TRUE)),
fluidRow(radioButtons("invest_data_tags_tags_filter", "Tags filter", fluidRow(radioButtons("invest_data_tags_tags_filter", "Tags filter",
choices = list("OR" = 1, "AND" = 2), selected = 1, inline = T)), choices = list("OR" = 1, "AND" = 2), selected = 1, inline = T)),
...@@ -204,7 +233,7 @@ body <- dashboardBody( ...@@ -204,7 +233,7 @@ body <- dashboardBody(
tabItem(tabName = "invest_analysis_tags", tabItem(tabName = "invest_analysis_tags",
fluidPage( fluidPage(
fluidRow(h2("Investments per tags")), fluidRow(h2("Analysis of investments per tags")),
fluidRow(uiOutput('invest_analysis_tags_slider')), fluidRow(uiOutput('invest_analysis_tags_slider')),
fluidRow(plotlyOutput("invest_analysis_tags")), fluidRow(plotlyOutput("invest_analysis_tags")),
fluidRow(DT::dataTableOutput("dt_invest_analysis_tags")), fluidRow(DT::dataTableOutput("dt_invest_analysis_tags")),
...@@ -215,6 +244,7 @@ body <- dashboardBody( ...@@ -215,6 +244,7 @@ body <- dashboardBody(
tabItem(tabName = "invest_data_tags_date_fund", tabItem(tabName = "invest_data_tags_date_fund",
fluidPage( fluidPage(
fluidRow(h2("Analysis of investments by tags, dates and fundings")),
fluidRow(selectizeInput('invest_data_tags_date_fund_tags', 'Tags', choices = df_tag$name, multiple = TRUE)), fluidRow(selectizeInput('invest_data_tags_date_fund_tags', 'Tags', choices = df_tag$name, multiple = TRUE)),
fluidRow(radioButtons("invest_data_tags_date_fund_tags_filter", "Tags filter", fluidRow(radioButtons("invest_data_tags_date_fund_tags_filter", "Tags filter",
choices = list("OR" = 1, "AND" = 2), selected = 1, inline = T)), choices = list("OR" = 1, "AND" = 2), selected = 1, inline = T)),
...@@ -234,7 +264,8 @@ body <- dashboardBody( ...@@ -234,7 +264,8 @@ body <- dashboardBody(
# 4. News ---- # 4. News ----
tabItem(tabName = "news_data_all", tabItem(tabName = "news_data_all",
fluidPage( fluidPage(
fluidRow(h2("News")) fluidRow(h2("Data about all news")),
fluidRow(DT::dataTableOutput("dt_news_data_all"))
)) ))
) )
...@@ -1500,15 +1531,40 @@ df_company_analysis_age_tags <- reactive({ ...@@ -1500,15 +1531,40 @@ df_company_analysis_age_tags <- reactive({
# 1. Data frame # 1. Data frame
df_news_data_all <- reactive({ df_news_data_all <- reactive({
# 1. Feature engineering
df_result <- df_news %>%
left_join(df_news_entity, by = c("id" = "news_id")) %>%
left_join(df_entity, by = c("entity_id" = "id")) %>%
left_join(df_media, by = c("media_id" = "id")) %>%
left_join(df_type, by = c("type_id" = "id")) %>%
left_join(df_region, by = c("region_id" = "id")) %>%
subset(select = c(id, title, publish_date, url.x,
name.x, name.y, name.x.x, name.y.y)) %>%
rename(url = url.x, entity_name = name.x, media_name = name.y,
type_name = name.x.x, region_name = name.y.y) %>%
mutate(publish_date = as.Date(publish_date))
# 2. Get result
return(df_result)
})
# View for DT table
df_news_data_all_view <- reactive({
df_news_data_all() %>%
mutate(
title = paste0(substr(title, 1, 20), "..."),
url = paste0(substr(url, 1, 20), "...")
) %>%
subset(select = c(id,title, publish_date, url, entity_name,
media_name, type_name, region_name))
}) })
# 1. Table # 1. Table
output$dt_news_data_all <- DT::renderDataTable( output$dt_news_data_all <- DT::renderDataTable(
DT::datatable(df_news_data_all(), options = list(pageLength = 10, searching = TRUE), rownames= FALSE) DT::datatable(df_news_data_all_view(), options = list(pageLength = 10, searching = TRUE), rownames= FALSE)
) )
} }
shinyApp(ui, server) shinyApp(ui, server)
\ No newline at end of file
File added
No preview for this file type
No preview for this file type
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# "News" tables analysis # "News" tables analysis
# #
# "wp_esi_news"
# "wp_esi_news_entity" # "wp_esi_news_entity"
# "wp_esi_news_radar" # "wp_esi_news_radar"
# "wp_esi_news_function" # "wp_esi_news_function"
...@@ -49,4 +48,28 @@ df_function <- db_load("wp_esi_function") ...@@ -49,4 +48,28 @@ df_function <- db_load("wp_esi_function")
# news tables # news tables
df_news <- db_load("wp_esi_news") df_news <- db_load("wp_esi_news")
df_news_entity <- db_load("wp_esi_news_entity")
# other tables
df_media <- db_load("wp_esi_media")
df_region <- db_load("wp_esi_region")
df_type <- db_load("wp_esi_type")
# Feature engineering
df_news_view <- df_news %>%
left_join(df_news_entity, by = c("id" = "news_id")) %>%
left_join(df_entity, by = c("entity_id" = "id")) %>%
left_join(df_media, by = c("media_id" = "id")) %>%
left_join(df_type, by = c("type_id" = "id")) %>%
left_join(df_region, by = c("region_id" = "id")) %>%
subset(select = c(id, title, publish_date, url.x,
name.x, name.y, name.x.x, name.y.y)) %>%
rename(url = url.x, entity_name = name.x, media_name = name.y,
type_name = name.x.x, region_name = name.y.y) %>%
mutate(publish_date = as.Date(publish_date))
# All columns in merge data set
# write.csv(colnames(df_news_view), "c.txt", row.names = F)
# df_news_view <- left_join(df_news_view, df_news_entity, by = c("id" = "news_id"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment