Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-13, r: 'oldrel'}
- {os: macos-15-intel, r: 'oldrel'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
Expand Down
9 changes: 8 additions & 1 deletion inst/include/cpp11/data_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include <string> // for string, basic_string
#include <utility> // for move

#include "R_ext/Arith.h" // for NA_INTEGER
#include "R_ext/Arith.h" // for NA_INTEGER
#include "Rversion.h"
#include "cpp11/R.hpp" // for Rf_xlength, SEXP, SEXPREC, INTEGER
#include "cpp11/attribute_proxy.hpp" // for attribute_proxy
#include "cpp11/list.hpp" // for list, r_vector<>::r_vector, r_v...
Expand All @@ -24,6 +25,7 @@ class data_frame : public list {

friend class writable::data_frame;

#if R_VERSION < R_Version(4, 6, 0)
/* we cannot use Rf_getAttrib because it has a special case for c(NA, -n) and creates
* the full vector */
static SEXP get_attrib0(SEXP x, SEXP sym) {
Expand All @@ -35,8 +37,10 @@ class data_frame : public list {

return R_NilValue;
}
#endif

static R_xlen_t calc_nrow(SEXP x) {
#if R_VERSION < R_Version(4, 6, 0)
auto nms = get_attrib0(x, R_RowNamesSymbol);
bool has_short_rownames =
(Rf_isInteger(nms) && Rf_xlength(nms) == 2 && INTEGER(nms)[0] == NA_INTEGER);
Expand All @@ -47,6 +51,9 @@ class data_frame : public list {
if (!Rf_isNull(nms)) {
return Rf_xlength(nms);
}
#else
if (Rf_isDataFrame(x)) return R_nrow(x);
#endif

if (Rf_xlength(x) == 0) {
return 0;
Expand Down
Loading