You should be able to do this by going to the menu Tools -> Install Packages. A small dialog will appear. Enter
lmtest
in the box labeled Packages and then click the button labeled Install. A bunch of stuff will be printed in the console. When it is done, look for any error message. If there are none, you can run the command
library(lmtest)
and then use the dwtest() function.