# Set working directorysetwd("~/Downloads/Intro to R/Cloud-Project")# Load required packages# install.packages(c("tidyverse", "ggpubr", "broom", "plotly"))library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.2 ✔ tibble 3.2.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggpubr)library(broom)library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
X seeding time sne
Min. : 1.00 Length:24 Min. : 0.00 Min. :1.300
1st Qu.: 6.75 Class :character 1st Qu.:15.75 1st Qu.:2.612
Median :12.50 Mode :character Median :32.50 Median :3.250
Mean :12.50 Mean :35.33 Mean :3.169
3rd Qu.:18.25 3rd Qu.:55.25 3rd Qu.:3.962
Max. :24.00 Max. :83.00 Max. :4.650
cloudcover prewetness echomotion rainfall
Min. : 2.200 Min. :0.0180 Length:24 Min. : 0.280
1st Qu.: 3.750 1st Qu.:0.1405 Class :character 1st Qu.: 2.342
Median : 5.250 Median :0.2220 Mode :character Median : 4.335
Mean : 7.246 Mean :0.3271 Mean : 4.403
3rd Qu.: 7.175 3rd Qu.:0.3297 3rd Qu.: 5.575
Max. :37.900 Max. :1.2670 Max. :12.850
# A tibble: 2 × 4
seeding mean_rainfall sd_rainfall n
<chr> <dbl> <dbl> <int>
1 no 4.17 3.52 12
2 yes 4.63 2.78 12
# Boxplotp1 <-ggboxplot(clouds, x ="seeding", y ="rainfall",color ="seeding", palette ="jco",add ="jitter") +theme_minimal()print(p1)
# T-testprint(t.test(rainfall ~ seeding, data = clouds))
Welch Two Sample t-test
data: rainfall by seeding
t = -0.3574, df = 20.871, p-value = 0.7244
alternative hypothesis: true difference in means between group no and group yes is not equal to 0
95 percent confidence interval:
-3.154691 2.229691
sample estimates:
mean in group no mean in group yes
4.171667 4.634167
# Multiple Linear Regression Modelmodel1 <-lm(rainfall ~ seeding + cloudcover + prewetness + echomotion + sne, data = clouds)print(summary(model1))
Call:
lm(formula = rainfall ~ seeding + cloudcover + prewetness + echomotion +
sne, data = clouds)
Residuals:
Min 1Q Median 3Q Max
-5.1158 -1.7078 -0.2422 1.3368 6.4827
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.37680 2.43432 2.620 0.0174 *
seedingyes 1.12011 1.20725 0.928 0.3658
cloudcover 0.01821 0.11508 0.158 0.8761
prewetness 2.55109 2.70090 0.945 0.3574
echomotionstationary 2.59855 1.54090 1.686 0.1090
sne -1.27530 0.68015 -1.875 0.0771 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.855 on 18 degrees of freedom
Multiple R-squared: 0.3403, Adjusted R-squared: 0.157
F-statistic: 1.857 on 5 and 18 DF, p-value: 0.1524