Extracting all values between ( ) and before % sign

Viewed 71

How can I extract just the number between the parentheses () and before %?

df <- data.frame(X = paste0('(',runif(3,0,1), '%)'))


                     X
1 (0.746698269620538%)
2 (0.104987640399486%)
3 (0.864544949028641%)

For instance, I would like to have a DF like this:

                  X
1 0.746698269620538
2 0.104987640399486
3 0.864544949028641
2 Answers
Related