I have a df with column named 'error (range)' containing the values with error range like below,
| error (range) |
|---|
| 25 (20 - 30) |
| 42 (39 - 48) |
| 35 (32 - 38) |
But I want to extract the values and my df columns should look like,
| error | error_min | error_max |
|---|---|---|
| 25 | 20 | 30 |
| 42 | 39 | 48 |
| 35 | 32 | 38 |
Can anyone help me with the coding in R to achieve this ?
CodePudding user response:
library(tidyverse)
df %>%
set_names('error')%>%
separate(error, c('error', 'error_min', 'error_max'),
convert = TRUE, extra = 'drop')
error error_min error_max
1 25 20 30
2 42 39 48
3 35 32 38
