/usr/lib/R/site-library/dplyr/include/dplyr/Replicator.h is in r-cran-dplyr 0.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #ifndef dplyr_Replicator_H
#define dplyr_Replicator_H
#include <tools/utils.h>
namespace dplyr {
class Replicator {
public:
virtual ~Replicator() {}
virtual SEXP collect() = 0;
};
template <int RTYPE, typename Data>
class ReplicatorImpl : public Replicator {
public:
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
ReplicatorImpl(SEXP v, int n_, int ngroups_) :
data(no_init(n_ * ngroups_)), source(v), n(n_), ngroups(ngroups_) {}
SEXP collect() {
for (int i = 0, k = 0; i < ngroups; i++) {
for (int j = 0; j < n; j++, k++) {
data[k] = source[j];
}
}
copy_most_attributes(data, source);
return data;
}
private:
Vector<RTYPE> data;
Vector<RTYPE> source;
int n;
int ngroups;
};
template <typename Data>
inline Replicator* replicator(SEXP v, const Data& gdf) {
int n = Rf_length(v);
switch (TYPEOF(v)) {
case INTSXP:
return new ReplicatorImpl<INTSXP, Data> (v, n, gdf.ngroups());
case REALSXP:
return new ReplicatorImpl<REALSXP, Data> (v, n, gdf.ngroups());
case STRSXP:
return new ReplicatorImpl<STRSXP, Data> (v, n, gdf.ngroups());
case LGLSXP:
return new ReplicatorImpl<LGLSXP, Data> (v, n, gdf.ngroups());
case CPLXSXP:
return new ReplicatorImpl<CPLXSXP, Data> (v, n, gdf.ngroups());
default:
break;
}
stop("is of unsupported type %s", Rf_type2char(TYPEOF(v)));
}
} // namespace dplyr
#endif
|