简体   繁体   中英

How to calculate time spent below a threshold?

I have a plot with time as a PosixCt object on the x-axis and a dependent variable "ODBA" on the y-axis . The experiment was a 600-second trial. How do I calculate the total time in seconds that ODBA was below a certain threshold (eg 0.25) ?

We can use sum

sum(as.numeric(format(time, "%S"))[ODBA > 0.25])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM