Skip to content

Commit

Permalink
Merge pull request #6 from anodaini/main
Browse files Browse the repository at this point in the history
Deployed the app
  • Loading branch information
vigneshRajakumar authored Jan 30, 2021
2 parents facf864 + cc35436 commit 89217e0
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 52 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM plotly/heroku-docker-r:3.6.3_heroku18

# on build, copy application files
COPY . /app/

# for installing additional dependencies etc.
RUN if [ -f '/app/onbuild' ]; then bash /app/onbuild; fi;

# look for /app/apt-packages and if it exists, install the packages contained
RUN if [ -f '/app/apt-packages' ]; then apt-get update -q && cat apt-packages | xargs apt-get -qy install && rm -rf /var/lib/apt/lists/*; fi;

# look for /app/init.R and if it exists, execute it
RUN if [ -f '/app/init.R' ]; then /usr/bin/R --no-init-file --no-save --quiet --slave -f /app/init.R; fi;

# You could install packages here, but I strongly reccomend that you use init.R instead.
# RUN R -e "install.packages('remotes', repos='http://cran.rstudio.com/')" \
# && R -e "remotes::install_github('facultyai/dash-bootstrap-components@r-release')"

# here app.R needs to match the name of the file which contains your app
CMD cd /app && /usr/bin/R --no-save -f /app/app.R
13 changes: 13 additions & 0 deletions Movie_Selection-R.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Movie Selection App with Dash in R

The Movie Selection App assists movie investors in selecting the popular and profitable movies for each genre and a specified budget range and compare different production studios. You can view the currently deployed version [here](https://movie-selection-app.herokuapp.com/)
The Movie Selection App assists movie investors in selecting the popular and profitable movies for each genre and a specified budget range and compare different production studios. You can view the currently deployed version [here](https://movie-selection-app-r.herokuapp.com/)

## Contributors: DSCI_532_group7

Expand Down
86 changes: 42 additions & 44 deletions src/app.R → app.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ library(dashCoreComponents)
library(dashHtmlComponents)
library(dashBootstrapComponents)
library(plotly)
#library(dashTable)


movies = read_csv("../data/processed/movies.csv")
movies <- readr::read_csv(here::here("data/processed/movies.csv"))

app <- Dash$new(external_stylesheets = dbcThemes$LUMEN)

Expand Down Expand Up @@ -67,7 +65,7 @@ genre_graphs = htmlDiv(list(dbcRow(list(
"border-width" = "0",
"width" = "100%",
"height" = 265
),
)
)
)),
color = "success",
Expand All @@ -85,12 +83,12 @@ studio_graphs = htmlDiv(list(dbcRow(list(dbcCol(
"border-width" = "0",
"width" = "100%",
"height" = "400px"
),
)
)
)),
color = "info",
outline = TRUE
),
)
))),
htmlBr(),
htmlBr(),
Expand All @@ -103,7 +101,7 @@ dbcRow(list(dbcCol(
"border-width" = "0",
"width" = "100%",
"height" = "400px"
),
)
)))
,
color = "info",
Expand Down Expand Up @@ -147,7 +145,7 @@ dbcFormGroup(list(
"100" = "100",
"200" = "200",
"300" = "300"
),
)
)
))),
body = TRUE,
Expand Down Expand Up @@ -179,23 +177,23 @@ app$callback(
list(input("xgenre-widget", "value"),
input("xbudget-widget", "value")),
function(xgenre, xbudget){
filtered_movies <- movies %>%
filtered_movies <- movies %>%
filter(genres == xgenre,
budget %in% (unlist(xbudget)[1]:unlist(xbudget)[2]))
vote_avg_by_studio <- filtered_movies %>%

vote_avg_by_studio <- filtered_movies %>%
ggplot(aes(x = as.factor(studios), y = vote_average)) +
geom_boxplot(fill="#20B2AA", color = 'turquoise4') +
geom_boxplot(fill="#20B2AA", color = 'turquoise4') +
labs(y = 'Vote Average') +
coord_flip() +
theme(axis.title.y = element_blank(),
axis.title.x = element_text(face = 'bold', color = 'turquoise4'),
axis.text = element_text(color = 'turquoise4'))
ggplotly(vote_avg_by_studio + aes(text = title), tooltip = 'text')

ggplotly(vote_avg_by_studio + aes(text = title), tooltip = 'text')

}

)


Expand All @@ -206,23 +204,23 @@ app$callback(
list(input("xgenre-widget", "value"),
input("xbudget-widget", "value")),
function(xgenre, xbudget){
filtered_movies <- movies %>%
filtered_movies <- movies %>%
filter(genres == xgenre,
budget %in% (unlist(xbudget)[1]:unlist(xbudget)[2]))
rev_by_studio <- filtered_movies %>%

rev_by_studio <- filtered_movies %>%
ggplot(aes(x = as.factor(studios), y = revenue)) +
geom_boxplot(fill="#20B2AA", color = 'turquoise4') +
geom_boxplot(fill="#20B2AA", color = 'turquoise4') +
labs(y = 'Revenue (US$ mil)') +
coord_flip() +
theme(axis.title.y = element_blank(),
axis.title.x = element_text(face = 'bold', color = 'turquoise4'),
axis.text = element_text(color = 'turquoise4'))
ggplotly(rev_by_studio + aes(text = title), tooltip = 'text')

ggplotly(rev_by_studio + aes(text = title), tooltip = 'text')

}

)


Expand All @@ -233,22 +231,22 @@ app$callback(
list(input("xgenre-widget", "value"),
input("xbudget-widget", "value")),
function(xgenre, xbudget){
filtered_movies <- movies %>%
filtered_movies <- movies %>%
filter(genres == xgenre,
budget %in% (unlist(xbudget)[1]:unlist(xbudget)[2]))
voting_profile <- filtered_movies %>%

voting_profile <- filtered_movies %>%
ggplot(aes(vote_average, vote_count)) +
geom_jitter(color = "#20B2AA", color = 'turquoise4', alpha = 0.6) +
labs(x = 'Vote Average', y = "Vote Count") +
theme(
axis.title = element_text(face = 'bold', color = 'turquoise4'),
axis.text = element_text(color = 'turquoise4'))
ggplotly(voting_profile + aes(text = title), tooltip = 'text')

ggplotly(voting_profile + aes(text = title), tooltip = 'text')

}

)


Expand All @@ -259,16 +257,16 @@ app$callback(
list(input("xgenre-widget", "value"),
input("xbudget-widget", "value")),
function(xgenre, xbudget){
filtered_movies <- movies %>%
filtered_movies <- movies %>%
filter(genres == xgenre,
budget %in% (unlist(xbudget)[1]:unlist(xbudget)[2]))
top_movies_by_vote <- filtered_movies %>%
group_by(title) %>%

top_movies_by_vote <- filtered_movies %>%
group_by(title) %>%
summarize(vote_average = mean(vote_average),
runtime = mean(runtime)) %>%
arrange(desc(vote_average)) %>%
slice(1:10) %>%
runtime = mean(runtime)) %>%
arrange(desc(vote_average)) %>%
slice(1:10) %>%
ggplot(aes(x= vote_average, y = reorder(title, vote_average), color = runtime)) +
geom_point(stat = 'identity', shape = 2, size = 5, stroke = 1) +
labs(x = "Vote Average", legend = "Runtime (mins)")+
Expand All @@ -277,12 +275,12 @@ app$callback(
theme(axis.title.y = element_blank(),
axis.title = element_text(face = 'bold', color = 'turquoise4'),
axis.text = element_text(color = 'turquoise4'))
ggplotly(top_movies_by_vote + aes(text = paste("Runtime:", runtime, "\nVote avg", vote_average)), tooltip = 'text')

ggplotly(top_movies_by_vote + aes(text = paste("Runtime:", runtime, "\nVote avg", vote_average)), tooltip = 'text')


}

)


Expand All @@ -294,7 +292,7 @@ app$callback(
list(input("xgenre-widget", "value"),
input("xbudget-widget", "value")),
function(xgenre, xbudget) {
filtered_movies <- movies %>%
filtered_movies <- movies %>%
filter(genres == xgenre,
budget %in% (unlist(xbudget)[1]:unlist(xbudget)[2]))
average_revenue <- paste("US$", round(mean(filtered_movies$revenue),2),"mil")
Expand All @@ -310,7 +308,7 @@ app$callback(
list(input("xgenre-widget", "value"),
input("xbudget-widget", "value")),
function(xgenre, xbudget) {
filtered_movies <- movies %>%
filtered_movies <- movies %>%
filter(genres == xgenre,
budget %in% (unlist(xbudget)[1]:unlist(xbudget)[2]))
average_vote <- round(mean(filtered_movies$vote_average),2)
Expand Down Expand Up @@ -341,4 +339,4 @@ app$callback(



app$run_server(debug = F)
app$run_server(host = '0.0.0.0')
3 changes: 3 additions & 0 deletions apt-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
libcurl4-openssl-dev
libxml2-dev
libv8-3.14-dev
3 changes: 3 additions & 0 deletions heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
docker:
web: Dockerfile
13 changes: 13 additions & 0 deletions init.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# R script to run author supplied code, typically used to install additional R packages
# contains placeholders which are inserted by the compile script
# NOTE: this script is executed in the chroot context; check paths!

r <- getOption('repos')
r['CRAN'] <- 'http://cloud.r-project.org'
options(repos=r)

# ======================================================================

# packages go here
install.packages(c('dash', 'readr', 'here', 'ggthemes', 'remotes', 'tidyverse', 'purrr'))
remotes::install_github('facultyai/dash-bootstrap-components@r-release')
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

0 comments on commit 89217e0

Please sign in to comment.