【问题标题】:Interactive Graphs in R using rggobiR 中使用 rggobi 的交互式图形
【发布时间】:2010-07-16 22:12:21
【问题描述】:

来自以下xml代码:

<?xml version = "1.0"?>
<Company >
 <shareprice>
  <timeStamp> 12:00:00.01</timeStamp>
  <Price>  25.02</Price>
 </shareprice>

 <shareprice>
        <timeStamp> 12:00:00.02</timeStamp>
  <Price>  15</Price>
 </shareprice>



    <shareprice>
        <timeStamp> 12:00:01.025</timeStamp>
        <Price>  15.02</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:01.031</timeStamp>
        <Price>  18.25</Price>
    </shareprice>



    <shareprice>
        <timeStamp> 12:00:01.039</timeStamp>
        <Price>  18.54</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:01.050</timeStamp>
        <Price> 16.52</Price>
    </shareprice>


    <shareprice>
        <timeStamp> 12:00:02.01</timeStamp>
        <Price>  17.50</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:03.01</timeStamp>
        <Price>  25.02</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:05.02</timeStamp>
        <Price>  30</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:11.025</timeStamp>
        <Price>  32.25</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:12.031</timeStamp>
        <Price>  26.05</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:15.039</timeStamp>
        <Price>  18.54</Price>
    </shareprice>

    <shareprice>
        <timeStamp> 12:00:19.050</timeStamp>
        <Price> 16.52</Price>
    </shareprice>


    <shareprice>
        <timeStamp> 12:01:02.01</timeStamp>
        <Price>  17.50</Price>
    </shareprice>
</Company>

并使用以下 R 代码:

library(ggplot2)
library (XML)
test.df <- xmlToDataFrame(file.choose())
test.df
sapply(test.df, class) 
test.df$timeStamp <- strptime(as.character(test.df$timeStamp), "%H:%M:%OS")
test.df$Price <- as.numeric(as.character(test.df$Price))
sapply(test.df, class)
options("digits.secs"=3)
summary (test.df)
with(test.df, plot(timeStamp, Price))
sd (test.df$Price)
mean(test.df$timeStamp)
test.df$timeStamp <- test.df[1,"timeStamp"] + cumsum(runif(7)*60)
summary(test.df)
qplot(timeStamp,Price,data=test.df,geom=c("point","line"))
Price <- summary(test.df$Price)
print (Price)

我想创建一个交互式图表,允许用户单击一个点并获取有关该点值的信息(例如,如果值跳跃的原因),我希望能够放置网页上的这个交互式图表。有人建议使用 GGOBI 来执行此操作,而其他人则表示可以保留在 R 中并使用 rggobi 库。由于我没有这方面的经验,所以我想我会直接或向特定资源寻求一些指示(一个人可能会花费数年时间在网上搜索却找不到任何东西)

在图表下,我想打印出价格摘要。目前我在 Windows 上的 BATCH 文件中运行代码,它返回 pdf 文件中的图形,但不返回摘要打印。有没有办法设置代码/BATCH 文件,以便生成交互式图表和摘要?

【问题讨论】:

  • Ggobi 与网络无关。您正在寻找错误的技术。
  • 如果不发布 xml 而是将其加载到 R 中,应用您想要的所有转换,然后将 dput(dest.df) 的输出粘贴到您的问题中,那将会很好。这将节省回答者几个步骤。
  • 我下次试试。假设我可以在我拥有的 R 代码末尾运行 dput(test.df) 并将结构(列表(....)粘贴到问题中,我是否正确?

标签: r graph interactive rggobi


【解决方案1】:

好吧,对于一些指针:

这里有Rapache

您可以使用Open Flash Chart 进行绘图

另外我在这个主题上发现了这个link

HTH

【讨论】:

    【解决方案2】:

    Anthony,我假设您指的是 GGobi 中提供的 Identify 功能。您可以使用 Tools > Save Display Description 和 CRAN 上可用的 DescribeDisplay 包,以便将 GGplot 图导出/导入到 R。您将需要 DescribeDisplayggplot2 或“内置”graphics 包,即您可以同时使用qplotplot 来获取图表。

    保存后,可以通过以下方式导入显示描述:见the link =)

    关于“点击并获取信息”功能 - RApache 也不会帮助您! identifylocator 函数可与 graphics 一起使用,并且可以帮助您在 R 中单击并获取信息(请参阅 Maindonald, J.H. -“使用 R 进行数据分析和图形” - 3.4. Figure Region 上的标识和位置,它是免费的并且可用here),但是如果你打算在网络上做一些更雄心勃勃的事情,请参考 HTML &lt;map&gt;&lt;area&gt; 标签,这里是an example。然后我猜你会做一些 JavaScript 魔术(定义坐标和东西),如果我注意到的话,这是非常雄心勃勃的。

    另请参阅:graphics::textggplot2::geom_text

    【讨论】:

      猜你喜欢
      • 2011-12-13
      • 2019-10-08
      • 2018-02-22
      • 2021-06-16
      • 1970-01-01
      • 2017-10-26
      • 1970-01-01
      • 2019-04-11
      • 1970-01-01
      相关资源
      最近更新 更多