How to pivot my data frame in R so that it turns into another data frame in this specific format? : <p>I have a small <code>data frame</code> in R called <code>df1</code>.</p>

<p>Below is how the <code>data frame</code> looks like:</p>

<pre><code>SubDept2        BasicSalary     BenchmarkSalary
Admin             10000          20000
Bar                9880          12000
Entertainment     11960          17000
F&amp;B                9680          12000
Finance           10310          17500
Housekeeping       9960          12000
Kitchen            9680          12000
Leisure &amp; Sport   10775          17000
Maintenance       10240          10000
Restaurant         9880          12000
Rooms Division     9680          12000
Security          10250          11000
Spa                9450          12000
</code></pre>

<p>I want to <code>pivot</code> this <code>data frame</code> so that it turns out like this:</p>

<pre><code>SubDept2              Amount     Type
 Admin                10000      BasicSalary
 Bar                   9880      BasicSalary
 Entertainment        11960      BasicSalary
 F&amp;B                   9680      BasicSalary
 Finance              10310      BasicSalary
 Housekeeping          9960      BasicSalary
 Kitchen               9680      BasicSalary
 Leisure &amp; Sport      10775      BasicSalary
 Maintenance          10240      BasicSalary
 Restaurant            9880      BasicSalary
 Rooms Division        9680      BasicSalary
 Security             10250      BasicSalary
 Spa                   9450      BasicSalary
 Admin                20000      BenchmarkSalary
 Bar                  12000      BenchmarkSalary
 Entertainment        17000      BenchmarkSalary
 F&amp;B                  12000      BenchmarkSalary
 Finance              17500      BenchmarkSalary
 Housekeeping         12000      BenchmarkSalary
 Kitchen              12000      BenchmarkSalary
 Leisure &amp; Sport      17000      BenchmarkSalary
 Maintenance          10000      BenchmarkSalary
 Restaurant           12000      BenchmarkSalary
 Rooms Division       12000      BenchmarkSalary
 Security             11000      BenchmarkSalary
 Spa                  12000      BenchmarkSalary
</code></pre>

<p>How can this be done?</p>
