Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
EhrmannS committed Apr 10, 2024
1 parent d58d2ad commit f31146e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions R/bf_encode.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ bf_encode <- function(registry){

tempBits <- separate_wider_position(data = tempBits, cols = "int", widths = widths)

.toInt <- function(x){
temp <- str_split(x, "")
map(seq_along(temp), function(y){
sum(+(rev(temp[[y]]) == "1") * 2^(seq(temp[[y]])-1))
}) |> unlist()
}

out <- tempBits |>
mutate(across(everything(), function(x){
temp <- str_split(x, "")
map(seq_along(temp), function(y){
sum(+(rev(temp[[y]]) == "1") * 2^(seq(temp[[y]])-1))
}) |> unlist()
}))
mutate(across(everything(), .toInt))

return(out)

Expand Down

0 comments on commit f31146e

Please sign in to comment.