How To get a list of in-built DataSets in R?

Do you have trouble getting a sample DataSet while practicing R? I did! But now, I have learned that there are some in-built DataSets in R which we can use for practice. So, now it is easy to play around with the different datasets. 

Problem:
How to get a list of in-built DataSets in R?
Solution:

1. Using data(), we can get a list of all the available datasets. We might have Installed some packages while learning and practicing R. data() function will list the datasets of all loaded packages. We can see the packages that we have already loaded in our RStudio ‘packages’ window and are checked like below:
So, there is a package for R datasets named ‘datasets’. if we type data() in our console, we will be able to see the datasets available for all the loaded packages like datasets, car data,dplyr etc. for the above example.
2: Using data(package = .packages(all.available = TRUE)), we can get a list of all datasets in the available packages (i.e. also the not-loaded ones).
3: Using data(package = “package name”), we can get the datasets of that specific package i.e. data(package = “datasets”) will list the datasets from the “dataset” package.
0

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *