data(AirQuality)
# Replace missing values (-200) with NA
AirQuality[AirQuality == -200] <- NA
# Check if there are non-NA values before plotting
if (sum(!is.na(AirQuality$CO.GT.)) > 0) {
plot(AirQuality$CO.GT., type = "l", ylab = "CO (mg/m³)",
main = "Hourly CO Concentration")
} else {
message("No non-NA values in CO.GT. column to plot")
}
Run the code above in your browser using DataLab