How to use built in data in R
Working with built-in data in R is really easy. It just requires you to call the data using a simple function.
Calling the Iris data set
The Iris data set is a classic set of petal and sepal measurements from three Iris species.
A list of all built-in data sets can be obtained by using the data() command
How to use data from the internet
This is a really strong tool for downloading data from websites that are hosting it.
.csv files
The most holy of file types for data sheets is .csv (comma separated values). Importing a .csv file from the internet is very easy.
Letโs download COVID-19 data from data.gov
We used the download.file() and read.csv() function
.xlsx files
If .csv files are the light side, .xlsx are certainly the dark side of data sheets (well not really). It just requires a external package โreadxlโ to read in the file.
Here we will download an .xlsx file of the data:
Airborne cues accelerate flowering and promote photosynthesis in Brassica rapa, from Dryad.
How to subset data
You can use the subset() function to extract data from a dataset based on a factor or set or factors. Here is an example using the Iris dataset:
Exporting data
You might also want to export data as a .csv to send to someone you are collaborating with. This is a really simple process using the write.csv() command.