Reputation: 17
I'm just starting out on Shiny and have been working with a dataset to try and get some experience. I've reworked a simple code for quite a few iterations and keep getting the ...argument is missing with no default. Does anyone see what I'm missing?
ui.R
=============================
library(shiny)
shinyUI(
pageWithSidebar(
headerPanel("Simple Cluster Example"),
sidebarPanel(
numericInput("var", "Cluster:", 2,
min = 2, max = 5, step = 1)),
mainPanel(
plotOutput("plot"),
#dataTableOutput("table")
)
)
)
-------------------------------
server.R
===============
library('shiny')
library('ggplot2')
shinyServer(function(input, output) {
protein <- read.csv("protein.csv")
vars.to.use <- colnames(protein) [-1]
pmatrix <- scale(protein[,vars.to.use])
pcenter <- attr(pmatrix, "scaled:center")
pscale <- attr(pmatrix, "scaled:scale")
d <- dist(pmatrix, method="euclidean")
pfit <- hclust(d, method="ward.D")
# This code is triggered whenever the drop-down menu is changed in the UI
component <- input$var
#rect.hclust(pfit, k=component)
groups <- cutree(pfit, k=component)
princ <- prcomp(pmatrix)
nComp <- 2
project <- predict(princ, newdata=pmatrix) [,1:nComp]
project.plus <- cbind(as.data.frame(project),
cluster=as.factor(groups),
country=protein$Country)
p <- ggplot(project.plus, aes(x=PC1, y=PC2)) +
geom_point(aes(shape=cluster))+geom_text(aes(label=country), hjust=0, vjust=1)
output$plot <- renderPlot({print(p)})
})
Upvotes: -1
Views: 1285
Reputation: 1232
Your problem is:
plotOutput("plot"),
When you end with "," (since you commented out the line after) it expects a new argument. But it is empty in your case, so remove the extra ",".
Upvotes: 1