Estadistica descriptiva con R.
datos<-read.table("http://math.uprm.edu/~edgar/clase97.dat",header=T)
datos
attach(datos)
table(familia)
mytable<-table(escuela,programa)
margin.table(mytable)
margin.table(mytable,1)
margin.table(mytable,2)
prop.table(mytable,2)
ftable(mytable)
fivenum(edad)
summary(edad)
library(Hmisc)
describe(mytable)
mytable
x<-rnorm(m,std)
curve(dnorm(x, mean=m, sd=std), col="darkblue", lwd=2, add=TRUE)
hist(gpa,density=20,nclass=6, probability=T,ylim=c(0,1))
table(programa)
pie(table(programa), main="Clase 1997", col=rainbow(length(table(programa))),labels=c("Biol","Bio Tec","Agric","Micro Biol","Pre Med"))
programa_labels <- round(table(programa)/sum(table(programa)) * 100, 1)
pie(table(programa), main="Clase 1997", col=rainbow(length(table(programa))),labels=programa_labels)
legend(1.5, 0.5, c("Biol","Bio Tec","Agric","Micro Biol","Pre Med"), cex=0.8, fill=colors)
colors <- c("white","grey70","grey90","grey50","black")
barplot(table(programa),ylim=c(0,14),main="Programa")
barplot(table(sexo,programa),ylim=c(0,14),main="Programa",beside=T, col=rainbow(2))
barplot(table(sexo,programa),ylim=c(0,14),main="Programa",beside=T, col=rainbow(2),legend = rownames(table(sexo,programa)))
legend("topleft", c("F","M"), cex=1 , bty="n", fill=rainbow(2))
cv=function(x) sd(x)/mean(x)
cv(gpa)
library(psych)
describe.by(gpa,sexo)
boxplot(gpa ~ sexo, notch = FALSE,col = "blue")
boxplot(gpa ~ sexo, notch = FALSE,col=(c("gold","darkgreen")))
quantile(gpa,probs=c(.1,.5,1,2,5,10,25,50,75,90,95,100)/100)
library(MASS)
data(UScereal)
attach(UScereal)
cereal<-data.frame(UScereal)
write.table(cereal,file="cereal.txt",col.names=TRUE,eol="\r\n")