@@ -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 ]), grep , skeys , fixed = TRUE ))
1923+ hits = unlist(lapply(paste0(" __" , names_x [cols ]), function ( x ) grep( x , 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,17 +2074,19 @@ 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 (is. data.table( xj ))
2077+ if (inherits( xj , " data.table" ))
20782078 xj = X [[j ]] = as.matrix(X [[j ]])
20792079 dnj = dimnames(xj )[[2L ]]
2080- collabs [[j ]] = paste(
2081- collabs [[j ]],
2082- if (length(dnj ) > 0L ) dnj else seq_len(dj [2L ]), sep = " ." )
2080+ collabs [[j ]] = paste(collabs [[j ]], if (length(dnj ) >
2081+ 0L )
2082+ dnj
2083+ else seq_len(dj [2L ]), sep = " ." )
20832084 }
20842085 if (! is.logical(xj ))
20852086 all.logical = FALSE
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" ))))
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" ))))
20882090 non.numeric = TRUE
20892091 if (! is.atomic(xj ))
20902092 non.atomic = TRUE
@@ -2102,7 +2104,7 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
21022104 if (is.character(X [[j ]])) next
21032105 xj = X [[j ]]
21042106 miss = is.na(xj )
2105- xj = if (nlevels( xj )) as.vector(xj ) else format(xj )
2107+ xj = if (length(levels( xj ) )) as.vector(xj ) else format(xj )
21062108 is.na(xj ) = miss
21072109 X [[j ]] = xj
21082110 }
@@ -2134,7 +2136,7 @@ tail.data.table = function(x, n=6L, ...) {
21342136 x [i ]
21352137}
21362138
2137- " [<-.data.table" = function (x , i , j , value ) {
2139+ " [<-.data.table" = function (x , i , j , value ) {
21382140 # [<- is provided for consistency, but := is preferred as it allows by group and by reference to subsets of columns
21392141 # 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.
21402142 if (! cedta()) {
@@ -2238,7 +2240,7 @@ dimnames.data.table = function(x) {
22382240 list (NULL , names(x ))
22392241}
22402242
2241- " dimnames<-.data.table" = function (x , value ) # so that can do colnames(dt)=<..> as well as names(dt)=<..>
2243+ " dimnames<-.data.table" = function (x , value ) # so that can do colnames(dt)=<..> as well as names(dt)=<..>
22422244{
22432245 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
22442246 if (! is.list(value ) || length(value ) != 2L ) stopf(" attempting to assign invalid object to dimnames of a data.table" )
@@ -2262,7 +2264,7 @@ dimnames.data.table = function(x) {
22622264 x # this returned value is now shallow copied by R 3.1.0 via *tmp*. A very welcome change.
22632265}
22642266
2265- within.data.table = function (data , expr , ... )
2267+ within.data.table = function (data , expr , ... )
22662268# basically within.list but retains key (if any)
22672269# will be slower than using := or a regular query (see ?within for further info).
22682270{
@@ -2287,7 +2289,7 @@ within.data.table = function(data, expr, ...)
22872289 ans
22882290}
22892291
2290- transform.data.table = function (`_data` , ... )
2292+ transform.data.table = function (`_data` , ... )
22912293# basically transform.data.frame with data.table instead of data.frame, and retains key
22922294{
22932295 if (! cedta()) return (NextMethod()) # nocov
@@ -2297,7 +2299,7 @@ transform.data.table = function(`_data`, ...)
22972299 `_data`
22982300}
22992301
2300- subset.data.table = function (x , subset , select , ... )
2302+ subset.data.table = function (x , subset , select , ... )
23012303{
23022304 key.cols = key(x )
23032305
@@ -2346,7 +2348,7 @@ subset.data.table = function(x, subset, select, ...)
23462348is_na = function (x , by = seq_along(x )) .Call(Cdt_na , x , by )
23472349any_na = function (x , by = seq_along(x )) .Call(CanyNA , x , by )
23482350
2349- na.omit.data.table = function (object , cols = seq_along(object ), invert = FALSE , ... ) {
2351+ na.omit.data.table = function (object , cols = seq_along(object ), invert = FALSE , ... ) {
23502352 # compare to stats:::na.omit.data.frame
23512353 if (! cedta()) return (NextMethod()) # nocov
23522354 if ( ! missing(invert ) && is.na(as.logical(invert )) )
@@ -2372,7 +2374,7 @@ which_ = function(x, bool = TRUE) {
23722374 .Call(Cwhichwrapper , x , bool )
23732375}
23742376
2375- is.na.data.table = function (x ) {
2377+ is.na.data.table = function (x ) {
23762378 if (! cedta()) return (`is.na.data.frame`(x ))
23772379 do.call(" cbind" , lapply(x , " is.na" ))
23782380}
0 commit comments