Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions Archivos_descargables/ARCHIVOS.r
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
# https://vincentarelbundock.github.io/Rdatasets/datasets.html
# https://archive.ics.uci.edu/ml/machine-learning-databases/

download.file(url="https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data",
destfile = "iris.data")

file.show("iris.data")

names <- c("nombre1","nombre2","nombre3","nombre4","tipo")

datairis <- read.table("iris.data",sep=",",col.names = names)

head(datairis)

download.file(url="https://vincentarelbundock.github.io/Rdatasets/csv/AER/Affairs.csv",
destfile = "affairs1.csv")
file.show("affairs1.csv")

affairs1 <- read.table("affairs1.csv",sep=",",header = FALSE)

head(affairs1)

affairs2 <- read.csv("affairs1.csv")

head(affairs2)


argentinaCPI <- read.csv("https://vincentarelbundock.github.io/Rdatasets/csv/AER/ArgentinaCPI.csv")


head(argentinaCPI)

### EXPORTANDO DATOS

write.table(x=datairis,file="datairis.txt",sep=";",row.names=FALSE,col.names = TRUE)


listaA <- list(
"a" = c(1,2,3,4),
"b" = matrix(1:6,ncol=2),
"c" = "Prueba"
)

saveRDS(object=listaA,file="lista.rds")

listaB <- readRDS("lista.rds")

listaB

## ARCHIVOS EXCEL

install.packages("readxl")
library(readxl)

hojas <- excel_sheets("prueba.xlsx")

hoja1 <- read_excel(path="prueba.xlsx",sheet = hojas[2],range="A2:B4",col_names=c("col1","col2"))

### OTROS TIPOS DE ARCHIVOS

install.packages("haven")
library(haven)

datospss <- read_spss("spss.sav")

head(datospss)

datostata <- read_stata("stata.DTA")

class(datostata)

head(datostata)













42 changes: 42 additions & 0 deletions Archivos_descargables/FUNCIONES.r
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
## DEFINICION DE UNA FUNCION
suma <- function(n1,n2){
return(n1+n2)
}

resta <- function(n1,n2) return(n1-n2)

suman <- function(n){
s <- 0
for(i in 1:n){
s <- s+i
}
return(s)
}
## FUNCIONES APPLY

M1 <- matrix(1:9,nrow=3)
apply(M1,1,sum)

df <- data.frame(rojo = 1:3,azul =3:5)
M2 <- as.matrix(df)

promedio <- function(vector){
N <- length(vector)
s <- 0
for ( i in 1:N){
s <- s+vector[i]
}
return(s/N)
}

## LISTAS Y FUNCION LAPPLY ##

L1 <- list("nombre" = "Pepito", "calificaciones" = c(7,4,8))

L2 <- list("quimica" = c(7,4,8,10), "matematica" = c(7,4,8))

# apply (matrices) -> vector
# lapply (listas) -> lista



57 changes: 57 additions & 0 deletions Archivos_descargables/GRAFICOS.r
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
### GRAFICOS EN R
x <- c(1,2,3,5)
y <- c(4,5,2,3)
plot(x,y,col='red',main='mi primer gráfico',xlab="Eje X",ylab="Eje Y")
z <- as.factor(c('si','no','si','si','no','si'))
plot(z,main="Gráfico de barras")

grid(lwd=2,col='blue')
par(new=TRUE)
plot(x,y,
col='red',
main='mi primer gráfico',
sub='Mi primer subtítulo',
xlab="Eje X",
ylab="Eje Y",
pch=16,
type='b',
lty=2,
lwd=3,
xlim=c(1.5,4.5),
ylim=c(2.5,6))
## GRAFICANDO FUNCIONES
x <- seq(1,3,length=100)
plot(x,x^2,
lwd=1,
type='l',
col='blue')
lines(x,x)


plot(iris$Species)

elementos <- table(iris$Species)
barplot(elementos,col='yellow')

hist(trees$Height,breaks=4)


boxplot(trees$Height)


boxplot(trees$Volume)

hist(trees$Volume)

## EXPORTANDO GRAFICOS

head(trees)

png(filename='grafico.png',height = 700,width = 700)
plot(x=trees$Height,y=trees$Volume,main="Volumen vs Altura",xlab="Altura",ylab="Volumen",col='blue')
dev.off()





29 changes: 29 additions & 0 deletions Archivos_descargables/INTEGRACION.r
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
head(iris)
summary(iris)
lapply(iris,class)

hist(iris$Petal.Length)
hist(iris$Petal.Width)

plot(iris)

plot(y=iris$Petal.Length,x=iris$Petal.Width)


modelo <- lm(Petal.Length~Petal.Width,data=iris)

modelo

#longitud = 2.230*ancho+1.084

names(modelo)

modelo$fitted.values

summary(modelo)


plot(y=iris$Petal.Length,x=iris$Petal.Width,col='red')
X <- seq(0,3,length=1000)
lines(X,2.230*X+1.084,col='green')

151 changes: 151 additions & 0 deletions Archivos_descargables/iris.data
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.4,3.2,1.3,0.2,Iris-setosa
5.0,3.5,1.6,0.6,Iris-setosa
5.1,3.8,1.9,0.4,Iris-setosa
4.8,3.0,1.4,0.3,Iris-setosa
5.1,3.8,1.6,0.2,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
4.9,2.4,3.3,1.0,Iris-versicolor
6.6,2.9,4.6,1.3,Iris-versicolor
5.2,2.7,3.9,1.4,Iris-versicolor
5.0,2.0,3.5,1.0,Iris-versicolor
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
5.6,2.9,3.6,1.3,Iris-versicolor
6.7,3.1,4.4,1.4,Iris-versicolor
5.6,3.0,4.5,1.5,Iris-versicolor
5.8,2.7,4.1,1.0,Iris-versicolor
6.2,2.2,4.5,1.5,Iris-versicolor
5.6,2.5,3.9,1.1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
6.1,2.8,4.0,1.3,Iris-versicolor
6.3,2.5,4.9,1.5,Iris-versicolor
6.1,2.8,4.7,1.2,Iris-versicolor
6.4,2.9,4.3,1.3,Iris-versicolor
6.6,3.0,4.4,1.4,Iris-versicolor
6.8,2.8,4.8,1.4,Iris-versicolor
6.7,3.0,5.0,1.7,Iris-versicolor
6.0,2.9,4.5,1.5,Iris-versicolor
5.7,2.6,3.5,1.0,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.4,3.7,1.0,Iris-versicolor
5.8,2.7,3.9,1.2,Iris-versicolor
6.0,2.7,5.1,1.6,Iris-versicolor
5.4,3.0,4.5,1.5,Iris-versicolor
6.0,3.4,4.5,1.6,Iris-versicolor
6.7,3.1,4.7,1.5,Iris-versicolor
6.3,2.3,4.4,1.3,Iris-versicolor
5.6,3.0,4.1,1.3,Iris-versicolor
5.5,2.5,4.0,1.3,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.1,3.0,4.6,1.4,Iris-versicolor
5.8,2.6,4.0,1.2,Iris-versicolor
5.0,2.3,3.3,1.0,Iris-versicolor
5.6,2.7,4.2,1.3,Iris-versicolor
5.7,3.0,4.2,1.2,Iris-versicolor
5.7,2.9,4.2,1.3,Iris-versicolor
6.2,2.9,4.3,1.3,Iris-versicolor
5.1,2.5,3.0,1.1,Iris-versicolor
5.7,2.8,4.1,1.3,Iris-versicolor
6.3,3.3,6.0,2.5,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
7.1,3.0,5.9,2.1,Iris-virginica
6.3,2.9,5.6,1.8,Iris-virginica
6.5,3.0,5.8,2.2,Iris-virginica
7.6,3.0,6.6,2.1,Iris-virginica
4.9,2.5,4.5,1.7,Iris-virginica
7.3,2.9,6.3,1.8,Iris-virginica
6.7,2.5,5.8,1.8,Iris-virginica
7.2,3.6,6.1,2.5,Iris-virginica
6.5,3.2,5.1,2.0,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
6.8,3.0,5.5,2.1,Iris-virginica
5.7,2.5,5.0,2.0,Iris-virginica
5.8,2.8,5.1,2.4,Iris-virginica
6.4,3.2,5.3,2.3,Iris-virginica
6.5,3.0,5.5,1.8,Iris-virginica
7.7,3.8,6.7,2.2,Iris-virginica
7.7,2.6,6.9,2.3,Iris-virginica
6.0,2.2,5.0,1.5,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
5.6,2.8,4.9,2.0,Iris-virginica
7.7,2.8,6.7,2.0,Iris-virginica
6.3,2.7,4.9,1.8,Iris-virginica
6.7,3.3,5.7,2.1,Iris-virginica
7.2,3.2,6.0,1.8,Iris-virginica
6.2,2.8,4.8,1.8,Iris-virginica
6.1,3.0,4.9,1.8,Iris-virginica
6.4,2.8,5.6,2.1,Iris-virginica
7.2,3.0,5.8,1.6,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
7.9,3.8,6.4,2.0,Iris-virginica
6.4,2.8,5.6,2.2,Iris-virginica
6.3,2.8,5.1,1.5,Iris-virginica
6.1,2.6,5.6,1.4,Iris-virginica
7.7,3.0,6.1,2.3,Iris-virginica
6.3,3.4,5.6,2.4,Iris-virginica
6.4,3.1,5.5,1.8,Iris-virginica
6.0,3.0,4.8,1.8,Iris-virginica
6.9,3.1,5.4,2.1,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
6.8,3.2,5.9,2.3,Iris-virginica
6.7,3.3,5.7,2.5,Iris-virginica
6.7,3.0,5.2,2.3,Iris-virginica
6.3,2.5,5.0,1.9,Iris-virginica
6.5,3.0,5.2,2.0,Iris-virginica
6.2,3.4,5.4,2.3,Iris-virginica
5.9,3.0,5.1,1.8,Iris-virginica

Binary file addedArchivos_descargables/spss.sav
Binary file not shown.
Binary file addedArchivos_descargables/stata.DTA
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,4 +23,4 @@ Una vez termines el curso podrás seguir con los mejores cursos de análisis de
8. Estadística descriptiva con datos cuantitativos
9. Estadística descriptiva con datos cualitativos agrupados
10. Introducción a la regresión lineal
11. Introducción a distribuciones de probabilidad
11. Introducción a distribuciones de probabilidad.
Binary file addedscripts/Tests/01.PRimerRM.pdf
Binary file not shown.
Loading