问题
I have a rPlot and I don´t want that it shows the names of the elements below the x axis. I´ve already done it with the following code, but appears an error above the plot. The word is hide, but if I give a double click, copy and paste I see that the word is "undefined". If I take off the line:
,numticks = 'none'
the error does not appear.
I need other solution to hide the names or fix this one.
Thanks in advance!
Luis
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
})
})
回答1:
Finally, I found a solution:
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
})
})
来源:https://stackoverflow.com/questions/25955887/rcharts-not-show-x-axis-elements