File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ class data_frame : public list {
2424
2525 friend class writable ::data_frame;
2626
27+ #if R_VERSION < R_Version(4,6,0)
2728 /* we cannot use Rf_getAttrib because it has a special case for c(NA, -n) and creates
2829 * the full vector */
2930 static SEXP get_attrib0 (SEXP x, SEXP sym) {
@@ -35,8 +36,10 @@ class data_frame : public list {
3536
3637 return R_NilValue;
3738 }
39+ #endif
3840
3941 static R_xlen_t calc_nrow (SEXP x) {
42+ #if R_VERSION < R_Version(4,6,0)
4043 auto nms = get_attrib0 (x, R_RowNamesSymbol);
4144 bool has_short_rownames =
4245 (Rf_isInteger (nms) && Rf_xlength (nms) == 2 && INTEGER (nms)[0 ] == NA_INTEGER);
@@ -47,6 +50,10 @@ class data_frame : public list {
4750 if (!Rf_isNull (nms)) {
4851 return Rf_xlength (nms);
4952 }
53+ #else
54+ if (Rf_isDataFrame (x))
55+ return R_nrow (x);
56+ #endif
5057
5158 if (Rf_xlength (x) == 0 ) {
5259 return 0 ;
You can’t perform that action at this time.
0 commit comments