I'm a beginner and practicing R and SQL connection. I connected R shiny with a classicmodels database and got an 'unused argument' error in the parameter settings. I've looked up various references and done a lot of experimenting but I still can't get around the error. I hope to receive help from more skilled friends.
below is what my code and the shiny window look like
part of my ui.R script
fluidRow(
tabBox(
height = "470px",
tabPanel(title = "Daily Sales",
sidebarLayout(
sidebarPanel(
selectInput(
inputId = "prod_type",
label = 'Product Type:',
choices = prodtype$productLine,
selected = '',
width = "200px"
),
dateRangeInput(
inputId = "date_range",
label = "Date Range:",
start = "2003-01-29",
end = "2005-05-31",
width = "200px"
),
status="primary"
),
mainPanel(
plotOutput(outputId = 'playChrt')
)
)
),
part of my server.R script
output$playChrt <- renderPlot(
{rconn=dbConnect(MySQL(),user="root",
password="",
host="127.0.0.1",
dbname="classicmodels")
d <- dbGetQuery(
conn = rconn,
statement =
'SELECT productLine,
orderDate as day,
sum(quantityOrdered) as qty,
sum(buyPrice*qty) as sales
FROM orders a
LEFT JOIN orderdetails b ON a.orderNumber = b.orderNumber
LEFT JOIN products c ON b.productCode = c.productCode
WHERE productLine = ? and (@day BETWEEN ? AND ?)
GROUP BY day
ORDER BY day DESC',
params = list(input$prod_type,
format(input$date_range[1], format="%Y-%m-%d"),
format(input$date_range[2], format="%Y-%m-%d"))
)
ggplot(data=d, aes(x = as.Date(day), y=sales)) +
geom_col(size=1) +
labs(x='Day', y='Sales Revenues ($)') +
theme_minimal(base_size=16) +
theme(axis.text.x=element_text(angle=60, hjust=1)) +
theme(legend.position = 'none')
}
)