I set up a local app with Shiny using native R plotting, where I can choose what type of plot from a drop down ...

It works fine with native R plotting. However when I try to use plotly, though I can get it to plot for single plots, once I add in if statements to call different plotting routines based on the drop-down, I don't get any plots output.
Code below, am I doing something silly?
UI.R
library(shiny)
library(plotly)
shinyUI(fluidPage(
titlePanel("Help Library Analysis"),
sidebarPanel(
selectInput("plot_type", "Plot Type:",
c("Page views by ION area" = "ua_views_by_area",
"Word Cloud" = "ua_search_word_cloud",
"Legacy Content Age versus Page Views" = "ua_age_access"
)),
dateRangeInput("dates",
"Date range",
start = "2015-12-01",
end = as.character(Sys.Date()))
),
mainPanel(
plotlyOutput("trendPlot")
)
))
Server.R
library(shiny)
library(plotly)
source("helpers.R")
shinyServer(function(input, output) {
output$trendPlot <- renderPlotly({
if(input$plot_type == "ua_views_by_area") ua_views_by_area(start_date,end_date)
if(input$plot_type == "ua_age_access") ua_age_access(start_date,end_date)
})
})
helper.R contains the plot routines that ultimately call plotly with something like this, eg ua_views_by_area
f <- list(
family = "Courier New, monospace",
size = 18,
color = "#7f7f7f"
)
x <- list(
title = "Legacy Document Age (Years)",
titlefont = f
)
y <- list(
title = "UA System Page Views",
titlefont = f
)
p <- plot_ly(data = allData, x = allData$Years_Old, y = allData$pageViews, mode = "markers",
color = allData$Space, text=allData$Title) %>% layout(xaxis = x, yaxis = y)