Filter is not working

hi there,
when i run this command
filter(mpg, year==2002)
i got this error
Error in filter(mpg, year == 2002) : object 'year' not found

i am facing this error?
what is the issue?
My R Studio is currpt??

Be sure to use dplyr::filter and not stats::filter

2 Likes

To this end ensure that the library dplyr is loaded.

e.g.

library(dplyr)

filter(mpg, year == 2002)
2 Likes

thank you very much

can you please tell me how can i explorer datasets installed in my rstudio
for example mpg,
i want to browse all data sets?
how can i export mpg dataset to excel or csv file

thanks,
rao

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")
1 Like

Hey! There is a function called data() if you run that it will show you all preinstalled data sets. : )

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.