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

Rowwise mutate gives unexpected result. #1381

Closed
dkesh opened this issue Sep 2, 2015 · 2 comments
Closed

Rowwise mutate gives unexpected result. #1381

dkesh opened this issue Sep 2, 2015 · 2 comments
Assignees

Comments

@dkesh
Copy link

@dkesh dkesh commented Sep 2, 2015

Package Version dplyr: 0.4.3
R version 3.2.2

Running this code:

library( dplyr )
f  <- function( x ) ifelse( x < 2, NA_real_, x )
data_frame( x = 1:3 ) %>% rowwise() %>% mutate( y = f(x) )

Expected result: data_frame( x = 1:3, y = c( NA, 2, 3))
Actual result: data_frame( x = 1:3, y = c( NA, 2, NA ) )

@dkesh
Copy link
Author

@dkesh dkesh commented Sep 4, 2015

Is this a duplicate of #958?

@romainfrancois romainfrancois self-assigned this Sep 15, 2015
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Sep 15, 2015

Hmm. that's odd:

> f  <- function( x ) { print(x); ifelse( x < 2, NA_real_, x ) }
> data_frame( x = 1:3 ) %>% rowwise() %>% mutate( y = f(x) )
[1] 1
[1] 1
[1] 2
Source: local data frame [3 x 2]
Groups: <by row>

      x     y
  (int) (int)
1     1    NA
2     2     2
3     3    NA

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants