【发布时间】: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