I have a dataframe with coefficients and standard errors (in parenthesis) of a regression model that looks like this:
data = data.frame(Variable = c('x1', 'x2', 'x3'),
Coefficients_se1 = c('0.04 (0.03)', '', ''),
Coefficients_se2 = c('', '0.08*** (0.01)', ''),
Coefficients_se3 = c('', '', '0.02* (0.01)'))
print(data)
Variable Coefficients_se1 Coefficients_se2 Coefficients_se3
1 x1 0.04 (0.03)
2 x2 0.08*** (0.01)
3 x3 0.02* (0.01)
I would like to know if there is a way to move the values in the parenthesis to the line above in the same dataset. This way, I would like to produce an output like above:
Variable Coefficients_se1 Coefficients_se2 Coefficients_se3
1 x1 0.04
2 (0.03)
3 x2 0.08***
4 (0.01)
5 x3 0.02*
6 (0.01)
Is it possible to do this using R ?