Skip to content

Commit 5be9a70

Browse files
committed
Copy attributes on subsetting
1 parent 4a8030c commit 5be9a70

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

inst/include/Rcpp/vector/Subsetter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class SubsetProxy {
118118
}
119119
Rf_setAttrib(output, R_NamesSymbol, out_names);
120120
}
121+
Rf_copyMostAttrib(lhs, output);
121122
return output;
122123
}
123124

inst/unitTests/runit.subset.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ if (.runThisTest) {
7171
subset_test_assign(x)
7272
)
7373

74+
attr(x, "foo") <- "bar"
75+
y <- subset_test_int(x, 0L)
76+
checkIdentical( attr(y, "foo"), "bar" )
77+
7478
}
7579

7680
}

0 commit comments

Comments
 (0)