How can I make legend next to my piechart in R?
<p>I have made a piechart in R with the next code:</p>

<pre><code>#make slices
slices &lt;- c(19, 26, 55)

# Define some colors 
colors &lt;- c("yellow2","olivedrab3","orangered3")

# Calculate the percentage for each day, rounded to one decimal place
slices_labels &lt;- round(slices/sum(slices) * 100, 1)

# Concatenate a '%' char after each value
slices_labels &lt;- paste(slices_labels, "%", sep="")

# Create a pie chart with defined heading and custom colors and labels
pie(slices, main="Sum", col=colors, labels=slices_labels, cex=0.8)

# Create a legend at the right   
legend("topright", c("DH","UT","AM"), cex=0.7, fill=colors)
</code></pre>

<p>But I want the legend next to my piechart. I have also tried the following code: <code>legend("centreright", c("DH","UT","AM"), cex=0.7, fill=colors)</code>.
But this does not give me a legend next to my pie chart.</p>

<p>Which code do I have to use to make a legend next to my pie chart in the middle?</p>