Skip to content
Back to formatted view

Raw Message

Message-ID: <23566.38257.155475.64454@rob.eddelbuettel.com>
Date: 2018-12-10T16:33:53Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Create scalar values in Rcpp
In-Reply-To: <CAL6gwn+pFvBb0GWdp_v04WcaP-dwUZf-dEx_oTrvXbYMRH1EEQ@mail.gmail.com>

On 10 December 2018 at 11:24, Avraham Adler wrote:
| There are no scalars in R; there are vectors of length 1.

Yep. An R feature, and gotcha if you come from somwhere else. See

  R> a <- 1
  R> is.vector(a)
  [1] TRUE
  R>

And while we can do this

  R> Rcpp::cppFunction("double wolf(double x) { return x+x; }")
  R> wolf(21.0)
  [1] 42
  R> 

it involves a combination of casts and our template magic so make it SEXPs
which, as representations of R types, are always vectors.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org