views:

90

answers:

2

From the following xml code:

<?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>

and using the following R code:

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)

I would like to create an interactive graph that would allow a user to click on a point and get information on the the value of the point (eg if the value jumped a reason so), I would like to be able to put this interactive graph on a web page. It has been suggested to use GGOBI to do this, while others say it is possible to remain in R and use the rggobi library. As I have no experience of this I thought I'd ask for some pointers either directly or to a specific resource (one can spend years searching the net and not find anything)

Under the graph I would like to print out the summary of the Price. At the moment I run the code in a BATCH file on windows and it returns the graphs in a pdf file but not the summary print. Is there a way to set up the code / BATCH file so that it can produce the interactive graph and summary?

+1  A: 

Well, for some pointers:

there´s Rapache

and you could possibly do the drawing with Open Flash Chart

plus i found this link on the topic

HTH

ran2
A: 

Anthony, I assume that you were referring to Identify function available in GGobi. You can use Tools > Save Display Description and the DescribeDisplay package available on CRAN in order to export/import GGplot graph to R. You'll be needing both DescribeDisplay and ggplot2 or the "built-in" graphics package, i.e. you can use both qplot or plot to get the graph.

Once saved, the display description can be imported with: see the link =)

About "click-and-get-info" feature - RApache is not going to help you either! There are identify and locator functions that work with the graphics, and can help you with click-and-get-info within R (see Maindonald, J.H. - "Using R for Data Analysis and Graphics" - 3.4. Identification and Location on the Figure Region, it's free and available here), but if you're planing to do something more ambitious on the web, refer to HTML <map> and <area> tags, here's an example. Then I guess you'll be doing some JavaScript magic (defining coordinates and stuff), which is, if I may notice, quite ambitious.

See also: graphics::text and ggplot2::geom_text.

aL3xa