Complete the code to add a legend to the plot.
plot(x, y, type = 'l') legend('topright', legend = [1], col = 'blue', lty = 1)
The legend function expects the legend argument as a character vector, so c('Data Line') is correct.
Complete the code to set the legend title.
plot(x, y, type = 'l') legend('topright', legend = c('Data'), title = [1], col = 'red', lty = 1)
The title argument expects a string, so it must be in quotes like 'Data Title'.
Fix the error in the legend position argument.
plot(x, y, type = 'l') legend([1], legend = c('Line'), col = 'green', lty = 1)
The position argument must be a string in quotes, so 'topright' is correct.
Fill both blanks to create a legend with two items and different colors.
plot(x, y, type = 'l') legend('bottomleft', legend = [1], col = [2], lty = 1)
The legend needs two labels and two colors, so c('Line1', 'Line2') and c('red', 'blue') are correct.
Fill all three blanks to customize the legend with line types and a title.
plot(x, y, type = 'l') legend('top', legend = [1], col = [2], lty = [3], title = 'Legend')
The legend labels are c('A', 'B'), colors c('black', 'orange'), and line types c(1, 2) for solid and dashed lines.
