I have the following dataframe, and I need to perform several functions on 4 specific columns. Here they are named as 'adjusted_cost','adjusted_cost_2','market_value','market_value_2'. However, the names keep changing with different dataframes, like 'cost', 'cost_2', 'value', 'value_2'.
structure(list(company = c("Investments", "Debt",
"Cash", "", ""), interest_rate = c("",
"", "7.46", "8.44", ""), adjusted_cost = c("", "", "$",
"", ""), adjusted_cost_2 = c("", "", "3,586 (EUR 3,381)", "3,564 (GBP 2,955)", "7,150"
), market_value = c("", "", "$3,505 (EUR 3,578)", "3,450(GBP 3,090)",
""), market_value_2 = c("", "", "$3,505 (EUR 3,578)", "3,450(GBP 3,090)",
"6,955")), row.names = c(NA, 5L), class = "data.frame")
I would like to remove the values in parentheses, ie (EUR 3,381) and (GBP 2,955) and then use the parse_number method to keep only the numbers from these specific columns.
Desired Output
company interest_rate adjusted_cost adjusted_cost_2 market_value market_value_2
<chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 Investments
2 Debt
3 Cash 7.46 3586 3505 3505
4 8.44 3564 3450 3450
5 7150 6955
Any suggestions would be appreciated. Thanks!