Convert Matrix to Dataframe in R Last Updated : 09 May, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss how to convert the matrix into DataFrame, or we can also say that we will discuss how to create a DataFrame from a matrix in R Programming Language. A matrix can be converted to a dataframe by using a function called as.data.frame(). It will take each column from the matrix and convert it to each column in the dataframe. Syntax: as.data.frame(matrix_data) Where, matrix_data is the input matrix. Example 1: R # create the matrix with 4 rows # with numeric elements matrix_data=matrix(c(1,2,3,4,5,6,7,8),nrow=4) # display the data print(matrix_data) # convert the matrix into dataframe dataframe_data=as.data.frame(matrix_data) # print dataframe data print(dataframe_data) Output: Example 2: R # create the matrix with 8 rows # with numeric elements matrix_data=matrix(c(1,2,3,4,5,6,7,8,11:18),nrow=8) # display the data print(matrix_data) # convert the matrix into dataframe dataframe_data=as.data.frame(matrix_data) # print dataframe data print(dataframe_data) Output: Example 3: R # create the matrix with 8 rows # with different elements matrix_data=matrix(c( "bobby","pinkey","rohith","gnanesh",5.3,6.6,7,8,11:18),nrow=8) # display the data print(matrix_data) # convert the matrix into dataframe dataframe_data=as.data.frame(matrix_data) # print dataframe data print(dataframe_data) Output: Comment More infoAdvertise with us Next Article Convert list of lists to dataframe in R G gottumukkalabobby Follow Improve Article Tags : R Language R Programs R-DataFrame R DataFrame-Programs Similar Reads Convert large list to dataframe in R In this article, we will discuss how to convert a large list to a dataframe in the R Programming Language. Method 1 : Using rbindlist() First, create a large list. Then use the Map function on the list and convert it to dataframe using the as.data.frame function in R. The map function applies a fun 3 min read Convert DataFrame Column to Numeric in R In this article, we are going to see how to convert DataFrame Column to Numeric in R Programming Language. All dataframe column is associated with a class which is an indicator of the data type to which the elements of that column belong to. Therefore, in order to simulate the data type conversion, 9 min read Convert list of lists to dataframe in R In this article, we will discuss how to convert a list of lists to dataframe in R Programming Language. We will convert a list of lists to a data frame both by row and by column. Example 1: R program to create three lists inside a list with numeric and character type and convert into dataframe by co 2 min read Convert dataframe column to list in R In this article, we will learn how to convert a dataframe into a list by columns in R Programming language. We will be using as.list() function, this function is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and data frames. Syntax: as.list( object ) Parameter 2 min read Convert DataFrame to Matrix with Column Names in R Data frames and matrices are R objects, both of which allow tabular storage of the data into well organized cells. However, the data in a data frame can consist of different data types, that is the cells may contain data belonging to a combination of data types. Matrices, on the other hand, strictly 3 min read Convert Named Vector to DataFrame in R In this article, we will see how to convert the named vector to Dataframe in the R Programming Language. Method 1: Generally while converting a named vector to a dataframe we may face a problem. That is, names of vectors may get converted into row names, and data may be converted into a single colu 1 min read Like