2026-06-14

Simple Weather Prediction App

author: mssm

Introduction

This application is a simple weather prediction App based on temperature (°C), humidity (%) and cloud cover (%).

The result depends on the variation of each variable.

Working process

To generate a weather prediction, three steps are followed:

  1. Adjust the sliders to set the temperature, humidity and cloud cover values.

  2. The selected conditions are evaluated according to predefined weather rules.

  3. Finally, a weather prediction is displayed instantly and updates automatically whenever a value changes.

Prediction rules

The weather prediction is determined according to the following rules:

  • If humidity > 80% then output = “Rainy 🌧”;
  • If cloud cover > 70% then output = “Cloudy ☁️”;
  • If temperature > 25°C then output = “Sunny ☀️”;
  • Otherwise = “Partly Cloudy ⛅”“.

Demonstration code

Considering the following input values: - Humidity = 90% - Cloud cover = 50% - Temperature = 20°C

if (input$humidity > 80) {
  "Rainy 🌧️"
} else if (input$cloud > 70) {
  "Cloudy ☁️"
} else if (input$temp > 25) {
  "Sunny ☀️"
} else {
  "Partly Cloudy ⛅"
}

Since the humidity exceeds 80%, he first condition in the code is satisfiedand the condition is classified as “Rainy 🌧”.

Therefore, the output generated by the application would be: “Rainy🌧”.

Conclusion:

The Weather Prediction App illustrates the core feature of Shiny, including user input widgets, server calculations, and reactive outputs.

Based on the selected weather conditions, the application generates an instant forecast in a simple and interactive way.