From 317b484f586bc5b8ff7677222c305120bc312d47 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Wed, 27 Feb 2013 12:45:48 -0600 Subject: [PATCH] Fix renderTimeSeries example --- _includes/tutorial/building-outputs.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/_includes/tutorial/building-outputs.md b/_includes/tutorial/building-outputs.md index 2c0c4e516..917085c68 100644 --- a/_includes/tutorial/building-outputs.md +++ b/_includes/tutorial/building-outputs.md @@ -18,18 +18,20 @@ renderTimeSeries <- function(expr, env=parent.frame(), quoted=FALSE) { # Convert the expression + environment into a function func <- exprToFunction(expr, env, quoted) - val <- func() - list(start = tsp(val)[1], - end = tsp(val)[2], - freq = tsp(val)[3], - data = as.vector(val)) + function() { + val <- func() + list(start = tsp(val)[1], + end = tsp(val)[2], + freq = tsp(val)[3], + data = as.vector(val)) + } } {% endhighlight %} which would then be used by the user like so: {% highlight r %} -output$timeSeries1 <- renderTimeSeries(function() { +output$timeSeries1 <- renderTimeSeries({ ts(matrix(rnorm(300), 100, 3), start=c(1961, 1), frequency=12) }) {% endhighlight %}