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.
df: Data frame to be converted.
Name Language Age 1 Amar R 26 2 Akbar Python 38 3 Ronald C# 22 Name Language Age [1, ] 2 3 26 [2, ] 1 2 38 [3, ] 3 1 22
x y z 1 A 1 1 2 D 2 2 3 C 3 3 4 A 4 4 5 B 1 5 6 B 2 6 7 A 3 7 8 C 4 8 x y z [1, ] 1 1 1 [2, ] 4 2 2 [3, ] 3 3 3 [4, ] 1 4 4 [5, ] 2 1 5 [6, ] 2 2 6 [7, ] 1 3 7 [8, ] 3 4 8
- Convert an Object to Data Frame in R Programming - as.data.frame() Function
- Check if the Object is a Data Frame in R Programming - is.data.frame() Function
- Convert a Data Frame into a Molten Form in R Programming - melt() Function
- Convert Factor to Numeric and Numeric to Factor in R Programming
- Check if an Object is of Type Numeric in R Programming - is.numeric() Function
- Get Transpose of a Matrix or Data Frame in R Programming - t() Function
- Modify Data of a Data Frame with an Expression in R Programming - with() Function
- Create Matrix and Data Frame from Lists in R Programming
- Convert an Object into a Matrix in R Programming - as.matrix() Function
- Accessing variables of a data frame in R Programming - attach() and detach() function
- Create a Data Frame of all the Combinations of Vectors passed as Argument in R Programming - expand.grid() Function
- Create Subsets of a Data frame in R Programming - subset() Function
- Rename Columns of a Data Frame in R Programming - rename() Function
- Choose Specific Columns of a Data Frame in R Programming - select() Function
- Add new Variables to a Data Frame using Existing Variables in R Programming - mutate() Function
- Condense Column Values of a Data Frame in R Programming - summarise() Function
- Take Random Samples from a Data Frame in R Programming - sample_n() Function
- Convert a Numeric Object to Character in R Programming - as.character() Function
- Creating a Data Frame from Vectors in R Programming
- Compute the Hyperbolic arctangent of numeric data in R Programming - atanh() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.