问题描述:

First of all many thanks for the great rChartsDygraphs package! It is working superb and a great extension to the usual plots, but unfortunately I have a problem with signals.

Similar to the example I have a data.frame for the signals

signals1 <- as.data.frame(signals1)

'data.frame': 2712 obs. of 3 variables: $ Date : Date, format:

"2004-03-29" "2004-03-30" "2004-03-31" "2004-04-01" ... $ Price: num

1.78 1.79 1.78 1.8 1.86 1.9 1.87 1.84 1.85 1.88 ... $ sig : num 0 0 0 0 0 0 0 1 0 0 ...

However, when applying to the dygraph

 d1 <- dygraph(data=as.data.frame(data),

sync=TRUE,

crosshair="vertical",

legendFollow=TRUE, height = 200, width=800,

title = paste('<font size="1">', Symbol, '</ font>', sep=''),

signals = signals1,

sigFigs=7,

axisLabelFontSize = 9)

I receive in function sigSeries <- function(colN, signals) in line 4

ann <- as.data.table(signals[, c(1, 2, eval(colN)), with = FALSE])

following error

Error in `[.data.frame`(signals, , c(1, 2, eval(colN)), with = FALSE):

unused argument (with = FALSE)

I am still getting my head around R and do not understand what is going wrong here as "colN" evaluates fine to int 3 and hence all should work fine?

Just to mention it, without the signals the graph renders absolutely fine... and buys are int 1, sells int -1 while no change are zeros in the sig column.

Did anyone encounter similar issues and could help?

Many thanks in advance!

EDIT 1: output from dput(head(signals1))

Browse[2]> dput(head(signals1)) structure(list(Date =

structure(c(12506, 12507, 12508, 12509, 12510, 12513), class =

"Date"), Price = c(1.78, 1.79, 1.78, 1.8,

1.86, 1.9), sig = c(0, 0, 0, 0, 0, 0)), .Names = c("Date", "Price", "sig"), row.names = c(NA, 6L), class = "data.frame")

网友答案:

It seems that dygraph requires its signals parameter to belong to the data.table class, despite the documentation says that it should be just data.frame. Thus, to fix the problem you need to load the data.table package and replace

 signals = signals1,

by

signals = as.data.table(signals1),

in your code.

相关阅读:
Top