Professional Documents
Culture Documents
Codigo Ojiva de Horas para La Familia
Codigo Ojiva de Horas para La Familia
> 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.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become e
rrors
> library(readr)
> library(ggplot2)
> library(readxl)
> TresEstados<-read_excel("C:/Users/admon/Documents/Taller 2 Probabilidad y estadistica dep2.xlsx
")
-/ /
- > Tres
Estados<-na.omit(TresEstados)
> TresEstados$Region <-factor(TresEstados$Region)
> TresEstados$Doing_Homework_Hours <- as.numeric(TresEstados$Doing_Things_With_Family_Hours)
> summary(TresEstados$Region)
GA MT OR
263 179 327
> summary(TresEstados$Doing_Homework_Hours)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.000 3.000 5.000 9.007 10.000 150.000
> TresEstados$Doing_Things_With_Family_Hours<- as.numeric(TresEstados$Doing_Things_With_Family_Ho
urs)
> summary(TresEstados$Doing_Things_With_Family_Hours)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.000 3.000 5.000 9.007 10.000 150.000
> x.OR <- TresEstados$Doing_Things_With_Family_Hours)
Error: inesperado ')' en "x.OR <- TresEstados$Doing_Things_With_Family_Hours)"
> x.OR <- TresEstados$Doing_Things_With_Family_Hours[TresEstados$Region=="OR"]
> x.MT <- TresEstados$Doing_Things_With_Family_Hours[TresEstados$Region=="MT"]
> x.GA <- TresEstados$Doing_Things_With_Family_Hours[TresEstados$Region=="GA"]
> par(mfrow=c(1,3))
> x.MT <-sort(x.MT)
> x.GA <-sort(x.GA)
> x.OR <-sort(x.OR)
> acum_x.MT <- (1:length(x.MT))/length(x.MT)
> acum_x.GA <- (1:length(x.GA))/length(x.GA)
> acum_x.OR <- (1:length(x.OR))/length(x.OR)
> plot(x.MT,acum_x.MT,type="s",ylim=c(0,1))
> plot(x.GA,acum_x.GA,type="s",ylim=c(0,1))
> plot(x.OR,acum_x.OR,type="s",ylim=c(0,1))
> intervalos<-c("[0,10)","[10,20)","[20,30)","[30,40)","[40,50)")
> datos<-c(TresEstados)
> hist_result<-hist(datos,breaks=intervalos,plot=FALSE)
Error in hist.default(datos, breaks = intervalos, plot = FALSE) :
'x' must be numeric
> hist_MT <- hist(x.MT, plot = FALSE)
> hist_GA <- hist(x.GA, plot = FALSE)
> hist_OR <- hist(x.OR, plot = FALSE)
>
> frec_acum_MT <- cumsum(hist_MT$counts) / sum(hist_MT$counts)
> frec_acum_GA <- cumsum(hist_GA$counts) / sum(hist_GA$counts)
> frec_acum_OR <- cumsum(hist_OR$counts) / sum(hist_OR$counts)
> print("Frecuencias acumuladas para Montana:")
[1] "Frecuencias acumuladas para Montana:"
> print(frec_acum_MT)
[1] 0.5195531 0.7988827 0.8659218 0.9050279 0.9385475 0.9553073
[7] 0.9608939 0.9608939 0.9720670 1.0000000
> print("Frecuencias acumuladas para Georgia:")
[1] "Frecuencias acumuladas para Georgia:"
> print(frec_acum_GA)
[1] 0.7452471 0.8859316 0.9429658 0.9543726 0.9961977 0.9961977
[7] 0.9961977 0.9961977 1.0000000
R Console Page 2