How to get the maximum and minimum length of character strings in a particular data frame column in the R programming language. More details: statisticsglob...
R code of this video:
data <- data.frame(x1 = c("Lala", "Lo", "Lelele"), # Create example data
x2 = c("Hi", "Hello", "Hey"),
x3 = c("aaa", "bbbbbb", "cccc"))
nchar(data$x1) # Length of strings in one column
apply(data, 2, nchar) # Length of strings in all columns
max(nchar(data$x1)) # Maximum length of string in one column
min(nchar(data$x1)) # Minimum length of string in one column
apply(data, 2, function(x) max(nchar(x))) # Maximum length of string in all columns
apply(data, 2, function(x) min(nchar(x))) # Minimum length of string in all columns
Follow me on Social Media:
Facebook: / statisticsglobecom
LinkedIn: / statisticsglobe
Twitter: / joachimschork
Негізгі бет Find Max & Min Length of Character Strings in Columns in R (4 Examples) | nchar, apply, max & min
No video
Пікірлер: 2