-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrix.R
More file actions
38 lines (25 loc) · 787 Bytes
/
matrix.R
File metadata and controls
38 lines (25 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#matrics
m=matrix(c(1,2,3,4,5,6,7,8,9), nrow=3, ncol=3) #creeates a matrix. follow the syntax
m
?matrix
m1=matrix(1:12, nrow=4)
m1
marks3=floor(runif(30,50,90)) #30 values from uniform distribtuion btw 50 and 90
marks3
?runif
m2=matrix(marks3,nrow=6) #this prints column wise so 2nd element is below the first
m2
m3=matrix(marks3,nrow=6, byrow=T) #this prints row wise so 2nd element is next to the first
m3
(x=1:5) #mean the same thing. used to assign values.
(x1<-1:5)
colSums(m3) #sum of each column
rowSums((m3))
colMeans(m3) # calculates mean
rowMeans(m3)
sum(m3) # sum of all elemts
m3 [m3>75] #prints elemts greater thn 75
m3[1,] #prints 1st row
m3[,3] #prints 3rd column
m3[3,5] #3rd row n 5th coulmn elemeny ... so only one elemt
m3[1:2,3:5]