Deploying APP on shinyapps.io which keeps asking for ggplot2

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)

The error you see when deploying should appear when you have not a version of the :package: installed. Did you manage to install it ? if an error, what is it ?

Hi, I have tried installing the ggplot2 package twice, but when I run the library(ggplot2) code, I get a message saying 'there is no package called ggplot2.'

Having downloaded the package, I get the following message in my console:

The downloaded source packages are in
‘C:\Users\Idiaye\AppData\Local\Temp\RtmpsNrvdR\downloaded_packages’

I have tried extracting the ggplot2 package folder from the zip folder it came in, but I am still not getting any result. What am I supposed to do next? this is really frustrating as I have never had troubles installing packages before.

R puts that message at the end of many package installation attempts, even if they weren’t successful. The answers lie in all the console output between your install.packages() call and that final message.

Can you paste all that other output in here? sessionInfo() output would also be helpful. (Don’t forget to properly format your pasted output — once you’ve pasted it into the posting box, select it and click the little </> button at the top of the box).

2 Likes
There is a binary version available but the source version is
  later:
        binary source needs_compilation
ggplot2  2.2.1  3.0.0             FALSE

installing the source package ‘ggplot2’

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.0.0.tar.gz'
Content type 'application/x-gzip' length 2847050 bytes (2.7 MB)
downloaded 2.7 MB

* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error : object 'enexprs' is not exported by 'namespace:rlang'
ERROR: lazy loading failed for package 'ggplot2'
* removing 'C:/Users/Idiaye/Documents/R/R-3.3.0/library/ggplot2'
* restoring previous 'C:/Users/Idiaye/Documents/R/R-3.3.0/library/ggplot2'
Warning in install.packages :
  running command '"C:/Users/Idiaye/DOCUME~1/R/R-33~1.0/bin/i386/R" CMD INSTALL -l "C:\Users\Idiaye\Documents\R\R-3.3.0\library" C:\Users\Idiaye\AppData\Local\Temp\Rtmpox3Rry/downloaded_packages/ggplot2_3.0.0.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\Idiaye\AppData\Local\Temp\Rtmpox3Rry\downloaded_packages’
type or paste code here

Try reinstalling rlang, and then ggplot2.

1 Like

WOW! it is an honor to be noticed by you. I will give it a try right away. Thanks

1 Like

I just did as you suggested and it worked. Thanks a whole lot Ms. Mara!:smiley:

1 Like

It is a real honor to be noticed by you. Thanks for your help :smiley:

1 Like

Sure thing! There was a hitch with rlang not exporting enexprs() at one point that you are not the first to run into:

Error : object 'enexprs' is not exported by 'namespace:rlang'

But, it's fixed now!

1 Like

Yes, fixed and my app has finally deployed. Thanks again Ms. Mara!

1 Like

Hi there! If your question's been answered, would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here's how to do it.

2 Likes

I reinstalled rlang and then installed ggplot2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.