r-lib / vctrs

Generic programming with typed R vectors
https://vctrs.r-lib.org
Other
290 stars 66 forks source link

Error in `vec_rbind()`: #1947

Open lauraDRH opened 3 months ago

lauraDRH commented 3 months ago

Hi! I just wanted to report this error

Error in `vec_rbind()`:
! Negative `n` in `compact_rep()`.
ℹ In file utils.c at line 897.
ℹ Install the winch package to get additional debugging info the next time you get this error.
ℹ This is an internal error that was detected in the vctrs package.
  Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex and the full backtrace.
Backtrace:
    ▆
 1. ├─purrr::map_dfr(1:10, ~collect(ss_data), .id = "iteration")
 2. │ └─dplyr::bind_rows(res, .id = .id)
 3. │   └─vctrs::vec_rbind(!!!dots, .names_to = .id, .error_call = current_env())
 4. └─rlang:::stop_internal_c_lib(...)
 5.   └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)

My code was:

collect <- function(data){
       data %>%  
        uncount(reads) %>% 
        sample_n(n()) %>%  
        mutate(observation=row_number()) %>%  
        arrange(otu, observation) %>% 
        group_by(otu) %>% 
        mutate(distinct= row_number()==1) %>%  
        ungroup %>% 
        arrange(observation)  %>% 
        mutate(s = cumsum(distinct)) %>%    
        select(observation,s) 
    }

collect_curves <- map_dfr(1:10, ~ collect(ss_data), .id="iteration")