View Dataset in R: Quick Guide
In R language, there are several functions that can be used to view datasets. Below are a few commonly used functions.
- head(): Display the first few rows of a dataset, by default it shows the first 6 rows. For example, using head(dataset) will display the first 6 rows of the dataset.
- tail() function: displays the last few rows of the dataset, by default it shows the last 6 rows. For example, using tail(dataset) will show the last 6 rows of the dataset.
- summary(): displays the summary statistics of the dataset, including minimum, maximum, median, etc. For example, using summary(dataset) will show the summary statistics of the dataset.
- str(): Displays the structure of the dataset, including the name, type, and first few values of each variable. For example, using str(dataset) can show the structure information of the dataset.
- View(): Open a viewing window for a dataset in RStudio, which allows for easy browsing and searching of the data by scrolling. For example, using View(dataset) displays a dataset in RStudio.
Additionally, you can utilize the functions names() to view the variable names of the dataset, dim() to see its dimensions, nrow() to check the number of rows, ncol() to determine the number of columns, and so on. For example, you can use names(dataset) to examine the variable names in the dataset.