Mar13 RPRIN
datos <- iris
str(datos)
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
plot(datos$Petal.Length, main= 'Datos "Iris", n=150')

plot(datos$Petal.Length, main= 'Datos "Iris", n=150', ylab = "Largo de Pétalo")

plot(datos$Petal.Width, main= 'Datos "Iris", n=150', ylab = "Ancho de Pétalo")

plot(datos$Petal.Width, main= 'Datos "Iris", n=150', ylab = "Ancho de Pétalo", pch = 12)

plot(datos$Petal.Width, main= 'Datos "Iris", n=150', ylab = "Ancho de Pétalo", pch = 10)

plot(datos$Sepal.Length, main= 'Datos "Iris", n=150', ylab = "Largo de Sépalo", pch = 15, bty = "l")

plot(datos$Sepal.Length, main= 'Datos "Iris", n=150', ylab = "Largo de Sépalo", pch = 15, bty = "c")

plot(datos$Sepal.Length, main= 'Datos "Iris", n=150', ylab = "Largo de Sépalo", pch = 15, bty = "u")

plot(datos$Sepal.Length, main= 'Datos "Iris", n=150', ylab = "Largo de Sépalo", pch = 15, bty = "7")

plot(datos$Sepal.Length, main= 'Datos "Iris", n=150', ylab = "Largo de Sépalo", pch = 15, bty = "n")

plot(datos$Sepal.Width, main= 'Datos "Iris", n=150', ylab = "Ancho de Sépalo", pch = 20, bty = "n")

plot(datos$Sepal.Width ~ datos$Species, main= 'Datos "Iris", n=150', ylab = "Ancho de Sépalo", pch = 20, bty = "n")

plot(datos$Sepal.Width ~ datos$Species, main= 'Datos "Iris", n=150', ylab = "Ancho de Sépalo")

plot(datos$Sepal.Width ~ datos$Species, main= 'Datos "Iris", n=150', ylab = "Ancho de Sépalo", pch= 20)

db1 <- data.frame(especie =c('a','b','c','d','e','f','g','h','i','j'),
abundancia = c(20,14,12,10,2,22,8,7,1,13))
db1
## especie abundancia
## 1 a 20
## 2 b 14
## 3 c 12
## 4 d 10
## 5 e 2
## 6 f 22
## 7 g 8
## 8 h 7
## 9 i 1
## 10 j 13
str(db1)
## 'data.frame': 10 obs. of 2 variables:
## $ especie : chr "a" "b" "c" "d" ...
## $ abundancia: num 20 14 12 10 2 22 8 7 1 13
db1$especie <- as.factor(db1$especie)
str(db1)
## 'data.frame': 10 obs. of 2 variables:
## $ especie : Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10
## $ abundancia: num 20 14 12 10 2 22 8 7 1 13
barplot(abundancia ~ especie, data= db1)

library(googlesheets4)
ss="https://docs.google.com/spreadsheets/d/14WQpDrw0rBhdHJq5J12cJw8xrrGPpZs26WKO6BG6OSs/edit?usp=sharing"
db2 <- read_sheet(ss,
sheet = 3,
col_names = TRUE,)
## Suitable tokens found in the cache, associated with these emails:
## * fvillatorop@miumg.edu.gt
## * msc.fvilla@digi.usac.edu.gt
## The first will be used.
## Using an auto-discovered, cached token.
## To suppress this message, modify your code or options to clearly consent to the use of a cached token.
## See gargle's "Non-interactive auth" vignette for more details:
## https://gargle.r-lib.org/articles/non-interactive-auth.html
## The googlesheets4 package is using a cached token for fvillatorop@miumg.edu.gt.
## Reading from "datosexcel"
## Range "'Sheet3'"
str(db2)
## tibble [26 x 5] (S3: tbl_df/tbl/data.frame)
## $ hh.id : num [1:26] 1 2 3 4 5 6 7 8 9 10 ...
## $ piso : chr [1:26] "A.Tyles" "Concrete" "Concrete" "Dirt" ...
## $ pared : chr [1:26] "1.Block" "1.Block" "1.Block" "adobe" ...
## $ rest.alim: chr [1:26] "No" "Si" "Si" "Si" ...
## $ techo : chr [1:26] "zinc" "zinc" "zinc" "zinc" ...
head(db2)
## # A tibble: 6 x 5
## hh.id piso pared rest.alim techo
## <dbl> <chr> <chr> <chr> <chr>
## 1 1 A.Tyles 1.Block No zinc
## 2 2 Concrete 1.Block Si zinc
## 3 3 Concrete 1.Block Si zinc
## 4 4 Dirt adobe Si zinc
## 5 5 Dirt adobe No zinc
## 6 6 Dirt adobe Si zinc
table(db2$pared)
##
## 1.Block adobe Wood-Cane zinc_other
## 10 13 1 2
barplot( table(db2$pared) )

barplot(table(db2$pared), ylab= "Cantidad de hogares")

barplot(table(db2$pared),
ylab= "Cantidad de hogares",
names.arg = c('A', 'B','C', "D"))

barplot(table(db2$pared),
xlab= "Cantidad de hogares",
horiz = TRUE,
names.arg = c('A', 'B','C', "D"),
las = 1)

barplot(table(db2$pared),
xlab= "Cantidad de hogares",
horiz = TRUE,
names.arg = c('A', 'B','C', "D"),
las = 2)

barplot(table(db2$pared),
xlab= "Cantidad de hogares",
horiz = TRUE,
names.arg = c('A', 'B','C', "D"),
las = 1)

barplot(table(db2$pared),
xlab= "Cantidad de hogares",
horiz = TRUE,
names.arg = c('A', 'B','C', "D"),
las = 2)

#
table(db2$piso, db2$pared)
##
## 1.Block adobe Wood-Cane zinc_other
## A.Tyles 1 0 0 0
## Concrete 4 1 0 1
## Dirt 5 12 1 1
db2 <- table(db2$piso, db2$pared)
db2
##
## 1.Block adobe Wood-Cane zinc_other
## A.Tyles 1 0 0 0
## Concrete 4 1 0 1
## Dirt 5 12 1 1
barplot( db2 )

barplot( db2 , legend.text = rownames(db2))

barplot( db2 , legend.text = rownames(db2), beside = TRUE)

barplot( db2 , legend.text = rownames(db2), beside = FALSE)

barplot( db2 , legend.text = rownames(db2), beside = TRUE)

datos <- iris
str(datos)
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
datos
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
## 7 4.6 3.4 1.4 0.3 setosa
## 8 5.0 3.4 1.5 0.2 setosa
## 9 4.4 2.9 1.4 0.2 setosa
## 10 4.9 3.1 1.5 0.1 setosa
## 11 5.4 3.7 1.5 0.2 setosa
## 12 4.8 3.4 1.6 0.2 setosa
## 13 4.8 3.0 1.4 0.1 setosa
## 14 4.3 3.0 1.1 0.1 setosa
## 15 5.8 4.0 1.2 0.2 setosa
## 16 5.7 4.4 1.5 0.4 setosa
## 17 5.4 3.9 1.3 0.4 setosa
## 18 5.1 3.5 1.4 0.3 setosa
## 19 5.7 3.8 1.7 0.3 setosa
## 20 5.1 3.8 1.5 0.3 setosa
## 21 5.4 3.4 1.7 0.2 setosa
## 22 5.1 3.7 1.5 0.4 setosa
## 23 4.6 3.6 1.0 0.2 setosa
## 24 5.1 3.3 1.7 0.5 setosa
## 25 4.8 3.4 1.9 0.2 setosa
## 26 5.0 3.0 1.6 0.2 setosa
## 27 5.0 3.4 1.6 0.4 setosa
## 28 5.2 3.5 1.5 0.2 setosa
## 29 5.2 3.4 1.4 0.2 setosa
## 30 4.7 3.2 1.6 0.2 setosa
## 31 4.8 3.1 1.6 0.2 setosa
## 32 5.4 3.4 1.5 0.4 setosa
## 33 5.2 4.1 1.5 0.1 setosa
## 34 5.5 4.2 1.4 0.2 setosa
## 35 4.9 3.1 1.5 0.2 setosa
## 36 5.0 3.2 1.2 0.2 setosa
## 37 5.5 3.5 1.3 0.2 setosa
## 38 4.9 3.6 1.4 0.1 setosa
## 39 4.4 3.0 1.3 0.2 setosa
## 40 5.1 3.4 1.5 0.2 setosa
## 41 5.0 3.5 1.3 0.3 setosa
## 42 4.5 2.3 1.3 0.3 setosa
## 43 4.4 3.2 1.3 0.2 setosa
## 44 5.0 3.5 1.6 0.6 setosa
## 45 5.1 3.8 1.9 0.4 setosa
## 46 4.8 3.0 1.4 0.3 setosa
## 47 5.1 3.8 1.6 0.2 setosa
## 48 4.6 3.2 1.4 0.2 setosa
## 49 5.3 3.7 1.5 0.2 setosa
## 50 5.0 3.3 1.4 0.2 setosa
## 51 7.0 3.2 4.7 1.4 versicolor
## 52 6.4 3.2 4.5 1.5 versicolor
## 53 6.9 3.1 4.9 1.5 versicolor
## 54 5.5 2.3 4.0 1.3 versicolor
## 55 6.5 2.8 4.6 1.5 versicolor
## 56 5.7 2.8 4.5 1.3 versicolor
## 57 6.3 3.3 4.7 1.6 versicolor
## 58 4.9 2.4 3.3 1.0 versicolor
## 59 6.6 2.9 4.6 1.3 versicolor
## 60 5.2 2.7 3.9 1.4 versicolor
## 61 5.0 2.0 3.5 1.0 versicolor
## 62 5.9 3.0 4.2 1.5 versicolor
## 63 6.0 2.2 4.0 1.0 versicolor
## 64 6.1 2.9 4.7 1.4 versicolor
## 65 5.6 2.9 3.6 1.3 versicolor
## 66 6.7 3.1 4.4 1.4 versicolor
## 67 5.6 3.0 4.5 1.5 versicolor
## 68 5.8 2.7 4.1 1.0 versicolor
## 69 6.2 2.2 4.5 1.5 versicolor
## 70 5.6 2.5 3.9 1.1 versicolor
## 71 5.9 3.2 4.8 1.8 versicolor
## 72 6.1 2.8 4.0 1.3 versicolor
## 73 6.3 2.5 4.9 1.5 versicolor
## 74 6.1 2.8 4.7 1.2 versicolor
## 75 6.4 2.9 4.3 1.3 versicolor
## 76 6.6 3.0 4.4 1.4 versicolor
## 77 6.8 2.8 4.8 1.4 versicolor
## 78 6.7 3.0 5.0 1.7 versicolor
## 79 6.0 2.9 4.5 1.5 versicolor
## 80 5.7 2.6 3.5 1.0 versicolor
## 81 5.5 2.4 3.8 1.1 versicolor
## 82 5.5 2.4 3.7 1.0 versicolor
## 83 5.8 2.7 3.9 1.2 versicolor
## 84 6.0 2.7 5.1 1.6 versicolor
## 85 5.4 3.0 4.5 1.5 versicolor
## 86 6.0 3.4 4.5 1.6 versicolor
## 87 6.7 3.1 4.7 1.5 versicolor
## 88 6.3 2.3 4.4 1.3 versicolor
## 89 5.6 3.0 4.1 1.3 versicolor
## 90 5.5 2.5 4.0 1.3 versicolor
## 91 5.5 2.6 4.4 1.2 versicolor
## 92 6.1 3.0 4.6 1.4 versicolor
## 93 5.8 2.6 4.0 1.2 versicolor
## 94 5.0 2.3 3.3 1.0 versicolor
## 95 5.6 2.7 4.2 1.3 versicolor
## 96 5.7 3.0 4.2 1.2 versicolor
## 97 5.7 2.9 4.2 1.3 versicolor
## 98 6.2 2.9 4.3 1.3 versicolor
## 99 5.1 2.5 3.0 1.1 versicolor
## 100 5.7 2.8 4.1 1.3 versicolor
## 101 6.3 3.3 6.0 2.5 virginica
## 102 5.8 2.7 5.1 1.9 virginica
## 103 7.1 3.0 5.9 2.1 virginica
## 104 6.3 2.9 5.6 1.8 virginica
## 105 6.5 3.0 5.8 2.2 virginica
## 106 7.6 3.0 6.6 2.1 virginica
## 107 4.9 2.5 4.5 1.7 virginica
## 108 7.3 2.9 6.3 1.8 virginica
## 109 6.7 2.5 5.8 1.8 virginica
## 110 7.2 3.6 6.1 2.5 virginica
## 111 6.5 3.2 5.1 2.0 virginica
## 112 6.4 2.7 5.3 1.9 virginica
## 113 6.8 3.0 5.5 2.1 virginica
## 114 5.7 2.5 5.0 2.0 virginica
## 115 5.8 2.8 5.1 2.4 virginica
## 116 6.4 3.2 5.3 2.3 virginica
## 117 6.5 3.0 5.5 1.8 virginica
## 118 7.7 3.8 6.7 2.2 virginica
## 119 7.7 2.6 6.9 2.3 virginica
## 120 6.0 2.2 5.0 1.5 virginica
## 121 6.9 3.2 5.7 2.3 virginica
## 122 5.6 2.8 4.9 2.0 virginica
## 123 7.7 2.8 6.7 2.0 virginica
## 124 6.3 2.7 4.9 1.8 virginica
## 125 6.7 3.3 5.7 2.1 virginica
## 126 7.2 3.2 6.0 1.8 virginica
## 127 6.2 2.8 4.8 1.8 virginica
## 128 6.1 3.0 4.9 1.8 virginica
## 129 6.4 2.8 5.6 2.1 virginica
## 130 7.2 3.0 5.8 1.6 virginica
## 131 7.4 2.8 6.1 1.9 virginica
## 132 7.9 3.8 6.4 2.0 virginica
## 133 6.4 2.8 5.6 2.2 virginica
## 134 6.3 2.8 5.1 1.5 virginica
## 135 6.1 2.6 5.6 1.4 virginica
## 136 7.7 3.0 6.1 2.3 virginica
## 137 6.3 3.4 5.6 2.4 virginica
## 138 6.4 3.1 5.5 1.8 virginica
## 139 6.0 3.0 4.8 1.8 virginica
## 140 6.9 3.1 5.4 2.1 virginica
## 141 6.7 3.1 5.6 2.4 virginica
## 142 6.9 3.1 5.1 2.3 virginica
## 143 5.8 2.7 5.1 1.9 virginica
## 144 6.8 3.2 5.9 2.3 virginica
## 145 6.7 3.3 5.7 2.5 virginica
## 146 6.7 3.0 5.2 2.3 virginica
## 147 6.3 2.5 5.0 1.9 virginica
## 148 6.5 3.0 5.2 2.0 virginica
## 149 6.2 3.4 5.4 2.3 virginica
## 150 5.9 3.0 5.1 1.8 virginica
plot(Petal.Width ~ Petal.Length, data=datos,
pch=19)

plot(Petal.Width ~ Petal.Length, data=datos,
col= c(1:3)[as.integer(Species)],
pch = c(1:3)[as.integer(Species)])

##
c(1:3)[as.integer(datos$Species)]
## [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3
## [112] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [149] 3 3
as.integer(datos$Species)
## [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
## [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3
## [112] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
## [149] 3 3
#
plot(Petal.Width ~ Petal.Length, data=datos,
col= c("brown", "red", "gray")[as.integer(Species)],
pch = c(1:3)[as.integer(Species)])

#
plot(Petal.Width ~ Petal.Length, data=datos,
col= c("brown", "red", "light blue")[as.integer(Species)],
pch = c(1:3)[as.integer(Species)])

plot(Petal.Width ~ Petal.Length, data=datos,
col= c("brown", "pink", "blue")[as.integer(Species)],
pch = c(1:3)[as.integer(Species)])

plot(Petal.Width ~ Petal.Length, data=datos,
col= c("brown", "pink", "blue")[as.integer(Species)],
pch = c(20, 15, 12)[as.integer(Species)])
legend(x="topleft",
legend= c('setosa','versicolor',
'virginica'),
pch= c(20, 15, 12),
col=c("brown", "pink", "blue"))
legend(x="topleft",
legend= c('setosa','versicolor',
'virginica'),
pch= c(20, 15, 12),
col=c("brown", "pink", "blue"))

plot(Petal.Width ~ Petal.Length, data=datos,
col= c("brown", "pink", "blue")[as.integer(Species)],
pch = c(20, 15, 12)[as.integer(Species)])
legend(x="topleft",
legend= c('setosa','versicolor',
'virginica'),
pch= c(20, 15, 12),
col=c("brown", "pink", "blue"))
lm <- lm( Petal.Width ~ Petal.Length, data= datos)
abline(lm, lty="dashed")
abline(lm, lty="dashed", col= 2)
abline(lm, lty="dashed", col= 4)
abline(lm, lty="dashed", col= 1)
abline(lm, lty="dashed", col= "green")
abline(lm, lty="dashed", col= 1)
abline(lm, col= 1)
abline(a= 0.5 , b=1.2, col= 1)

plot(Petal.Width ~ Petal.Length, data=datos,
col= c("brown", "pink", "blue")[as.integer(Species)],
pch = c(20, 15, 12)[as.integer(Species)])
legend(x="topleft",
legend= c('setosa','versicolor',
'virginica'),
pch= c(20, 15, 12),
col=c("brown", "pink", "blue"))
abline(lm, col= 1)

help(abline)
## starting httpd help server ...
## done
head(datos)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
plot(datos)

plot(datos, pch= 20)

plot(datos, pch= 19)

plot(datos, pch= 21)

plot(datos, pch= 12)

plot(datos, pch= 20)

3D
library(scatterplot3d)
library(rgl)
## Warning: package 'rgl' was built under R version 4.0.4
attach(datos)
scatterplot3d(Sepal.Length,
Sepal.Width,
Petal.Length,
pch=19,
type='h',
color = c(1:3)[as.integer(Species)])

scatterplot3d(Sepal.Length,
Sepal.Width,
Petal.Length,
pch=19,
color = c(1:3)[as.integer(Species)])

##
scatterplot3d(Sepal.Length,
Sepal.Width,
Petal.Length,
pch=19,
type='h',
color = c(1:3)[as.integer(Species)])

#
scatterplot3d(Sepal.Length,
Sepal.Width,
Petal.Length,
pch=19,
type='h',
color = c("red", "blue", "green")[as.integer(Species)])

detach(datos)
### rgl
attach(iris)
plot3d(Sepal.Length, Sepal.Width, Petal.Length,
pch = 16,
size = 2,
type = "s",
col = c(1:3)[as.integer(Species)])
plot3d(Sepal.Length, Sepal.Width, Petal.Length,
pch = 16,
size = 3,
type = "s",
col = c(1:3)[as.integer(Species)])
plot3d(Sepal.Length, Sepal.Width, Petal.Length,
pch = 16,
size = 1.5,
type = "s",
col = c(1:3)[as.integer(Species)])
plot3d(Sepal.Length, Sepal.Width, Petal.Length,
pch = 16,
size = 2,
type = "s",
col = c(1:3)[as.integer(Species)])
legend3d("topright",
col=c(1:3),
legend=levels(Species),
pch=16)
##
diente <- ToothGrowth
diente
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
## 7 11.2 VC 0.5
## 8 11.2 VC 0.5
## 9 5.2 VC 0.5
## 10 7.0 VC 0.5
## 11 16.5 VC 1.0
## 12 16.5 VC 1.0
## 13 15.2 VC 1.0
## 14 17.3 VC 1.0
## 15 22.5 VC 1.0
## 16 17.3 VC 1.0
## 17 13.6 VC 1.0
## 18 14.5 VC 1.0
## 19 18.8 VC 1.0
## 20 15.5 VC 1.0
## 21 23.6 VC 2.0
## 22 18.5 VC 2.0
## 23 33.9 VC 2.0
## 24 25.5 VC 2.0
## 25 26.4 VC 2.0
## 26 32.5 VC 2.0
## 27 26.7 VC 2.0
## 28 21.5 VC 2.0
## 29 23.3 VC 2.0
## 30 29.5 VC 2.0
## 31 15.2 OJ 0.5
## 32 21.5 OJ 0.5
## 33 17.6 OJ 0.5
## 34 9.7 OJ 0.5
## 35 14.5 OJ 0.5
## 36 10.0 OJ 0.5
## 37 8.2 OJ 0.5
## 38 9.4 OJ 0.5
## 39 16.5 OJ 0.5
## 40 9.7 OJ 0.5
## 41 19.7 OJ 1.0
## 42 23.3 OJ 1.0
## 43 23.6 OJ 1.0
## 44 26.4 OJ 1.0
## 45 20.0 OJ 1.0
## 46 25.2 OJ 1.0
## 47 25.8 OJ 1.0
## 48 21.2 OJ 1.0
## 49 14.5 OJ 1.0
## 50 27.3 OJ 1.0
## 51 25.5 OJ 2.0
## 52 26.4 OJ 2.0
## 53 22.4 OJ 2.0
## 54 24.5 OJ 2.0
## 55 24.8 OJ 2.0
## 56 30.9 OJ 2.0
## 57 26.4 OJ 2.0
## 58 27.3 OJ 2.0
## 59 29.4 OJ 2.0
## 60 23.0 OJ 2.0
str(diente)
## 'data.frame': 60 obs. of 3 variables:
## $ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
## $ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
## $ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
plot(diente$len, pch= 19)
plot(diente$len, pch= 19)

plot(diente$len, pch= 20)

plot(diente$len, pch= 20, col= "brown")

plot(diente$len, pch= 20, col= "brown", type= "n")

plot(diente$len, pch= 20, col= "brown", bty= "n")

plot(diente$len ~ diente$supp, pch= 20, col= "brown", bty= "n")

plot(diente$len ~ diente$dose, pch= 20, col= "brown", bty= "n")

head(diente)
## len supp dose
## 1 4.2 VC 0.5
## 2 11.5 VC 0.5
## 3 7.3 VC 0.5
## 4 5.8 VC 0.5
## 5 6.4 VC 0.5
## 6 10.0 VC 0.5
str(diente)
## 'data.frame': 60 obs. of 3 variables:
## $ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
## $ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
## $ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
plot(diente$len ~ as.factor(diente$dose), pch= 20, col= "brown", bty= "n")

boxplot(diente$len ~ diente$supp*diente$dose)

plot(diente$len ~ diente$supp*diente$dose)


boxplot(diente$len ~ diente$supp*diente$dose)

plot(diente$len ~ diente$supp*diente$dose)


plot(diente$len ~ diente$supp*as.factor(diente$dose) )


plot(diente$len ~ diente$supp )

plot(diente$len ~ diente$supp, notch=T )

plot(diente$len ~ diente$supp, notch=T , horizontal=T)

help(boxplot)
help(hist)