I am new to writing function in R, I have a dataset(created by me for practice from a large dataset), I want to loop through each column and flag the outlier.Any help or advice is appreciable! This is my dataset:
Time Temperature.C. Relative_Humidity
1 10/24/2022 16:45 32.2 50.0
2 10/24/2022 16:46 30.0 49.0
3 10/24/2022 16:47 31.0 50.0
4 10/24/2022 16:48 30.0 50.5
5 10/24/2022 16:49 30.0 50.0
6 10/24/2022 16:50 31.0 49.0
7 10/24/2022 16:51 32.2 51.0
8 10/24/2022 16:52 86.0 50.5
9 10/24/2022 16:53 30.0 50.0
10 10/24/2022 16:54 30.0 120.0
11 10/24/2022 16:55 30.0 50.0
12 10/24/2022 16:56 86.0 50.0
13 10/24/2022 16:57 30.0 51.0
14 10/24/2022 16:58 31.0 51.0
15 10/24/2022 16:59 31.0 50.0
16 10/24/2022 17:00 31.0 49.0
17 10/24/2022 17:01 3.0 52.0
18 10/24/2022 17:02 32.2 49.0
19 10/24/2022 17:03 30.0 2.0
structure(list(Time = c("10/24/2022 16:45", "10/24/2022 16:46",
"10/24/2022 16:47", "10/24/2022 16:48", "10/24/2022 16:49", "10/24/2022 16:50",
"10/24/2022 16:51", "10/24/2022 16:52", "10/24/2022 16:53", "10/24/2022 16:54",
"10/24/2022 16:55", "10/24/2022 16:56", "10/24/2022 16:57", "10/24/2022 16:58",
"10/24/2022 16:59", "10/24/2022 17:00", "10/24/2022 17:01", "10/24/2022 17:02",
"10/24/2022 17:03"), Temperature.C. = c(32.2, 30, 31, 30, 30,
31, 32.2, 86, 30, 30, 30, 86, 30, 31, 31, 31, 3, 32.2, 30), Relative_Humidity = c(50,
49, 50, 50.5, 50, 49, 51, 50.5, 50, 120, 50, 50, 51, 51, 50,
49, 52, 49, 2)), class = "data.frame", row.names = c(NA, -19L
))
I am expecting my output like this.