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

add more informative error message when group_by() is missing #24

Open
Aariq opened this issue Jun 4, 2020 · 0 comments
Open

add more informative error message when group_by() is missing #24

Aariq opened this issue Jun 4, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@Aariq
Copy link
Owner

Aariq commented Jun 4, 2020

library(holodeck)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

sim_cat(n_obs = 20, n_groups = 2) %>% 
  sim_discr(n_vars = 5, var = 1, cov = 0, group_means = c(-1, 1))
#> Error: Must subset rows with a valid subscript vector.
#> ℹ Logical subscripts must match the size of the indexed input.
#> x Input has size 20 but subscript `!duplicated(x, fromLast = fromLast, ...)` has size 0.

#correct:
sim_cat(n_obs = 20, n_groups = 2) %>% 
  group_by(group) %>% 
  sim_discr(n_vars = 5, var = 1, cov = 0, group_means = c(-1, 1))
#> # A tibble: 20 x 6
#> # Groups:   group [2]
#>    group     V1      V2      V3     V4     V5
#>    <chr>  <dbl>   <dbl>   <dbl>  <dbl>  <dbl>
#>  1 a     -0.247 -0.0864 -1.17   -1.89   0.132
#>  2 a     -2.23  -1.45   -1.87   -0.934 -2.37 
#>  3 a     -1.82  -1.88   -0.108  -0.937 -1.50 
#>  4 a     -2.31  -0.0288 -0.897   1.12  -1.57 
#>  5 a     -1.24  -1.90    0.688  -1.62  -2.83 
#>  6 a     -1.06  -1.29   -1.63    0.409 -0.474
#>  7 a     -0.633 -0.404   0.0105  2.19  -1.79 
#>  8 a     -0.326 -0.0370 -1.17    0.907  0.565
#>  9 a     -0.409 -0.0451  2.04   -2.08  -1.52 
#> 10 a     -0.830 -0.960  -0.874  -0.875 -0.504
#> 11 b      1.42  -0.199   1.43   -0.696  0.531
#> 12 b      0.618  3.50   -0.775   2.34   1.48 
#> 13 b     -0.229  0.559   2.51    0.982  0.384
#> 14 b      1.63   0.682   0.982   1.18   1.20 
#> 15 b      1.51   2.24    1.23    1.57  -0.514
#> 16 b     -1.15   0.601  -0.0712  0.275  2.38 
#> 17 b      0.815  0.661   2.27    1.37   1.24 
#> 18 b      1.70   1.55   -0.344   2.55   1.45 
#> 19 b      0.837  1.36   -0.770   0.505  2.93 
#> 20 b      0.753  1.39    0.469   0.867  3.64

Created on 2020-06-04 by the reprex package (v0.3.0)

@Aariq Aariq added the enhancement New feature or request label Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant