Hello guys,
Please can anyone help me out. I am trying to deploy an app on shinyapps.io but I keep getting this error message:
* Application depends on package "ggplot2" but it is not installed.
Please resolve before continuing.
In addition: Warning messages:
1: In FUN(X[[i]], ...) :
Failed to infer source for package 'ggplot2'; using latest available version on CRAN instead
2: In FUN(X[[i]], ...) :
Failed to infer source for package 'ggplot2'; using latest available version on CRAN instead
3: In FUN(X[[i]], ...) :
Failed to infer source for package 'ggplot2'; using latest available version on CRAN instead
4: Unable to package DESCRIPTION files: Couldn't find DESCRIPTION file for ggplot2
Execution halted
I have tried installing ggplot2 package many times, but to no avail. I included library (ggplot2) in my script but it didn't work. Could it be the version of r studio I am using, which is why I can load ggplot2? My app code is written below
library(shiny)
library(shinythemes)
library(DT)
ui<-fluidPage(
theme=shinytheme("sandstone"),
h2(titlePanel("Descriptive Data")),
sidebarLayout(
sidebarPanel(
radioButtons("radio","Select Dataset",choices=c(
"People",
"Industries",
"Schools",
"Hospitals"
),select="People"),
fileInput("file","Upload Dataset",placeholder="No file selected"),
sliderInput("slider","Pie Chart Angle",min=45,max=405,value=45,step=5),
selectInput("xAxis","Select X variable",choices=c(
"People",
"Industries",
"Schools",
"Hospitals"
),selected="People"),
selectInput("yAxis","Select Y variable",choices=c(
"People",
"Industries",
"Schools",
"Hospitals"
),selected="Industries"),
sliderInput("point","Point Size",min=1,max=10,value=3,step=1),
textAreaInput("text","Research Observation"),actionButton("action","Post Observation")
),
mainPanel(strong(h2("Choose How Data is Displayed",style="color:#5dade2")),
tabsetPanel(
tabPanel(h4("Histogram",style="color:#3498db"),selectInput("col","Change Graph Colour",choices=c(
"Red",
"Blue",
"Green",
"Yellow",
"Orange",
"Purple"
),selected="Blue"),plotOutput("histo",height=500,width=550)),
tabPanel(h4("Bar Plot",style="color:green"),selectInput("colo","Change Graph Colour",choices=c(
"Red",
"Blue",
"Green",
"Yellow",
"Orange",
"Purple"
),selected="Green"),plotOutput("Bar",height=500,width=550)),
tabPanel(h4("Pie Chart",style="color:red"),plotOutput("Pie",height=500,width=600)),
tabPanel(h4("Scatter Plot",style="color:#f39c12"),selectInput("scolo","Change Point Colour",choices=c(
"Red",
"Blue",
"Green",
"Yellow",
"Orange",
"Purple"
),selected="Blue"),plotOutput("Scatter",height=500,width=550)),
tabPanel(h4("Box Plot",style="color:#8e44ad"),selectInput("colos","Change Graph Colour",choices=c(
"Red",
"Blue",
"Green",
"Yellow",
"Orange",
"Purple"
),selected="Purple"),plotOutput("Box",height=500,width=550)),
tabPanel(h4("Table",style="color:brown"),DTOutput("Tab",width="100%",height="100%")),
tabPanel(h4("Observations",style="color:black"),textOutput("txt"))
)
)))
server<-function(input,output,session){
output$histo<-renderPlot({
data<-switch(input$radio,
"People"=people,
"Industries"=industries,
"Schools"=schools,
"Hospitals"=hospitals)
color<-switch(input$col,
"Red"=red,
"Blue"=blue,
"Green"=green,
"Yellow"=yellow,
"Orange"=orange,
"Purple"=purple)
hist(data,col=color,main="Histogram",xlab="Dataset",
ylab="Values",border="white")
})
output$Bar<-renderPlot({
data<-switch(input$radio,
"People"=people,
"Industries"=industries,
"Schools"=schools,
"Hospitals"=hospitals)
colors=switch(input$colo,
"Red"=red,
"Blue"=blue,
"Green"=green,
"Yellow"=yellow,
"Orange"=orange,
"Purple"=purple)
barplot(data,col=colors,border="white",xlab="Dataset",
ylab="Values",main="Bar Plot")
})
output$Pie<-renderPlot({
prop<-c(
"People"=people.prop,
"Industries"=industries.prop,
"Schools"=schools.prop,
"Hospitals"=hospitals.prop)
pie(prop,init.angle=input$slider,radius=1.1,clockwise=TRUE,col=c(4:7),
labels=c("People","Industries","Schools","Hospitals"),border="white")
legend("topright",legend=prop,fill=c(col=c(4:7)),cex=1,
box.lty=1,box.lwd=2,text.font=2,inset=.02)
})
output$Box<-renderPlot({
data<-switch(input$radio,
"People"=people,
"Industries"=industries,
"Schools"=schools,
"Hospitals"=hospitals)
colorly=switch(input$colos,
"Red"=red,
"Blue"=blue,
"Green"=green,
"Yellow"=yellow,
"Orange"=orange,
"Purple"=purple)
boxplot(data,col=colorly)
})
output$Scatter<-renderPlot({
variable<-switch(input$xAxis,
"People"=people,
"Industries"=industries,
"Schools"=schools,
"Hospitals"=hospitals)
variables<-switch(input$yAxis,
"People"=people,
"Industries"=industries,
"Schools"=schools,
"Hospitals"=hospitals)
colory=switch(input$scolo,
"Red"=reds,
"Blue"=blues,
"Green"=greens,
"Yellow"=yellows,
"Orange"=oranges,
"Purple"=purples)
plot(variable,variables,xlab="X Variable",ylab="Y Variable",
main="Scatter Plot Diagram",col=colory,pch=16,type="p",
cex=input$point)
})
output$Tab<-renderDT({
data.frame(
"People"=people,
"Industries"=industries,
"Schools"=schools,
"Hospitals"=hospitals)
})
output$txt<-renderText({
input$action
isolate(paste(input$text))
})
}
people=c(5,15,60,66,70,15,8,9,23,40,40,8,15,7,6)
industries=c(33,20,87,60,34,42,71,10,54,12,33,45,17,45,90)
schools=c(21,45,65,87,32,97,21,33,55,41,57,23,82,14,53)
hospitals=c(10,24,54,71,82,64,53,23,14,72,18,16,32,23,15)
red="#e74c3c"
blue="#3498db"
green="#2ecc71"
yellow="#f1c40f"
orange="#e67e22"
purple="#8e44ad"
reds="red"
blues="blue"
greens="green"
yellows="yellow"
oranges="orange"
purples="purple"
people.prop=0.5
industries.prop=0.35
schools.prop=0.10
hospitals.prop=0.05
shinyApp(ui=ui,server=server)