loopurrr
loopurrr copied to clipboard
Translate purrr functions into regular for loops
``` r library(loopurrr) #> Loading required package: purrr x [[2]] #> [1] 221 #> #> [[3]] #> [1] 331 # doesn't work pmap(a, sum) %>% as_loop() #> Error in !is_clipr:...
R's lazy evaluation can lead to different results when translating `map` function calls to `for` loops. Below is one example that Claus Wilke provided on Twitter. Lets think about, whether...
When `as_loop` is used on a non-working call it throws an error. This behavior makes it impossible to use it as debugging tool.
Find the reason why this is not working: ```r map(1:5, ~.x) %>% as_loop #> Error in expr[[i]] : object of type 'symbol' is not subsettable ```
It is possible that the function in `.f` uses the same variable as specified in `idx` which defaults to `i`. There should be a check in place, checking this ,...
```r map(1:4, function(x) { x }) %>% as_loop() #> Error: 'text' should either be length 1, or same length as 'ranges' ``` This error is probably raised in `insert_and_reformat_text`.