Skip to content

Commit

Permalink
style workflow
Browse files Browse the repository at this point in the history
moviesApp >> shinyAppPkgs
  • Loading branch information
mjfrigaard committed Jul 30, 2024
1 parent 9523e50 commit a3be3d7
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 66 deletions.
6 changes: 3 additions & 3 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
^.*\.Rproj$
^\.Rproj\.user$
^moviesApp\.Rcheck$
^moviesApp.*\.tar\.gz$
^moviesApp.*\.tgz$
^shinyAppPkgs\.Rcheck$
^shinyAppPkgs.*\.tar\.gz$
^shinyAppPkgs.*\.tgz$
_\.new\.png$
^\.github$
^\data\-raw$
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
.RData
.Ruserdata
.DS_Store
moviesApp.Rcheck/
moviesApp*.tar.gz
moviesApp*.tgz
shinyAppPkgs.Rcheck/
shinyAppPkgs*.tar.gz
shinyAppPkgs*.tgz
_stash*.R
# {shinytest2}: Ignore new debug snapshots for `$expect_values()`
*_.new.png
15 changes: 7 additions & 8 deletions R/display_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ display_type <- function(run = "w") {
p = options(shiny.launch.browser = .rs.invokeShinyPaneViewer),
b = options(shiny.launch.browser = .rs.invokeShinyWindowExternal),
w = options(shiny.launch.browser = .rs.invokeShinyWindowViewer),
NULL = options(shiny.launch.browser = NULL)
)
NULL = options(shiny.launch.browser = NULL))
environment <- "RStudio"
shinyViewerType <- getOption("shiny.launch.browser") |>
attributes() |>
unlist() |>
unname()

shinyViewerType <- getOption('shiny.launch.browser') |>
attributes() |>
unlist() |>
unname()
cli::cli_alert_info("App running in {environment}")
cli::cli_alert_info("shinyViewerType set to {shinyViewerType}")
} else {
environment <- "RStudio"
cli::cli_alert_info("App not running in {environment}")
}
}
}
2 changes: 1 addition & 1 deletion R/ggp2_launch_app.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ggp2_launch_app <- function(options = list(), run = "w", ...) {
}
shinyAppDir(
appDir = system.file("dev",
package = "moviesApp"
package = "shinyAppPkgs"
),
options = options
)
Expand Down
2 changes: 1 addition & 1 deletion R/mod_scatter_display.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod_scatter_display_server <- function(id, var_inputs) {
output$scatterplot <- renderPlot({
plot <- scatter_plot(
# data --------------------
df = moviesApp::movies,
df = shinyAppPkgs::movies,
x_var = inputs()$x,
y_var = inputs()$y,
col_var = inputs()$z,
Expand Down
30 changes: 10 additions & 20 deletions R/mod_var_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,37 @@ mod_var_input_ui <- function(id) {
selectInput(
inputId = ns("y"),
label = "Y-axis:",
choices = c(
"IMDB rating" = "imdb_rating",
choices = c("IMDB rating" = "imdb_rating",
"IMDB number of votes" = "imdb_num_votes",
"Critics Score" = "critics_score",
"Audience Score" = "audience_score",
"Runtime" = "runtime"
), selected = "audience_score"
"Runtime" = "runtime"), selected = "audience_score"
),
selectInput(
inputId = ns("x"),
selectInput(inputId = ns("x"),
label = "X-axis:",
choices = c(
"IMDB rating" = "imdb_rating",
choices = c("IMDB rating" = "imdb_rating",
"IMDB number of votes" = "imdb_num_votes",
"Critics Score" = "critics_score",
"Audience Score" = "audience_score",
"Runtime" = "runtime"
), selected = "imdb_rating"
"Runtime" = "runtime"), selected = "imdb_rating"
),
selectInput(
inputId = ns("z"),
selectInput(inputId = ns("z"),
label = "Color by:",
choices = c(
"Title Type" = "title_type",
choices = c("Title Type" = "title_type",
"Genre" = "genre",
"MPAA Rating" = "mpaa_rating",
"Critics Rating" = "critics_rating",
"Audience Rating" = "audience_rating"
), selected = "mpaa_rating"
"Audience Rating" = "audience_rating"), selected = "mpaa_rating"
),
sliderInput(
inputId = ns("alpha"),
sliderInput(inputId = ns("alpha"),
label = "Alpha:",
min = 0, max = 1, step = 0.1, value = 0.5
),
sliderInput(
inputId = ns("size"),
label = "Size:", min = 0, max = 5, value = 2
),
textInput(
inputId = ns("plot_title"),
textInput(inputId = ns("plot_title"),
label = "Plot title",
placeholder = "Enter plot title"
)
Expand Down
2 changes: 1 addition & 1 deletion R/movies_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
movies_ui <- function(bslib = FALSE) {
addResourcePath(
prefix = "www",
directoryPath = system.file("www", package = "moviesApp")
directoryPath = system.file("www", package = "shinyAppPkgs")
)
if (isFALSE(bslib)) {
tagList(
Expand Down
2 changes: 1 addition & 1 deletion R/scatter_plot.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Create scatter plot
#'
#' Custom [`ggplot2`](https://ggplot2.tidyverse.org/) function for building scatter plots in `moviesApp()`.
#' Custom [`ggplot2`](https://ggplot2.tidyverse.org/) function for building scatter plots in `shinyAppPkgs`.
#'
#'
#' @param df `data.frame` or `tibble`
Expand Down
30 changes: 20 additions & 10 deletions R/test_logger.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,35 @@
#' @export test_logger
#'
test_logger <- function(start = NULL, end = NULL, msg) {

if (is.null(start) & is.null(end)) {

cat("\n")

logger::log_info("{msg}")
} else if (!is.null(start) & is.null(end)) {

} else if (!is.null(start) & is.null(end)) {

cat("\n")

logger::log_info("\n[ START {start} = {msg}]")
} else if (is.null(start) & !is.null(end)) {

} else if (is.null(start) & !is.null(end)) {

cat("\n")

logger::log_info("\n[ END {end} = {msg}]")
} else {

} else {

cat("\n")

logger::log_info("\n[ START {start} = {msg}]")

cat("\n")

logger::log_info("\n[ END {end} = {msg}]")
}

}

}
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">

<code>moviesApp</code>
<code>shinyAppPkgs</code>

</h1>

Expand All @@ -18,9 +18,9 @@ Code examples for <a href="https://mjfrigaard.github.io/shinyap/"> Shiny App-Pac

<hr>

# moviesApp
# shinyAppPkgs

`moviesApp` provides the code examples in for the [Shiny App-Packages](https://mjfrigaard.github.io/shiny-app-pkgs/) book and the [Developing & Testing Your Shiny Application](https://mjfrigaard.github.io/dev-test-shiny/) workshop provided at R in Pharma (2023).
`shinyAppPkgs` provides the code examples in for the [Shiny App-Packages](https://mjfrigaard.github.io/shiny-app-pkgs/) book and the [Developing & Testing Your Shiny Application](https://mjfrigaard.github.io/dev-test-shiny/) workshop provided at R in Pharma (2023).

## Movie review data application

Expand Down Expand Up @@ -58,25 +58,25 @@ launch(app = "02.3_proj-app")
Or use the terminal

``` bash
git clone https://github.com/mjfrigaard/moviesApp.git
cd moviesApp
git clone https://github.com/mjfrigaard/shinyAppPkgs.git
cd shinyAppPkgs
git checkout <branch_name>
open moviesApp.Rproj
open shinyAppPkgs.Rproj
```

------------------------------------------------------------------------

# Branches

View all the applications in the [`moviesApp` branches](https://github.com/mjfrigaard/moviesApp/branches/all).
View all the applications in the [`shinyAppPkgs` branches](https://github.com/mjfrigaard/shinyAppPkgs/branches/all).

## GitHub Actions

This chapter introduces GitHub Actions and CI/CD.

### `16.1_gha-style`

[`16.1_gha-style`](https://github.com/mjfrigaard/moviesApp/tree/16.1_gha-style) gives examples [GitHub Actions](https://docs.github.com/en/actions).
[`16.1_gha-style`](https://github.com/mjfrigaard/shinyAppPkgs/tree/16.1_gha-style) gives examples [GitHub Actions](https://docs.github.com/en/actions).

The style workflow is stored in the `.github` folder:

Expand Down Expand Up @@ -182,7 +182,7 @@ The results for `devtools::test()` should be the following (the `tests/testthat/
==> devtools::test()
ℹ Testing moviesApp
ℹ Testing shinyAppPkgs
Loading required package: shiny
✔ | F W S OK | Context
⠏ | 0 | mod_scatter_display
Expand Down
4 changes: 2 additions & 2 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ withr::with_options(new = list(shiny.autoload.r = FALSE), code = {
sink(stderr(), type = "output")
tryCatch(
expr = {
library(moviesApp)
library(shinyAppPkgs)
},
error = function(e) {
pkgload::load_all()
}
)
# create shiny object from prod/app ----
shinyAppDir(appDir =
system.file("prod/app", package = "moviesApp"))
system.file("prod/app", package = "shinyAppPkgs"))
} else {
pkgload::load_all()
}
Expand Down
2 changes: 1 addition & 1 deletion inst/dev/R/devServer.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
devServer <- function(input, output, session) {

selected_vars <- moviesApp::mod_var_input_server("vars")
selected_vars <- shinyAppPkgs::mod_var_input_server("vars")

dev_mod_scatter_server("plot", var_inputs = selected_vars)

Expand Down
2 changes: 1 addition & 1 deletion inst/dev/R/devUI.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ devUI <- function() {
addResourcePath(
prefix = "dev",
directoryPath = system.file("dev",
package = "moviesApp")
package = "shinyAppPkgs")
)
tagList(
bslib::page_fillable(
Expand Down
2 changes: 1 addition & 1 deletion inst/dev/R/dev_mod_scatter.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dev_mod_scatter_server <- function(id, var_inputs) {

observe({
output$scatterplot <- renderPlot({
plot <- moviesApp::scatter_plot(
plot <- shinyAppPkgs::scatter_plot(
df = graph_data(),
x_var = inputs()$x,
y_var = inputs()$y,
Expand Down
4 changes: 2 additions & 2 deletions inst/prod/app/app.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
withr::with_options(new = list(shiny.autoload.r = FALSE), code = {
shiny::shinyApp(
ui = moviesApp::movies_ui(bslib = TRUE),
server = moviesApp::movies_server)
ui = shinyAppPkgs::movies_ui(bslib = TRUE),
server = shinyAppPkgs::movies_server)
})
2 changes: 1 addition & 1 deletion man/scatter_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/test-specs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ knitr::opts_chunk$set(
```

```{r setup}
library(moviesApp)
library(shinyAppPkgs)
```

## Movies App Specifications
Expand Down

0 comments on commit a3be3d7

Please sign in to comment.