/usr/lib/R/site-library/dplyr/include/dplyr/Result/RowwiseSubset.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 | #ifndef dplyr_RowwiseSubset_H
#define dplyr_RowwiseSubset_H
#include <tools/ShrinkableVector.h>
#include <tools/utils.h>
#include <dplyr/checks.h>
#include <dplyr/Result/GroupedSubsetBase.h>
namespace dplyr {
template <int RTYPE>
class RowwiseSubsetTemplate : public RowwiseSubset {
public:
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE;
RowwiseSubsetTemplate(SEXP x) :
object(x), output(1), start(Rcpp::internal::r_vector_start<RTYPE>(object))
{
copy_most_attributes(output, x);
SET_DPLYR_SHRINKABLE_VECTOR((SEXP)output);
}
~RowwiseSubsetTemplate() {
UNSET_DPLYR_SHRINKABLE_VECTOR((SEXP)output);
}
virtual SEXP get(const SlicingIndex& indices) {
output[0] = start[ indices.group() ];
return output;
}
virtual SEXP get_variable() const {
return object;
}
virtual bool is_summary() const {
return false;
}
private:
SEXP object;
Vector<RTYPE> output;
STORAGE* start;
};
template <>
class RowwiseSubsetTemplate<VECSXP> : public RowwiseSubset {
public:
RowwiseSubsetTemplate(SEXP x) :
object(x), start(Rcpp::internal::r_vector_start<VECSXP>(object))
{}
virtual SEXP get(const SlicingIndex& indices) {
return start[ indices.group() ];
}
virtual SEXP get_variable() const {
return object;
}
virtual bool is_summary() const {
return false;
}
private:
SEXP object;
SEXP* start;
};
inline RowwiseSubset* rowwise_subset(SEXP x) {
switch (check_supported_type(x)) {
case DPLYR_INTSXP:
return new RowwiseSubsetTemplate<INTSXP>(x);
case DPLYR_REALSXP:
return new RowwiseSubsetTemplate<REALSXP>(x);
case DPLYR_LGLSXP:
return new RowwiseSubsetTemplate<LGLSXP>(x);
case DPLYR_STRSXP:
return new RowwiseSubsetTemplate<STRSXP>(x);
case DPLYR_CPLXSXP:
return new RowwiseSubsetTemplate<CPLXSXP>(x);
case DPLYR_VECSXP:
return new RowwiseSubsetTemplate<VECSXP>(x);
}
stop("Unreachable");
return 0;
}
}
#endif
|