logo
down
shadow

subset data and plot this subsetted data with Shiny


subset data and plot this subsetted data with Shiny

By : ChuTing
Date : November 18 2020, 11:13 AM
may help you . If I have the following data frame: , You have superfluous comma's in your ui.R:
code :
shinyUI(pageWithSidebar(
  headerPanel("Project Data"),
  sidebarPanel(
    selectInput("proj", "Project:",ulist) # remove comma here
  ),
  mainPanel(
    plotOutput("testPlot") # remove comma here
  )
) )


Share : facebook icon twitter icon
How subset a data frame by a factor and repeat a plot for each subset?

How subset a data frame by a factor and repeat a plot for each subset?


By : Raghav_Core_Develope
Date : March 29 2020, 07:55 AM
Hope this helps Because you want to split up the dataset and make a plot for each level of a factor, I would approach this with one of the split-apply-return tools from the plyr package.
Here is a toy example using the mtcars dataset. I first create the plot and name it p, then use dlply to split the dataset by a factor and return a plot for each level. I'm taking advantage of %+% from ggplot2 to replace the data.frame in a plot.
code :
p = ggplot(data = mtcars, aes(x = wt, y = mpg)) + 
    geom_line()

require(plyr)
dlply(mtcars, .(cyl), function(x) p %+% x)
plots = dlply(mtcars, .(cyl), function(x) p %+% x)
plots[1]
dlply(mtcars, .(cyl), function(x) p %+% x + facet_wrap(~cyl))
pdf()
plots
dev.off()
library(dplyr)
plots = mtcars %>%
    group_by(cyl) %>%
    do(plots = p %+% . + facet_wrap(~cyl))


Source: local data frame [3 x 2]
Groups: <by row>

  cyl           plots
1   4 <S3:gg, ggplot>
2   6 <S3:gg, ggplot>
3   8 <S3:gg, ggplot>
plots$plots
pdf()
plots$plots
dev.off()
Create input$selection to subset data AND radiobuttons to choose plot type in Shiny

Create input$selection to subset data AND radiobuttons to choose plot type in Shiny


By : user2956140
Date : November 22 2020, 10:54 AM
this will help I've been trying to utilize shiny to create several visualizations for several different classes of data. Last night I was able to subset data but I do not know how to switch plot types with this data. I have the following data frame: , You need to use reactive functions.
ui.R:
code :
library(shiny)
ulist=levels(cd$Project)
names(ulist) = ulist
shinyUI(pageWithSidebar(
  headerPanel("Project Data"),
  sidebarPanel(
    radioButtons("pType", "Choose plot type:",
                 list("A", "B", "C")),
    selectInput("proj", "Project:",ulist)
  ),
  mainPanel(
    plotOutput("testPlot")
  )
)
)
library(shiny)
library(ggplot2)
library(lattice)

# Define shiny server
shinyServer(function(input, output) {
  pdata <- reactive({
    subset(cd, Project==input$proj)
  }
  )
  plotType <- reactive({
    switch(input$pType,
           A = hist,
           B = barplot,
           C = pie)
  })
  output$testPlot <- renderPlot({ 
    plotType()(pdata()[["Hours"]])
  })
})
Select row(s) from a summary data table and use cell value to subset original data and create a new data table in Shiny

Select row(s) from a summary data table and use cell value to subset original data and create a new data table in Shiny


By : ÅbÐül RëhmÅn Ålï
Date : March 29 2020, 07:55 AM
around this issue I have created a summary table from iris data set and when i select any row from that datatable I want to use the row selected to subset main data and later publish that subset data as a datatable. , Your error message most probably comes from this line
code :
selected_column <-  df1[as.integer(input$summarytable_rows_selected),]$get(input$group)
selected_column <-  df1()[as.integer(input$summarytable_rows_selected),][[input$group]]
df[df$get(input$group) %in% selected_column, ]
df[df[[input$group]] %in% selected_column, ]
Shiny/ggvis Reactivity to Subset Plot Data

Shiny/ggvis Reactivity to Subset Plot Data


By : user4827738
Date : March 29 2020, 07:55 AM
I hope this helps . Further search would indicate that this is a known bug for ggvis: https://github.com/rstudio/ggvis/issues/71
R subset function: why does it include non subsetted data?

R subset function: why does it include non subsetted data?


By : asasher
Date : March 29 2020, 07:55 AM
wish of those help Because us12 is a data.frame in which nationality and response columns are factors, including all the levels of the original data.frame.
In fact, table(us12) returns you the counts, and as you can see, all the counts for nationalities different from United States are zero.
Related Posts Related Posts :
  • Error Handling with Lapply
  • data.table - split multiple columns
  • How to compute the overall mean for several files in R?
  • R: Graph Plotting: Subscripts in the legend like LaTeX
  • Restructuring data in R
  • Distance of pointsfrom cluster centers after K means clustering
  • R incorrect value of date function
  • Package "Imports" not loading in R development package
  • r - run a user defined function several times by taking column elements as parameters
  • Create input$selection to subset data AND radiobuttons to choose plot type in Shiny
  • Generate crosstabulations from dataframe of categorical variables in survey
  • Restructure output of R summary function
  • New behavior in data.table? .N / something with `by` (calculate proportion)
  • search certain number vector in R
  • R version doesn't support quartz graphic device - RStudio won't plot
  • Referencing a function parameter in R
  • How to synchronize signals using a cross-correlation and FFT in R?
  • Plotting coefficients and corresponding confidence intervals
  • passing expressions to curve() within a function
  • More effective merging of matched column with duplicates in data.table
  • Easy way to export multiple data.frame to multiple Excel worksheets
  • R Foreach Iterator - Walkforward
  • Table format and output in R
  • Restructuring data and duplicating rows in R
  • use ggplot2 to plot two lines with ribbons
  • how to plot a graph on lattice with two different colors
  • How can I keep a date formatted in R using sqldf?
  • Generating simulation data based on a specified distribution
  • Joining list of data frames in R
  • Subset data in R
  • R: How to avoid 2 'for' loops in R in this function
  • + signs appearing in console in R
  • how to create a dataframe form a lists within a list in R
  • Best way to combine and keep columns
  • Using identify and attach in a function
  • Apply function to each submatrix
  • How to assign regular strings for quarterly and monthly observation labels to the row names of a data frame?
  • Adjust hexbin legend breaks
  • Different lowess curves in plot and qplot in R
  • Extract words only with R
  • switch case: several equivalent cases expressions in r
  • R data.table to calculate a formula using a column as a variable across levels of a factor
  • how to create a line plot frame in ggplot2
  • Subset by row number within magrittr chain
  • GGPLOT - two curves in one plot in B_W mode
  • How can i build a for function for matrix?
  • How to Word-like-merge columns or rows of a data frame for displaying purposes in R?
  • How to keep all rows of a table on the same page in RMarkdown when rendering a PDF file?
  • Add transparency to GoogleMap plot (loa package)
  • replace a column in a dataframe given a corresponding vector in r
  • How can i count the numbers in every subset?
  • Request URL failed/timeout in R
  • IF then do end equivalent in r... EDIT: in dplyr
  • how to check if each cells (list) of a column of a dataframe are unique in R?
  • Column widths not aligned with table data in pander tables sent from R with sendmailr
  • Getting the value of a Variable which has its name based upon another variable (in R)
  • Web Page Click Through Heat Map using R
  • Add a label to map at each leg start
  • R Caret Random Forest view miss-classified
  • For each line of a Data.Frame, get the column name where a value is TRUE
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org