hadley / mastering-shiny Goto Github PK
View Code? Open in Web Editor NEWMastering Shiny: a book
Home Page: https://mastering-shiny.org/
License: Other
Mastering Shiny: a book
Home Page: https://mastering-shiny.org/
License: Other
Dear authors:
I find the first figure in the https://mastering-shiny.org/basic-reactivity.html#controlling-timing-of-evaluation is wrong
It is not consistent with the reactive graph
Please check it.
Best,
Shixiang
Hi,
I'm trying to work through the Chapter 5 case study, but I can't seem to access the neiss/injuries.tsv.gv referenced.
Specifically, running
injuries <- vroom::vroom("neiss/injuries.tsv.gz")
in the console returns evaluation errors about the file not existing. Did I miss a step about how the data is supposed to be downloaded/set-up for this case study?
Apologies if I'm missing something obvious.
Thanks for this great book!
I spotted the following minor typo in section 7.2:
"Expressions and outputs should update whenever one of there input values changes. This ensures that input and output stay in sync."
mastering-shiny/reactivity-motivation.Rmd
Line 21 in 0b236cf
Cheers,
-Lucas
Hey @jimhester & @hadley.
I think I know why it doesn't deploy to Netlify in the recent commits.
I was trying to get this set up for our bookdown site the other day https://github.com/EmilHvitfeldt/tidy-nlp-in-R-book and I found that I needed to also run netlify link ...
Could that be what you needed?
I also wrote a post detailing the process with a sample repository https://github.com/EmilHvitfeldt/bookdown-github-actions-netlify
demo$screenshot("max-increase") is showing the max at 3, not 4. I haven't dug through how things work enough to find where that figure actually "lives" to make sure it hasn't already been updated, though.
i thought this text was wrong but it is not:
Because both of the rendering code blocks I wrote used input$dataset,
Similar to the first case study (Getting Started section), I would see a slot for a case study in the advanced-ui part. There are a lot of features mentioned in Chapter 12 that would require a practical example to fit with business needs, that is creating a new template From scratch for instance. I can help in the process.
In this app if you add some text to the textInput, you can't then select another button without first deleting the text. Is this intentional? Fixing this would add a few more lines of code so I wasn't sure if you were trying to keep the example short.
mastering-shiny/action-modules.Rmd
Line 481 in dc2bf86
shinyProgress <- function(expr) {
progress <- NULL
on.exit(if (!is.null(progress)) progress$close())
tryCatch(expr,
progress_message = function(cnd) {
switch(cnd$msgtype,
add_job = {
progress <<- Progress$new()
},
complete_job = {
progress$close()
progress <<- NULL
},
set_job_status = progress$set(message = cnd$status),
set_job_output = progress$set(details = cnd$output),
set_job_progress = progress$set(value = cnd$progress),
add_job_progress = progress$inc(amount = cnd$increment)
)
}
)
}
long_process <- functon() {
pb <- progress_bar$new(total = 100)
for (i in 1:100) {
pb$tick()
Sys.sleep(1 / 100)
}
100
}
And with vroom since it already uses progress.
Hi Hadley,
First, thanks for this awesome book, I learned a gazillion things!
In chapters 7 and 10, you use the consoleReactive(TRUE)
statement, but I could not find this function anywhere, even in shiny github repo or in google search.
From where am I supposed to import it?
I get an error when clicking on the download links for https://mastering-shiny.org/shiny-book.epub and https://mastering-shiny.org/shiny-book.pdf.
What's the best way to turn the result of a sequence of UI calls into a screenshot?
i.e. in the url field, put https://jcheng5.github.io/shiny-book/
Select a geom; conditional panel includes extra controls.
I've been writing Shiny apps in recent 2 years and learned a lot from scattered places. It will be great to have one book to include all the key ideas.
In my learning experience, I think some good examples can really help readers to understand the concept and apply to their own problems. I also would like to share some of tricks I think are very useful.
My first suggestion of example is based on my two answers in Stackoverflow -
Add weblink to actionButton, basically I used actionButton css class for a link, so a link will look like a button. Further more we can make a material button for a link. The key take away in this example is to print the tag function output, explore and set attributes properly.
In customizing css part, it's also worth mentioning the development tools within rstudio or chrome which can work on shiny app directly(you probably have this in mind already).
In reactivity part:
options(shiny.trace = TRUE)
is often very helpful(I found the reactive log is often overwhelming and less useful).freezeReactiveValue
can be helpful (I found different priority settings never worked for me), but often there is a better design by choosing different reactive variables.I also have to go through lots of trial and errors in using DT row selection to trigger app behavior, because the row selection event was the slowest in shiny app, which often create problem of updates order in reactive context. I can help to provide some example on this but not sure if there is a need for this kind of usage.
What's the easiest way to execute code in a throw away reactive environment? i.e. how could you run this code in order to product an error:
# Don't do this!
dataset <- get(input$dataset, "package:datasets", inherits = FALSE)
output$summary <- renderPrint({
summary(dataset)
})
output$table <- renderTable({
dataset
})
https://rstudio.github.io/sortable/ β particularly for picking variables
And use it in dynamic-ui.Rmd
to deploy fleshed out nested select example
I hope you don't mind having user feedback at this early stage π
I think there should be a section devoted to how a developer can take advantage of tidy evaluation. Ever since your keynote at R/Pharma 2018 with the demo of the possibilities, it was a real π opener and I could see that being relevant to not just pharma use cases.
In action-feedback.Rmd about line 96, delete the hashtag from Section \@ref(#upload)
.
Then in action-transfer.Rmd, add the id {#upload}
to (I assume) ## Upload
.
Appears to be related to change to Github Actions 1bcd54b.
We are having similar problems after converting EmilHvitfeldt/smltar#33
I can't seem to get this solution to work, I have found the 2 of the 3 supposed bugs, but I was wondering if maybe there is another error in the code before it is published, I have been working on it for atleast a week, here is my github if you can help with a solution. Thank you https://github.com/Danieldavid521/Mastering_Shiny_solutions/blob/master/Mastering_Shiny_Chapter_2-5_solutions.R
It's shiny when it's the package, but Shiny when it's a "Shiny app".
This issue is to remember to do a search for " shiny"
and where appropriate replace it with " Shiny"
periodically / before writing is done.
Is this 1st sentence partially a reference to what you've already outlined here (seems like it)?
Either way, it might be useful to draw a connection here.
In order to get better feel for size of book.
The original code doesn't 'do' anything meaningful.
Consider expanding the code a little, like this (added server and shinyApp at bottom of function) to make the function 'theme_demo' work across the example themes:
theme_demo <- function(theme) {
ui <- fluidPage(
theme = shinythemes::shinytheme(theme),
sidebarLayout(
sidebarPanel(
textInput("txt", "Text input:", "text here"),
sliderInput("slider", "Slider input:", 1, 100, 30)
),
mainPanel(
h1("Header 1"),
h2("Header 2"),
p("Some text")
)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
}
theme_demo("darkly")
theme_demo("flatly")
theme_demo("sandstone")
theme_demo("united")
Or turn it into an exercise...
Without using dynamic UI β e.g. imagine you have a bunch of sliders who's min, max, and starting value change every 3 months, and are recorded in a csv file (i.e. they're supplied by the business stakeholders and you want to make them as easy to update as possible). Show how to use a little functional programming to create en masse.
Hi,
A small suggestion of a package that I often use to provide user feedback in a shiny app.
https://github.com/andrewsali/shinycssloaders
It provides a very simple function to add a spinner to a plot or table
withSpinner(plotOutput("my_plot"))
This compliments the wonderful Waiter/Waitress package that is already mentioned as it is added via the ui rather than the server function.
The use of spinners has provided the best UX improvement in Shiny apps that I have built.
Cheers,
Iain
The text uses "ID", but argument names seem to have Id
. I'd suggest "Id" for consistency.
Prompted by this discussion on Twitter, here's an issue to remind you to include info on running shiny app as a background job. This video has a demonstration of how to do this at 34:02.
In these sort of scenarios I find it helpful to work backwards: first show the completed app (maybe link to a gif or video demoing the interactive behavior). Then you could even make some exercises for the reader before walking through the details, could ask:
(1) What are the reactive values in this app? Asking this question first and partially addressing it right away can help explain why your script has these "configuration variables"
(2) What are the outputs?
(3) Can you predict how reactive expressions might be useful for this app?
Then you could introduce the data and walk through the steps
Since tidyverse is imported, should packages like readr, dplyr, etc. also be there?
It would be nice if you can explain where the consoleReactive()
function comes. In the book, I see that the function is mentioned in reactivity-related sections, but it's usually placed after library(shiny)
statement. I find this confusing because that function is not one of the exported functions in Shiny. And there's no reference to the common.R
file where is the place of this function.
https://github.com/hadley/mastering-shiny/search?q=consoleReactive&unscoped_q=consoleReactive
Or do you have plans to move that function to the Shiny soon?
Re: action-modules.Rmd
, line 15: It would be valuable to explain in more detail why global.R
is not the preferred place to put globally-accessible code.
As of October 2019, several pages extolling the virtues of global.R
appear high on a Google search for shiny global.R
. This would be a good place to present arguments against global.R
.
That seems like a more natural progression
Line 194 in eed0f64
Should be:
fileInput()
requires special handling on the server side,...
(The word requires is missing).
There is a diagram here with just reactive values and observers.
I think it would be nice to have another diagram, maybe below this paragraph, with all three (reactive values, expressions, and observers)
Though outputs allow (and may even require) side effects, this doesnβt mean you should include just any side effects in your output code.
In the previous paragraph, you mention that renderPrint()
expects calls to print()
, and renderPlot()
(may) expect you to draw a plot, but you don't explicitly mention these are side-effects. I think it would be good to be a little more explicit about that (i.e., don't leave your readers wondering: what is a side-effect? when and why do outputs require them?)
It might also be worthwhile demonstrating or explaining why you should avoid side-effects in your output code (and maybe even in general), even if you just point to another section or appendix
Give the reader some sense of how IT folks view the world, and what they are going to worry about when they deploy an app.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.