0

Il try to create a shiny app that print a pca ggplot with hierarchical clustering and the following error appears: Warning: Error in : You're passing a function as global data. Have you misspelled the data argument in ggplot(). what could be the problem? Here's the server:


    
    palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
             "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
    
    ggplot(swissDf, aes(x=PC1, y=PC2)) +
      theme_classic() +
      geom_hline(yintercept = 0, color = "gray70") +
      geom_vline(xintercept = 0, color = "gray70") +
      geom_point(aes(color = cluster), alpha = 0.55, size = 3) +
      xlab("PC1") +
      ylab("PC2") + 
      
      ggtitle("PCA Clusters from Hierarchical Clustering of Cars Data")
    
    })
  
}



shinyApp(ui, server)

  • `swissDf` is a reactive. You have to called it like a function, i.e. try with `ggplot(swissDf(), ....`. – stefan Jan 10 '21 at 18:47
  • I tried it, it returned an error : Warning: Error in unique.default: unique() applies only to vectors – Alona Boiko Jan 10 '21 at 19:12
  • First. This is a warning. Not an error. Second. Probably related to a different issue. Third. I just had another at you code. It probably should also be `clusters()` in `data.frame(PCA(), "cluster" = factor(clusters))`. Interestingly there you use `()` in `PCA()`. – stefan Jan 10 '21 at 19:19

0 Answers0