Lectura de los datos

Pregunta 1,2,3,4

eggs <- read_ods("Eggsorg.ods", sheet = 1); eggs #Lectura de datos (ods)
## # A tibble: 96 × 9
##    `Name                   ` `Family       ` `   Size    ` `     Nesting ground            ` `       Eggs     ` `         Length ` `    Width` `   Mass ` `  Hatch`
##    <chr>                     <chr>                   <dbl> <chr>                             <chr>                           <dbl>       <dbl>      <dbl> <chr>    
##  1 Barn owl                  Owl                      34   Hollow trees, barns               4-7                              39.2        30.8       20.7 30       
##  2 Black cap                 Warbler                  14   Bushes, low trees                 4-6                              19.6        14.7        1.9 14-15    
##  3 Black redstaft            Chat                     14   Hales, crevices                   5-6                              19.4        14.4        2   13       
##  4 Blackbird                 Thrush                   25   Trees, bushes                     4-6                              28.6        21          9   13-14    
##  5 Blue tit                  Tit                      11.5 Holes                             10-13                            15.4        11.9        1.3 13-15    
##  6 Brambling                 Finch                    14.5 Trees, bushes                     5-6                              19.5        14.6        2.2 12-13    
##  7 Bullfinch                 Finch                    15   Bushes, conifers                  4-5                              20.2        15.1        2.1 13       
##  8 Canada goose              Goose                    95   Islets, marshes                   5-6                              85.7        58.2      228   28-30    
##  9 Carrion crow              Crow                     47   Tall trees                        4-6                              43.5        30.1       19   17-19    
## 10 Chaffinch                 Finch                    15   Bushes, trees, hedges             4-6                              19.3        14.6        2.1 12-13    
## # ℹ 86 more rows
str(eggs) # estructura data-frame
## tibble [96 × 9] (S3: tbl_df/tbl/data.frame)
##  $ Name                           : chr [1:96] "Barn owl" "Black cap" "Black redstaft" "Blackbird" ...
##  $ Family                         : chr [1:96] "Owl" "Warbler" "Chat" "Thrush" ...
##  $    Size                        : num [1:96] 34 14 14 25 11.5 14.5 15 95 47 15 ...
##  $      Nesting ground            : chr [1:96] "Hollow trees, barns" "Bushes, low trees" "Hales, crevices" "Trees, bushes" ...
##  $        Eggs                    : chr [1:96] "4-7" "4-6" "5-6" "4-6" ...
##  $          Length                : num [1:96] 39.2 19.6 19.4 28.6 15.4 19.5 20.2 85.7 43.5 19.3 ...
##  $     Width                      : num [1:96] 30.8 14.7 14.4 21 11.9 14.6 15.1 58.2 30.1 14.6 ...
##  $    Mass                        : num [1:96] 20.7 1.9 2 9 1.3 2.2 2.1 228 19 2.1 ...
##  $   Hatch                        : chr [1:96] "30" "14-15" "13" "13-14" ...
eggs <- read_ods("Eggsorg.ods", sheet = 1, row_names = TRUE,as_tibble = FALSE); eggs #Lectura de datos de la hoja 1
##                         Family           Size          Nesting ground                    Eggs               Length      Width    Mass    Hatch
## Barn owl                          Owl        34.0             Hollow trees, barns              4-7             39.2      30.8     20.7      30
## Black cap                     Warbler        14.0               Bushes, low trees              4-6             19.6      14.7      1.9   14-15
## Black redstaft                   Chat        14.0                 Hales, crevices              5-6             19.4      14.4      2.0      13
## Blackbird                      Thrush        25.0                   Trees, bushes              4-6             28.6      21.0      9.0   13-14
## Blue tit                          Tit        11.5                           Holes            10-13             15.4      11.9      1.3   13-15
## Brambling                       Finch        14.5                   Trees, bushes              5-6             19.5      14.6      2.2   12-13
## Bullfinch                       Finch        15.0                Bushes, conifers              4-5             20.2      15.1      2.1      13
## Canada goose                    Goose        95.0                 Islets, marshes              5-6             85.7      58.2    228.0   28-30
## Carrion crow                     Crow        47.0                      Tall trees              4-6             43.5      30.1     19.0   17-19
## Chaffinch                       Finch        15.0           Bushes, trees, hedges              4-6             19.3      14.6      2.1   12-13
## Chiff-chaff                   Warbler        11.0          Wood verges, hedgerows              5-6             15.5      12.0      1.3   13-14
## Chough                           Crow        39.0         Crevices, cliff, ledges              3-5             39.4      27.9     13.0   19-21
## Cirl bunting                  Bunting        16.0                  Bushes, hedges              3-5             20.9      15.9      2.8   11-13
## Coal tit                          Tit        11.0                  Holes, burrows             7-10             14.7      11.6      1.4   14-16
## Collared dove                  Pigeon        32.0                   Trees, bushes                2             31.9      24.0      8.5   15-16
## Common sandpiper            Sandpiper        20.0                     Lake shores                4             36.3      36.0     12.0   21-22
## Corn bunting                  Bunting        18.0                  Grassy hollows              5-6             23.8      17.7      3.7   12-13
## Crested tit                       Tit        11.5                      Tree hales              5-7             16.0      12.4      1.3   15-18
## Crossbill                       Finch        16.0                        Conifers              3-4             22.1      16.1      2.9   12-13
## Dotterel                       Plover        22.0                    Moors, scree              2-4             41.1      28.9     11.0   27-28
## Dunlin                      Sandpiper        18.0                  Moors, marshes              3-5             34.7      24.7     11.0      17
## Eider                            Duck        60.0                Near sea, islets              4-6             77.6      51.9    110.3   25-26
## Fieldfare                      Thrush        26.0                  Woodland trees              5-6             28.8      20.9      7.0   13-14
## Firecrest                     Warbler         9.0                        Conifers             7-12             13.5      10.3      0.7   14-15
## Gadwall                          Duck        51.0                        Reedbeds             8-12             51.8      37.5     42.5      26
## Garden warbler                Warbler        14.0                Shrubs, brambles              4-5             20.1      14.8      2.5      12
## Garganey                         Duck        39.0          Dry ground, vegetation             8-11             45.3      33.3     25.7   21-23
## Goldcrest                     Warbler         9.0                   Tall conifers             8-11             13.6      10.3      0.7      16
## Golden Plover                  Plover        28.0                     Boggy moors                4             51.8      35.9     34.0      27
## Goldeneye                        Duck        46.0             Tree holes, burrows             6-11             58.4      43.2     56.5      30
## Goldfinch                       Finch        12.0                           Trees              5-6             17.0      12.8      1.4   12-13
## Goosander                        Duck        62.0                      Tree holes             8-12             66.4      46.4     83.5      32
## Grasshopper warbler           Warbler        13.0                  Moors, marshes              5-6             18.1      13.8      1.7   13-15
## Great tit                         Tit        14.0                      Tree holes             7-10             17.3     135.0      1.6   13-14
## Green sandpiper             Sandpiper        23.0          Trees on marshy ground                4             39.1      28.0     16.0   20-22
## Greenfinch                      Finch        14.5                  Bushes, hedges                5             20.2      14.5      2.0   13-14
## Grey wagtail                  Wagtail        18.0                   Holes, ledges              5-6             19.0      14.5      1.9   12-14
## Greylag goose                   Goose        83.0                        Reedbeds              5-8             85.3      58.0    176.0   28-29
## Howlinch                        Finch        18.0                 Deciduous trees              5-6             24.5      17.5      3.4      14
## Hooded crow                      Crow        47.0                   Trees, bushes              5-6             43.5      30.1     19.0   17-19
## House sparrow                 Sparrow        14.5                 Holes, crevices              5-6             22.5      15.7      3.0      13
## Jackdaw                          Crow        34.0                 Holes, crevices              5-6             33.7      25.2     12.0   17-18
## Jay                              Crow        34.0                   Bushes, trees              5-6             31.6      23.0      8.0   16-17
## Lapwing                        Plover        30.0                   Fields, moors                4             47.1      33.7     25.0   24-26
## Lesser whitethrwt             Warbler        13.5             Thickets, Hedgerows              5-6             16.5      12.6      1.7   10-11
## Linnet                          Finch        13.0                Bushes, thickets              5-6             17.7      13.3      2.0   12-14
## Little owl                        Owl        22.0                       Treeholes              3-5             33.6      28.1     15.5      28
## Little ringed plover           Plover        15.0                 Mud, gravelpits                4             29.8      22.1      7.0   23-26
## Long-eared owl                    Owl        36.0                 Abondoned nests              4-6             40.9      32.7     23.0   27-28
## Long-tailed tit                   Tit        14.0                 Trees, thickets             7-11             13.6      10.9      0.9   12-13
## Magpie                           Crow        46.0              Tall trees, hedges              5-7             34.1      24.2      9.0   17-18
## Mallard                          Duck        58.0                    Ground cover             7-11             58.4      39.5     49.5      28
## Marsh tit                         Tit        11.5                      Tree holes              7-9             16.1      12.2      1.0      14
## Mistle thrush                  Thrush        27.0                      Tall trees              3-5             31.2      22.3      7.0   13-14
## Nightingale                      Chat        16.5                    Ground cover              4-6             21.0      15.6      2.6      13
## Pied wagtail                  Wagtail        18.0                   Holes, niches              5-6             20.4      15.1      2.2   12-14
## Pintail                          Duck        58.0                  Moors, marshes             7-11             51.8      37.0     47.0   22-23
## Pochard                          Duck        45.0                    Reeds, banks              6-9             61.3      43.7     67.0   24-26
## Raven                            Crow        64.0         Ledges, crevices, trees              4-7             49.7      33.4     33.0   20-21
## Redpoll                         Finch        11.5                    Scrub growth              5-6             16.9      12.6      1.3   10-11
## Redstart                         Chat        14.0                      Tree holes              5-7             18.7      13.8      2.0   13-14
## Redwing                        Thrush        21.0                   Bushes, trees                5             25.8      19.2      6.5      13
## Reed bunting                  Bunting        15.0                  Reeds, marshes              5-6             19.3      14.3      2.1   13-14
## Reed warbler                  Warbler        12.5                   Reeds, bushes              3-5             18.3      13.6      1.8   11-12
## Ring ouzel                     Thrush        24.0             Bushes, small trees              4-5             30.4      21.5      8.0      14
## Ringed plover                  Plover        19.0                    Beaches, mud              3-5             35.7      25.9     10.0   24-27
## Robin                            Chat        14.0                  Hollows, holes              5-7             19.4      14.8      2.0   13-14
## Rock dove                      Pigeon        33.0                     Cliff holes                2             39.3      29.1     17.0      17
## Rook                             Crow        46.0                      Tall trees              4-5             41.0      28.3     16.0   16-18
## Scaup                            Duck        47.0                  Moors, islands             7-11             63.2      43.5     60.0   24-25
## Sedge warbler                 Warbler        13.0                 Reeds, thickets              4-6             17.7      13.1      1.5   12-13
## Shelduck                         Duck        62.0                   Sandy burrows             8-12             65.8      47.6     78.0   28-29
## Shoit-eared owl                   Owl        38.0                  Moors, marshes              4-7             40.1      31.8     21.5   26-27
## Shoveler                         Duck        48.0                  Moors, marshes             8-12             51.8      37.0     39.0   23-25
## Siskin                          Finch        12.0                        Conifers              4-5             16.4      12.3      1.0   11-12
## Skylark                          Lark        18.0                     Open ground              3-5             24.1      16.8      3.4      14
## Snow bunting                  Bunting        16.5                    Stony ground              5-6             22.4      16.8      1.7   10-13
## Song thrush                    Thrush        23.0                   Bushes, trees              4-6             27.3      20.4      6.5   12-13
## Stock dove                     Pigeon        33.0                      Tree holes              2-3             37.9      29.0     16.0   16-17
## Stonechat                        Chat        12.5                  Grassy hollows              5-6             18.9      14.4      2.0   14-15
## Towny owl                         Owl        38.0                    Hollow trees              2-5             48.2      38.7     39.0   28-29
## Teal                             Duck        36.0          Dry ground, vegetotion                5             45.6      33.5     26.8   21-22
## Temminck's stint            Sandpiper        14.0                          Islets                4             28.0      20.4      6.0   13-14
## Tree sparrow                  Sparrow        14.0                 Holes, crevices              5-6             19.3      14.0      2.0   13-14
## Turtle dove                    Pigeon        32.0                   Trees, hedges              2-3             30.7      23.0      9.0   13-15
## Twite                           Finch        13.0                    Ground cover              5-6             17.2      12.9      1.5   12-13
## Wheatear                         Chat        15.0                  Holes, burrows              5-6             21.2      15.9      2.5      14
## Whinchat                         Chat        12.5                  Grassy hollows              5-7             19.2      14.8      2.0   13-14
## Whitethroat                   Warbler        14.0                   Scrub, bushes              4-5             18.1      13.8      2.0   11-13
## Wigeon                           Duck        48.0            Islets, ground cover                9             53.9      38.2     44.0   22-23
## Wood sandpiper              Sandpiper        20.0                     Boggy moors                4             38.3      27.0     13.0   21-24
## Wood warbler                  Warbler        13.0                 Woodland ground              5-6             16.1      12.6      1.3      13
## Wood-pigeon                    Pigeon        41.0                   Trees, bushes              2-3             40.1      28.7     18.5   15-17
## Woodlark                         Lork        15.0                     Wood verges              3-4             21.6      16.3      2.7   13-15
## Yellow wagtail                Wagtail        16.5                  Grassy hollows              5-6             19.1      14.3      1.9   13-14
## Yellowhammer                  Bunting        16.5                  Grassy hollows              3-5             21.2      15.9      2.7   12-14
str(eggs) # estructura data-frame
## 'data.frame':    96 obs. of  8 variables:
##  $ Family                         : chr  "Owl" "Warbler" "Chat" "Thrush" ...
##  $    Size                        : num  34 14 14 25 11.5 14.5 15 95 47 15 ...
##  $      Nesting ground            : chr  "Hollow trees, barns" "Bushes, low trees" "Hales, crevices" "Trees, bushes" ...
##  $        Eggs                    : chr  "4-7" "4-6" "5-6" "4-6" ...
##  $          Length                : num  39.2 19.6 19.4 28.6 15.4 19.5 20.2 85.7 43.5 19.3 ...
##  $     Width                      : num  30.8 14.7 14.4 21 11.9 14.6 15.1 58.2 30.1 14.6 ...
##  $    Mass                        : num  20.7 1.9 2 9 1.3 2.2 2.1 228 19 2.1 ...
##  $   Hatch                        : chr  "30" "14-15" "13" "13-14" ...
write.csv(eggs, file = "Eggs.csv") #escritura en csv
egg <- read_ods("Eggsorg.ods", sheet = 1) # Lectura de datos de la hoja 1
eggs <- egg[,2:9] # selección de las variables en posición 2 al 9
rownames(eggs) <- trimws(rownames(eggs), which = c("both")); eggs # eliminación de espacios en blanco (inicio y final)
## Warning: Setting row names on a tibble is deprecated.
## # A tibble: 96 × 8
##    `Family       ` `   Size    ` `     Nesting ground            ` `       Eggs     ` `         Length ` `    Width` `   Mass ` `  Hatch`
##  * <chr>                   <dbl> <chr>                             <chr>                           <dbl>       <dbl>      <dbl> <chr>    
##  1 Owl                      34   Hollow trees, barns               4-7                              39.2        30.8       20.7 30       
##  2 Warbler                  14   Bushes, low trees                 4-6                              19.6        14.7        1.9 14-15    
##  3 Chat                     14   Hales, crevices                   5-6                              19.4        14.4        2   13       
##  4 Thrush                   25   Trees, bushes                     4-6                              28.6        21          9   13-14    
##  5 Tit                      11.5 Holes                             10-13                            15.4        11.9        1.3 13-15    
##  6 Finch                    14.5 Trees, bushes                     5-6                              19.5        14.6        2.2 12-13    
##  7 Finch                    15   Bushes, conifers                  4-5                              20.2        15.1        2.1 13       
##  8 Goose                    95   Islets, marshes                   5-6                              85.7        58.2      228   28-30    
##  9 Crow                     47   Tall trees                        4-6                              43.5        30.1       19   17-19    
## 10 Finch                    15   Bushes, trees, hedges             4-6                              19.3        14.6        2.1 12-13    
## # ℹ 86 more rows
write.csv(eggs, file = "Eggs.csv") #escritura en csv
colnames(eggs) # etiquetas columnas 
## [1] "Family       "                   "   Size    "                     "     Nesting ground            " "       Eggs     "                "         Length "                "    Width"                       "   Mass "                        "  Hatch"
colnames(eggs) <- c("Family","Size","Nesting ground" ,"Eggs","Length","Width","Mass","Hatch") # Etiquetas de columnas
write_ods(eggs, "Eggs.ods", sheet = "Data", row_names = TRUE, col_names = TRUE) #escritura en ods
write.csv(eggs, file = "Eggs.csv") #escritura en csv

Pregunta 5

SudAmerica

#########################################################################################
# Lectura de los datos
SudAmerica <- read.csv("SudAmerica.csv", row.names = 1) 
# Guardando el marco de datos SudAmerica en un archivo .ods.
# y se incluirán los nombres de fila y columna en el archivo.
write_ods(SudAmerica, "SudAmerica.ods", row_names = TRUE, col_names = TRUE)

Baseball

# Lectura de los datos Baseball
Baseball <- read.csv("Baseball.csv", row.names = 1)
# Guardar a un archivo .ods para Baseball.csv
write_ods(Baseball, "Baseball.ods", row_names = TRUE, col_names = TRUE)

Students

# Lectura de los datos Students
Students <- read.csv("Students.csv", row.names = 1)
# Seleccionar las variables midterm, final
Students <- Students[,1:2]
# Guardar a un archivo .ods para Baseball.csv
write_ods(Students, "Students.ods", row_names = TRUE, col_names = TRUE)

Pregunta 6

SudAmerica

# Gráfico de Variables Tajo_Urbano y IDH del dataframe de Sudamerica 

attach(SudAmerica)                                  # archivo en uso
lab1        <- rownames(SudAmerica)                  # etiquetas de las unidades en lab1 
plot(Tajo_urbano,IDH,xlab="Tajo_urbano",ylab="IDH") # diagrama de dispersión de dos carácteres
text(Tajo_urbano,IDH,lab1)                           # escritura de etiquetas sobre el gráfico
identify(Tajo_urbano,IDH,lab1)                       # escritura de etiquetas cliqueando cadauna

## integer(0)
# Comentarios: En el gráfico de dispersión entre las variables Tajo Urbano y IDH, observamos una tendencia que sugiere que a mayores valores de Tajo Urbano podrían corresponder mayores valores de IDH. Esta tendencia indica una posible correlación positiva entre el desarrollo urbano y el índice de desarrollo humano en las ubicaciones estudiadas

#Algunos países, como Uruguay, Chile y Argentina, parecen tener tanto un "Tajo_urbano" alto como un IDH alto, lo que podría indicar un nivel de desarrollo urbano y humano más avanzado. Por otro lado, Bolivia se destaca con un valor más bajo en ambas variables

Baseball

# Gráfico de Variables BattingAvg y WinningPerc del dataframe de Baseball 

attach(Baseball)                                  # archivo en uso
lab2        <- rownames(Baseball)                  # etiquetas de las unidades en lab2 
plot(BattingAvg,WinningPerc,xlab="BattingAvg",ylab="WinningPerc") # diagrama de dispersión de dos carácteres
text(BattingAvg,WinningPerc,lab2)                           # escritura de etiquetas sobre el gráfico
identify(BattingAvg,WinningPerc,lab2)                       # escritura de etiquetas cliqueando cadauna

## integer(0)
# Comentarios: El gráfico de dispersión entre las variables BattingAvg y WinningPerc podemos obervar que hay una tendencia, donde a mayor valor de BattingAvg se obtendrá mayores valores de WinningPerc

# BattingAvg parecen variar entre aproximadamente 0.245 y 0.275, mientras que el WinningPerc varía entre 0.40 y 0.65.

Students

# Gráfico de Variables midterm y final del dataframe de Students 

attach(Students)                                  # archivo en uso
lab3   <- rownames(Students)                  # etiquetas de las unidades en lab3
plot(midterm,final,xlab="midterm",ylab="final") # diagrama de dispersión de dos carácteres
text(midterm,final,final)                           # escritura de etiquetas sobre el gráfico
identify(midterm,final,lab3)                       # escritura de etiquetas cliqueando cadauna

## integer(0)
# Comentarios: El gráfico de dispersión entre las variables midterm y final podemos obervar que hay una tendencia, donde a mayor valor de midterm se obtendrá mayores valores de midterm. Además que hay una mayor concentración de datos entre valores de 15 a 25 respecto a la variable midterm. Asimismo, si analizamos la variable final hay mayor cantidad de datos en el rango de 15 a 35

Pregunta 7

SudAmerica

# regresión lm dibujo de datos con recta y predictos
attach(SudAmerica)
## The following objects are masked from SudAmerica (pos = 5):
## 
##     IDH, Tajo_urbano
plot(Tajo_urbano,IDH,xlab="Tajo_urbano",ylab="IDH") # otro diagrama
identify(Tajo_urbano,IDH,lab1)                       # escritura de etiquetas cliqueando cadauna
## integer(0)
lmSA       <- lm(IDH~Tajo_urbano,data=SudAmerica)   # regresión
abline(lmSA,col="red")                              # se traza la recta estimada                    
points(Tajo_urbano,lmSA$fitted.values,col="red")    # y los IDH estimados

Baseball

# regresión lm dibujo de datos con recta y predictos
# Baseball
attach(Baseball)
## The following objects are masked from Baseball (pos = 5):
## 
##     BattingAvg, WinningPerc
plot(BattingAvg,WinningPerc,xlab="BattingAvg",ylab="WinningPerc") # otro diagrama
identify(BattingAvg,WinningPerc,lab2)                       # escritura de etiquetas cliqueando 
## integer(0)
lmSA2<-lm(WinningPerc~BattingAvg,data=Baseball)   # regresión
abline(lmSA2,col="red")                              # se traza la recta estimada                   
points(BattingAvg,lmSA2$fitted.values,col="red")    # y los WinningPerc estimados

Students

# regresión lm dibujo de datos con recta y predictos
# Baseball
attach(Students)
## The following objects are masked from Students (pos = 5):
## 
##     final, midterm
plot(midterm,final,xlab="midterm",ylab="final") # otro diagrama
identify(midterm,final,lab3)                       # escritura de etiquetas cliqueando 
## integer(0)
lmSA3<-lm(final~midterm,data=Students)   # regresión
abline(lmSA3,col="red")                              # se traza la recta estimada                   
points(midterm,lmSA3$fitted.values,col="red")    # y los final estimados