Creating Matrices using Data Frames - English
- Questions posted on Forums
- R Tutorials - English
-
TRUE MATRIX MULTIPLICATION
Hi,I have a doubt regarding true matrix multiplication.matrixA as per the video - 45,49,47,22,21,14,12,13,14 subdata <- captaincy[1:3,c("played","won","lost")] > matrixA <- as.matrix(subdata)> print(matrixA) played won lost [1] 45 22 12 [2] 49 21 13 [3] 47 14 14 matrixB - my own values <- c(1,0,1,1,0,1,0,1,0)> matrixB <- matrix(values,nrow=3,ncol=3,byrow=FALSE) print(matrixB) [,1] [,2] [,3] [1,] 1 1 0[2,] 0 0 1 [3,] 1 1 0 true matric multiplication - matrixA %*% matrixB - THE RESULTS I AM GETTING ARE - [,1] [,2] [,3] 1 57 57 22 2 62 62 21 3 61 61 14 THE RESULTS SHOWN IN THE VIDEO - (with matrixB values of his own <-c(1,0,0,0,1,0,0,0,1)) [,1] [,2] [,3] 1 45 22 12 2 49 21 13 3 47 14 14 Could you please explain where am I going wrong ? Thanks!
07-08M 50-60SMay 15, 2025, 3:45 p.m. PRANATHI_KALANGI
-
by enter the command as given in tutorial matrix didn't make
print(matrixB)Error in print(matrixB) : object 'matrixB' not foundTHE ABOVE LINE SHOWN BY R STUDIO WHILE MAKING MATRIX.
03-04M 10-20SMay 15, 2025, 8:19 a.m. tanishagoyal
-
Assignment
matrixB=matrix(nrow=4,ncol=2,data = c(9,10,11,12,13,14,15,16))print(matrixB) [,1] [,2][1,] 9 13[2,] 10 14[3,] 11 15[4,] 12 16Sir i have doubt if i type the above coding i am getting the above solution but the assignment was to create two vectors so i have the coding as x=c(9,10,11,12)y=c(13,14,15,16)matrixB=matrix(nrow=4,ncol=2,x,y) print(matrixB) [,1] [,2][1,] 9 10[2,] 11 12[3,] 9 10[4,] 11 12i am getting like above solution , pls correct me sir
10-11M 50-60SMay 14, 2025, 3:52 p.m. kajalmeena
-
Assignment
Is an assignment, for submission or practice? if it is for submission so how to submit?
09-10M 30-40SMay 15, 2025, 3:48 p.m. shiksha_saxena
-
Matrix multiplication
what is the difference between matrixA*matrixBmatrixA%*%matrixB
08-09M 20-30SMay 14, 2025, 11:14 p.m. bindukannan
-
what is %*%
what operation exactly perform ?
08-09M 10-20SMay 15, 2025, 3:33 p.m. nameisbond7@gmail.com
-
Assignment
Check for the assignment sirx=c(9,10,11,12) y=c(13,14,15,16) matrixA=matrix(x,y,nrow = 4,ncol = 2) print(matrixA) [,1] [,2] [1,] 9 10 [2,] 11 12 [3,] 9 10 [4,] 11 12
09-10M 40-50SMay 15, 2025, 3:36 p.m. Alamu
-
subdata
Sir in the current vidoe "subdata" you used small letter for data but in the previous lecture indexing and slicing for the subset you used " "subData". Is both correct sir
06-07M 20-30SMay 13, 2025, 12:28 p.m. Alamu
-
Print command
When should print command be used for displaying output and when is it not required? In this video, the author is using print(matrixB) command to obtain matrix output in Console window.However, in assignment solution, output is being obtained even without print command.How is it so?
06-07M 40-50SMay 14, 2025, 9:58 a.m. dsouzafleur@gmail.com
-
Creating Matrices using Data Frames
Is there an option to create matrix directly without creating a vector?
05-06M 50-60SMay 15, 2025, 3:59 p.m. angaiaruvi@gmail.com
-
MATRICES- Creating 3 X 3 IDENTITY MATRIX
I have encountered a problem in creating 3 x 3 identity matrix. #create a matrix of 3 rows and 3 columns using the following codevalues <- c(1,0,0,0,1,0,0,0,1)matrixB <- as.matrix(values, nrow = 3, ncol = 3, byrow = TRUE) print(matrixB)But output i am getting isprint(matrixB) [,1] [1,] 1 [2,] 0 [3,] 0 [4,] 0 [5,] 1 [6,] 0 [7,] 0 [8,] 0 [9,] 1Please tell me the solution..Thanks.
06-07M 30-40SMay 15, 2025, 4:29 a.m. annieahuja89@gmail.com
-
1Overview of R and RStudio
-
2Installing R and RStudio on Linux
-
3Installing R and RStudio on Windows
-
4Introduction to basics of R
-
5Introduction to Data Frames in R
-
6Introduction to RStudio
-
7Introduction to R script
-
8Working directories in RStudio
-
9Indexing and Slicing Data Frames
-
Creating Matrices using Data Frames
-
11Operations on Matrices and Data Frames
-
12Merging and Importing Data
-
13Data types and Factors
-
14Lists and its Operations
-
15Plotting Histograms and Pie Chart
-
16Plotting Bar Charts and Scatter Plot
-
17Introduction to ggplot2
-
18Aesthetic Mapping in ggplot2
-
19Data Manipulation using dplyr Package
-
20More Functions in dplyr Package
-
21Pipe Operator
-
22Conditional Statements
-
23Functions in R
Questions posted on ST Forums:
Outline:
Data required in a matrix format Convert a data frame into a matrix Create a matrix with known data Add two matrices Subtract two matrices Multiply two matrices elementwise Perform true matrix multiplication Calculate the transpose of a matrix Calculate the determinant of a matrix