Convert an Object to Data Frame in R Programming - as.data.frame() Function Last Updated : 22 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report as.data.frame() function in R Programming Language is used to convert an object to data frame. These objects can be Vectors, Lists, Matrices, and Factors. Syntax: as.data.frame(object) Parameters: object: Vector, Matrix, factor, or data frameR - as.data.frame() Function ExampleExample 1: Basic example of as.data.frame() Function in R R # R program to convert object to data frame # Creating Vectors x1 <- c(1, 2, 3, 4) x2 <- c("a", "B", "C", "D") x3 <- c("hello", "Geeks", "for", "geeks") # Creating list of vectors x <- list(col1 = x1, col2 = x2, col2 = x3) x # Converting list to data frame as.data.frame(x) Output: $col1 [1] 1 2 3 4 $col2 [1] "a" "B" "C" "D" $col2 [1] "hello" "Geeks" "for" "geeks" col1 col2 col2.1 1 1 a hello 2 2 B Geeks 3 3 C for 4 4 D geeks Example 2: R # R program to convert object to list # Converting pre-defined dataset to list x < - as.list(BOD) x # Converting list to data frame as.data.frame(x) Output: $Time [1] 1 2 3 4 5 7 $demand [1] 8.3 10.3 19.0 16.0 15.6 19.8 attr(, "reference") [1] "A1.4, p. 270" Time demand 1 1 8.3 2 2 10.3 3 3 19.0 4 4 16.0 5 5 15.6 6 7 19.8 Comment More infoAdvertise with us Next Article Check if the Object is a Data Frame in R Programming - is.data.frame() Function N nidhi_biet Follow Improve Article Tags : R Language R DataFrame-Function Similar Reads Check if the Object is a Data Frame in R Programming - is.data.frame() Function is.data.frame() function in R Language is used to return TRUE if the specified data type is a data frame else return FALSE. R data.frame is a powerful data type, especially when processing table (.csv). It can store the data as row and columns according to the table. Syntax: is.data.frame(x) Paramet 1 min read Convert an Object to List in R Programming - as.list() Function as.list() function in R Programming Language is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and dataframes. Syntax: as.list(object) Parameters: object: Vector, Matrix, factor, or data frame R - as.list() Function ExampleExample 1: Converting Vector to list 2 min read Convert a Data Frame into a Numeric Matrix in R Programming - data.matrix() Function data.matrix() function in R Language is used to create a matrix by converting all the values of a Data Frame into numeric mode and then binding them as a matrix. Syntax: data.matrix(df) Parameters: df: Data frame to be converted. Example 1: Python3 1== # R program to convert a data frame # into a nu 2 min read Convert a Vector into Factor in R Programming - as.factor() Function as.factor() function in R Programming Language is used to convert the passed object(usually Vector) into a Factor. Syntax: as.factor(object) Parameters: Object: Vector to be convertedas.factor() Function in R ExampleExample 1: Convert a Factor in RR # Creating a vector x<-c("female", "male", "ma 1 min read Convert an Object to a Table in R Programming - as.table() Function as.table() function in R Language is used to convert an object into a table. Syntax: as.table(x) Parameters: x: Object to be converted Example 1: Python3 1== # R Program to convert # an object to a table # Creating a vector vec = c(2, 4, 3, 1, 2, 3, 2, 1, 4, 2) # Calling as.table() Function as.table 1 min read Convert type of data object in R Programming - type.convert() Function type.convert() function in R Language is used to compute the data type of a particular data object. It can convert data object to logical, integer, numeric, or factor. Syntax: type.convert(x) Parameter: x: It can be a vector matrix or an array Example 1: Apply type.convert to vector of numbers Pytho 2 min read Like