rPivotTable in Shiny showing black areas outside of pivot when scrolled - shiny

I an using rpivotTable in a Shiny app
in UI it is inside a tabSetPanel:
tabPanel("Pivot Table",
shinycssloaders::withSpinner(
rpivotTableOutput("pivot_table")
)
)
in Server it is updated once the dataframe is loaded and filtered:
output$pivot_table <- renderRpivotTable({
rpivotTable(data = filtered_df(), rows=c("HIGH_LEVEL_GROUP_TERM", "HIGH_LEVEL_TERM", "AE_AS_PREFERRED_TERM"),
vals = "SAPPHIRE_CASE_ID_VERSION", aggregatorName = "Count Unique Values", rendererName = "Heatmap", width="100%")
})
When I scroll down the page, anything not observable immediately seems to have black on the outside of the pivot table?
I am using "shinydashboard"....

Related

R Flexdashboard, how to get map to show in dashboard?

library(flexdashboard)
library(tidycensus)
library(tidyverse)
library(mapview)
library(dplyr)
library(tigris)
library(leafsync)
library(leafpop)
library(readxl)
library(DT)
library(highcharter)
{r}
#Importing Data ****Update file path before running****
states=data.frame(read_excel('C:/Users/pmckercher/Documents/CISA Research/CISA Funding Data.xlsx',
sheet = 'Funding By State',col_names = TRUE ))
us_geo=tigris::states(cb=FALSE, resolution = '20m') #State Sahpe File Download
all_data=inner_join(us_geo,states, by=c("NAME"="State")) #Joinging the two datasets
# These are shells, replace zcol= '' with a percentage of use column (will have to
#update the python file to calculate this when we get the real data) to make the display
#show how much of each states allocation has been provided.
Map22=mapview(all_data,zcol=c('fund_22'),col.regions = RColorBrewer::brewer.pal(11, "RdYlGn"), alpha.regions = 1, popup= popupTable(all_data,zcol=c('NAME', 'fund_22','fund_23','fund_24','fund_25')), label=c('NAME'))
Map22
This produces this visualization in the viewer:
Mapview Interactive Map
But, when the Dashaboard window pops up. it produces this where the map should be:
Buffering bars
How do I get the Interactive map to show up in the Dashboard window?

How can I modify this shiny app example to conditionally display a color of bus on a map (depending on output of a model)?

I'm trying to understand Shiny apps in particular this example of the bus dashboard located at
https://github.com/rstudio/shiny-examples/tree/master/086-bus-dashboard
I'd like to modify the update rule so colors are displayed depending on whether or not locations$Bearing >= 200.
I tried modifying the locations dataframe which has Bearing but can't figure out how to chnage the color on map when the leaflet map is updated. It looks like it may have something to do with color = ~dirPal(Direction)
addTiles('http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png') %>%
addCircleMarkers(
~VehicleLongitude,
~VehicleLatitude,
color = ~dirPal(Direction),
opacity = 0.8,
radius = 16
)```
where dirColors is defined at beginning of script
dirColors <-c("1"="#595490", "2"="#527525", "3"="#A93F35", "4"="#BA48AA", "5" = "#BA48AA")
I'd like to basically add a color here but conditionally displayed only for buses where Bearing >= 200 in location dataframe.
routeVehicleLocations <- reactive({
if (is.null(input$routeNum))
return()
locations <- vehicleLocations()
anomalies <- locations[locations$Bearing > 200,]
if (as.numeric(input$routeNum) == 0)
return(locations)
locations[locations$Route == input$routeNum, ]
})
The rest of the app is fine but would like to overwrite the color if condition above is met (Bearing >=200). Eventually would like to replace this rule with my own model and own data sources.

Avoiding overlapping plotly subplots in Shiny

I've been struggling to find the best way to avoid overlapping subplots. I tried autosize, where height is dependent on the number of rows but then the plotly graph overlaps with the proceeding widget (in this case a datatable) below it. The number of subplots changes based on user input.
Here's an image of what I get:
plotly:: subplot(subplots, nrows = rows,titleY = TRUE) %>%
layout(margin = list(b=200)) #,autosize=F, height=(300*rows))
Does anyone know how to render a plotly subplot that avoids these overlap issues?
The best answer I've found is to create a reactive where the plotly figure is constructed. The dynamically changing height should be based on user inputs. In my case, it was the number of processes and impact categories the user selectes to display in the figure so I came up with a relationship like height = 100*n_pro*n_imp. This height should be passed into plot_ly() (as well as the renderUI). The reactive is then called by a renderPlotly which is in turn called by a renderUI. In my case, I kept the width at 100% but that could also be updated. It would look as follows:
fig_creation = reactive({
height = (something based on user input$)
plot_ly(..., height = height)
)}
output$plotlyFig = renderPlotly({ fig_creation() })
output$figPlotly = renderUI({
height = (something based on user input$) + 100 #the 100 is a buffer
plotlyOutput("plotlyFig",width = "100%", height = paste0(height)
})
On the UI side you simply use uiOutput("figPlotly"), where you want the figure to be placed.

Changing from Navlist Panel to tabPanels in Shiny

I have a shiny Application which has a navigation List to the Left , I am having issues with the User Interface file in which i try to change the Navigation list to tabsets , But the below code does it for all the entire tabs that are present in shiny , But i want to choose a specific side tab in this case "Word Network " and want plot1 and plot 2 coded below should be shown only in this navigation and not other .
navlistPanel(
tabPanel("Introduction",
fluidRow(h3("Introduction",align="center"),tags$img(src="TextAnalytics.jpg",height=300,width=600),align="center"),
value=11,verbatimTextOutput("introduction")),
#tags$img(src="TextAnalytics.jpg",height=800,width=800),
tabPanel("Upload the File",fileInput("data1",label=("Upload the Unstructured Textual data To be analysed"))),
tabPanel("structure",value=1,verbatimTextOutput("str")),
tabPanel("data",value=2,tableOutput("data")),
tabPanel("Summary",value=3,verbatimTextOutput("summary")),
tabPanel("Word Cloud",value=4,plotOutput("plot",width=1000,height=600)),
tabPanel("Sentiment Analysis",value=5,plotOutput("plot2",width=1000,height=600)),
tabPanel("Topic Modelling",value=6,plotOutput("plot3",width=1000,height=600)),
#tabPanel("Word Frequency",value=7,plotOutput("plot4",width=1000,height=800)),
tabsetPanel(
tabPanel("plot1",value = 11),
tabPanel("plot2",value = 11)
),
tabPanel("Hierarchial Clustering",value=8,plotOutput("graph1",width=1500,height=h)),
tabPanel("Correlation Analysis",value=9,plotOutput("corelation",width=1000,height=1000)),
tabPanel("Word Network",value=10,plotOutput("graph2",width=1000,height=600)),
tabPanel("Community Detection",value=12,plotOutput("democommunity",width=1000,height=600)),
id="tabselected"
)
)

How to use OnClick action buttons in R ShinyDashBoard

I am doing sentiment analysis of twitter data using R and shiny dashboard.
I have plotted the persentages valueboxes of positive, negative and neutral tweets.
valueBoxOutput("positivePercent",width = 3)
output$positivePercent <- renderValueBox({
positivePercent <- round((nrow(positive)*100)/total)
valueBox(
value = paste(positivePercent, "%"),
subtitle = "Positive",
color = "green",
icon = icon("thumbs-up")
)
})
And I have shown what are the positive tweets using
tabItem(tabName = "pTweets",
h2(HTML("<center><b><span style='color: green'>Positive</span> Tweets <i></i></b></center>")),
tableOutput("positivitweets")
Now here I would like when I click that percentage value box then it should show positive tweets below of that box.
I am completely new to HTML and JAVASCRIPT,started to learn.