How to transform database organized like A into B-type?
| fruits | marker | conf_1 | conf_2 |
|---|---|---|---|
| Orange | C | 123 | 456 |
| Orange | B | 123 | 456 |
| Orange | A | 123 | 456 |
| Apple | C | 987 | 654 |
| Apple | B | 987 | 654 |
| Apple | A | 987 | 654 |
| Plum | C | 321 | 654 |
| Plum | B | 321 | 654 |
| Plum | A | 321 | 654 |
| Pear | C | 765 | 890 |
| Pear | B | 765 | 890 |
| Pear | A | 765 | 890 |
| Grape | C | 235 | 652 |
| Peach | A | 876 | 325 |
| Peach | C | 876 | 325 |
I have this data set in Excel, but also work in R. So I can perform this operation in Excel or in R. But how?

This PowerQuery would do it:
Or as @Zack suggested you could use a pivot table.
Pivot tables definitely aren't my strong point, so is probably a better way.
Remove the tick from grand totals for rows and grand total for columns under the Totals & Filters tab.
Select None for the subtotals.