File tree Expand file tree Collapse file tree 4 files changed +10
-12
lines changed Expand file tree Collapse file tree 4 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 226
226
convention once Unicode restricted the number of Unicode points
227
227
to \eqn {2 {^ 31 } - 1 }{2 ^ 31 - 1 } and so will never need more than 6
228
228
digits. )
229
+
230
+ \item \code {NCOL(NULL )} now returns 0 instead of 1 , for
231
+ consistency with \code {cbind()}.
229
232
}
230
233
}
231
234
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ nrow <- function(x) dim(x)[1L]
30
30
ncol <- function (x ) dim(x )[2L ]
31
31
32
32
NROW <- function (x ) if (length(d <- dim(x ))) d [1L ] else length(x )
33
- NCOL <- function (x ) if (length(d <- dim(x )) > 1L ) d [2L ] else 1L
33
+ NCOL <- function (x )
34
+ if (is.null(x )) 0L else if (length(d <- dim(x )) > 1L ) d [2L ] else 1L
34
35
35
36
rownames <- function (x , do.NULL = TRUE , prefix = " row" )
36
37
{
Original file line number Diff line number Diff line change @@ -52,8 +52,10 @@ NROW(1:12) # 12, the length() of the vector
52
52
# # and so does cbind() :
53
53
dim(as.matrix(numeric ())) # 0 1
54
54
dim( cbind(numeric ())) # ditto
55
- # # consequently, NCOL(.) gives 1, too :
56
- NCOL(numeric ()) # 1 and hence
57
- NCOL(NULL ) # 1
55
+ NCOL(numeric ()) # 1
56
+ # # However, as.matrix(NULL) fails and cbind(NULL) gives NULL, hence for
57
+ # # consistency:
58
+ NCOL(NULL ) # 0
59
+ # # (This gave 1 in R < 4.4.0.)
58
60
}
59
61
\keyword {array }
Original file line number Diff line number Diff line change @@ -128,11 +128,3 @@ local({
128
128
129
129
makeActiveBinding(" .Library.site" , slfun , globalenv())
130
130
})
131
-
132
- if (isTRUE(as.logical(Sys.getenv(" _R_NCOL_NULL_IS_ZERO_" ,
133
- " FALSE" )))) {
134
- NCOL <- function (x )
135
- if (is.null(x )) 0L
136
- else if (length(d <- dim(x )) > 1L ) d [2L ]
137
- else 1L
138
- }
You can’t perform that action at this time.
0 commit comments