<div dir="ltr"><div dir="ltr">Thanks for the tips.<div><br></div><div>Still, <font face="monospace">Range() </font>is the correct way to write:</div><div><br></div><div><font face="monospace">NumericVector my_vec(200);</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">my_vec(Range(0,10)) = 10;</font></div><div><br></div><div>?</div><div><br></div><div>Thanks in advance</div><div><br></div><div><br></div><div><br></div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><span style="font-size:12.8px">--</span><br style="font-size:12.8px"><span style="font-size:large">Francisco Bischoff, MD, MSc</span></div><div>Faculty of Medicine of the University of Porto, Portugal<br></div><div><br></div><div dir="ltr">- Master of Medical Informatics | topic: time series<br>- Research Associate | <a href="https://mailtrack.io/trace/link/1765b288bbce44d233e851a8d862ec594378aa04?url=http%3A%2F%2Fcintesis.eu%2Fai4health%2F&userId=3785237&signature=1b62d7a180130981" target="_blank">artificial intelligence for health</a> @ <a href="https://mailtrack.io/trace/link/89b15c4212d5d6c8d4ba354ec92ab002ba9a96ef?url=http%3A%2F%2Fcintesis.eu&userId=3785237&signature=5fa97b31373fa664" target="_blank">cintesis.eu</a><br>- Teaching Assistant | department of community medicine, information and health decision sciences @ <a href="https://mailtrack.io/trace/link/32f5f446b7bc0d597241524764b3636b5a75d466?url=http%3A%2F%2Fmed.up.pt&userId=3785237&signature=cfbca25f5fe210b3" target="_blank">med.up.pt</a><br><br>ORCID: 0000-0002-5301-8672 | Mendeley: francisco-bischoff | Google: tCeA0uUAAAAJ | ResearcherID: H-8261-2016 | ResearchGate: Francisco_Bischoff | CiênciaID B413-E0A0-DE8D | LinkedIn: franzbischoff</div></div></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 16, 2021 at 1:54 AM Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On 16 January 2021 at 01:35, Francisco Bischoff wrote:<br>
| About the Range() function, I think it should handle decreasing ranges<br>
| too...<br>
| But, idk if using Matlabs approach or R approach:<br>
| <br>
| R's:<br>
| <br>
| a <- 1<br>
| b <- 10<br>
| <br>
| print(a:b)<br>
| 1 2 3 4 5 6 7 8 9 10<br>
| print(b:a)<br>
| 10 9 8 7 6 5 4 3 2 1<br>
| <br>
| Matlab's<br>
| a = 1;<br>
| b = 10;<br>
| disp(a:b);<br>
| 1 2 3 4 5 6 7 8 9 10<br>
| disp(b:a);<br>
| numeric(0)<br>
| disp(b:-1:a)<br>
| 10 9 8 7 6 5 4 3 2 1<br>
| <br>
| I think that we are in the R domain, so we should use Range(b, a) normally<br>
| (my humble opinion).<br>
<br>
Hm but I think the Range class in Rcpp is not the same as R's seq(). It is<br>
used internally in a few places and may not generalize well to the 'b:-1:a'<br>
use.<br>
<br>
I had a quick look, and Armadillo may not have anything directly relevant<br>
either. linspace() is close but not quite the same.<br>
<br>
I would probably just write myself a little helper function.<br>
<br>
| About Casting, this is a good example:<br>
| <br>
| Rcout << Range(0, 10) << std::endl;<br>
| <br>
| This does not compute...<br>
| <br>
| What should I do?<br>
| <br>
| Rcout << as<IntegerVector>(Range(0, 10)) << std::endl;<br>
| or<br>
| Rcout << (IntegerVector)(Range(0, 10)) << std::endl;<br>
<br>
That can happen as template expressions can get in the way. Alternatives are<br>
maybe using Armadillo types for, again, just using a quick loop and printing<br>
elements.<br>
<br>
Rcpp has a lot of functions. But it doesn't have "all of R's functions" and<br>
should not be seen as aiming for that.<br>
<br>
Dirk<br>
<br>
-- <br>
<a href="https://mailtrack.io/trace/link/ec16eaacf00108f6b925d8cd55d469ea736d3313?url=https%3A%2F%2Fdirk.eddelbuettel.com&userId=3785237&signature=5ff5161e5ff16475" rel="noreferrer" target="_blank">https://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
</blockquote></div><img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/ece8208368387aa8431713f85fa36b8d930e430c.png?u=3785237"></div>