Export using write.csv
First set your file directory, or else it will default to Documents.
You can set it via Session > Set Working Directory > To Source File Location (i.e. where your R script is stored). Or specify it using setwd
setwd("C:/Users/me/Desktop/MyFile")
write.csv(mpg, file = "mpgdataset.csv")