/usr/lib/R/site-library/dplyr/include/dplyr/Result/ConstantResult.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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | #ifndef dplyr_Result_ConstantResult_H
#define dplyr_Result_ConstantResult_H
#include <dplyr/Result/Result.h>
namespace dplyr {
template <int RTYPE>
class ConstantResult : public Result {
public:
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
ConstantResult(SEXP x) : value(Rcpp::internal::r_vector_start<RTYPE>(x)[0]) {}
SEXP process(const GroupedDataFrame& gdf) {
return Vector<RTYPE>(gdf.ngroups(), value);
}
SEXP process(const RowwiseDataFrame& gdf) {
return Vector<RTYPE>(gdf.ngroups(), value);
}
virtual SEXP process(const FullDataFrame&) {
return Vector<RTYPE>::create(value);
}
virtual SEXP process(const SlicingIndex&) {
return Vector<RTYPE>::create(value);
}
STORAGE value;
};
template <int RTYPE>
class TypedConstantResult : public Result {
public:
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
TypedConstantResult(SEXP x, SEXP classes_) :
value(Rcpp::internal::r_vector_start<RTYPE>(x)[0]), classes(classes_) {}
SEXP process(const GroupedDataFrame& gdf) {
return get(gdf.ngroups());
}
SEXP process(const RowwiseDataFrame& gdf) {
return get(gdf.ngroups());
}
virtual SEXP process(const FullDataFrame&) {
return get(1);
}
virtual SEXP process(const SlicingIndex&) {
return get(1);
}
private:
SEXP get(int n) const {
Vector<RTYPE> res(n, value);
set_class(res, classes);
return res;
}
STORAGE value;
SEXP classes;
};
template <int RTYPE>
class DifftimeConstantResult : public Result {
public:
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
DifftimeConstantResult(SEXP x) :
value(Rcpp::internal::r_vector_start<RTYPE>(x)[0]),
units(Rf_getAttrib(x, Rf_install("units")))
{}
SEXP process(const GroupedDataFrame& gdf) {
return get(gdf.ngroups());
}
SEXP process(const RowwiseDataFrame& gdf) {
return get(gdf.ngroups());
}
virtual SEXP process(const FullDataFrame&) {
return get(1);
}
virtual SEXP process(const SlicingIndex&) {
return get(1);
}
private:
SEXP get(int n) const {
Vector<RTYPE> res(n, value);
set_class(res, "difftime");
res.attr("units") = units;
return res;
}
STORAGE value;
CharacterVector units;
};
}
#endif
|