When I run this code
plot(c(0,1), c(0, 1), type = "n")
legend("topleft", legend = c("Model", "Data"),
lwd = c(3, NA),
pch = c(NA, 16),
bty = "n", inset = 0.02,
cex = 2)
as expected, I see this:

However, when I wrap it in pdf("legendTest.pdf") … dev.off(), the saved PDF has a line through the point.

Can I correct this, or do I need to just save in another format? I’m on a Mac, and the problem is present viewing the PDF using Preview and Chrome. I downloaded Adobe Reader to see what it did, and then the legend text and pch point disappeared, leaving only the model line.
You can fix this by explicitly setting the line type (argument
lty), like this:EDIT
The documentation for the
lwdargument, in?parexplains that:Mac’s default R graphical device must be one of those. (FWIW, with your code, my own Windows graphics device does show a line through the data point, just as in the pdf.)
In any case, it looks like it’s generally safer to use
ltythanlwdto control this particular detail.