|
1 | 1 | # File src/library/stats/R/nafns.R |
2 | 2 | # Part of the R package, https://www.R-project.org |
3 | 3 | # |
4 | | -# Copyright (C) 1995-2018 The R Core Team |
| 4 | +# Copyright (C) 1995-2025 The R Core Team |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify |
7 | 7 | # it under the terms of the GNU General Public License as published by |
@@ -75,14 +75,15 @@ na.omit.data.frame <- function(object, ...) |
75 | 75 | for(ii in 1L:d[2L]) |
76 | 76 | omit <- omit | x[, ii] |
77 | 77 | } |
78 | | - xx <- object[!omit, , drop = FALSE] |
79 | 78 | if (any(omit > 0L)) { |
| 79 | + xx <- object[!omit, , drop = FALSE] |
80 | 80 | temp <- setNames(seq(omit)[omit], |
81 | 81 | attr(object, "row.names")[omit]) |
82 | 82 | attr(temp, "class") <- "omit" |
83 | 83 | attr(xx, "na.action") <- temp |
| 84 | + object <- xx |
84 | 85 | } |
85 | | - xx |
| 86 | + object |
86 | 87 | } |
87 | 88 |
|
88 | 89 | na.exclude <- function(object, ...) UseMethod("na.exclude") |
@@ -129,14 +130,15 @@ na.exclude.data.frame <- function(object, ...) |
129 | 130 | for(ii in 1L:d[2L]) |
130 | 131 | omit <- omit | x[, ii] |
131 | 132 | } |
132 | | - xx <- object[!omit, , drop = FALSE] |
133 | 133 | if (any(omit > 0L)) { |
| 134 | + xx <- object[!omit, , drop = FALSE] |
134 | 135 | temp <- setNames(seq(omit)[omit], |
135 | 136 | attr(object, "row.names")[omit]) |
136 | 137 | attr(temp, "class") <- "exclude" |
137 | 138 | attr(xx, "na.action") <- temp |
| 139 | + object <- xx |
138 | 140 | } |
139 | | - xx |
| 141 | + object |
140 | 142 | } |
141 | 143 |
|
142 | 144 | naresid <- function(omit, x, ...) UseMethod("naresid") |
|
0 commit comments