Estadística descriptivas

Variables individuales

1
summary(iris)
1
2
quantile(iris$Sepal.Length)
quantile(iris$Sepal.Length, c(.1, .3, .65))
1
2
var(iris$Sepal.Length)
hist(iris$Sepal.Length)
1
plot(density(iris$Sepal.Length))
1
2
table(iris$Species)
pie(table(iris$Species))
1
barplot(table(iris$Species))

Múltiples variables

1
2
3
4
cov(iris$Sepal.Length, iris$Petal.Length)
cov(iris[,1:4])
cor(iris$Sepal.Length, iris$Petal.Length)
cor(iris[,1:4])
1
aggregate(Sepal.Length ~ Species, summary, data=iris)
1
boxplot(Sepal.Length~Species, data=iris)
1
2
with(iris, plot(Sepal.Length, Sepal.Width,
                col=Species, pch=as.numeric(Species)))
1
plot(jitter(iris$Sepal.Length), jitter(iris$Sepal.Width))
1
pairs(iris)

Y seguimos explorando

1
2
library(scatterplot3d)
scatterplot3d(iris$Petal.Width, iris$Sepal.Length, iris$Sepal.Width)
1
2
## library(rgl)
## plot3d(iris$Petal.Width, iris$Sepal.Length, iris$Sepal.Width)
1
2
distMatrix <- as.matrix(dist(iris[,1:4]))
heatmap(distMatrix)
1
2
3
library(lattice)
levelplot(Petal.Width~Sepal.Length*Sepal.Width, iris, cuts=9,
          col.regions=grey.colors(10)[10:1])
1
2
filled.contour(volcano, color=terrain.colors, asp=1,
               plot.axes=contour(volcano, add=T))
1
persp(volcano, theta=25, phi=30, expand=0.5, col="lightblue")
1
2
library(MASS)
parcoord(iris[1:4], col=iris$Species)
1
2
library(lattice)
parallelplot(~iris[1:4] | Species, data=iris)
1
2
library(ggplot2)
qplot(Sepal.Length, Sepal.Width, data=iris, facets=Species ~.)

Guardar un gráfico en un archivo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## # save as a PDF file
## pdf("myPlot.pdf")
## x <- 1:50
## plot(x, log(x))
## graphics.off()
## #
## # Save as a postscript file
## postscript("myPlot2.ps")
## x <- -20:20
## plot(x, x^2)
## graphics.off()
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.