File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,31 @@ namespace internal{
56
56
return *this ;
57
57
}
58
58
59
+ inline DimNameProxy& operator =(const DimNameProxy& other) {
60
+ SEXP dim = Rf_getAttrib (data_, R_DimSymbol);
61
+ if (INTEGER (dim)[dim_] != INTEGER (dim)[other.dim_ ]) {
62
+ std::stringstream s;
63
+ s << " dimension extent is '"
64
+ << INTEGER (dim)[dim_]
65
+ << " ' while length of names is '"
66
+ << INTEGER (dim)[other.dim_ ]
67
+ << " '" ;
68
+ stop (s.str ());
69
+ }
70
+ SEXP dimnames = Rf_getAttrib (data_, R_DimNamesSymbol);
71
+ SEXP dims = Rf_getAttrib (data_, R_DimSymbol);
72
+ SEXP other_dimnames = SEXP (other);
73
+ if (Rf_isNull (dimnames)) {
74
+ Shield<SEXP> new_dimnames (Rf_allocVector (VECSXP, Rf_length (dims)));
75
+ SET_VECTOR_ELT (new_dimnames, dim_, other_dimnames);
76
+ Rf_setAttrib (data_, R_DimNamesSymbol, new_dimnames);
77
+ } else {
78
+ SET_VECTOR_ELT (dimnames, dim_, other_dimnames);
79
+ }
80
+ return *this ;
81
+ }
82
+
83
+
59
84
inline operator SEXP () const {
60
85
SEXP dimnames = Rf_getAttrib (data_, R_DimNamesSymbol);
61
86
return Rf_isNull (dimnames) ? (R_NilValue) : (VECTOR_ELT (dimnames, dim_));
You can’t perform that action at this time.
0 commit comments