@@ -129,7 +129,7 @@ replace_dot_alias = function(e) {
129129 }
130130}
131131
132- " [.data.table" = function (x , i , j , by , keyby , with = TRUE , nomatch = NA , mult = " all" , roll = FALSE , rollends = if (roll == " nearest" ) c(TRUE ,TRUE ) else if (roll > = 0 ) c(FALSE ,TRUE ) else c(TRUE ,FALSE ), which = FALSE , .SDcols , verbose = getOption(" datatable.verbose" ), allow.cartesian = getOption(" datatable.allow.cartesian" ), drop = NULL , on = NULL , env = NULL )
132+ " [.data.table" = function (x , i , j , by , keyby , with = TRUE , nomatch = NA , mult = " all" , roll = FALSE , rollends = if (roll == " nearest" ) c(TRUE ,TRUE ) else if (roll > = 0 ) c(FALSE ,TRUE ) else c(TRUE ,FALSE ), which = FALSE , .SDcols , verbose = getOption(" datatable.verbose" ), allow.cartesian = getOption(" datatable.allow.cartesian" ), drop = NULL , on = NULL , env = NULL )
133133{
134134 # ..selfcount <<- ..selfcount+1 # in dev, we check no self calls, each of which doubles overhead, or could
135135 # test explicitly if the caller is [.data.table (even stronger test. TO DO.)
@@ -1920,7 +1920,7 @@ replace_dot_alias = function(e) {
19201920 attrs = attr(x , ' index' , exact = TRUE )
19211921 skeys = names(attributes(attrs ))
19221922 if (! is.null(skeys )) {
1923- hits = unlist(lapply(paste0(" __" , names_x [cols ]), function ( x ) grep( x , skeys , fixed = TRUE ) ))
1923+ hits = unlist(lapply(paste0(" __" , names_x [cols ]), grep , skeys , fixed = TRUE ))
19241924 hits = skeys [unique(hits )]
19251925 for (i in seq_along(hits )) setattr(attrs , hits [i ], NULL ) # does by reference
19261926 }
@@ -2074,19 +2074,17 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
20742074 if (is.ff(X [[j ]])) X [[j ]] = X [[j ]][] # nocov to bring the ff into memory, since we need to create a matrix in memory
20752075 xj = X [[j ]]
20762076 if (length(dj <- dim(xj )) == 2L && dj [2L ] > 1L ) {
2077- if (inherits( xj , " data.table" ))
2077+ if (is. data.table( xj ))
20782078 xj = X [[j ]] = as.matrix(X [[j ]])
20792079 dnj = dimnames(xj )[[2L ]]
2080- collabs [[j ]] = paste(collabs [[j ]], if (length(dnj ) >
2081- 0L )
2082- dnj
2083- else seq_len(dj [2L ]), sep = " ." )
2080+ collabs [[j ]] = paste(
2081+ collabs [[j ]],
2082+ if (length(dnj ) > 0L ) dnj else seq_len(dj [2L ]), sep = " ." )
20842083 }
20852084 if (! is.logical(xj ))
20862085 all.logical = FALSE
2087- if (length(levels(xj )) > 0L || ! (is.numeric(xj ) || is.complex(xj ) || is.logical(xj )) ||
2088- (! is.null(cl <- attr(xj , " class" , exact = TRUE )) && any(cl %chin %
2089- c(" Date" , " POSIXct" , " POSIXlt" ))))
2086+ if (nlevels(xj ) > 0L || ! (is.numeric(xj ) || is.complex(xj ) || is.logical(xj )) ||
2087+ (! is.null(cl <- attr(xj , " class" , exact = TRUE )) && any(cl %chin % c(" Date" , " POSIXct" , " POSIXlt" ))))
20902088 non.numeric = TRUE
20912089 if (! is.atomic(xj ))
20922090 non.atomic = TRUE
@@ -2104,7 +2102,7 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
21042102 if (is.character(X [[j ]])) next
21052103 xj = X [[j ]]
21062104 miss = is.na(xj )
2107- xj = if (length(levels( xj ) )) as.vector(xj ) else format(xj )
2105+ xj = if (nlevels( xj )) as.vector(xj ) else format(xj )
21082106 is.na(xj ) = miss
21092107 X [[j ]] = xj
21102108 }
@@ -2136,7 +2134,7 @@ tail.data.table = function(x, n=6L, ...) {
21362134 x [i ]
21372135}
21382136
2139- " [<-.data.table" = function (x , i , j , value ) {
2137+ " [<-.data.table" = function (x , i , j , value ) {
21402138 # [<- is provided for consistency, but := is preferred as it allows by group and by reference to subsets of columns
21412139 # with no copy of the (very large, say 10GB) columns at all. := is like an UPDATE in SQL and we like and want two symbols to change.
21422140 if (! cedta()) {
@@ -2240,7 +2238,7 @@ dimnames.data.table = function(x) {
22402238 list (NULL , names(x ))
22412239}
22422240
2243- " dimnames<-.data.table" = function (x , value ) # so that can do colnames(dt)=<..> as well as names(dt)=<..>
2241+ " dimnames<-.data.table" = function (x , value ) # so that can do colnames(dt)=<..> as well as names(dt)=<..>
22442242{
22452243 if (! cedta()) return (`dimnames<-.data.frame`(x ,value )) # nocov ; will drop key but names<-.data.table (below) is more common usage and does retain the key
22462244 if (! is.list(value ) || length(value ) != 2L ) stopf(" attempting to assign invalid object to dimnames of a data.table" )
@@ -2264,7 +2262,7 @@ dimnames.data.table = function(x) {
22642262 x # this returned value is now shallow copied by R 3.1.0 via *tmp*. A very welcome change.
22652263}
22662264
2267- within.data.table = function (data , expr , ... )
2265+ within.data.table = function (data , expr , ... )
22682266# basically within.list but retains key (if any)
22692267# will be slower than using := or a regular query (see ?within for further info).
22702268{
@@ -2289,7 +2287,7 @@ within.data.table = function (data, expr, ...)
22892287 ans
22902288}
22912289
2292- transform.data.table = function (`_data` , ... )
2290+ transform.data.table = function (`_data` , ... )
22932291# basically transform.data.frame with data.table instead of data.frame, and retains key
22942292{
22952293 if (! cedta()) return (NextMethod()) # nocov
@@ -2299,7 +2297,7 @@ transform.data.table = function (`_data`, ...)
22992297 `_data`
23002298}
23012299
2302- subset.data.table = function (x , subset , select , ... )
2300+ subset.data.table = function (x , subset , select , ... )
23032301{
23042302 key.cols = key(x )
23052303
@@ -2348,7 +2346,7 @@ subset.data.table = function (x, subset, select, ...)
23482346is_na = function (x , by = seq_along(x )) .Call(Cdt_na , x , by )
23492347any_na = function (x , by = seq_along(x )) .Call(CanyNA , x , by )
23502348
2351- na.omit.data.table = function (object , cols = seq_along(object ), invert = FALSE , ... ) {
2349+ na.omit.data.table = function (object , cols = seq_along(object ), invert = FALSE , ... ) {
23522350 # compare to stats:::na.omit.data.frame
23532351 if (! cedta()) return (NextMethod()) # nocov
23542352 if ( ! missing(invert ) && is.na(as.logical(invert )) )
@@ -2374,7 +2372,7 @@ which_ = function(x, bool = TRUE) {
23742372 .Call(Cwhichwrapper , x , bool )
23752373}
23762374
2377- is.na.data.table = function (x ) {
2375+ is.na.data.table = function (x ) {
23782376 if (! cedta()) return (`is.na.data.frame`(x ))
23792377 do.call(" cbind" , lapply(x , " is.na" ))
23802378}
0 commit comments