Hi All,
I have the following R code:
df <- xmlToDataFrame(/Users/usr/Desktop/shares.xml)
df$timeStamp <- strptime(as.character(df$XTimeStamp), "%H:%M:%OS")
df$SharePrice <- as.numeric(as.character(df$SharePrice))
sapply(df, class)
options("digits.secs"=3)
diff <- diff(df$SharePrice)
diff
sink (file="c:/xampp/htdocs/data.xml", type="output",split=FALSE)
cat("<graph caption=\"Share Price Data Wave\" subcaption=\"For Company's Name\" xAxisName=\"Time\" yAxisMinValue=\"0\" yAxisName=\"Price\" decimalPrecision=\"5\" formatNumberScale=\"0\" numberPrefix=\"\" showNames=\"1\" showValues=\"0\" showAlternateHGridColor=\"1\" AlternateHGridColor=\"ff5904\" divLineColor=\"ff5904\" divLineAlpha=\"20\" alternateHGridAlpha=\"5\">\n")
cat(sprintf(" <set name=\"%s\" value=\"%f\" hoverText = \"The difference from last value = %d\" ></set>\n", df$XTimeStamp, df$SharePrice, diff))
I am creating a new xml file in a format that FusionChart Free can read and I am trying to put the message in the hoverText area. However, when I run the commands I get the following error:
Error in sprintf(" <set name=\"%s\" value=\"%f\" hoverText = \"The difference from last value = %d\" ></set>\n", :
arguments cannot be recycled to the same length
When I view the diff it has one less diff than SharePrice (obviously because the difference from point 1 to point 1 is zero), so how can account for this in the sprint function (It produces the correct format xml file if I leave out the diff)?