The “tail” Function in R
- Package: Base R (no specific package required) 
- Purpose: Returns the last n elements of a vector, matrix, or data frame. 
- General Class: Utility/Basic 
- Required Argument(s): 
- x: A vector, matrix, or data frame. 
- Notable Optional Arguments: 
- n: The number of elements to display. Default is 6. 
- nrow: The number of rows to display for a matrix or data frame. The default is n or 6 if n is not specified. 
- ncol: The number of columns to display for a matrix or data frame. The default is 1 for a vector or ncol for a data frame. 
- Example: 
- # Example vector 
 data <- c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
 
 # Display the last 3 elements of the vector
 result <- tail(data, n = 3)
 print(result)
- In this example, the tail function is used to display the last 3 elements of the numeric vector data. The result is then printed to the console. 
 
                        