Created
October 17, 2020 15:53
-
-
Save ifknot/d6fb86c11af2493235460b76e9aacf65 to your computer and use it in GitHub Desktop.
r-ish head
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "head.h" | |
| namespace R { | |
| variant_vector head(const variant_vector& x, size_t n) { | |
| return variant_vector (x.begin(), (x.size() < n) ? x.end() : x.begin() + 6); | |
| } | |
| data_frame head(const data_frame& x, size_t n) { | |
| data_frame df; | |
| for (const auto& [key, vctr] : x) { // keys as column headings | |
| df[key] = head(vctr, n); | |
| } | |
| return df; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment