x<-seq(1,39,2)
x
## [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39
#dim(x)<-c(4,5)
#x
x<-matrix(x,ncol=5)
x
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 9 17 25 33
## [2,] 3 11 19 27 35
## [3,] 5 13 21 29 37
## [4,] 7 15 23 31 39
s1<-c(rep("dark",5),rep("light",5))
#s1
s2<-c("king", "queen", "pawn", "pawn", "knight", "bishop", "king", "rook", "pawn", "pawn")
chess<-c(s1,s2)
#length(chess)
dim(chess)<-c(10,2)
colnames(chess)<-c("Pl","Pi")
chess
## Pl Pi
## [1,] "dark" "king"
## [2,] "dark" "queen"
## [3,] "dark" "pawn"
## [4,] "dark" "pawn"
## [5,] "dark" "knight"
## [6,] "light" "bishop"
## [7,] "light" "king"
## [8,] "light" "rook"
## [9,] "light" "pawn"
## [10,] "light" "pawn"
s.matr<-matrix(chess,ncol=2,dimnames=list(NULL,c("PL","PI")))
s.matr
## PL PI
## [1,] "dark" "king"
## [2,] "dark" "queen"
## [3,] "dark" "pawn"
## [4,] "dark" "pawn"
## [5,] "dark" "knight"
## [6,] "light" "bishop"
## [7,] "light" "king"
## [8,] "light" "rook"
## [9,] "light" "pawn"
## [10,] "light" "pawn"
c.bind<-cbind("PLL"=s1,"PII"=s2)
c.bind
## PLL PII
## [1,] "dark" "king"
## [2,] "dark" "queen"
## [3,] "dark" "pawn"
## [4,] "dark" "pawn"
## [5,] "dark" "knight"
## [6,] "light" "bishop"
## [7,] "light" "king"
## [8,] "light" "rook"
## [9,] "light" "pawn"
## [10,] "light" "pawn"
gdp<-matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,byrow = T,dimnames = list(c("de","usa","ind"),c("2014","2015","2016")))
gdp
## 2014 2015 2016
## de 1 2 3
## usa 4 5 6
## ind 7 8 9
exmpl<-matrix(1:10,nrow=4,ncol=4)
## Warning in matrix(1:10, nrow = 4, ncol = 4): äëèíà äàííûõ [10] íå ÿâëÿåòñÿ
## ìíîæèòåëåì êîëè÷åñòâà ñòðîê [4]
exmpl
## [,1] [,2] [,3] [,4]
## [1,] 1 5 9 3
## [2,] 2 6 10 4
## [3,] 3 7 1 5
## [4,] 4 8 2 6
gross<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
hp.mat<-matrix(gross,nrow=8,byrow=T)
hp.mat
## [,1] [,2]
## [1,] 1 2
## [2,] 3 4
## [3,] 5 6
## [4,] 7 8
## [5,] 9 10
## [6,] 11 12
## [7,] 13 14
## [8,] 15 16
hp.mat[6,2]
## [1] 12
hp.mat[6,]
## [1] 11 12
hp.mat[,1]
## [1] 1 3 5 7 9 11 13 15