Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] - Add na.pad argument in row/colDiffs() #151

Open
Eluvias opened this issue Jun 18, 2019 · 0 comments
Open

[FR] - Add na.pad argument in row/colDiffs() #151

Eluvias opened this issue Jun 18, 2019 · 0 comments

Comments

@Eluvias
Copy link

Eluvias commented Jun 18, 2019

It would be nice to have this feature when rowDiffs() / colDiffs() is used within intermediate calculations that require positional matching.

x <- matrix(1:27, ncol = 3)
library(matrixStats)
colDiffs(x)
     [,1] [,2] [,3]
[1,]    1    1    1
[2,]    1    1    1
[3,]    1    1    1
[4,]    1    1    1
[5,]    1    1    1
[6,]    1    1    1
[7,]    1    1    1
[8,]    1    1    1

With na.pad set to TRUE

library(xts)
xts::diff.xts(x, na.pad = TRUE)
      [,1] [,2] [,3]
 [1,]   NA   NA   NA
 [2,]    1    1    1
 [3,]    1    1    1
 [4,]    1    1    1
 [5,]    1    1    1
 [6,]    1    1    1
 [7,]    1    1    1
 [8,]    1    1    1
 [9,]    1    1    1

Also, on a different note I think dim. argument is not coerced to integer as intended when the dim. is given manually. I believe the expression dim <- as.integer(dim.) was placed there to enforce it, but it's not passed into C call:

 body(colDiffs)
{
    dim <- as.integer(dim.)
    .Call(C_rowDiffs, x, dim., rows, cols, as.integer(lag), as.integer(differences), 
        FALSE)
}
@Eluvias Eluvias changed the title [FR] - Add na.pad argument in row/colDiff() [FR] - Add na.pad argument in row/colDiffs() Jun 19, 2019
@HenrikBengtsson HenrikBengtsson added this to the Next release milestone Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants