You are on page 1of 12

R version 3.6.

0 (2019-04-26) -- "Planting of a Tree"


Copyright (C) 2019 The R Foundation for Statistical
Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO


WARRANTY.
You are welcome to redistribute it under certain
conditions.
Type 'license()' or 'licence()' for distribution
details.

Natural language support but running in an English


locale

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in
publications.

Type 'demo()' for some demos, 'help()' for on-line


help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

During startup - Warning messages:


1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_MONETARY failed, using "C"
[R.app GUI 1.70 (7657) x86_64-apple-darwin15.6.0]

WARNING: You're using a non-UTF8 locale, therefore only


ASCII characters will work.
Please read R for Mac OS X FAQ (see Help) section 9 and
adjust your system preferences accordingly.
[History restored from /Users/victor/.Rapp.history]

> a1<-c(1,2,3,4)
> a2<-c(5,6,7,8)
> a3<-c(9,10,11,12)
> a<-(a1,a2,a3)
Error: unexpected ',' in "a<-(a1,"
> a<-c(a1,a2,a3)
> a
[1] 1 2 3 4 5 6 7 8 9 10 11 12
> ma<-cbind(a1,a2,a3)
> ma
a1 a2 a3
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> dim(ma)
[1] 4 3
> na<-matrix(a,ncol=3,byrow=F)
> na
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> la<-matrix(a,ncol=3,byrow=T)
> la
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
[4,] 10 11 12
> ka<-matrix(a,4,3)
> ka
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> dim(a)<-c(4,3)
> a
[,1] [,2] [,3]
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> ja<-matrix(scan(),ncol=3,byow=T)
Error in matrix(scan(), ncol = 3, byow = T) : unused
argument (byow = T)
> ja<-matrix(scan(), ncol=3, byow=T)
Error in matrix(scan(), ncol = 3, byow = T) : unused
argument (byow = T)
> ja<-matrix(scan(),ncol=3,byrow=T)
1: ja
1: 1 5 9
Error in scan() : scan() expected 'a real', got 'ja'
> ja<-matrix(scan(),ncol=3,byrow=T)
1: 1 2 3
4: 4 5 6
7: 7 8 9
10: 10 11 12
13:
Read 12 items
> ja
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
[4,] 10 11 12
> dimnames(ma)<-list(NULL,c("Enero","Febrero","Marzo"))
> ma
Enero Febrero Marzo
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> nomcol<-c("Octubre","Noviembre","Diciembre")
> dimanes(ja)<-list(NULL,nomcol)
Error in dimanes(ja) <- list(NULL, nomcol) :
could not find function "dimanes<-"
> dimnames(ja)<-list(NULL,nomcol)
>
> ja
Octubre Noviembre Diciembre
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
[4,] 10 11 12
> dinames(a)<-list(c("Fila #1","Fila #2","Fila
#3","Fila #4"),NULL)
Error in dinames(a) <- list(c("Fila #1", "Fila #2",
"Fila #3", "Fila #4"), :
could not find function "dinames<-"
> dimnames(a)<-list(c("Fila #1","Fila #2","Fila
#3","Fila #4"),NULL)
> a
[,1] [,2] [,3]
Fila #1 1 5 9
Fila #2 2 6 10
Fila #3 3 7 11
Fila #4 4 8 12
> nomcol<-c("Puto","El que","Lo lea")
> nomfilas<-c("Waro","Perico","Poper","Tuzi y Sexo")
> dimnames(ka)<-list(nomfilas,nomcol)
> ka
Puto El que Lo lea
Waro 1 5 9
Perico 2 6 10
Poper 3 7 11
Tuzi y Sexo 4 8 12
> la
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
[4,] 10 11 12
> pa<-
matrix(a,nrow4,byrow=F,dimnames=list(nomfilas,nomcol))
Error in matrix(a, nrow4, byrow = F, dimnames =
list(nomfilas, nomcol)) :
object 'nrow4' not found
> a<-matrix(a,nrow=44,byrow=F,
dimnames=list(nomfilas,nomcol))
Error in matrix(a, nrow = 44, byrow = F, dimnames =
list(nomfilas, nomcol)) :
length of 'dimnames' [1] not equal to array extent
In addition: Warning message:
In matrix(a, nrow = 44, byrow = F, dimnames =
list(nomfilas, nomcol)) :
data length [12] is not a sub-multiple or multiple of
the number of rows [44]
> ja<-matrix(a,nrow=44,byrow=F,
dimnames=list(nomfilas,nomcol))
Error in matrix(a, nrow = 44, byrow = F, dimnames =
list(nomfilas, nomcol)) :
length of 'dimnames' [1] not equal to array extent
In addition: Warning message:
In matrix(a, nrow = 44, byrow = F, dimnames =
list(nomfilas, nomcol)) :
data length [12] is not a sub-multiple or multiple of
the number of rows [44]
> ja<-matrix(a,nrow=4,byrow=F,
dimnames=list(nomfilas,nomcol))
> ja
Puto El que Lo lea
Waro 1 5 9
Perico 2 6 10
Poper 3 7 11
Tuzi y Sexo 4 8 12
> ma + mb
Error: object 'mb' not found
> ma + ja
Enero Febrero Marzo
[1,] 2 10 18
[2,] 4 12 20
[3,] 6 14 22
[4,] 8 16 24
> ma % ja
Error: unexpected input in "ma % ja"
> ma * ja
Enero Febrero Marzo
[1,] 1 25 81
[2,] 4 36 100
[3,] 9 49 121
[4,] 16 64 144
> ma
Enero Febrero Marzo
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> ja
Puto El que Lo lea
Waro 1 5 9
Perico 2 6 10
Poper 3 7 11
Tuzi y Sexo 4 8 12
> ma*ja
Enero Febrero Marzo
[1,] 1 25 81
[2,] 4 36 100
[3,] 9 49 121
[4,] 16 64 144
> ma # ja
Enero Febrero Marzo
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> ma%%ja
Enero Febrero Marzo
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
[4,] 0 0 0
> ma%ja
Error: unexpected input in "ma%ja"
> ma % ja
Error: unexpected input in "ma % ja"
> ma & ja
Enero Febrero Marzo
[1,] TRUE TRUE TRUE
[2,] TRUE TRUE TRUE
[3,] TRUE TRUE TRUE
[4,] TRUE TRUE TRUE
> ma - ja
Enero Febrero Marzo
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
[4,] 0 0 0
> x<-1:100
> xa<-matrix(x,20)
> xa
[,1] [,2] [,3] [,4] [,5]
[1,] 1 21 41 61 81
[2,] 2 22 42 62 82
[3,] 3 23 43 63 83
[4,] 4 24 44 64 84
[5,] 5 25 45 65 85
[6,] 6 26 46 66 86
[7,] 7 27 47 67 87
[8,] 8 28 48 68 88
[9,] 9 29 49 69 89
[10,] 10 30 50 70 90
[11,] 11 31 51 71 91
[12,] 12 32 52 72 92
[13,] 13 33 53 73 93
[14,] 14 34 54 74 94
[15,] 15 35 55 75 95
[16,] 16 36 56 76 96
[17,] 17 37 57 77 97
[18,] 18 38 58 78 98
[19,] 19 39 59 79 99
[20,] 20 40 60 80 100
> rownames(xa)<-rownames(xa,do.NULL=F,prefix="Fila.")
> xa
[,1] [,2] [,3] [,4] [,5]
Fila.1 1 21 41 61 81
Fila.2 2 22 42 62 82
Fila.3 3 23 43 63 83
Fila.4 4 24 44 64 84
Fila.5 5 25 45 65 85
Fila.6 6 26 46 66 86
Fila.7 7 27 47 67 87
Fila.8 8 28 48 68 88
Fila.9 9 29 49 69 89
Fila.10 10 30 50 70 90
Fila.11 11 31 51 71 91
Fila.12 12 32 52 72 92
Fila.13 13 33 53 73 93
Fila.14 14 34 54 74 94
Fila.15 15 35 55 75 95
Fila.16 16 36 56 76 96
Fila.17 17 37 57 77 97
Fila.18 18 38 58 78 98
Fila.19 19 39 59 79 99
Fila.20 20 40 60 80 100
> colnames(xa)<-paste("mes",seq(1,dim(xa)[2]),sep="")
> xa
mes1 mes2 mes3 mes4 mes5
Fila.1 1 21 41 61 81
Fila.2 2 22 42 62 82
Fila.3 3 23 43 63 83
Fila.4 4 24 44 64 84
Fila.5 5 25 45 65 85
Fila.6 6 26 46 66 86
Fila.7 7 27 47 67 87
Fila.8 8 28 48 68 88
Fila.9 9 29 49 69 89
Fila.10 10 30 50 70 90
Fila.11 11 31 51 71 91
Fila.12 12 32 52 72 92
Fila.13 13 33 53 73 93
Fila.14 14 34 54 74 94
Fila.15 15 35 55 75 95
Fila.16 16 36 56 76 96
Fila.17 17 37 57 77 97
Fila.18 18 38 58 78 98
Fila.19 19 39 59 79 99
Fila.20 20 40 60 80 100
>
> xa
mes1 mes2 mes3 mes4 mes5
Fila.1 1 21 41 61 81
Fila.2 2 22 42 62 82
Fila.3 3 23 43 63 83
Fila.4 4 24 44 64 84
Fila.5 5 25 45 65 85
Fila.6 6 26 46 66 86
Fila.7 7 27 47 67 87
Fila.8 8 28 48 68 88
Fila.9 9 29 49 69 89
Fila.10 10 30 50 70 90
Fila.11 11 31 51 71 91
Fila.12 12 32 52 72 92
Fila.13 13 33 53 73 93
Fila.14 14 34 54 74 94
Fila.15 15 35 55 75 95
Fila.16 16 36 56 76 96
Fila.17 17 37 57 77 97
Fila.18 18 38 58 78 98
Fila.19 19 39 59 79 99
Fila.20 20 40 60 80 100
> t(ma)
[,1] [,2] [,3] [,4]
Enero 1 2 3 4
Febrero 5 6 7 8
Marzo 9 10 11 12
> t(ja)
Waro Perico Poper Tuzi y Sexo
Puto 1 2 3 4
El que 5 6 7 8
Lo lea 9 10 11 12
> vecfila<-m[2,]
Error: object 'm' not found
> vecfila<-ma[2,]
> veccol<-ma[,1]
> vecfila
Enero Febrero Marzo
2 6 10
> veccol
[1] 1 2 3 4
> b<-1:45
> b
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[17] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
[33] 33 34 35 36 37 38 39 40 41 42 43 44 45
> ma+4
Enero Febrero Marzo
[1,] 5 9 13
[2,] 6 10 14
[3,] 7 11 15
[4,] 8 12 16
> ma4
Error: object 'ma4' not found
> ma*3
Enero Febrero Marzo
[1,] 3 15 27
[2,] 6 18 30
[3,] 9 21 33
[4,] 12 24 36
> ma+3
Enero Febrero Marzo
[1,] 4 8 12
[2,] 5 9 13
[3,] 6 10 14
[4,] 7 11 15
> ma
Enero Febrero Marzo
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> ja%*%ma
Error in ja %*% ma : non-conformable arguments
> ma%*%ja
Error in ma %*% ja : non-conformable arguments
> ma%*%ma
Error in ma %*% ma : non-conformable arguments
> ja
Puto El que Lo lea
Waro 1 5 9
Perico 2 6 10
Poper 3 7 11
Tuzi y Sexo 4 8 12
> ma
Enero Febrero Marzo
[1,] 1 5 9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12
> ma%*%t(ma)
[,1] [,2] [,3] [,4]
[1,] 107 122 137 152
[2,] 122 140 158 176
[3,] 137 158 179 200
[4,] 152 176 200 224
>

You might also like