How to Retrieve Row Numbers in R DataFrame? Last Updated : 19 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will discuss how to Retrieve Row Numbers in R Programming Language. The dataframe column can be referenced using the $ symbol, which finds its usage as data-frame$col-name. The which() method is then used to retrieve the row number corresponding to the true condition of the specified expression in the dataframe. The column values are matched and then the row number is returned. In case, the condition doesn't correspond to any row number, then integer(0) is returned. Syntax: which (df$col-name == val) Example: R #creating a dataframe data_frame <- data.frame(col1 = letters[1:10], col2 = 2:11, col3 = TRUE) print ("Original DataFrame") print(data_frame) print("DataFrame Row Number Where Column1 value is b") # get column value b in col1 column which(data_frame$col1 == "b") Output Rownames can also be assigned to the rows in a dataframe using the rownames() method. It takes a vector of length equivalent to the number of rows in the dataframe. The rownames(df) can also be checked to compare a value and then return a row number which corresponds to it. Example 2: R # creating a dataframe data_frame <- data.frame(col1 = letters[1:10], col2 = 2:11, col3 = TRUE) # GETTING THE ROWS OF dataframe rows <- nrow(data_frame) rownames(data_frame) <- LETTERS[1:rows] print ("Original DataFrame") print(data_frame) print("DataFrame Row Number Where Row Name value is E") # get R value in column which(rownames(data_frame)=="E") Output Comment More infoAdvertise with us Next Article How to Retrieve Row Numbers in R DataFrame? Y yashchuahan Follow Improve Article Tags : R Language R Programs R-DataFrame R DataFrame-Programs Similar Reads How to Remove Rows in R DataFrame? In this article, we will discuss how to remove rows from dataframe in the R programming language. Method 1: Remove Rows by Number By using a particular row index number we can remove the rows. Syntax: data[-c(row_number), ] where. data is the input dataframerow_number is the row index position Exam 2 min read How to change Row Names of DataFrame in R ? The rows are stacked together, each denoted by a unique name. By default, the integer identifiers beginning from 1 to the number of rows are assigned to the data frame by default. The task here is to change the Rows names in given dataframe using R programming. Dataset in use: First SecondThird1a72a 3 min read How to split DataFrame in R In this article, we will discuss how to split the dataframe in R programming language. A subset can be split both continuously as well as randomly based on rows and columns. The rows and columns of the dataframe can be referenced using the indexes as well as names. Multiple rows and columns can be r 4 min read Remove First Row of DataFrame in R In this article, we are going to see how to remove the first row from the dataframe. We can remove first row by indexing the dataframe. Syntax: data[-1,] where -1 is used to remove the first row which is in row position Example 1: R program to create a dataframe with 2 columns and delete the first 1 min read How to Unnest dataframe in R ? In this article, we will discuss how to unnest dataframes in R Programming Language. Unnesting of dataframe refers to flattening it. Method 1: Using do.call approach The do.call() method in base R constructs and executes a function call from a function using its corresponding argument list. Syntax 3 min read Like