When I calculate the area under curve using trapz () of pracma package, it always showed the following error:
Error in pracma::trapz(., wlPGP, L30) : unused argument (L30)
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))
#> time wlPGP L30
#> 1 2015-01-08 10:30:00 750.33 34.83817
#> 2 2015-01-08 12:30:00 750.33 16.40378
#> 3 2015-01-08 13:00:00 750.33 16.11985
#> 4 2015-01-08 13:30:00 750.33 13.73157
#> 5 2015-01-08 14:00:00 750.33 13.60467
#> 6 2015-01-08 10:30:00 750.74 34.55233
#> 7 2015-01-08 12:30:00 750.74 16.21831
#> 8 2015-01-08 13:00:00 750.74 15.89608
#> 9 2015-01-08 13:30:00 750.74 13.58716
#> 10 2015-01-08 14:00:00 750.74 13.42270
#> 11 2015-01-08 10:30:00 751.15 34.43519
#> 12 2015-01-08 12:30:00 751.15 16.07507
#> 13 2015-01-08 13:00:00 751.15 15.83114
#> 14 2015-01-08 13:30:00 751.15 13.49602
#> 15 2015-01-08 14:00:00 751.15 13.42132
Using the above dataset, I write a code as follow:
A <- data.frame(........)
Area_A <- A %>%
filter(wlPGP > 750 & wlPGP < 752) %>%
group_by(time) %>%
pracma::trapz(wlPGP, L30)
When I run the code, it shows:
Error in pracma::trapz(., wlPGP, L30) : unused argument (L30)
How could I solve it?
Thanks in advance~