0
У меня возникли некоторые проблемы с Блестящим и ggplotОшибки при импорте ggplot пузыря диаграммы в Shiny
Когда я запускаю следующий код для получения пузырьковой диаграммы в Shiny я получаю сообщение об ошибке:
«Ошибка в $<-.data.frame
(*tmp*
, "значение", значение = числовой (0)): замена имеет 0 строк, данные 3"
Но когда я запускаю его вне его отлично
Любая идея?
Благодаря
library(shiny)
library(ggplot2)
gtest = data.frame(cbind(sort(rep(c(1:3),5)),rep(c(1:5),3),sample(-8:8, 15)/10))
# Define a server for the Shiny app
server <- function(input, output) {
g3 <- reactive({
g2 <- gtest[gtest[2]==input$article,]
g2 <-g2[order(g2[3],decreasing = TRUE), ]
g2 <- rbind(g2[g2[1]==input$article,], g2[!g2[1]==input$article,])
angl <-seq(0, 360, length.out =(nrow(g2)))
angl <-angl[1:(length(angl)-1)]
g2[3] <-(max(g2[3])-min(g2[3]))*.3+(max(g2[3])-g2[3])
x<-c(0,g2[2:nrow(g2),3]*cos(angl%*%(pi/180)))
y<-c(0,g2[2:nrow(g2),3]*round(sin((pi/180)*angl),2))
g2<-cbind(g2,x,y)
colnames(g2) <- c("col1","col2","value","x","y")
g2
})
# Fill in the spot we created for a plot
output$g3plot = renderPlot({
p<-ggplot(g3(),aes(x,y,label= col1))+
geom_point(colour="white", fill="red", shape=21, size = 20)+
geom_text(size=5)+
theme_bw()
print(p)
})
}
#runApp("R/Test_shiny")
# Define the overall UI
ui <- fluidPage(
titlePanel("Articles by similarities"),
sidebarLayout(
sidebarPanel(
selectInput("article", "Article:", choice=unique(gtest[2]))), hr()),
mainPanel(
plotOutput("g3plot")
)
)
shinyApp(ui = ui, server = server)