1

I have the following code in server.R, I am getting the error shown below. I have seen other examples which are working fine, I don't know why this is not working?

   output$mytabs = renderUI({
if(some_condition)
        myTabs = c(tabPanel('Title 1', h4("Tab 1"), htmlOutput("tab_data_1")),
                   tabPanel("Title 2",h4("Tab 2"), verbatimTextOutput("tab_data_2")))
if(some_other_condition)
        myTabs = c(tabPanel('Title 3', h4("Tab 4"), htmlOutput("tab_data_3")),
                   tabPanel("Title 2",h4("Tab 2"), verbatimTextOutput("tab_data_2")))

        do.call(tabsetPanel, myTabs)
# I also tried
# do.call(tabsetPanel, c("tabpanel", myTabs))
      })

Error in `*tmp*`$attribs : $ operator is invalid for atomic vectors
Community
  • 1
  • 1
BigDataScientist
  • 1,045
  • 5
  • 17
  • 37

1 Answers1

2

This should work:

do.call(tabsetPanel, list(myTabs))

Or even simpler :

tabsetPanel(myTabs)
agstudy
  • 119,832
  • 17
  • 199
  • 261
  • This is working, but an additional text is showing up some thing like `div tab-pane active tab-5665-1` and `div tab-pane Tab 2` and I also would like to have additional (which is static not dynamic) tab, which I am unable to get, its showing in the same tab. – BigDataScientist Dec 11 '13 at 15:46
  • I could solve the additional tab issue with `tabs = c(tabsetPanel(tabPanel('Title 1', h4('Tab 1'), htmlOutput('tab_data_1')), tabPanel('Title 2',h4('Tab 2'),verbatimTextOutput('tab_data_2'))))` `mainPanel(tabs)`. But, I am still concerned with the extra text `div tabbable` showing up in the app – BigDataScientist Dec 11 '13 at 16:30
  • @user2684128 I don't see any relation with your original question and your comments. Honestly I am lost. I don't understand what do you mean. – agstudy Dec 11 '13 at 16:51
  • Thank You, I figured it out, The extra text is showing up because of c() – BigDataScientist Dec 11 '13 at 17:36