簡體   English   中英

在 R shiny 中繪制熱圖問題

[英]Plotting issue with HeatMap in R shiny

我想 plot rshiny 應用程序中的熱圖。 我設法讓它在 r 筆記本上工作,結果正確。 但是,當我將相同的代碼放入我的 rshiny 應用程序時,熱圖結果是不同的。

這是我的 r shiny 筆記本中的代碼

這是插入 rshiny 應用程序中的相同代碼:

output$heatmapPlot <- renderPlotly({

heat_map_data <- data %>% 
   group_by(year,town,estate_type,flat_type,storey_range) %>% 
  summarise(median_sales = median(resale_price ))

df_matrix <- data.frame(heat_map_data)
print(df_matrix)

ggplot(df_matrix, aes(x = flat_type, y = storey_range, fill = median_sales)) + 
  geom_tile() +
  scale_y_discrete(limits = rev(levels(as.factor(df_matrix$storey_range))))              
})

rshinyapp 中的結果: rshiny 中的結果

有人可以幫我解決這個問題。 謝謝!

由於您使用了 renderPlotly() ,請將ggplot() object 分配給ggplotly() renderPlotly()

p<- ggplot(....)

p1<- ggplotly(p)

p1

ggplot() ) function 之前比較 print() function 的結果。 將您的數據集包含在反應式 function 中並相應地使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM