Get the First parts of a Data Set in R Programming - head() Function Last Updated : 30 Jun, 2020 Comments Improve Suggest changes Like Article Like Report head() function in R Language is used to get the first parts of a vector, matrix, table, data frame or function. Syntax: head(x, n) Parameters: x: specified data types n: number of row need to be printed Example 1: Python3 # R program to illustrate # head function # Calling the head() function to # get the iris demo dataset head(iris) Output: Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa Example 2: Python3 # R program to illustrate # head function # Calling the head() function to # get the iris demo dataset in # 4 rows head(iris, 4) Output: Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa Comment More infoAdvertise with us Next Article Get the First parts of a Data Set in R Programming - head() Function K Kanchan_Ray Follow Improve Article Tags : R Language R DataFrame-Function Similar Reads Get the Last parts of a Data Set in R Programming - tail() Function tail() function in R Language is used to get the last parts of a vector, matrix, table, data frame or function. Syntax: tail(x, n) Parameters: x: specified data types n: number of row need to be printed Example 1: Python3 # R program to illustrate # tail function # Calling the tail() function to # g 1 min read Generate a set of Sample data from a Data set in R Programming - sample() Function sample() function in R Language creates random sample based on the parameters provided in the function call. It takes either a vector or a positive integer as the object in the function parameter. Syntax: sample(x, size, replace) Parameters: x: indicates either vector or a positive integer or data f 2 min read Create Subsets of a Data frame in R Programming - subset() Function subset() function in R Programming Language is used to create subsets of a Data frame. This can also be used to drop columns from a data frame.Syntax: subset(df, expr)Parameters: df: Data frame usedexpr: Condition for subsetCreate Subsets of Data Frames in R Programming LanguageHere we will make sub 3 min read Choose Specific Columns of a Data Frame in R Programming - select() Function select() function in R Language is used to choose whether a column of the data frame is selected or not. Syntax: select(x, expr) Parameters: x: Data frame expr: condition for selection Example 1: Python3 1== # R program to select specific columns # Loading library library(dplyr) # Create a data fram 2 min read How to print the first or last rows of a data set A data set typically means a collection of data organized in a tabular form, like a spreadsheet or a database table. Various programming languages have different techniques/methods to represent a data set in C++ we use vectors or arrays of structs/objects, In python pandas Data Frames, and Java 2D a 5 min read Like