R to Table and as.Date function

I am a noob in R, so this is probably my fault, but I am getting slightly different results from running my code in RStudio and in KNIME.

In my code I take the min and max date of a data set for the current loop iteration. I do the following steps:

  1. use as.Date() to convert my “week_ending” column in my data frame to a date.
  2. get the min(week_ending) and max(week_ending) points for the current loop iteration
  3. convert the min & max to date using as.Date (I’m not sure why I have to do this, but if I don’t, the data ends up like in the last screenshot)
  4. save my results as a data frame…

In R Studio, the results are as expected:

When I view the dataframe output in KNIME’s R to Table by double clicking on the name in the workspace, the results are as expected:

However, when I actually view the table in KNIME, the results are not as expected:

Can anyone help me figure out why this is happening?
If it is helpful, I am using packages: “changepoint” and “dplyr” (changepoint also bundles the package “zoo”, which I believe is where as.Date comes from)

Thanks for your help :slight_smile:

1 Like

Hi @Snowy,

Dates and going back and forth between Knime-tables and R isn’t going very smooth. When you start with a date in a Knime table and use the Table to R node it becomes within R a string. As you found out, by using the as.Date() function you can get it into a date again.

Going the other way around with a R to Table node requires that you change the Date-column into a string again.

So something like this:
The result is again something looking like a date in the outputresults.

If you need it to become a real date again you would have to add a String to Date&Time node to change these strings into real dates.


You are totally right. We’ll look into it and check if there is an easier way. Thx 4 bringing this up.

Happy Kniming


Thanks so much @JanDuo. This solved my problem, and this knowledge I am sure will come in handy in the future.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.