Extracción de datos

Dat(D,r,c)
D:Matriz de datos,r=filas asignadas,c=columnas asignadas

D=Ip('s4') #Ejemplo sencillo: Puntaje de 4 personas
## File: s4.txt / Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
Dat(r='1,3') #r: Asignar número(s) de fila
##         v1.English v2.Physics v3.Latin
## i1.Ana           9         14       18
## i3.Mary         15         13       14
Dat(r='i1,i3') #r: Asignar inicial(es) de fila
##         v1.English v2.Physics v3.Latin
## i1.Ana           9         14       18
## i3.Mary         15         13       14
Dat(c='1,2') #c: Asignar número(s) de columna
##         v1.English v2.Physics
## i1.Ana           9         14
## i2.Juan         17          7
## i3.Mary         15         13
## i4.Ken           5         18

Extracción de datos de acuerdo con condiciones

D=diamonds; Dt() #Datos: diamonds
## Class: tbl_df, tbl, data.frame / Rows: 53940 / Columns: 10
##  
##    carat cut       color clarity depth table price x    y    z   
## 1  0.23  Ideal     E     SI2     61.5  55    326   3.95 3.98 2.43
## 2  0.21  Premium   E     SI1     59.8  61    326   3.89 3.84 2.31
## 3  0.23  Good      E     VS1     56.9  65    327   4.05 4.07 2.31
## 4  0.29  Premium   I     VS2     62.4  58    334   4.20 4.23 2.63
## 5  0.31  Good      J     SI2     63.3  58    335   4.34 4.35 2.75
## 6  0.24  Very Good J     VVS2    62.8  57    336   3.94 3.96 2.48
## 7  0.24  Very Good I     VVS1    62.3  57    336   3.95 3.98 2.47
## 8  0.26  Very Good H     SI1     61.9  55    337   4.07 4.11 2.53
## 9  0.22  Fair      E     VS2     65.1  61    337   3.87 3.78 2.49
## 10 0.23  Very Good H     VS1     59.4  61    338   4.00 4.05 2.39
Dat(D,'ca>=0.5') # Condición: ca(rat)>=0.5
## # A tibble: 36,266 x 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  0.7  Ideal     E     SI1      62.5    57  2757  5.7   5.72  3.57
##  2  0.86 Fair      E     SI2      55.1    69  2757  6.45  6.33  3.52
##  3  0.7  Ideal     G     VS2      61.6    56  2757  5.7   5.67  3.5 
##  4  0.71 Very Good E     VS2      62.4    57  2759  5.68  5.73  3.56
##  5  0.78 Very Good G     SI2      63.8    56  2759  5.81  5.85  3.72
##  6  0.7  Good      E     VS2      57.5    58  2759  5.85  5.9   3.38
##  7  0.7  Good      F     VS1      59.4    62  2759  5.71  5.76  3.4 
##  8  0.96 Fair      F     SI2      66.3    62  2759  6.27  5.95  4.07
##  9  0.73 Very Good E     SI1      61.6    59  2760  5.77  5.78  3.56
## 10  0.8  Premium   H     SI1      61.5    58  2760  5.97  5.93  3.66
## # ... with 36,256 more rows
Dat(D,'v1>=0.5') # (Id)
## # A tibble: 36,266 x 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  0.7  Ideal     E     SI1      62.5    57  2757  5.7   5.72  3.57
##  2  0.86 Fair      E     SI2      55.1    69  2757  6.45  6.33  3.52
##  3  0.7  Ideal     G     VS2      61.6    56  2757  5.7   5.67  3.5 
##  4  0.71 Very Good E     VS2      62.4    57  2759  5.68  5.73  3.56
##  5  0.78 Very Good G     SI2      63.8    56  2759  5.81  5.85  3.72
##  6  0.7  Good      E     VS2      57.5    58  2759  5.85  5.9   3.38
##  7  0.7  Good      F     VS1      59.4    62  2759  5.71  5.76  3.4 
##  8  0.96 Fair      F     SI2      66.3    62  2759  6.27  5.95  4.07
##  9  0.73 Very Good E     SI1      61.6    59  2760  5.77  5.78  3.56
## 10  0.8  Premium   H     SI1      61.5    58  2760  5.97  5.93  3.66
## # ... with 36,256 more rows
Dat(D,'ca>=0.5,ca<0.8') # Condición múltiple: ca dentro del rango [0.5,0.8]
## # A tibble: 13,453 x 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  0.7  Ideal     E     SI1      62.5    57  2757  5.7   5.72  3.57
##  2  0.7  Ideal     G     VS2      61.6    56  2757  5.7   5.67  3.5 
##  3  0.71 Very Good E     VS2      62.4    57  2759  5.68  5.73  3.56
##  4  0.78 Very Good G     SI2      63.8    56  2759  5.81  5.85  3.72
##  5  0.7  Good      E     VS2      57.5    58  2759  5.85  5.9   3.38
##  6  0.7  Good      F     VS1      59.4    62  2759  5.71  5.76  3.4 
##  7  0.73 Very Good E     SI1      61.6    59  2760  5.77  5.78  3.56
##  8  0.75 Very Good D     SI1      63.2    56  2760  5.8   5.75  3.65
##  9  0.75 Premium   E     SI1      59.9    54  2760  6     5.96  3.58
## 10  0.74 Ideal     G     SI1      61.6    55  2760  5.8   5.85  3.59
## # ... with 13,443 more rows
Dat(D,'ca>=0.5,ca<0.8,co=E') #Id. + co(lor)=E
## # A tibble: 3,022 x 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  0.7  Ideal     E     SI1      62.5    57  2757  5.7   5.72  3.57
##  2  0.71 Very Good E     VS2      62.4    57  2759  5.68  5.73  3.56
##  3  0.7  Good      E     VS2      57.5    58  2759  5.85  5.9   3.38
##  4  0.73 Very Good E     SI1      61.6    59  2760  5.77  5.78  3.56
##  5  0.75 Premium   E     SI1      59.9    54  2760  6     5.96  3.58
##  6  0.59 Ideal     E     VVS2     62      55  2761  5.38  5.43  3.35
##  7  0.74 Ideal     E     SI2      62.2    56  2761  5.8   5.84  3.62
##  8  0.7  Ideal     E     VS2      60.7    58  2762  5.73  5.76  3.49
##  9  0.74 Ideal     E     SI1      62.3    54  2762  5.8   5.83  3.62
## 10  0.7  Very Good E     VS2      62.6    60  2765  5.62  5.65  3.53
## # ... with 3,012 more rows
Dat(D,'cl#^S') # cl(arity) ExpReg.=^S
## # A tibble: 22,259 x 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  0.23 Ideal     E     SI2      61.5    55   326  3.95  3.98  2.43
##  2  0.21 Premium   E     SI1      59.8    61   326  3.89  3.84  2.31
##  3  0.31 Good      J     SI2      63.3    58   335  4.34  4.35  2.75
##  4  0.26 Very Good H     SI1      61.9    55   337  4.07  4.11  2.53
##  5  0.3  Good      J     SI1      64      55   339  4.25  4.28  2.73
##  6  0.22 Premium   F     SI1      60.4    61   342  3.88  3.84  2.33
##  7  0.31 Ideal     J     SI2      62.2    54   344  4.35  4.37  2.71
##  8  0.2  Premium   E     SI2      60.2    62   345  3.79  3.75  2.27
##  9  0.3  Ideal     I     SI2      62      54   348  4.31  4.34  2.68
## 10  0.3  Good      J     SI1      63.4    54   351  4.23  4.29  2.7 
## # ... with 22,249 more rows
D=Ip('dle') #Datos: dle.txt (lemas de DLE(RAE))
## File: dle.txt / Class: data.frame / Rows: 87532 / Columns: 4
##  
##    Forma     Ac CV Fin
## 1  a         0  V  a  
## 2  aba       2  V  a  
## 3  abaá      1  V  a  
## 4  ababol    1  C  l  
## 5  abacá     1  V  a  
## 6  abacal    1  C  l  
## 7  abacalero 2  V  o  
## 8  abacería  2  V  a  
## 9  abacero   2  V  o  
## 10 abacial   1  C  l
E=Dat(D,'Fo#a$'); Dt(E) #Exp.Reg.: Fo(rma) con (a$)
## Class: data.frame / Rows: 18531 / Columns: 4
##  
##    Forma    Ac CV Fin
## 1  a        0  V  a  
## 2  aba      2  V  a  
## 8  abacería 2  V  a  
## 12 abacora  2  V  a  
## 15 abada    2  V  a  
## 19 abadesa  2  V  a  
## 21 abadía   2  V  a  
## 28 abajera  2  V  a  
## 31 abalada  2  V  a  
## 43 ábana    3  V  a
E=Dat(D,'Fo#graf'); Dt(E) #Exp.Reg.: Fo(rma) con (a$)
## Class: data.frame / Rows: 292 / Columns: 4
##  
##      Forma            Ac CV Fin
## 1983 aerocriptografía 2  V  a  
## 1998 aerofotografía   2  V  a  
## 2000 aerografía       2  V  a  
## 2002 aerógrafo        3  V  o  
## 2532 agrafe           2  V  e  
## 2533 agrafia          2  V  a  
## 2534 ágrafo           3  V  o  
## 5516 ampelografía     2  V  a  
## 5518 ampelógrafo      3  V  o  
## 5938 anemografía      2  V  a
E=Dat(s='Fo#graf'); Dt(E) #Exp.Reg.: Fo(rma) con (graf)
## Class: data.frame / Rows: 292 / Columns: 4
##  
##      Forma            Ac CV Fin
## 1983 aerocriptografía 2  V  a  
## 1998 aerofotografía   2  V  a  
## 2000 aerografía       2  V  a  
## 2002 aerógrafo        3  V  o  
## 2532 agrafe           2  V  e  
## 2533 agrafia          2  V  a  
## 2534 ágrafo           3  V  o  
## 5516 ampelografía     2  V  a  
## 5518 ampelógrafo      3  V  o  
## 5938 anemografía      2  V  a
E=Dat(D,'Ac=1,CV=V'); Dt(E) #Exp.Reg.: A con 1, CV con V
## Class: data.frame / Rows: 971 / Columns: 4
##  
##     Forma   Ac CV Fin
## 3   abaá    1  V  a  
## 5   abacá   1  V  a  
## 20  abadí   1  V  i  
## 30  abakuá  1  V  a  
## 102 abasí   1  V  i  
## 117 abatí   1  V  i  
## 134 abecé   1  V  e  
## 283 abonaré 1  V  e  
## 482 abudabí 1  V  i  
## 538 acá     1  V  a

Reordenación y ordenación

Reordenación de filas/columnas

D=Ip('x45') #Ejemplo sencillo: Matriz(4x5)
## File: x45.txt / Class: data.frame / Rows: 4 / Columns: 5
##  
##    A  B  C  D  E 
## w1 10 19 14  7 12
## w2 11  7 10  0  1
## w3  0  0  1 12  1
## w4  0  1  2  3  3
Dat(r='2,1,3,4') #Reordenación de filas
##     A  B  C  D  E
## w2 11  7 10  0  1
## w1 10 19 14  7 12
## w3  0  0  1 12  1
## w4  0  1  2  3  3
Dat(c='2,1,3,4,5') #Reordenación de columnas
##     B  A  C  D  E
## w1 19 10 14  7 12
## w2  7 11 10  0  1
## w3  0  0  1 12  1
## w4  1  0  2  3  3
Dat(c='B,A,C,D,E') #Id.
##     B  A  C  D  E
## w1 19 10 14  7 12
## w2  7 11 10  0  1
## w3  0  0  1 12  1
## w4  1  0  2  3  3
Dat(c=5:1) #Reordenación inversa (5:1=5,4,3,2,1)
##     E  D  C  B  A
## w1 12  7 14 19 10
## w2  1  0 10  7 11
## w3  1 12  1  0  0
## w4  3  3  2  1  0
D=iris; Dt(cn=T) #Datos: iris, representar rótulos de columna
## Class: data.frame / Rows: 150 / Columns: 5
##  
##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1  5.1          3.5         1.4          0.2         setosa 
## 2  4.9          3.0         1.4          0.2         setosa 
## 3  4.7          3.2         1.3          0.2         setosa 
## 4  4.6          3.1         1.5          0.2         setosa 
## 5  5.0          3.6         1.4          0.2         setosa 
## 6  5.4          3.9         1.7          0.4         setosa 
## 7  4.6          3.4         1.4          0.3         setosa 
## 8  5.0          3.4         1.5          0.2         setosa 
## 9  4.4          2.9         1.4          0.2         setosa 
## 10 4.9          3.1         1.5          0.1         setosa 
## 
## Column names: 1.Sepal.Length 2.Sepal.Width 3.Petal.Length 4.Petal.Width 5.Species
D=Dat(c='5,1,2'); Dt() #Reordenación y selección
## Class: data.frame / Rows: 150 / Columns: 3
##  
##    Species Sepal.Length Sepal.Width
## 1  setosa  5.1          3.5        
## 2  setosa  4.9          3.0        
## 3  setosa  4.7          3.2        
## 4  setosa  4.6          3.1        
## 5  setosa  5.0          3.6        
## 6  setosa  5.4          3.9        
## 7  setosa  4.6          3.4        
## 8  setosa  5.0          3.4        
## 9  setosa  4.4          2.9        
## 10 setosa  4.9          3.1

Ordenación de filas/columnas

Dat([D],sr=NULL,sc=NULL,d=F)
D:Matriz,sr:Número de fila,sc:Número de column,d=T:Ordenación descendente

D=Ip('s4'); Dt() #Ejemplo sencillo: Pntaje de 4 personas
## File: s4.txt / Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
## Class: data.frame / Rows: 4 / Columns: 3
##  
##         v1.English v2.Physics v3.Latin
## i1.Ana   9         14         18      
## i2.Juan 17          7         11      
## i3.Mary 15         13         14      
## i4.Ken   5         18          8
Dat(sc=1) #Columna:1, Ordenación ascendente
##         v1.English v2.Physics v3.Latin
## i4.Ken           5         18        8
## i1.Ana           9         14       18
## i3.Mary         15         13       14
## i2.Juan         17          7       11
Dat(sc='v1') #Id.
##         v1.English v2.Physics v3.Latin
## i4.Ken           5         18        8
## i1.Ana           9         14       18
## i3.Mary         15         13       14
## i2.Juan         17          7       11
Dat(sc=1,d=T)#Columna:1, Ordenación descendente
##         v1.English v2.Physics v3.Latin
## i2.Juan         17          7       11
## i3.Mary         15         13       14
## i1.Ana           9         14       18
## i4.Ken           5         18        8
Dat(sr=2) ##Columna:2, Ordenación ascendente
##         v2.Physics v3.Latin v1.English
## i1.Ana          14       18          9
## i2.Juan          7       11         17
## i3.Mary         13       14         15
## i4.Ken          18        8          5
Dat(sr='i2') #Id.
##         v2.Physics v3.Latin v1.English
## i1.Ana          14       18          9
## i2.Juan          7       11         17
## i3.Mary         13       14         15
## i4.Ken          18        8          5
Dat(sr=2,d=T)#Columna:2, Ordenación descendente
##         v1.English v3.Latin v2.Physics
## i1.Ana           9       18         14
## i2.Juan         17       11          7
## i3.Mary         15       14         13
## i4.Ken           5        8         18
D=iris; Dt() #Datos: iris
## Class: data.frame / Rows: 150 / Columns: 5
##  
##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1  5.1          3.5         1.4          0.2         setosa 
## 2  4.9          3.0         1.4          0.2         setosa 
## 3  4.7          3.2         1.3          0.2         setosa 
## 4  4.6          3.1         1.5          0.2         setosa 
## 5  5.0          3.6         1.4          0.2         setosa 
## 6  5.4          3.9         1.7          0.4         setosa 
## 7  4.6          3.4         1.4          0.3         setosa 
## 8  5.0          3.4         1.5          0.2         setosa 
## 9  4.4          2.9         1.4          0.2         setosa 
## 10 4.9          3.1         1.5          0.1         setosa
D=Dat(sc=1); Dt() #Columna:1, Ordenación ascendente
## Class: data.frame / Rows: 150 / Columns: 5
##  
##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 14 4.3          3.0         1.1          0.1         setosa 
## 9  4.4          2.9         1.4          0.2         setosa 
## 39 4.4          3.0         1.3          0.2         setosa 
## 43 4.4          3.2         1.3          0.2         setosa 
## 42 4.5          2.3         1.3          0.3         setosa 
## 4  4.6          3.1         1.5          0.2         setosa 
## 7  4.6          3.4         1.4          0.3         setosa 
## 23 4.6          3.6         1.0          0.2         setosa 
## 48 4.6          3.2         1.4          0.2         setosa 
## 3  4.7          3.2         1.3          0.2         setosa
D=Dat(sc=1,d=T); Dt() #Columna:1, Ordenación descendente
## Class: data.frame / Rows: 150 / Columns: 5
##  
##     Sepal.Length Sepal.Width Petal.Length Petal.Width Species  
## 132 7.9          3.8         6.4          2.0         virginica
## 118 7.7          3.8         6.7          2.2         virginica
## 119 7.7          2.6         6.9          2.3         virginica
## 123 7.7          2.8         6.7          2.0         virginica
## 136 7.7          3.0         6.1          2.3         virginica
## 106 7.6          3.0         6.6          2.1         virginica
## 131 7.4          2.8         6.1          1.9         virginica
## 108 7.3          2.9         6.3          1.8         virginica
## 110 7.2          3.6         6.1          2.5         virginica
## 126 7.2          3.2         6.0          1.8         virginica
D=Ip('dle.txt') #Datos: DLE (RAE)
## File: dle.txt / Class: data.frame / Rows: 87532 / Columns: 4
##  
##    Forma     Ac CV Fin
## 1  a         0  V  a  
## 2  aba       2  V  a  
## 3  abaá      1  V  a  
## 4  ababol    1  C  l  
## 5  abacá     1  V  a  
## 6  abacal    1  C  l  
## 7  abacalero 2  V  o  
## 8  abacería  2  V  a  
## 9  abacero   2  V  o  
## 10 abacial   1  C  l
D=Dat(D,r=1:20); Dt(r=20) #Seleccionar 1:20
## Class: data.frame / Rows: 20 / Columns: 4
##  
##    Forma     Ac CV Fin
## 1  a         0  V  a  
## 2  aba       2  V  a  
## 3  abaá      1  V  a  
## 4  ababol    1  C  l  
## 5  abacá     1  V  a  
## 6  abacal    1  C  l  
## 7  abacalero 2  V  o  
## 8  abacería  2  V  a  
## 9  abacero   2  V  o  
## 10 abacial   1  C  l  
## 11 ábaco     3  V  o  
## 12 abacora   2  V  a  
## 13 abacorar  1  C  r  
## 14 abad      1  C  d  
## 15 abada     2  V  a  
## 16 abadejo   2  V  o  
## 17 abadengo  2  V  o  
## 18 abadernar 1  C  r  
## 19 abadesa   2  V  a  
## 20 abadí     1  V  i
S=Dat(sc=2); Dt(S,r=20) #Columna:2, Ordenación ascendente
## Class: data.frame / Rows: 20 / Columns: 4
##  
##    Forma     Ac CV Fin
## 1  a         0  V  a  
## 3  abaá      1  V  a  
## 4  ababol    1  C  l  
## 5  abacá     1  V  a  
## 6  abacal    1  C  l  
## 10 abacial   1  C  l  
## 13 abacorar  1  C  r  
## 14 abad      1  C  d  
## 18 abadernar 1  C  r  
## 20 abadí     1  V  i  
## 2  aba       2  V  a  
## 7  abacalero 2  V  o  
## 8  abacería  2  V  a  
## 9  abacero   2  V  o  
## 12 abacora   2  V  a  
## 15 abada     2  V  a  
## 16 abadejo   2  V  o  
## 17 abadengo  2  V  o  
## 19 abadesa   2  V  a  
## 11 ábaco     3  V  o
S=Dat(sc=2:3); Dt(S,r=20) #Columna:2:3, Ordenación ascendente
## Class: data.frame / Rows: 20 / Columns: 4
##  
##    Forma     Ac CV Fin
## 1  a         0  V  a  
## 4  ababol    1  C  l  
## 6  abacal    1  C  l  
## 10 abacial   1  C  l  
## 13 abacorar  1  C  r  
## 14 abad      1  C  d  
## 18 abadernar 1  C  r  
## 3  abaá      1  V  a  
## 5  abacá     1  V  a  
## 20 abadí     1  V  i  
## 2  aba       2  V  a  
## 7  abacalero 2  V  o  
## 8  abacería  2  V  a  
## 9  abacero   2  V  o  
## 12 abacora   2  V  a  
## 15 abada     2  V  a  
## 16 abadejo   2  V  o  
## 17 abadengo  2  V  o  
## 19 abadesa   2  V  a  
## 11 ábaco     3  V  o

Dígitos decimales

D=diamonds; Dt() #Datos: diamonds
## Class: tbl_df, tbl, data.frame / Rows: 53940 / Columns: 10
##  
##    carat cut       color clarity depth table price x    y    z   
## 1  0.23  Ideal     E     SI2     61.5  55    326   3.95 3.98 2.43
## 2  0.21  Premium   E     SI1     59.8  61    326   3.89 3.84 2.31
## 3  0.23  Good      E     VS1     56.9  65    327   4.05 4.07 2.31
## 4  0.29  Premium   I     VS2     62.4  58    334   4.20 4.23 2.63
## 5  0.31  Good      J     SI2     63.3  58    335   4.34 4.35 2.75
## 6  0.24  Very Good J     VVS2    62.8  57    336   3.94 3.96 2.48
## 7  0.24  Very Good I     VVS1    62.3  57    336   3.95 3.98 2.47
## 8  0.26  Very Good H     SI1     61.9  55    337   4.07 4.11 2.53
## 9  0.22  Fair      E     VS2     65.1  61    337   3.87 3.78 2.49
## 10 0.23  Very Good H     VS1     59.4  61    338   4.00 4.05 2.39
D=Ip('iris'); Dt(j=T) #Dt(j=T): Justificación derecha
## File: iris.txt / Class: data.frame / Rows: 150 / Columns: 5
##  
##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1  5.1          3.5         1.4          0.2         setosa 
## 2  4.9          3.0         1.4          0.2         setosa 
## 3  4.7          3.2         1.3          0.2         setosa 
## 4  4.6          3.1         1.5          0.2         setosa 
## 5  5.0          3.6         1.4          0.2         setosa 
## 6  5.4          3.9         1.7          0.4         setosa 
## 7  4.6          3.4         1.4          0.3         setosa 
## 8  5.0          3.4         1.5          0.2         setosa 
## 9  4.4          2.9         1.4          0.2         setosa 
## 10 4.9          3.1         1.5          0.1         setosa
## Class: data.frame / Rows: 150 / Columns: 5
##  
##    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1           5.1         3.5          1.4         0.2  setosa
## 2           4.9         3.0          1.4         0.2  setosa
## 3           4.7         3.2          1.3         0.2  setosa
## 4           4.6         3.1          1.5         0.2  setosa
## 5           5.0         3.6          1.4         0.2  setosa
## 6           5.4         3.9          1.7         0.4  setosa
## 7           4.6         3.4          1.4         0.3  setosa
## 8           5.0         3.4          1.5         0.2  setosa
## 9           4.4         2.9          1.4         0.2  setosa
## 10          4.9         3.1          1.5         0.1  setosa
D=Ip('diamonds')
## File: diamonds.txt / Class: data.frame / Rows: 53940 / Columns: 10
##  
##    carat cut       color clarity depth table price x    y    z   
## 1  0.23  Ideal     E     SI2     61.5  55    326   3.95 3.98 2.43
## 2  0.21  Premium   E     SI1     59.8  61    326   3.89 3.84 2.31
## 3  0.23  Good      E     VS1     56.9  65    327   4.05 4.07 2.31
## 4  0.29  Premium   I     VS2     62.4  58    334   4.20 4.23 2.63
## 5  0.31  Good      J     SI2     63.3  58    335   4.34 4.35 2.75
## 6  0.24  Very Good J     VVS2    62.8  57    336   3.94 3.96 2.48
## 7  0.24  Very Good I     VVS1    62.3  57    336   3.95 3.98 2.47
## 8  0.26  Very Good H     SI1     61.9  55    337   4.07 4.11 2.53
## 9  0.22  Fair      E     VS2     65.1  61    337   3.87 3.78 2.49
## 10 0.23  Very Good H     VS1     59.4  61    338   4.00 4.05 2.39
N=Dat(c='ca,p,x,y,z'); Dt(N) #Seleccionar columnas numérica
## Class: data.frame / Rows: 53940 / Columns: 5
##  
##    carat price x    y    z   
## 1  0.23  326   3.95 3.98 2.43
## 2  0.21  326   3.89 3.84 2.31
## 3  0.23  327   4.05 4.07 2.31
## 4  0.29  334   4.20 4.23 2.63
## 5  0.31  335   4.34 4.35 2.75
## 6  0.24  336   3.94 3.96 2.48
## 7  0.24  336   3.95 3.98 2.47
## 8  0.26  337   4.07 4.11 2.53
## 9  0.22  337   3.87 3.78 2.49
## 10 0.23  338   4.00 4.05 2.39
S=Sta(N,s='sum,min,q1,median,mean,q3,max',d=3); Dt(S)
## Class: matrix, array / Rows: 7 / Columns: 5
##  
##        carat     price        x          y          z         
## sum    43040.870 212135217.00 309138.620 309320.330 190879.300
## min        0.200       326.00      0.000      0.000      0.000
## q1         0.400       950.00      4.710      4.720      2.910
## median     0.700      2401.00      5.700      5.710      3.530
## mean       0.798      3932.80      5.731      5.735      3.539
## q3         1.040      5324.25      6.540      6.540      4.040
## max        5.010     18823.00     10.740     58.900     31.800
Round(S,'m=1') #Dígito decimal de la matriz=1
##          carat       price        x        y        z
## sum    43040.9 212135217.0 309138.6 309320.3 190879.3
## min        0.2       326.0      0.0      0.0      0.0
## q1         0.4       950.0      4.7      4.7      2.9
## median     0.7      2401.0      5.7      5.7      3.5
## mean       0.8      3932.8      5.7      5.7      3.5
## q3         1.0      5324.2      6.5      6.5      4.0
## max        5.0     18823.0     10.7     58.9     31.8
Round(S,'r1=0') #Dígito decimal de la fila=1
##            carat        price          x          y          z
## sum    43041.000 212135217.00 309139.000 309320.000 190879.000
## min        0.200       326.00      0.000      0.000      0.000
## q1         0.400       950.00      4.710      4.720      2.910
## median     0.700      2401.00      5.700      5.710      3.530
## mean       0.798      3932.80      5.731      5.735      3.539
## q3         1.040      5324.25      6.540      6.540      4.040
## max        5.010     18823.00     10.740     58.900     31.800
Round(S,'c1=1,c2=3') #Dígitos decimales de las columnas 1,2=1,3
##          carat        price          x          y          z
## sum    43040.9 212135217.00 309138.620 309320.330 190879.300
## min        0.2       326.00      0.000      0.000      0.000
## q1         0.4       950.00      4.710      4.720      2.910
## median     0.7      2401.00      5.700      5.710      3.530
## mean       0.8      3932.80      5.731      5.735      3.539
## q3         1.0      5324.25      6.540      6.540      4.040
## max        5.0     18823.00     10.740     58.900     31.800
Round(S,'m=2,r1=1,c2=1') #Dígitos decimales. matriz=2, de fila=1,de columna=1
##           carat       price         x         y         z
## sum    43040.90 212135217.0 309138.60 309320.30 190879.30
## min        0.20       326.0      0.00      0.00      0.00
## q1         0.40       950.0      4.71      4.72      2.91
## median     0.70      2401.0      5.70      5.71      3.53
## mean       0.80      3932.8      5.73      5.74      3.54
## q3         1.04      5324.2      6.54      6.54      4.04
## max        5.01     18823.0     10.74     58.90     31.80

Cambio de clase

D=diamonds; Dt() #Datos: diamonds
## Class: tbl_df, tbl, data.frame / Rows: 53940 / Columns: 10
##  
##    carat cut       color clarity depth table price x    y    z   
## 1  0.23  Ideal     E     SI2     61.5  55    326   3.95 3.98 2.43
## 2  0.21  Premium   E     SI1     59.8  61    326   3.89 3.84 2.31
## 3  0.23  Good      E     VS1     56.9  65    327   4.05 4.07 2.31
## 4  0.29  Premium   I     VS2     62.4  58    334   4.20 4.23 2.63
## 5  0.31  Good      J     SI2     63.3  58    335   4.34 4.35 2.75
## 6  0.24  Very Good J     VVS2    62.8  57    336   3.94 3.96 2.48
## 7  0.24  Very Good I     VVS1    62.3  57    336   3.95 3.98 2.47
## 8  0.26  Very Good H     SI1     61.9  55    337   4.07 4.11 2.53
## 9  0.22  Fair      E     VS2     65.1  61    337   3.87 3.78 2.49
## 10 0.23  Very Good H     VS1     59.4  61    338   4.00 4.05 2.39
D=Dat(c='cu,co,p'); Dt()
## Class: tbl_df, tbl, data.frame / Rows: 53940 / Columns: 3
##  
##    cut       color price
## 1  Ideal     E     326  
## 2  Premium   E     326  
## 3  Good      E     327  
## 4  Premium   I     334  
## 5  Good      J     335  
## 6  Very Good J     336  
## 7  Very Good I     336  
## 8  Very Good H     337  
## 9  Fair      E     337  
## 10 Very Good H     338
D=mtcars; Dt() #Datos: mtcars
## Class: data.frame / Rows: 32 / Columns: 11
##  
##                   mpg  cyl disp  hp  drat wt    qsec  vs am gear carb
## Mazda RX4         21.0 6   160.0 110 3.90 2.620 16.46 0  1  4    4   
## Mazda RX4 Wag     21.0 6   160.0 110 3.90 2.875 17.02 0  1  4    4   
## Datsun 710        22.8 4   108.0  93 3.85 2.320 18.61 1  1  4    1   
## Hornet 4 Drive    21.4 6   258.0 110 3.08 3.215 19.44 1  0  3    1   
## Hornet Sportabout 18.7 8   360.0 175 3.15 3.440 17.02 0  0  3    2   
## Valiant           18.1 6   225.0 105 2.76 3.460 20.22 1  0  3    1   
## Duster 360        14.3 8   360.0 245 3.21 3.570 15.84 0  0  3    4   
## Merc 240D         24.4 4   146.7  62 3.69 3.190 20.00 1  0  4    2   
## Merc 230          22.8 4   140.8  95 3.92 3.150 22.90 1  0  4    2   
## Merc 280          19.2 6   167.6 123 3.92 3.440 18.30 1  0  4    4
D=Dat(c='v,a,m'); Dt()
## Class: data.frame / Rows: 32 / Columns: 3
##  
##                   vs am mpg 
## Mazda RX4         0  1  21.0
## Mazda RX4 Wag     0  1  21.0
## Datsun 710        1  1  22.8
## Hornet 4 Drive    1  0  21.4
## Hornet Sportabout 0  0  18.7
## Valiant           1  0  18.1
## Duster 360        0  0  14.3
## Merc 240D         1  0  24.4
## Merc 230          1  0  22.8
## Merc 280          1  0  19.2
D=ReplaceCol(D,'vs','0=>V-shaped,1=>Straight'); Dt() #Reemplzar la columna 'vs'
## Class: data.frame / Rows: 32 / Columns: 3
##  
##                   vs       am mpg 
## Mazda RX4         V-shaped 1  21.0
## Mazda RX4 Wag     V-shaped 1  21.0
## Datsun 710        Straight 1  22.8
## Hornet 4 Drive    Straight 0  21.4
## Hornet Sportabout V-shaped 0  18.7
## Valiant           Straight 0  18.1
## Duster 360        V-shaped 0  14.3
## Merc 240D         Straight 0  24.4
## Merc 230          Straight 0  22.8
## Merc 280          Straight 0  19.2
D=ReplaceCol(D,'am','0=>Automatic,1=>Manual') ; Dt() #Reemplzar la columna 'am'
## Class: data.frame / Rows: 32 / Columns: 3
##  
##                   vs       am        mpg 
## Mazda RX4         V-shaped Manual    21.0
## Mazda RX4 Wag     V-shaped Manual    21.0
## Datsun 710        Straight Manual    22.8
## Hornet 4 Drive    Straight Automatic 21.4
## Hornet Sportabout V-shaped Automatic 18.7
## Valiant           Straight Automatic 18.1
## Duster 360        V-shaped Automatic 14.3
## Merc 240D         Straight Automatic 24.4
## Merc 230          Straight Automatic 22.8
## Merc 280          Straight Automatic 19.2
D=Titanic; Dt() #Datos: Titanic
## Class: table / Rows: 4 / Columns: 2
##  
##    Class Sex    Age   Survived Freq
## 1  1st   Male   Child No         0 
## 2  2nd   Male   Child No         0 
## 3  3rd   Male   Child No        35 
## 4  Crew  Male   Child No         0 
## 5  1st   Female Child No         0 
## 6  2nd   Female Child No         0 
## 7  3rd   Female Child No        17 
## 8  Crew  Female Child No         0 
## 9  1st   Male   Adult No       118 
## 10 2nd   Male   Adult No       154
E=T2D(); Dt(E) #table => df
## Class: data.frame / Rows: 32 / Columns: 5
##  
##    Class Sex    Age   Survived Freq
## 1  1st   Male   Child No         0 
## 2  2nd   Male   Child No         0 
## 3  3rd   Male   Child No        35 
## 4  Crew  Male   Child No         0 
## 5  1st   Female Child No         0 
## 6  2nd   Female Child No         0 
## 7  3rd   Female Child No        17 
## 8  Crew  Female Child No         0 
## 9  1st   Male   Adult No       118 
## 10 2nd   Male   Adult No       154
E=T2D(); Dt(E) #table => df
## Class: data.frame / Rows: 32 / Columns: 5
##  
##    Class Sex    Age   Survived Freq
## 1  1st   Male   Child No         0 
## 2  2nd   Male   Child No         0 
## 3  3rd   Male   Child No        35 
## 4  Crew  Male   Child No         0 
## 5  1st   Female Child No         0 
## 6  2nd   Female Child No         0 
## 7  3rd   Female Child No        17 
## 8  Crew  Female Child No         0 
## 9  1st   Male   Adult No       118 
## 10 2nd   Male   Adult No       154

—–

Referencia

Portada

(Hiroto Ueda, Universidad de Tokio, 2022)