Using xts package in R Snippet

Hello people,

I’m taking a course of forecasting product demand and I’ll use R xts package. I’ve loaded a data set and I want to assign a time series with it.

Right below is the code of the exercise (in Bold). Unfortunately, the Console brings an error statement of “Error: :3:1: unexpected symbol”. Could you help me with some advise?

library(xts)
dates <- seq(as.Date(“2014-01-19”, length = 176, by = “weeks”)
knime.out <- xts(knime.in, order.by = dates)

Best regards

first you will have to use other quotation marks and then you will have to close the bracket in the second line. Then still the syntax does not work in RStudio (I do not know what the command does).

Your code does not mention any knime.in Data Base. If you want to export the result of your R code it would look something like this - again: I have no idea what you want to do with the code, just checking if it would run.

library(xts)
dates <- seq(as.Date(“2014-01-19”), length=176, by=“weeks”)
knime.out <- as.data.frame(xts(dates, order.by = dates))

Hi,

The fuction seq was used to generate a sequence of 176 dates starting in “2014-01-09” by week. At the first moment, i didn’t notice that it was missing the final bracket. I have made this correction, but it didn’t work yet.

Now I’ve find out the solution. Inside the Knime console, it was necessary to declare the seq function exactly in the order of the function declaration (including commas for unnecessary statements). The code below run perfectly:

dates <- seq(test,“weeks”,176)

Best regards

1 Like