Perhaps something like this.
The mistake you made at first is incorrect use of the pipe.
This code assumes the max L30 for each time is what defines the dotted line. If this is not the case, we require a column in the data that defines the dotted line.
library(tidyverse)
df <- data.frame(
time = c("2015-01-08 10:30:00", "2015-01-08 12:30:00",
"2015-01-08 13:00:00", "2015-01-08 13:30:00", "2015-01-08 14:00:00",
"2015-01-08 10:30:00", "2015-01-08 12:30:00", "2015-01-08 13:00:00",
"2015-01-08 13:30:00", "2015-01-08 14:00:00", "2015-01-08 10:30:00",
"2015-01-08 12:30:00", "2015-01-08 13:00:00", "2015-01-08 13:30:00",
"2015-01-08 14:00:00"),
wlPGP = c(750.33, 750.33, 750.33,
750.33, 750.33, 750.74, 750.74, 750.74, 750.74, 750.74, 751.15,
751.15, 751.15, 751.15, 751.15),
L30 = c(34.8381682164527,
16.4037816745955, 16.1198492561195, 13.7315701800825, 13.6046706387906,
34.5523259386597, 16.2183131142457, 15.8960774061323, 13.5871635950505,
13.4227034871889, 34.4351879005441, 16.075073665463, 15.8311421893508,
13.4960208643065, 13.4213241443487)
)
# should plot first to see what you're integrating
df %>%
ggplot() +
aes(wlPGP, L30) +
geom_line() +
facet_wrap(~time, scales = "free")

df %>%
filter(wlPGP > 750 & wlPGP < 752) %>%
group_by(time) %>%
mutate(max_L30 = max(L30)) %>% # assume the max L30 for each time is what defines the
# dotted line. if this is not the case, require a column
# in the data that defines the dotted line
summarize(
B = pracma::trapz(wlPGP, max_L30), # area under dottted line
B2 = pracma::trapz(wlPGP, L30), # area under solid line
B1 = B - B2 # difference
)
#> # A tibble: 5 x 4
#> time B B2 B1
#> * <chr> <dbl> <dbl> <dbl>
#> 1 2015-01-08 10:30:00 28.6 28.4 0.200
#> 2 2015-01-08 12:30:00 13.5 13.3 0.143
#> 3 2015-01-08 13:00:00 13.2 13.1 0.151
#> 4 2015-01-08 13:30:00 11.3 11.2 0.107
#> 5 2015-01-08 14:00:00 11.2 11.0 0.112
Created on 2021-09-10 by the reprex package (v1.0.0)