I want to replicate the following R function in Rcpp:
fR = function(x) x[1:2]
fR(c(1,2,3))
#[1] 1 2
fR(c(\'a\',\'b\',\'c\'))
#[1] \"a\" \"b\"
<
You need to pick a type (ie do not use signature="SEXP" [ oh and you should look into Attributes anyway ]).
Or you keep the SEXP type, and dispatch internally. See for example this post on the Rcpp Gallery.
Edit: And C is of course statically typed. These very switches depending on the type are all over the R sources too. No free lunch here.