Creando un diccionario vamos a tener una serie de valores asociados a unas claves

Cargamos nuestros datos

``````mi_diccionario<- c(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)

mi_diccionario``````
`````` [1]  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] 26``````

Asociamos a un nombre

``names(mi_diccionario)<- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")``

Comprobamos el valor de la clave

``mi_diccionario["a"]``
``````a
1 ``````
``mi_diccionario["m"]``
`````` m
13 ``````
``mi_diccionario["z"]``
`````` z
26 ``````

Obtener la lista de pares clave y valor

``mi_diccionario``
`````` a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
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 ``````

## 7.1 Iterando un diccionario

``````mi_diccionario<- c(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)

mi_diccionario``````
`````` [1]  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] 26``````
``````alfabeto<- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")

alfabeto``````
`````` [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
[20] "t" "u" "v" "w" "x" "y" "z"``````
``````for (i in 1:length(alfabeto)) {

print(paste("El valor de la clave",mi_diccionario[i],"es",alfabeto[i], sep = " "))

}``````
``````[1] "El valor de la clave 1 es a"
[1] "El valor de la clave 2 es b"
[1] "El valor de la clave 3 es c"
[1] "El valor de la clave 4 es d"
[1] "El valor de la clave 5 es e"
[1] "El valor de la clave 6 es f"
[1] "El valor de la clave 7 es g"
[1] "El valor de la clave 8 es h"
[1] "El valor de la clave 9 es i"
[1] "El valor de la clave 10 es j"
[1] "El valor de la clave 11 es k"
[1] "El valor de la clave 12 es l"
[1] "El valor de la clave 13 es m"
[1] "El valor de la clave 14 es n"
[1] "El valor de la clave 15 es o"
[1] "El valor de la clave 16 es p"
[1] "El valor de la clave 17 es q"
[1] "El valor de la clave 18 es r"
[1] "El valor de la clave 19 es s"
[1] "El valor de la clave 20 es t"
[1] "El valor de la clave 21 es u"
[1] "El valor de la clave 22 es v"
[1] "El valor de la clave 23 es w"
[1] "El valor de la clave 24 es x"
[1] "El valor de la clave 25 es y"
[1] "El valor de la clave 26 es z"``````