R:rCharts 和 Shiny,运行时图表不会显示 [英] R: rCharts and Shiny, charts won't show up when I run it

查看:76
本文介绍了R:rCharts 和 Shiny,运行时图表不会显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个持续存在的问题.我多次看到这个帖子,我尝试了人们提供的所有不同的解决方案.但没有什么对我有用.我的图表在运行时不会显示:(

This seems like an ongoing question. I saw this posted a few times, I tried all the different solutions people offered. But nothing works for me. My chart won't show up when I run it :(

这是我的 ui.R

## ui.R
require('rCharts')
require('shiny')
require("quantmod")
require("TTR")
require("stringr")
require('lubridate')
options(RCHART_LIB = 'polycharts')

shinyUI(pageWithSidebar(
  headerPanel('test'),
  sidebarPanel(p('test')
  ),
  mainPanel(
    showOutput('graph',lib='polycharts')
  )
))

这是我的服务器.R

#Dependencies
require('rCharts')
require('shiny')
require("quantmod")
require("TTR")
require("stringr")
require('lubridate')

#functions
SYM<-function (x,loc='yahoo') {
  getSymbols(x,src=loc)
  return(get(x))}

data.setup<-function(data,loc='yahoo',start.date=Sys.Date()-months(1),
                     end.date=Sys.Date()) {
  getSymbols(data,src=loc)
  x<-as.data.frame(window(SYM(data,loc=loc),
                          start=as.character(start.date),
                          end=as.character(end.date)))
  x$dates<-row.names(x)
  return(return(x)) 
}

## server.r
shinyServer(function(input, output) {
  output$graph <- renderChart2({
    a<-data.setup('AAPL')  
    m1 <- mPlot(x = 'dates', y = c("AAPL.High", "AAPL.Low"), type = "Line", data = a)
    m1$set(dom = 'graph')
    return(m1)
  })
})

*我的主要问题是我无法理解 showOutput 函数是如何工作的.showOutput 中的 lib 指的是什么?我找不到任何解释这一点的指南.对于 R 中的环境,我仍然是新手.非常感谢针对此的答案!

*My main issue is that I can't understand how does the showOutput function works. What is the lib in showOutput referring to? I can't find any guide that explains that. I am still a newbie when it comes to environments in R. A answer aimed at that is greatly appreciated!

推荐答案

showOutput 行需要使用 lib = "morris" 因为 OP 使用的是 mPlot.有关库的完整列表,您可以查看 README.或者,您也可以通过键入 m1$lib 来获取库的名称.

The showOutput line needs to use lib = "morris" since the OP is using mPlot. For a full list of libraries, you can see the README. Alternately, you can also get the name of the library by typing m1$lib.

这篇关于R:rCharts 和 Shiny,运行时图表不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆