Reputation: 645
I am creating shiny application with two files: ui.R
and server.R
. Each of them looks like:
# ui.R
dashboardPage(
dashboardHeader(title = "Content"),
dashboardSidebar(
sidebarMenu(id="tabs", sidebarMenuOutput("menu"))
),
dashboardBody(
............................
and
# server.R
library(shinydashboard)
library(shiny)
load(file = "table word freq.RData")
function(input, output,session) {
output$menu <- renderMenu({
sidebarMenu(
menuItem("Tags", tabName="m1", icon = icon("database"),
menuSubItem("Tags1", tabName = "m1"),
menuSubItem("Tags2", tabName = "m2"),
menuSubItem("Tags3", tabName = "m3")
),
................
As you see, I'm using shinydashboard
package, but when I press Run App
I get an error:
Warning: Error in ..stacktraceon..: could not find function "dashboardPage"
Stack trace (innermost first):
1: shiny::runApp
Error : could not find function "dashboardPage".
Have you any idea why library(shinydashboard)
doesn't attach to my code as other packages?
Upvotes: 3
Views: 6153
Reputation: 22847
Although the documentation states that you need to define the shiny package only in the server.R
file, and not necessarily the ui.R
file, it seems to be referring to "normal" shiny apps only, not "Shiny Dashboards". It looks like R-Studio preloads the shiny
library for a shiny file named ui.R
, but not the shinydashboard
library. Perhaps they though this might lead to unwanted conflicts.
It is seems inconsistent to me as well, so I checked RTVS, and it behaves the same way.
So you need to have a library(shinydashboard)
as the first line in the ui.R
file of a Shiny Dashboard app.
Upvotes: 7