2014-09-21 83 views
0

我有一個rPlot,我不希望它顯示x軸下方元素的名稱。我已經用下面的代碼完成了它,但在圖上方出現一個錯誤。這個詞是隱藏的,但如果我給雙擊,複製並粘貼,我看到這個詞是「未定義」。如果我脫線:rCharts - 不顯示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

回答

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 =列表(標題= 「汽車」, 蜱= ''),

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

})