R - shiny app - ERROR: Invalid git repo specification: 'ShinySky' - r

I try to run a shiny app on R studio, I get the error
"ERROR: Invalid git repo specification: 'ShinySky'"
with the message at the console:
"there is no package called ‘shinysky’
Warning: Error in parse_repo_spec: Invalid git repo specification: 'ShinySky'"
Any ideas how to resolve the issue?
install.packages("shiny")
library(shiny)
ui <- fluidPage(
sliderInput(inputId ="num", label = "Choose the sample size", value=5,
min=1, max=25 ),
plotOutput("hist")
)
server <- function(input, output, session) {
output$hist <- renderPlot({
hist(rnorm(input$num))
})
}
shinyApp (ui, server)

Related

Shiny App Issue, ShinyDirButton is unresponsive

This code should produce a pop up that allows Directory Selection for a Shiny App.
However, when I run the code the button appears but is unresponsive in both the R-studio viewer and when run in a web-browser.
Does the code work for you? Is there anything that I am not doing right?
library(shiny)
library(shinyFiles)
ui <- fluidPage(
shinyDirButton('folder', 'Select a folder', 'Please select a folder', FALSE)
)
server <- function(input, output){
volumes = getVolumes() # this makes the directory at the base of your computer.
observe({
shinyDirChoose(input, 'folder', roots=volumes, filetypes=c('', 'txt'))
print(input$folder)
})
}
shinyApp(ui=ui, server=server)
Thank you in advance
I found a different function that works, choose.dir().
library(shiny)
library(shinyFiles)
ui <- fluidPage(
actionButton("dir", 'select a folder'),
textOutput("wd") #display working directory
)
server <- function(input, output) {
observeEvent(input$dir, {
setwd(choose.dir("c:/")) #selecting a directory
output$wd <- renderText(getwd())})
}
shinyApp(ui = ui, server = server)

How to use the results of a reactive expression in an output

I'm trying to build a Shiny App that monitors my running containers on a host machine, and here is what I have tried so far. Question is how can I display the outputs, in this case (docker ps -a) contents in the mainPanel? I'm new to Rshiny, so any help will be much appreciated!
library(shiny)
library(ssh)
ui <- fluidPage(
titlePanel("Dashboard"),
sidebarLayout(
sidebarPanel(
actionButton("bttn", "Click")
),
mainPanel(
h1("Running containers"),
textOutput("dispContainers")
)
)
)
# Define server logic
server <- function(input, output, session) {
session <- ssh_connect("jeroen#dev.opencpu.or")
observeEvent(input$bttn, {
ssh_exec_wait(session, command = 'docker ps -a')
})
}
# Run the application
shinyApp(ui, server)
You can use the other ssh_exec_internal instead to collect the output of your docker command. Something like:
server <- function(input, output, session) {
session <- ssh_connect("jeroen#dev.opencpu.or")
text_output <- reactiveVal("")
observeEvent(input$bttn, {
response <- ssh_exec_internal(session, command = 'docker ps -a')
text_output(rawToChar(response$stdout))
})
output$dispContainers <- renderText(text_output())
}
You might also want to switch textOutput to verbatimTextOutput to get the text as you'd see it in a terminal.

R Shiny GoogleSheets4: Authentication error in Shinyio server on deployment?

Here is my code for a simple test app:
library(shiny)
library(shinydashboard)
library(googlesheets4)
library(googledrive)
library(DT)
drive_auth(email = "xxxx")
shinyws1<-gs4_create("WS1")
#table<-read_sheet("xxx")
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("Test App"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
numericInput("bins",
"Number of friends:",
min = 1,
max = 100,
value = 50),
actionButton("submit","Submit",class="btn-success")
),
# Show a plot of the generated distribution
mainPanel(
#blank so far
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
#results<-reactive(input$bins)
observeEvent(input$submit,{
shinyws1 %>% sheet_append(as.data.frame(input$bins))
})
}
# Run the application
shinyApp(ui = ui, server = server)
It works okay in my local server. But deployment fails.
Here is the error message generated after deployment in Shinyio server:
Error in value[[3L]](cond) : Can't get Google credentials.
Are you running googledrive in a non-interactive session? Consider:
* `drive_deauth()` to prevent the attempt to get credentials.
* Call `drive_auth()` directly with all necessary specifics.
* Read more in: https://gargle.r-lib.org/articles/non-interactive-auth.html
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
Does anyone know how to fix it? I've tried every workaround I found online, but it didn't work.

Shinyapps.io deploy fails on package install

I'm posting this because I have not managed to get the solutions posted other places working. I'm trying to re-deploy a shiny dash, but it is failing to install a package at deploy.
It's the BioConductor error, but the package it claims to fail for is a CRAN package, and so I have no idea what to do.
MRE:
library(ggseg); library(shiny); library(tidyverse); library(plotly)
# Define UI ----
ui <- fluidPage(
# Application title
titlePanel("Demonstration of ggseg package"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
radioButtons(inputId = "atlasChoice", label="Choose atlas",
choiceValues = c("dkt_3d","yeo7_3d",),
choiceNames = c("DKT", "Yeo7"),
inline = FALSE, width = NULL),
radioButtons(inputId = "positionChoice", label="Choose position",
choices = c("LCBC left","LCBC right"),
inline = FALSE, width = NULL)
),
# Show a plot of the generated distribution
mainPanel(
uiOutput("plotUI")
)
)
)
# Define server ----
server <- function(input, output) {
output$plotUI <- renderUI({
plotlyOutput("plotlyPlot")
})
output$plotlyPlot <- renderPlotly({
cc = strsplit(input$positionChoice, " ")[[1]]
ggseg3d(atlas=input$atlasChoice,
surface=cc[1],
hemisphere=cc[2]
)
})
}
# Run the application
shinyApp(ui = ui, server = server)
My repos are set as so:
getOption("repos")
BioCsoft
"https://bioconductor.org/packages/3.7/bioc"
BioCann
"https://bioconductor.org/packages/3.7/data/annotation"
BioCexp
"https://bioconductor.org/packages/3.7/data/experiment"
BioCworkflows
"https://bioconductor.org/packages/3.7/workflows"
CRAN
"https://cran.rstudio.com"
And the error is as following:
Preparing to deploy document...DONE
Uploading bundle for document: 619289...DONE
Deploying bundle: 1770029 for document: 619289 ...
Waiting for task: 573690766
building: Parsing manifest
################################ Begin Task Log ################################
################################# End Task Log #################################
Error: Unhandled Exception: Child Task 573690767 failed:
Error parsing manifest: Unable to determine package source for Bioconductor package oompaBase: Repository must be specified
Execution halted
I don't know if Athanasia's solved this in the end, but I had a similar problem today, so here's what worked for me, in case it's useful for someone else :)
My app uses biomaRt, which I think depends on Biobase. When I tried to deploy, I had the error:
Error: Unhandled Exception: Child Task 601909864 failed: Error parsing manifest: Unable to
determine package source for Bioconductor package Biobase: Repository must be specified
I changed my repos settings based on instructions I found here. This alone also didn't work for me.
Once I reinstalled Biomart using BiocInstaller::biocLite(), my app deployed successfully :)

How to remove tags in textOutput - RShiny

I am new to R and I am actually developing a page where a directory (string characters like "xx/xx") is given in the server and I want to take back this directory to include it in the source of my ui app.
UI:
library(shiny)
file<-textOutput("paramfile")
source(file(file), local = TRUE, encoding = 'UTF-8')
SERVER :
filedir<-renderText({
"entries/5429_param.R"
})
output$paramfile<-renderText({
filedir()
})
I then have an error :
"Warning in file(filename, "r", encoding = encoding) : cannot open
file '< div id="paramfile" class="shiny-text-output">< /div>':
Invalid argument
Error in file(filename, "r", encoding = encoding) :
cannot open the connection"
Do you know how can I remove those tags or if there is another function that can allow me to take a string in the server and to include it into a source.
Here is a basic example of a ShinyApp:
# Example of UI with fluidPage
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
textInput("dir", label = "Enter a directory")
),
mainPanel(
verbatimTextOutput("dirPrint"),
verbatimTextOutput("lsFiles")
)
)
)
# Server logic
server <- function(input, output) {
output$dirPrint <- renderPrint({
print(input$dir)
})
output$lsFiles <- renderPrint({
fls <- list.files(input$dir)
print(fls)
})
}
# Complete app with UI and server components
shinyApp(ui, server)
If you enter the path of a directory in the textinput, the second renderPrint function is showing all files, that are found at that path.
I would suggest you go over the Shiny-Tutorials, as there seem to be some syntax-problems in your code and I am not sure what exactly you want to achieve.

Resources