rCharts - 不显示x轴元素

时间:2014-09-21 04:42:48

标签: r shiny rcharts

我有一个rPlot,我不希望它显示x轴下方元素的名称。我已经使用以下代码完成了它,但在绘图上方出现错误。这个词是隐藏的,但是如果我双击,复制并粘贴我看到这个词是“未定义的”。如果我脱线:

,numticks = 'none'

错误没有出现。

我需要其他解决方案来隐藏名称或修复此名称。

提前致谢!

路易斯

ui.R

shinyUI(pageWithSidebar(

  headerPanel("New Application"),

  sidebarPanel(

           selectInput('feature', 'Choose a variable:', colnames(mtcars))


  ),

  mainPanel(
    showOutput('plot32', 'polycharts')
  )
))

server.R

shinyServer(function(input, output) {

  mydata<- reactive({
    Feature<-input$feature
    mtcars2<-cbind(rownames(mtcars),mtcars)
    colnames(mtcars2)<-c("Cars",colnames(mtcars))

    a<-mtcars2[,c("Cars",Feature)]
    colnames(a)<-c("Cars","Feature")
    a
  })


  output$plot32<- renderChart2({
    data2<-mydata()
    Feature<-input$feature
    p1<-rPlot(Feature ~ Cars, color = 'Cars', data = data2, type = 'bar')
    p1$guides(
      color = list(
        numticks = length((data2[,1]))
      ),
      x = list(title="Cars",
               numticks = 'none'
      ),
      y = list(title=input$feature
      )
    )
    p1$addParams(width = 800, height = 400, 
                 title = "Title")
    p1
  })

})

enter image description here

1 个答案:

答案 0 :(得分:0)

最后,我找到了一个解决方案:

shinyServer(function(input, output) {

  mydata<- reactive({
    Feature<-input$feature
    mtcars2<-cbind(rownames(mtcars),mtcars)
    colnames(mtcars2)<-c("Cars",colnames(mtcars))

    a<-mtcars2[,c("Cars",Feature)]
    colnames(a)<-c("Cars","Feature")
    a
  })


  output$plot32<- renderChart2({
    data2<-mydata()
    Feature<-input$feature
    p1<-rPlot(Feature ~ Cars, color = 'Cars', data = data2, type = 'bar')
    p1$guides(
      color = list(
        numticks = length((data2[,1]))
      ),

x = list(title =“Cars”,                ticks'''),

y = list(title=input$feature
      )
    )
    p1$addParams(width = 800, height = 400, 
                 title = "Title")
    p1
  })

})