Shiny App Time Series plot with data table
我正在尝试构建一个简单的 Shiny 应用程序,它可以从 CSV 文件中获取数据输入,然后将数据与绘图一起显示,这是我编写的 R 代码,
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
require(graphics)
shinyServer(function(input, output) { #This function is repsonsible for loading in the selected file })
#This previews the CSV data file #Plot time Series plot |
但是当我运行它时,我收到一个错误”错误:无法将类型”闭包”强制转换为”双”类型的向量,无法找出问题所在
也许你应该试试这个:
1
2 3 4 5 6 7 8 9 |
output$tsplot <- renderPlot({
x <- as.numeric(filedata())### call the data file with parenthesis ts.obj <- ts(x) lowess.obj <- lowess(ts.obj, f = 10) plot.ts(x, main =”Sample Time Series”, xlab =”Time”) points(x) lines(lowess.obj$y, col =”red”) legend(“top”, legend =”Loess Smoother”, col =”red”, lty = 1) }) |
- 当我尝试这个时,我得到这个错误'(列表)对象不能被强制输入’double’
- as.numeric() 函数与向量一起使用,因此您必须选择要转换为数字的输入文件的哪一列并使用它
- @Vikram您能否显示选择输入文件列的代码?我尝试了几个版本,但总是出错。如果您可以指定行 x <- as.numeric(filedata()) 的更改,那就太好了!
来源:https://www.codenong.com/44717556/