Hello. I can´t upload an image in my shiny app. Even though I´ve done what some have suggested in stackoverflow and in this group, my image doesn´t appear in my app. The image I want to show in my app is in the same directory where I have my App.R code.
Here is some code.
setwd("C:/Users/User/Documents/5.-Shiny")
library(shiny)
library(markdown)
library(corrplot)
ui<-fluidPage(
titlePanel(title = "Some App"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Cargar archivo',
accept = c(
'text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv',
'.tsv'
)
),
checkboxInput('header', '¿Contiene Encabezado?', TRUE),
radioButtons('sep', 'Delimitador',
c(Comma=',',
"Punto y coma"=';',
Tab='\t'),
','),
radioButtons('resume', 'Summary',
c('Individual',
'Múltiple'), selected = "Individual",
inline = TRUE),
img(src = "C:/Users/User/Documents/5.-Shiny/Logo.png", align="right")
),
mainPanel(
img(src = "C:/Users/User/Documents/5.-Shiny/Logo.png", align="right"),
tabsetPanel(
tabPanel("Datos",
dataTableOutput('contents')),
tabPanel("Exploratorio",
h3("Muestra del archivo cargado:"),
#dataTableOutput('contents'),
verbatimTextOutput("summary"),
plotOutput("histog")
#textOutput("vare")
)#,
#tabPanel("Panel3",
# dataTableOutput('contents'))
)
)
)
)
server<-function(input, output, session) {
tableData <- reactive({
inFile <- input$file1
if (!is.null(inFile)){
read.csv(inFile$datapath, header=input$header, sep=input$sep,
quote=input$quote)
}
else {
return(NULL)
}
})
observe({
updateSelectInput(
session,
"xcol",
choices=names(tableData()))
})
var_name<-reactive(input$xcol)
nuevo_df<-reactive(tableData()[sapply(tableData(),is.numeric)])
output$contents <- renderDataTable({
head(tableData(), n=100)
#if (!is.null(input$file1))
# head(tableData()) else return(NULL)
})
output$summary <- renderPrint({
if (!is.null(input$file1)){if(input$resume == 'Individual')
summary(tableData()[,c(input$xcol)]) else (summary(tableData()))}
})
#output$vare<-renderPrint(names(tableData()))
#output$vare<-renderPrint(tableData()[,c(input$xcol)])
output$histog<-renderPlot({
if (!is.null(input$file1)){hist(tableData()[,c(input$xcol)],probability = TRUE, breaks= seq(0,max(tableData()[,c(input$xcol)]),l=input$bins+1), l=input$bins+1,
col = input$color, main = paste("Histograma de", input$xcol), xlab=paste(input$xcol))}
if (input$density) {
dens <- density(tableData()[,c(input$xcol)],
adjust = input$bw_adjust)
lines(dens, col = "white",type = "h")
}
})
}
shinyApp(ui = ui, server = server)