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

Filtering on a column with NaNs multiple times returns variable numbers of rows #726

Closed
tleonardi opened this issue Oct 27, 2014 · 1 comment
Assignees
Milestone

Comments

@tleonardi
Copy link

@tleonardi tleonardi commented Oct 27, 2014

test <- data.frame( Name = c("a", "b","c", "d", "e"),
                    ID = c(1, 1, 1, 1, 1),
                    expression = c(NaN, NaN, NaN, NaN, NaN)
                  )

rep <- replicate( 5000, nrow(group_by(test, ID) %>% filter(min_rank(desc(expression))==1)))

table(rep)

>rep
>   1    2    5
>4654  345    1

sessionInfo()

R version 3.1.0 (2014-04-10)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] dplyr_0.3.0.2

loaded via a namespace (and not attached):
[1] assertthat_0.1 DBI_0.3.1      lazyeval_0.1.9 magrittr_1.0.1 parallel_3.1.0 Rcpp_0.11.3    tools_3.1.0
@romainfrancois romainfrancois added this to the 0.3.1 milestone Oct 28, 2014
@romainfrancois romainfrancois self-assigned this Oct 28, 2014
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Nov 4, 2014

Hum. Another way to exhibit the problem:

> replicate( 10, { data <- group_by(test, ID) %>% mutate(rank = min_rank(expression) ); data$rank  } )
           [,1]       [,2]       [,3]       [,4]       [,5]       [,6]
[1,]          1          1          1          1          1          1
[2,]      32735      32735      32735      32735      32735      32735
[3,] 1384250248 1384250248 1384250248 1384250248 1384250248 1381406080
[4,]      32735      32735      32735      32735      32735      32735
[5,] 1384169064 1384169064 1384169064 1384169064 1384169064 1381409544
           [,7]       [,8] [,9] [,10]
[1,]          1          1    1     1
[2,]      32735 1072693248    3     1
[3,] 1381406120          0  100     1
[4,]      32735 1074790400   39     1
[5,] 1381409584          0    3     1

In this example, only the 10th result is what I'd expect :/

Loading

@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2018
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