1

Have the following dataframe

df = data.frame(Metric = c("Profit before tax 240", "Earnings per share 0.240" , "EBITDA Margin 37%"), Values =c(5, 1, 3))

gives

Metric                         Values
Profit before tax 240           5
Earnings per share 0.240        1
EBITDA Margin 37%               3

I have tried to split with the stringr package str_split_fixed(df$Metric, " ", 3) and then using cbind to add my column, without good results.

Below is what I'm trying to achieve in a new dataframe.

Metric                         Values       Line  
Profit before tax               240          5
Earnings per share              0.240        1
EBITDA Margin                   37%          3

Thanks

Adni
  • 133
  • 1
  • 11

0 Answers0