r

R Shiny: Updating an output before another (relatively long) computation is finished

孤街醉人 提交于 2021-02-11 07:10:27
问题 I have the following problem. My shiny app is basically doing the following on the server side after a button is clicked: observe({ isolate({ ## Here are a lots of computations with the results shown iteratively using invalidateLater(): }) if( computations not done ){ invalidateLater(500) } else { #Once the computations are done, I create a final output table and also a image. output$example <- renderTable( something based on the computations ) output$example2 <- renderPlot( something based

R Shiny: Updating an output before another (relatively long) computation is finished

◇◆丶佛笑我妖孽 提交于 2021-02-11 07:09:07
问题 I have the following problem. My shiny app is basically doing the following on the server side after a button is clicked: observe({ isolate({ ## Here are a lots of computations with the results shown iteratively using invalidateLater(): }) if( computations not done ){ invalidateLater(500) } else { #Once the computations are done, I create a final output table and also a image. output$example <- renderTable( something based on the computations ) output$example2 <- renderPlot( something based

Shiny Dashboard: Reset the conditional panel state when we navigate across different tabitems

柔情痞子 提交于 2021-02-11 07:08:01
问题 I have the following code in which there are various conditional panels in the dashboard. If we navigate from one conditional panel to next in dashboard and then go to widget and finally come back to dashboard, the dashboard is in the previous state. I want the dashboard to be refreshed(reset to original condition) when I come back from another tab panel. Is is possible to do that? library(shiny) library(shinydashboard) library(maps) library(leaflet) ui <- dashboardPage( dashboardHeader(title

R Shiny: Updating an output before another (relatively long) computation is finished

不羁的心 提交于 2021-02-11 07:07:52
问题 I have the following problem. My shiny app is basically doing the following on the server side after a button is clicked: observe({ isolate({ ## Here are a lots of computations with the results shown iteratively using invalidateLater(): }) if( computations not done ){ invalidateLater(500) } else { #Once the computations are done, I create a final output table and also a image. output$example <- renderTable( something based on the computations ) output$example2 <- renderPlot( something based

R equivalent of Stata's for-loop over macros

二次信任 提交于 2021-02-11 07:02:00
问题 I have a variable x that is between 0 and 1, or (0,1]. I want to generate 10 dummy variables for 10 deciles of variable x . For example x_0_10 takes value 1 if x is between 0 and 0.1, x_10_20 takes value 1 if x is between 0.1 and 0.2, ... The Stata code to do above is something like this: forval p=0(10)90 { local Next=`p'+10 gen x_`p'_`Next'=0 replace x_`p'_`Next'=1 if x<=`Next'/100 & x>`p'/100 } Now, I am new at R and I wonder how I can do above in R? 回答1: cut is your friend here; its output

replacing values of a dataframe column using values of a list and list name in R

*爱你&永不变心* 提交于 2021-02-11 07:00:09
问题 I would like to replace Values inside of a column with a list name conditional upon the values being inside the list values: df <- data.frame(Activity = c("Checking emails", "Playing games", "Reading", "Watching TV", "Watching YouTube", "Watching TV", "Relaxing", "Getting ready", "Working/ studying", "Relaxing")) mylist <-list(Tech_activity = c("Browsing social media", "Checking emails", "Video calling", "On my computer/ PC", "Watching YouTube", "Browsing the internet", "On my phone",

replacing values of a dataframe column using values of a list and list name in R

我是研究僧i 提交于 2021-02-11 06:59:50
问题 I would like to replace Values inside of a column with a list name conditional upon the values being inside the list values: df <- data.frame(Activity = c("Checking emails", "Playing games", "Reading", "Watching TV", "Watching YouTube", "Watching TV", "Relaxing", "Getting ready", "Working/ studying", "Relaxing")) mylist <-list(Tech_activity = c("Browsing social media", "Checking emails", "Video calling", "On my computer/ PC", "Watching YouTube", "Browsing the internet", "On my phone",

How to predict values using estimates from rjags / JAGS

妖精的绣舞 提交于 2021-02-11 06:58:50
问题 After setting up the model and training it with Gibbs Sampling, I got the result of all the prediction of hidden values with: jags <- jags.model('example.bug', data = data, n.chains = 4, n.adapt = 100) update(jags, 1000) samples <- jags.samples(jags, c('r','alpha','alpha_i','alpha_u','u','i'), 1000) Where r is a list of rating, and some of them are withheld for a prediction with the model. And suppose I can get them with r[test] , where test is a list of integer indicating the index of the

How to predict values using estimates from rjags / JAGS

我是研究僧i 提交于 2021-02-11 06:57:38
问题 After setting up the model and training it with Gibbs Sampling, I got the result of all the prediction of hidden values with: jags <- jags.model('example.bug', data = data, n.chains = 4, n.adapt = 100) update(jags, 1000) samples <- jags.samples(jags, c('r','alpha','alpha_i','alpha_u','u','i'), 1000) Where r is a list of rating, and some of them are withheld for a prediction with the model. And suppose I can get them with r[test] , where test is a list of integer indicating the index of the

Changing lower limit of graph y-axis when x is a discrete variable without cutting off bottom of bars

本秂侑毒 提交于 2021-02-11 06:52:08
问题 I am trying to adjust the y-axis of this graph so that it starts at 1 instead of 0. What's the best way to do this? The solution offered here cuts off the bottom of the graph. I would like for the bars to look pretty much identical to the graph below, but with the lower y-limit at 1 and each bar moved down 1 unit to match. I would like to preserve the small amount of gray space below each bar. Code: groups %>% ungroup() %>% mutate(message = fct_relevel(message, "Personal", "General"),