-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.R
More file actions
171 lines (166 loc) · 6.85 KB
/
app.R
File metadata and controls
171 lines (166 loc) · 6.85 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# setwd("D:/UNIVERSITY UTARA MALAYSIA/Datathon 2020 - Documents/datathon2020")
library(shiny)
library(shinydashboard)
library(dashboardthemes)
ui <- dashboardPage(
title = "Niubility Online Seller",
header = dashboardHeader(
title = textOutput("title")
),
sidebar = dashboardSidebar(
sidebarMenu(
id = "tabs",
menuItem("Product Category", tabName = "cat", icon = icon("gifts")),
menuItem("Price Prediction", tabName = "price", icon = icon("dollar-sign")),
menuItem("Keywords Analysis", tabName = "title", icon = icon("key"))
)
),
body=dashboardBody(
shinyDashboardThemes("grey_light"),
tags$head(
includeScript("js/press_enter.js"),
tags$style(".content-wrapper {min-height: 100rem !important;}")
),
tabItems(
tabItem(
"cat",
tags$style(".col-sm-3 {height: 68vh} .well {height: 100%}"),
fluidRow(
tags$style(".small-box.bg-yellow { background-color: #ec742c !important; color: #000000 !important; }"),
valueBox(
tagList(
tags$h3(
style = "font-style: italic;font-size: 50px;text-align: center;font-family: \"Computer Modern\"",
HTML("What Should I Sell?")
)
),
"", width = 12, color = "yellow"
)
),
sidebarLayout(
sidebarPanel(
style="height:auto",
width = 3,
p(style="text-align:justify", "From the Sunburst chart, we have the top 5 hottest selling products in the 2nd half of 2019: Men Shoes, Motor, Women's Shoes and Clothing, Sport and Outdoor & Mother and Baby. These 5 product categories make up to ", strong("40% of the total sales quantity.")),
p(style="text-align:justify", 'These figures reflect a general trend of top-selling items in online shopping. Hence, if someone wants to become the highest "niubility" online seller on the platform, ', strong("they should focus on the Mother & Baby products,"), "which is the top sales product overall (~10% of total sales quantity). In the next analysis, our team presumed the online seller has decided to sell Mother & Baby products."),
p(style="text-align:justify", "You can click into the sunburst chart to see more information!")
),
mainPanel(
width = 9,
includeHTML("output/html_files/top5_other_categories.html")
)
)
),
tabItem(
"price",
tags$style(".col-sm-3 {height: 68vh} .well {height: 100%}"),
fluidRow(
tags$style(".small-box.bg-green { background-color: #a4bb2c !important; color: #000000 !important; }"),
valueBox(
tagList(
tags$h3(
style = "font-style: italic;font-size: 50px;text-align: center;font-family: \"Computer Modern\"",
HTML("How Much is the Actual Price?")
)
),
"", width = 12, color = "green"
)
),
sidebarLayout(
sidebarPanel(
style="height:auto",
width = 3,
div(
p(style="text-align:justify", "Pricing is crucial in online selling, lower prices might attract customers, but may cause a backfire on profit. To find the optimum discount rate, a regression model was used to predict the actual price (less discount) from original price of Mother & Baby products."),
p(style="text-align:justify", "The optimum discount rate is 47.67% and the actual price is predicted by the regression formula:"),
p(style="font-style:italic", HTML("Predicted Actual Price <br>= 0.52 Original Price + 0.86")),
inputPanel(
fluidRow(
column(
width = 8,
textInput(
inputId = "price_ori",
label = "Original Price: ",
placeholder = "RM 0.00"
)
),
column(
width = 4,
actionButton('submit', 'GO!', width="100%"),
style = "margin-top: 25px;"
)
)
),
inputPanel(
p(strong("Actual Price: ")),
textOutput("predict")
)
)
),
mainPanel(
width = 9,
includeHTML("output/html_files/scatter.html")
)
)
),
tabItem(
"title",
tags$style(".col-sm-3 {height: 68vh} .well {height: 100%}"),
fluidRow(
tags$style(".small-box.bg-blue { background-color: #042b5b !important; color: #000000 !important; }"),
valueBox(
tagList(
tags$h3(
style = "font-style: italic;font-size: 50px;text-align: center;font-family: \"Computer Modern\"",
HTML("Which Keywords are Important?")
)
),
"", width = 12, color = "blue"
)
),
sidebarLayout(
sidebarPanel(
style="height:auto",
width = 3,
p(style="text-align:justify", "With the help of Natural Language Processing (NLP) in analyzing the product title, the output was presented in Word Cloud. The bigger the word showed, the more important the keyword is."),
p(style="text-align:justify", "By using the TF-IDF model, we found out the following words are fairly important in the product title:", strong("Animal, Freezer, Home, Prado & Picnic."), "It is recommended to include these words in the product title, to catch customers' eyeballs."),
p(style="text-align:justify", "We also observed that the appearance of proper nouns in the bags of keywords: Prado, XJING, Aldo, Perfeclan, Groboc, etc. Hence, it is also advised to ", strong("have a specific brand name in the product title.")),
p("Thanks for Watching!"),
a(href="https://github.com/Rexpert/datathon2020", target="_blank", "Bring me to Source Code!")
),
mainPanel(
width = 9,
includeHTML("output/html_files/wordcloud.html")
)
)
)
)
)
)
server <- function(input, output, session) {
output$title <- renderText({
switch (
input$tabs,
"cat" = "Product Category",
"price" = "Price Prediction",
"title" = "Keywords Analysis")
})
val <- reactiveValues(
predict = "RM 0.00"
)
observeEvent(input$submit, {
prediction <- function(value) {
value = as.numeric(value)
if(!is.na(value)) {
value = 0.858328 + value * 0.523259
value = round(value, 2)
} else {
value = 0
}
return(paste("RM", format(value, nsmall = 2, big.mark=",")))
}
val$predict = prediction(input$price_ori)
})
output$predict <- renderText({val$predict})
}
shinyApp(ui, server)