par(mfrow=c(1, 2))boxplot(data$Pressure_height ~ data$Month, main="Pressure Height across months") boxplot(data$Pressure_height ~ data$Day_of_week, main="Pressure Height for days of week") dev.off()
Funci贸n outliers()
La funci贸n propia outliers() proporciona datos at铆picos, modifica la funci贸n para detectar datos extremos y apl铆cala a las distintas variables de la base de datos ozone, luego piensa que har铆as
# Aplicar la funci贸n a m煤ltiples variables num茅ricas o enterasnumeric_integer_vars <-names(which(sapply(data, is.numeric) |sapply(data, is.integer)))outliers_results <-lapply(paste0("data$", numeric_integer_vars), outliers)###Eliminar el valor extremo de Wind_speedeliminar_extreme("data$Wind_speed")
Estudio Multivariante
library(dbscan)library(class)library(ggplot2)data <-read.csv("ozone.csv") # import datalof<-lof(data[,4:ncol(data)])lof[lof>1.5]data[lof>1.5,]ggplot(data, aes(x = Pressure_height, y = Wind_speed, colour = lof))+geom_point()+scale_color_gradient(low ="blue", high ="red", name ="LOF Score")+labs(title ="Detecci贸n de Valores At铆picos con LOF", x ="Pressure_height", y ="Wind_speed")ggplot(data, aes(x = Pressure_height, y = Ozone_reading, colour = lof))+geom_point()+scale_color_gradient(low ="blue", high ="red", name ="LOF Score")+labs(title ="Detecci贸n de Valores At铆picos con LOF",x ="Pressure_height", y ="Ozone_reading")data$Day_of_week<-as.factor(data$Day_of_week)ggplot(data, aes(x = Pressure_height, y = Wind_speed, color = Day_of_week))+geom_point()+labs(title ="Conjunto de Datos de Ozone", x ="Pressure_height", y ="Wind_speed")