chooseCRANmirror(graphics=FALSE, ind=1)
if (!requireNamespace("tree", quietly = TRUE)) {
  install.packages("tree")
}
if (!requireNamespace("ggplot2", quietly = TRUE)) {
  install.packages("ggplot2")
}
library(tree)
library(ggplot2)
data("trees")
Arboles <- subset(trees, Height >= 70 & Height <= 80 & Girth < 13)
head(Arboles)
##    Girth Height Volume
## 1    8.3     70   10.3
## 4   10.5     72   16.4
## 8   11.0     75   18.2
## 9   11.1     80   22.6
## 10  11.2     75   19.9
## 11  11.3     79   24.2
summary(Arboles)
##      Girth           Height          Volume     
##  Min.   : 8.30   Min.   :70.00   Min.   :10.30  
##  1st Qu.:11.03   1st Qu.:74.25   1st Qu.:18.43  
##  Median :11.25   Median :75.00   Median :20.45  
##  Mean   :11.11   Mean   :75.20   Mean   :19.53  
##  3rd Qu.:11.40   3rd Qu.:76.00   3rd Qu.:22.00  
##  Max.   :12.90   Max.   :80.00   Max.   :24.20
ggplot(trees, aes(x = Girth, y = Height)) +
  geom_point(aes(color = ifelse(Height >= 70 & Height <= 80 & Girth < 13, "Filtered", "Not Filtered")),
             shape = 15, size = 4) +
  scale_color_manual(values = c("Filtered" = "green", "Not Filtered" = "black")) +
  labs(
    title = "Altura y Ancho de Árboles Cherry Negros",
    x = "Diámetro (pulgadas)",
    y = "Altura (pies)",
    color = "Diametro vs Altura"
  ) +
  theme_minimal() +
  theme(legend.title = element_blank())