How to access the built-in datasets in R language?
To access R’s built-in datasets, you can use the data() function. This function will list all the datasets that come with R. You can load a specific dataset by entering its name in the function.
Here is an example of loading a dataset using the data() function in R language:
# 列出R语言自带的所有数据集
data()
# 加载指定的数据集
data(mtcars)
# 查看加载的数据集
head(mtcars)
In this example, the data() function displayed all the datasets built-in to R language. We then loaded a dataset called mtcars using data(mtcars). Finally, we used head(mtcars) to view the first few rows of the loaded dataset.
You can choose the appropriate dataset to load and analyze according to your needs.