Allan Tanaka
2017-Mar-03 12:43 UTC
[R] Error in curve 'expr' did not evaluate to an object of length 'n'
Please help. I try to re-produce R-script by plotting a set of functionWhen i running code: plot(Vectorize(running.acf.max))it gets the error message like this:?Error in curve(expr = x, from = from, to = to, xlim = xlim, ylab = ylab, ?:?? 'expr' did not evaluate to an object of length 'n' Even though i have vectorized the function argument. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sample1.txt URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170303/88a27287/attachment.txt>
Rolf Turner
2017-Mar-05 22:55 UTC
[R] [FORGED] Error in curve 'expr' did not evaluate to an object of length 'n'
On 04/03/17 01:43, Allan Tanaka wrote:> Please help. I try to re-produce R-script by plotting a set of functionWhen i running code: plot(Vectorize(running.acf.max))it gets the error message like this: Error in curve(expr = x, from = from, to = to, xlim = xlim, ylab = ylab, : 'expr' did not evaluate to an object of length 'n' > Even though i have vectorized the function argument.Your example is not reproducible. We do not have the file EURJPY.m14401.csv. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276
William Dunlap
2017-Mar-05 23:39 UTC
[R] Error in curve 'expr' did not evaluate to an object of length 'n'
You define a function called running.acf.max and then call plot(running.acf.max) R's plot, when given a function f, makes a plot of f(x) vs. x by calling curve(). Did you mean to plot the result of running.acf.max with its default arguments? That would be done with plot(running.acf.max()) There are several other problems with this code. E.g., you have running.acf.max <- function (data = returns, window = 100, nlags = 5, plot = T, main = "") { clevel <- qnorm(0.5 + 0.95/2)/sqrt(window) series <- rollapply(data = returns, window, align = "right", by = 1, function(w) { ... You should have data=data in the call to rollapply so it depends on the 'data' argument to running.acf.max. Use traceback() after an error to see where the error came from. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Mar 3, 2017 at 4:43 AM, Allan Tanaka <allantanaka11 at yahoo.com> wrote:> Please help. I try to re-produce R-script by plotting a set of functionWhen i running code: plot(Vectorize(running.acf.max))it gets the error message like this: Error in curve(expr = x, from = from, to = to, xlim = xlim, ylab = ylab, : 'expr' did not evaluate to an object of length 'n' > Even though i have vectorized the function argument. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.