Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples for DateVector and DateTimeVector to Rcpp Gallery #118

Open
aryoda opened this issue Nov 17, 2019 · 1 comment
Open

Add examples for DateVector and DateTimeVector to Rcpp Gallery #118

aryoda opened this issue Nov 17, 2019 · 1 comment

Comments

@aryoda
Copy link

aryoda commented Nov 17, 2019

Motivation

It is not obvious how to instantiate DateVector and DatetimeVector using Rcpp in C++ code.
Eg. this does not work:

DateVector d = DateVector::create("2010-12-31", "2011-01-01", "2011-05-29");

Currently there is only one article available which mainly focuses on how to work with non-vectorized Dates and Datetimes or using an existing DatetimeVector passed to the example function: https://gallery.rcpp.org/articles/parsing-datetimes/

Request

Add a new article (or modify the existing article) to show examples how to instantiate DateVector and DatetimeVector.

Example code snippets to be included:

// assumes an origin as base for counting the days (risky)
DateVector d = DateVector::create(14974, 14975, 15123);

// uses constructors (shows different ways to create the date elements)
DateVector d = DateVector::create(Date("2010-12-31"), Date("01.01.2011", "%d.%m.%Y"), Date(2011, 05, 29));

References

Rcpp for everyone: Ch 16 - Dates
SO question on how to create a new DateVector from dates as strings

@eddelbuettel
Copy link
Member

Maybe the easiest solution might be an update to the parsing-datetimes piece?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants