An R2-D2 droid that was used in several "Star Wars" films has sold at auction for nearly $3 million.