#install.packages(lubridate)
library(lubridate)
##
## Adjuntando el paquete: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(dbplyr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ purrr 1.0.4 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::ident() masks dbplyr::ident()
## ✖ dplyr::lag() masks stats::lag()
## ✖ dplyr::sql() masks dbplyr::sql()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Este reporte es de ejemplo de uso de rmarkdown
nombres=c("Nico", "Lujan", "Alex" , "Otto", "Rodrigo", "Federico", "Wilfrido", "Tania" )
nombres
## [1] "Nico" "Lujan" "Alex" "Otto" "Rodrigo" "Federico" "Wilfrido"
## [8] "Tania"
fechanac=c("23/10/1999" , "1/1/2005", "3/6/2000" , "17/8/2000", "5/3/2004" , "23/12/2002", "28/02/2005", "5/11/2003")
fechanac=as.Date(fechanac, format = "%d/%m/%Y")
fechanac
## [1] "1999-10-23" "2005-01-01" "2000-06-03" "2000-08-17" "2004-03-05"
## [6] "2002-12-23" "2005-02-28" "2003-11-05"
estatura=c(170, 170, 183 , 178, 185, 167, 175, 159)
estatura
## [1] 170 170 183 178 185 167 175 159
hist(estatura)
sexo=c("H", "M", "H", "H", "H" , "H", "H", "M")
sexo=factor(sexo)
plot(sexo)
lugar=c("San Lorenzo", "Limpio", "San Lorenzo", "Itagua", "San Lorenzo", "Asunción", "J. Augusto", "Capiata")
lugar
## [1] "San Lorenzo" "Limpio" "San Lorenzo" "Itagua" "San Lorenzo"
## [6] "Asunción" "J. Augusto" "Capiata"
lugar=factor(lugar)
plot(lugar)
datos = data.frame(nombres, sexo, estatura, lugar, fechanac)
datos
## nombres sexo estatura lugar fechanac
## 1 Nico H 170 San Lorenzo 1999-10-23
## 2 Lujan M 170 Limpio 2005-01-01
## 3 Alex H 183 San Lorenzo 2000-06-03
## 4 Otto H 178 Itagua 2000-08-17
## 5 Rodrigo H 185 San Lorenzo 2004-03-05
## 6 Federico H 167 Asunción 2002-12-23
## 7 Wilfrido H 175 J. Augusto 2005-02-28
## 8 Tania M 159 Capiata 2003-11-05
# calcular la edad
datos$fecharef <- today()
datos
## nombres sexo estatura lugar fechanac fecharef
## 1 Nico H 170 San Lorenzo 1999-10-23 2025-08-12
## 2 Lujan M 170 Limpio 2005-01-01 2025-08-12
## 3 Alex H 183 San Lorenzo 2000-06-03 2025-08-12
## 4 Otto H 178 Itagua 2000-08-17 2025-08-12
## 5 Rodrigo H 185 San Lorenzo 2004-03-05 2025-08-12
## 6 Federico H 167 Asunción 2002-12-23 2025-08-12
## 7 Wilfrido H 175 J. Augusto 2005-02-28 2025-08-12
## 8 Tania M 159 Capiata 2003-11-05 2025-08-12
datos$edad = floor((datos$fecharef - datos$fechanac)/365.55)
datos$edad
## Time differences in days
## [1] 25 20 25 24 21 22 20 21
barplot(table(datos$sexo, datos$edad) )