[[Rcpp::export]]
| 24 | |
| 25 | // [[Rcpp::export]] |
| 26 | IntegerVector RcppTable(SEXP x) { |
| 27 | switch (TYPEOF(x)) { |
| 28 | case INTSXP: return table(as<IntegerVector>(x)); |
| 29 | case REALSXP: return table(as<NumericVector>(x)); |
| 30 | case STRSXP: return table(as<CharacterVector>(x)); |
| 31 | case LGLSXP: return table(as<LogicalVector>(x)); |
| 32 | default: { |
| 33 | stop("untested SEXP type"); |
| 34 | return R_NilValue; |
| 35 | } |
| 36 | } |
| 37 | } |