x
[1] 1 3 5
y
[1] 1 6 2
length(x)
[1] 3
length(y)
[1] 3
x+y
[1] 2 9 7
ls()
[1] "x" "y"
ls()
character(0)
x
[,1] [,2]
[1,] 1 3
[2,] 2 4
y
[,1] [,2]
[1,] 1 2
[2,] 3 4
sqrt(y)
[,1] [,2]
[1,] 1.000000 1.414214
[2,] 1.732051 2.000000
x^2
[,1] [,2]
[1,] 1 9
[2,] 4 16
cor(x,y)
[1] 0.6688024
round(rnorm(50), 4)
[1] -1.1440 1.3421 2.1854 0.5364 0.0632 0.5022 -0.0004 0.5658 -0.5725 -1.1102
[11] -0.0487 -0.6957 0.8289 0.2067 -0.2357 -0.5563 -0.3648 0.8624 -0.6308 0.3136
[21] -0.9315 0.8239 0.5234 0.7069 0.4202 -0.2691 -1.5103 -0.6902 -0.1435 -1.0135
[31] 1.5733 0.0127 0.8726 0.4221 -0.0188 2.6157 -0.6931 -0.2663 -0.7206 1.3677
[41] 0.2640 0.6322 -1.3307 0.0269 1.0406 1.3120 -0.0300 -0.2500 0.0234 1.6599
mean(y)
[1] 0.01103557
var(y)
[1] 0.7328675
sqrt(var(y))
[1] 0.8560768
sd(y)
[1] 0.8560768
x
[1] 1 2 3 4 5 6 7 8 9 10
x
[1] 1 2 3 4 5 6 7 8 9 10
round(x, 4)
[1] -3.1416 -3.0134 -2.8851 -2.7569 -2.6287 -2.5005 -2.3722 -2.2440 -2.1158
[10] -1.9875 -1.8593 -1.7311 -1.6029 -1.4746 -1.3464 -1.2182 -1.0899 -0.9617
[19] -0.8335 -0.7053 -0.5770 -0.4488 -0.3206 -0.1923 -0.0641 0.0641 0.1923
[28] 0.3206 0.4488 0.5770 0.7053 0.8335 0.9617 1.0899 1.2182 1.3464
[37] 1.4746 1.6029 1.7311 1.8593 1.9875 2.1158 2.2440 2.3722 2.5005
[46] 2.6287 2.7569 2.8851 3.0134 3.1416
A
[,1] [,2] [,3] [,4]
[1,] 1 5 9 13
[2,] 2 6 10 14
[3,] 3 7 11 15
[4,] 4 8 12 16
A[2,3]
[1] 10
A[c(1,3), c(2,4)]
[,1] [,2]
[1,] 5 13
[2,] 7 15
A[1:3, 2:4]
[,1] [,2] [,3]
[1,] 5 9 13
[2,] 6 10 14
[3,] 7 11 15
A[1:2, ]
[,1] [,2] [,3] [,4]
[1,] 1 5 9 13
[2,] 2 6 10 14
A[,1:2]
[,1] [,2]
[1,] 1 5
[2,] 2 6
[3,] 3 7
[4,] 4 8
A[1,]
[1] 1 5 9 13
A[-c(1,3), ]
[,1] [,2] [,3] [,4]
[1,] 2 6 10 14
[2,] 4 8 12 16
A[-c(1,3), -c(1,3,4)]
[1] 6 8
names(Auto)
[1] "mpg" "cylinders" "displacement" "horsepower" "weight"
[6] "acceleration" "year" "origin" "name"
plot(horsepower, mpg)
identify(horsepower, mpg, name)
integer(0)
summary(Auto)
mpg cylinders displacement horsepower weight
Min. : 9.00 Min. :3.000 Min. : 68.0 Min. : 46.0 Min. :1613
1st Qu.:17.00 1st Qu.:4.000 1st Qu.:105.0 1st Qu.: 75.0 1st Qu.:2225
Median :22.75 Median :4.000 Median :151.0 Median : 93.5 Median :2804
Mean :23.45 Mean :5.472 Mean :194.4 Mean :104.5 Mean :2978
3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:275.8 3rd Qu.:126.0 3rd Qu.:3615
Max. :46.60 Max. :8.000 Max. :455.0 Max. :230.0 Max. :5140
acceleration year origin name
Min. : 8.00 Min. :70.00 Min. :1.000 amc matador : 5
1st Qu.:13.78 1st Qu.:73.00 1st Qu.:1.000 ford pinto : 5
Median :15.50 Median :76.00 Median :1.000 toyota corolla : 5
Mean :15.54 Mean :75.98 Mean :1.577 amc gremlin : 4
3rd Qu.:17.02 3rd Qu.:79.00 3rd Qu.:2.000 amc hornet : 4
Max. :24.80 Max. :82.00 Max. :3.000 chevrolet chevette: 4
(Other) :365
summary(mpg)
Min. 1st Qu. Median Mean 3rd Qu. Max.
9.00 17.00 22.75 23.45 29.00 46.60
dim(College)
[1] 777 18
summary(college)
Private Apps Accept Enroll Top10perc
No :212 Min. : 81 Min. : 72 Min. : 35 Min. : 1.00
Yes:565 1st Qu.: 776 1st Qu.: 604 1st Qu.: 242 1st Qu.:15.00
Median : 1558 Median : 1110 Median : 434 Median :23.00
Mean : 3002 Mean : 2019 Mean : 780 Mean :27.56
3rd Qu.: 3624 3rd Qu.: 2424 3rd Qu.: 902 3rd Qu.:35.00
Max. :48094 Max. :26330 Max. :6392 Max. :96.00
Top25perc F.Undergrad P.Undergrad Outstate Room.Board
Min. : 9.0 Min. : 139 Min. : 1.0 Min. : 2340 Min. :1780
1st Qu.: 41.0 1st Qu.: 992 1st Qu.: 95.0 1st Qu.: 7320 1st Qu.:3597
Median : 54.0 Median : 1707 Median : 353.0 Median : 9990 Median :4200
Mean : 55.8 Mean : 3700 Mean : 855.3 Mean :10441 Mean :4358
3rd Qu.: 69.0 3rd Qu.: 4005 3rd Qu.: 967.0 3rd Qu.:12925 3rd Qu.:5050
Max. :100.0 Max. :31643 Max. :21836.0 Max. :21700 Max. :8124
Books Personal PhD Terminal S.F.Ratio
Min. : 96.0 Min. : 250 Min. : 8.00 Min. : 24.0 Min. : 2.50
1st Qu.: 470.0 1st Qu.: 850 1st Qu.: 62.00 1st Qu.: 71.0 1st Qu.:11.50
Median : 500.0 Median :1200 Median : 75.00 Median : 82.0 Median :13.60
Mean : 549.4 Mean :1341 Mean : 72.66 Mean : 79.7 Mean :14.09
3rd Qu.: 600.0 3rd Qu.:1700 3rd Qu.: 85.00 3rd Qu.: 92.0 3rd Qu.:16.50
Max. :2340.0 Max. :6800 Max. :103.00 Max. :100.0 Max. :39.80
perc.alumni Expend Grad.Rate Elite
Min. : 0.00 Min. : 3186 Min. : 10.00 Yes: 78
1st Qu.:13.00 1st Qu.: 6751 1st Qu.: 53.00 No :699
Median :21.00 Median : 8377 Median : 65.00
Mean :22.74 Mean : 9660 Mean : 65.46
3rd Qu.:31.00 3rd Qu.:10830 3rd Qu.: 78.00
Max. :64.00 Max. :56233 Max. :118.00
summary(Elite)
Yes No
78 699
Con la data podemos darnos cuenta que más de 500 universidades en Estados Unidos aceptan menos de 1000 personas al año.
Al rededor de 200 universidades tiene de 70 a 80 Ph. D. en su claustro.
Definitivamente las universidades que son consideradas de elite son más costosas que las universidades que no son conideradas de elite, por la matriculación out-of-state.
names(Auto)
[1] "mpg" "cylinders" "displacement" "horsepower" "weight"
[6] "acceleration" "year" "origin" "name"
typeof(mpg)
[1] "double"
typeof(cylinders)
[1] "integer"
typeof(displacement)
[1] "double"
typeof(horsepower)
[1] "double"
typeof(weight)
[1] "double"
typeof(acceleration)
[1] "double"
typeof(year)
[1] "double"
typeof(origin)
[1] "double"
typeof(name)
[1] "integer"
head(Auto)
ranges<-data.frame(range(mpg),
range(displacement),
range(horsepower),
range(weight),
range(acceleration))
ranges
means<-c(mean(mpg), mean(displacement),
mean(horsepower), mean(weight), mean(acceleration))
sds<-c(sd(mpg), sd(displacement),
sd(horsepower), sd(weight), sd(acceleration))
meanss<-data.frame(t(means))
sdss<-data.frame(t(sds))
colnames(meanss)<-c("mpg", "displacment", "horsepower", "weight", "acceleration")
colnames(sdss)<-c("mpg", "displacment", "horsepower", "weight", "acceleration")
statss
statss<-rbind(meanss, sdss)
rownames(statss)<-c("Means", "Std. Devs")
statss
Auto<-Auto[-(10:84),] #Removemos desde la observacion 10 hasta la 85
attach(Auto)
meant<-c(mean(mpg), mean(displacement),
mean(horsepower), mean(weight), mean(acceleration))
sdt<-c(sd(mpg), sd(displacement),
sd(horsepower), sd(weight), sd(acceleration))
meants<-data.frame(t(meant))
sdts<-data.frame(t(sdt))
colnames(meants)<-c("mpg", "displacment", "horsepower", "weight", "acceleration")
colnames(sdts)<-c("mpg", "displacment", "horsepower", "weight", "acceleration")
statts<-rbind(meants, sdts)
rownames(statts)<-c("Means", "Std. Devs")
statts
De la información anterior podemos notar que:
Yo sugeriría utilizar las variables “displacement”, “horsepower”, “weight”, acceleration, y year ya que de las graficas anteriores, parecen tener una relación estrecha ya sea posistiva o negativa con la variable “mpg”.
dim(Boston)
[1] 506 14
names(Boston)
[1] "crim" "zn" "indus" "chas" "nox" "rm" "age"
[8] "dis" "rad" "tax" "ptratio" "black" "lstat" "medv"
De las gráficas anteriores podemos deducir:
highTax<-Boston %>%
filter(tax > mean(tax))
highCrim<-Boston %>%
filter(crim > mean(crim))
highPtratio<-Boston %>%
filter(crim > mean(ptratio))
sum(subsBoundRiv)
[1] 35
Con el dataset nos damos cuenta que 35 suburbios están cercanos al Rio Charles.
median(medPTR$ptratio)
[1] 19.05
La media de Pupil-Tutor Ratio es 19.05
nrow(rm7)
[1] 64
En promedio 64 viviendas tiene más de 7 cuartos.
En promedio 13 viviendas tiene más de 8 cuartos