How to get the classes of all columns in a dataframe in R ? Last Updated : 16 May, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss how to find all the classes of the dataframe in R Programming Language. There are two methods to find the classes of columns in the dataframe. Using str() functionUsing lapply() function Method1 : Using str() function This function will return the class and value of the input data. Syntax: str(dataframe_name) Example: R program to create a dataframe and apply str() function. R # create vector with integer # elements a = c(7058, 7059, 7072, 7075) # create vector with floating # point elements c = c(98.00, 92.56, 90.00, 95.00) # pass these vectors as inputs to # the dataframe data = data.frame( id = a, percentage = c) print(data) # apply str function to get columns # class of the dataframe print(str(data)) Output: id percentage 1 7058 98.00 2 7059 92.56 3 7072 90.00 4 7075 95.00 'data.frame': 4 obs. of 2 variables: $ id : num 7058 7059 7072 7075 $ percentage: num 98 92.6 90 95 NULL Method 2: Using lapply() function lapply() function will result only the class of the dataframe column Syntax: lapply(data_frame_name,class) where: data_frame_name is the dataframe. R program to create the dataframe and use lapply() function to find a class. R # create vector with integer # elements a = c(7058, 7059, 7072, 7075) # create vector with string elements b = c("sravan", "jyothika", "harsha", "deepika") # create vector with floating point # elements c = c(98.00, 92.56, 90.00, 95.00) # pass these vectors as inputs to # the dataframe data = data.frame(id = a, names = b, percentage = c) print(data) # lapply function to get columns class # of the dataframe print(lapply(data, class)) Output: id names percentage 1 7058 sravan 98.00 2 7059 jyothika 92.56 3 7072 harsha 90.00 4 7075 deepika 95.00 $id [1] "numeric" $names [1] "factor" $percentage [1] "numeric" Comment More infoAdvertise with us Next Article How to get the classes of all columns in a dataframe in R ? S sravankumar_171fa07058 Follow Improve Article Tags : R Language R Programs R-DataFrame R DataFrame-Programs Similar Reads How to calculate the mode of all rows or columns from a dataframe in R ? In this article, we will discuss how to calculate the mode of all rows and columns from a dataframe in R Programming Language. Method 1: Using DescTools package The DescTools package in R is used to perform descriptive analysis. It contains a collection of miscellaneous basic statistic functions and 4 min read How to Add an Empty Column to DataFrame in R? In this article, we will discuss how to add an empty column to the dataframe in R Programming Language. Add One Empty Column to dataframe Here we are going to add an empty column to the dataframe by assigning column values as NA. Syntax: dataframe[ , 'column_name'] = NA where, dataframe  is the inpu 1 min read How to assign column names based on existing row in R DataFrame ? In this article, we will discuss how assign column names or headers to a DataFrame based on rows in R Programming Language. Method 1 : Using as.character() method unlist() method in R is used to simulate the conversion of a list to vector. It simplifies to produce a vector by preserving all componen 3 min read How to Select DataFrame Columns by Index in R? In this article, we will discuss how to select columns by index from a dataframe in R programming language. Note: The indexing of the columns in the R programming language always starts from 1. Method 1: Select Specific Columns By Index with Base R Here, we are going to select columns by using index 2 min read How to Extract a Column from R DataFrame to a List ? In this article, we will discuss how to extract a column from a DataFrame to a List in R Programming Language. Method 1: Converting all columns to list In this method, we are going to create a vector with character (names) and integer(marks) type data and passing to the student dataframe. Similarly, 2 min read Like