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

tidyr update cause failure when replacing na's. #9

Open
price0416 opened this issue Jul 6, 2022 · 0 comments
Open

tidyr update cause failure when replacing na's. #9

price0416 opened this issue Jul 6, 2022 · 0 comments

Comments

@price0416
Copy link
Contributor

price0416 commented Jul 6, 2022

In the line referenced below, an error results when using tidyr 1.2.0+.

tidyr::replace_na(list(start_residue = 0, end_residue = 0)) %>%

The error generates is as follows:
Error in vec_assign():
! Can't convert replace$start_residue to match type of data$start_residue .
Backtrace:

  1. └─global annotate_maf_with_hotspots(combined_maf)
  2. └─annotateMaf::hotspot_annotate_maf(maf)
  3. └─... %>% ...
    
  4.   ├─base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
    
  5.   └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
    
  6.     └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
    
  7.       └─annotateMaf `_fseq`(`_lhs`)
    
  8.         └─magrittr::freduce(value, `_function_list`)
    
  9.           └─function_list[[i]](value)
    
  10.             ├─tidyr::replace_na(., list(start_residue = 0, end_residue = 0))
    
  11.             └─tidyr:::replace_na.data.frame(., list(start_residue = 0, end_residue = 0))
    
  12.               └─vctrs::vec_assign(...)
    
  13.                 └─vctrs `<fn>`()
    
  14.                   └─vctrs::vec_default_cast(...)
    
  15.                     └─vctrs::stop_incompatible_cast(...)
    
  16.                       └─vctrs::stop_incompatible_type(...)
    
  17.                         └─vctrs:::stop_incompatible(...)
    
  18.                           └─vctrs:::stop_vctrs(...)
    
  19.                             └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
    

The issue is caused by the following tidyr updates:
replace_na() no longer allows the type of data to change when the replacement is applied. replace will now always be cast to the type of data before the replacement is made. For example, this means that using a replacement value of 1.5 on an integer column is no longer allowed. Similarly, replacing missing values in a list-column must now be done with list("foo") rather than just "foo".

replace_na() no longer replaces empty atomic elements in list-columns (like integer(0)). The only value that is replaced in a list-column is NULL (#1168).

This might be fixed by casting start_residue and end_residue to double in the replace_na() call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant