How to find maximum string length by column in R DataFrame ? Last Updated : 21 Nov, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we are going to see how to find maximum string length by column in R Programming Language. To find the maximum string length by column in the given dataframe, first, nchar() function is called to get the length of all the string present in the particular column of the dataframe, and then the max() function must be called to get the maximum value of the length of the string generated by the nchar() function. The nchar() and the max() function are base functions of the R programming language, so there is no need to import any package. nchar() function takes a character vector as an argument and returns a vector whose elements contain the sizes of the corresponding elements of x Syntax: nchar(x, type = "chars", allowNA = FALSE, keepNA = NA) Parameter: x: character vector or a vector to be coerced to a character vector. Giving a factor is an error.type:character string: partial matching to one of c("bytes", "chars", "width"). See ‘Details’.allowNA: logical, should NA be returned for invalid multibyte strings or "bytes"-encoded strings (rather than throwing an error)?keepNA:logical: should NA be returned wherever x is NA? max() function finds the maximum value among the data provided. Syntax: MAX(vector, rank = 1, value = FALSE, rank.adjust = TRUE, forceChoice = FALSE) Parameter: vector: Vector in which maximum/minimum element needs to be identifiedrank:value(s) or rank(s) of maximum values.value: Should value or rank be returned?rank.adjust: If the maximum value of a range of ranks exceeds vector length, should this be adjusted?forceChoice: In the case of ties, should all results be returned or only one? Example1: R gfg_data <- data.frame(x = c("geeks", "for", "geeks"), y = c("I", "Love", "Coding"), z=c("R", "programming ", "language")) max(nchar(gfg_data$y)) Output: [1] 6 Example 2: R gfg_data <- data.frame(x = c("geeks", "for", "geeks"), y = c("I", "Love", "Coding"), z=c("R", "programming ", "language")) max(nchar(gfg_data$z)) Output: [1] 12 Comment More infoAdvertise with us Next Article How to Get substring from a column in PySpark Dataframe ? G geetansh044 Follow Improve Article Tags : R Language R-DataFrame R DataFrame-Programs Similar Reads How to Loop Through Column Names in R dataframes? In this article, we will discuss how to loop through column names in dataframe in R Programming Language. Method 1: Using sapply() Here we are using sapply() function with some functions to get column names. This function will return column names with some results Syntax: sapply(dataframe,specific f 2 min read How to Get substring from a column in PySpark Dataframe ? In this article, we are going to see how to get the substring from the PySpark Dataframe column and how to create the new column and put the substring in that newly created column. We can get the substring of the column using substring() and substr() function. Syntax: substring(str,pos,len) df.col_n 3 min read Get Column Index in Data Frame by Variable Name in R R is an open-source programming language that is used as a statistical software and data analysis tool. In R Programming Language we can work on specific columns based on their names. In this article, we will learn different methods to extract the Get Column Index in Data Frame by Variable Name in R 5 min read How to Find the Longest or Shortest Text String in a Column in Excel? In this article, we will see how to find the longest or shortest text string in a column in Excel? Usually, for finding the longest or shortest string we can visit the all string in columns one by one and compare them to get results. This seems to work when you have less amount of data in an excel s 4 min read How to find length of matrix in R In this article, we will examine various methods to find the length of a matrix by using R Programming Language. What is a matrix?A matrix is a two-dimensional data structure that is a collection of rows and columns. A matrix can able to contain data of various types such as numeric, characters, and 4 min read How to check for a substring in a PySpark dataframe ? In this article, we are going to see how to check for a substring in PySpark dataframe. Substring is a continuous sequence of characters within a larger string size. For example, "learning pyspark" is a substring of "I am learning pyspark from GeeksForGeeks". Let us look at different ways in which w 5 min read Like