Matrices

an anonymous user · January 23, 2021 · R
assign(r,c(3,7,8,9))
Error in assign(r, c(3, 7, 8, 9)) : invalid first argument
assign("r",c(3,7,8,9))
r
[1] 3 7 8 9
a
[1] 6
v1<-c(6,8,9,10,2,5,46,12)
v1
[1]  6  8  9 10  2  5 46 12
max(v1)
[1] 46
min(v1)
[1] 2
sort(v1)
[1]  2  5  6  8  9 10 12 46
prod(v1)
[1] 23846400
mean(v1)
[1] 12.25
sum(v1)
[1] 98
length(v1)
[1] 8
1:10
 [1]  1  2  3  4  5  6  7  8  9 10
3*1:10
 [1]  3  6  9 12 15 18 21 24 27 30
12*1:10
 [1]  12  24  36  48  60  72  84  96 108 120
15*1:10
 [1]  15  30  45  60  75  90 105 120 135 150
2:10
[1]  2  3  4  5  6  7  8  9 10
2*2:10
[1]  4  6  8 10 12 14 16 18 20
seq(1,10)
 [1]  1  2  3  4  5  6  7  8  9 10
seq(1,10,0.5)
 [1]  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0  7.5  8.0
[16]  8.5  9.0  9.5 10.0
seq(2,10,2)
[1]  2  4  6  8 10
2:10
[1]  2  3  4  5  6  7  8  9 10
s1<-seq(1,10,0.5)
s1
 [1]  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0  7.5  8.0
[16]  8.5  9.0  9.5 10.0
rep(s1,times=3)
 [1]  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0  7.5  8.0
[16]  8.5  9.0  9.5 10.0  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0
[31]  6.5  7.0  7.5  8.0  8.5  9.0  9.5 10.0  1.0  1.5  2.0  2.5  3.0  3.5  4.0
[46]  4.5  5.0  5.5  6.0  6.5  7.0  7.5  8.0  8.5  9.0  9.5 10.0
rep(s1,each=3)
 [1]  1.0  1.0  1.0  1.5  1.5  1.5  2.0  2.0  2.0  2.5  2.5  2.5  3.0  3.0  3.0
[16]  3.5  3.5  3.5  4.0  4.0  4.0  4.5  4.5  4.5  5.0  5.0  5.0  5.5  5.5  5.5
[31]  6.0  6.0  6.0  6.5  6.5  6.5  7.0  7.0  7.0  7.5  7.5  7.5  8.0  8.0  8.0
[46]  8.5  8.5  8.5  9.0  9.0  9.0  9.5  9.5  9.5 10.0 10.0 10.0
a1<-c(4,6,7)
a2<-c(7,8,9)
a1>a2
[1] FALSE FALSE FALSE
a1==a2
[1] FALSE FALSE FALSE
a2>a1
[1] TRUE TRUE TRUE
p<-paste("A",1:5,sep="")
p
[1] "A1" "A2" "A3" "A4" "A5"
val<-1:12
dim(val)<-c(4,3)
val
     [,1] [,2] [,3]
[1,]    1    5    9
[2,]    2    6   10
[3,]    3    7   11
[4,]    4    8   12

Comments

Please sign up or log in to contribute to the discussion.