【发布时间】:2019-11-11 15:18:24
【问题描述】:
我正在尝试创建一个闪亮的交互式网络应用程序,但我遇到了与绘图相关的渲染问题。我的目标是上传一个 csv 文件,可以选择要绘制的列(在 y 轴上),并且可以选择绘制数据的数据范围。这是我的代码:
library(dplyr)
library(shiny)
library(networkD3)
library(igraph)
library(ggplot2)
db = as.data.frame(read.csv("./util_df.csv"))
EmotionalDB = as.data.frame(read.csv("./MainDB.csv"))
my_list = as.list(names(EmotionalDB))
my_list = my_list[c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11)]
ui <- fluidPage(
column(12, wellPanel(
dateRangeInput('dateRangeEmotions',
label = 'Filter emotions by date',
start = as.Date('2019-05-20') ,
end = as.Date('2019-05-26')
)
)),
selectInput("data1",
label = "Choose an Emotion",
choices = my_list
),
plotOutput("Emotions")
)
server <- function(input, output, session) {
output$Emotions <- renderPlot({
x <- EmotionalDB$Date
y <- EmotionalDB$Anger
plot(main="Emotions", x, y, type="l", xlim=c(input$dateRangeEmotions[1],input$dateRangeEmotions[2]), xaxt = "n")
axis.Date(side = 1, at = x, format = "%Y-%m-%d")
})
}
shinyApp(ui = ui, server = server)
不幸的是,情节中没有输出。这是一张图片:
这是我的数据集的示例:
"Date","Anger","Anticipation","Disgust","Fear","Joy","Negative","Positive","Sadness","Surprise","Trust"
"2019-05-20",12521,14652,2687,5164,13085,18309,23214,12882,12091,18623
"2019-05-21",13073,14988,3170,5773,13191,18988,24747,12973,12005,19435
"2019-05-22",15085,18608,3428,6475,16354,22671,30028,15765,15347,23680
"2019-05-23",23586,32597,5092,10084,24827,34827,44475,24468,23021,35440
"2019-05-24",61955,74395,10963,19597,65097,88223,104236,67361,59611,86375
"2019-05-25",19017,23540,4170,8595,19640,29740,34746,21793,18817,27907
"2019-05-26",9379,11909,1849,4535,10046,14791,17525,10757,9306,14095
谁能帮帮我?
【问题讨论】:
-
您能否提供示例数据以使其可重现(例如,您的 csv 文件中的 EmotionalDB 样本)?
-
当然!!我已经添加了一个示例。