Holalalalal mi nombre esn wilmar y nos va a ir bien This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see https://www.youtube.com/watch?v=Jjc20VoMBwI.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:la explicación sapo perro
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
##tabla de frecuencia de una variable categorica
## instalar el paquete fdth
library(readr)
Datos_Parcial <- read_delim("Enero.csv (1)/Enero.csv/Área - Vivienda y Hogares.csv",
delim = ";", escape_double = FALSE, trim_ws = TRUE)
## Rows: 9016 Columns: 59
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (5): P5090S1, REGIS, AREA, MES, DPTO
## dbl (53): DIRECTORIO, SECUENCIA_P, P5000, P5010, P5020, P5030, P5040, P5050,...
## num (1): fex_c_2011
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(Datos_Parcial)
library(fdth)
## Warning: package 'fdth' was built under R version 4.2.2
##
## Attaching package: 'fdth'
##
## The following objects are masked from 'package:stats':
##
## sd, var
attach(Datos_Parcial)
Datos_Parcial$P5020_a=as.factor(Datos_Parcial$P5020) ## as factor para cambiar una variable numerica
attach(Datos_Parcial)
## The following objects are masked from Datos_Parcial (pos = 3):
##
## AREA, DIRECTORIO, DPTO, fex_c_2011, HOGAR, MES, P4000, P4010,
## P4020, P4030S1, P4030S1A1, P4030S2, P4030S3, P4030S4, P4030S4A1,
## P4030S5, P4040, P5000, P5010, P5020, P5030, P5040, P5050, P5070,
## P5080, P5090, P5090S1, P5100, P5110, P5130, P5140, P5210S1,
## P5210S10, P5210S11, P5210S14, P5210S15, P5210S16, P5210S17,
## P5210S18, P5210S19, P5210S2, P5210S20, P5210S21, P5210S22,
## P5210S24, P5210S3, P5210S4, P5210S5, P5210S6, P5210S7, P5210S8,
## P5210S9, P5220, P5220S1, P6007, P6007S1, P6008, REGIS, SECUENCIA_P
class(P5020_a) ## para decir que esa variable es un numero
## [1] "factor"
tabla1=fdt_cat(Datos_Parcial$P5020_a, stort=TRUE)
tabla1
## Category f rf rf(%) cf cf(%)
## 1 8874 0.98 98.43 8874 98.43
## 2 100 0.01 1.11 8974 99.53
## 3 35 0.00 0.39 9009 99.92
## 6 5 0.00 0.06 9014 99.98
## 5 2 0.00 0.02 9016 100.00
table(P5020)
## P5020
## 1 2 3 5 6
## 8874 100 35 2 5
hist(P5020)
## ahora puedo hacer la estadistica descriptiva como si fuera una variable cuantitativa es decir sacrale media moda
# entre otras cosas se debe instalar los paquetes "psych" y "modeest"
library(psych)
## Warning: package 'psych' was built under R version 4.2.2
library(modeest)
## Warning: package 'modeest' was built under R version 4.2.2
## Registered S3 method overwritten by 'rmutil':
## method from
## plot.residuals psych
##
## Attaching package: 'modeest'
##
## The following object is masked from 'package:fdth':
##
## mfv
median(P5020, na.rm = T)
## [1] 1
mfv(P5020, na_rm = T)
## [1] 1
table(P5020)
## P5020
## 1 2 3 5 6
## 8874 100 35 2 5
hist(P5020)
## repetir para las variables categoricas q hayan
##ahora para hacer la estadistica descriptiva de las cuantitativas tenemos lo siguiente
## se deben instalar los siguientes paquetes "psych" "modeest"
median(P5140, na.rm = T) # mediana
## [1] 450000
prome=mean(P5140 , na.rm = T) # promedio
prome
## [1] 614236.7
desv=sd(P5140 , na.rm = T) #desviacion estandar
desv
## [1] 4931456
var(P5140 , na.rm = T) # varianza
## [1] 2.431926e+13
cv= desv/prome
cv
## [1] 8.028593
mfv(P5140, na_rm = T) # moda
## [1] 4e+05
skew(P5140) #coeficiente de asimetria
## [1] 56.80662
kurtosi(P5140) # kurtosis
## [1] 3382.72
hist(P5140)
# este codigo se debe repetir para las dos cuantitativas o continuas
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.