简体   繁体   中英

How to calculate mean, median, sd , min and max value for a time stamp

I have a data frame with raw meter reading every 5 minutes. The file is in the format of CSV file.

this is the part of my data frame(it also contain missing values)

DateTime;ActivePower
01.11.2018,00:00:00;13731302000
01.11.2018,00:05:00;13731358000
01.11.2018,00:10:00;13731418000
01.11.2018,00:15:00;13731476000
01.11.2018,00:20:00;13731530000
01.11.2018,00:25:00;13731588000
01.11.2018,00:30:00;13731646000
01.11.2018,00:35:00;13731702000
01.11.2018,00:40:00;13731758000
01.11.2018,00:45:00;13731814000
01.11.2018,00:50:00;13731866000
01.11.2018,00:55:00;13731920000
01.11.2018,01:00:00;13731978000
01.11.2018,01:05:00;13732034000
01.11.2018,01:10:00;13732090000
01.11.2018,01:15:00;13732144000
01.11.2018,01:20:00;13732196000
01.11.2018,01:25:00;13732250000
01.11.2018,01:30:00;13732304000

I want mean/median/the standard deviation/min/max value for every 15 min timestamp and I want to plot these as a curve.

Is this is possible with R?

I have already tried various functions.

I was able to cut the data by 15 min initially, but that code is not running anymore.

aggregate() is not helping me as I don't want to aggregate.

I am learning R, but I am not able to find any solution for this. I am really stuck in this and need a solution for this so that I can proceed.

After this, I will need to cluster these results as well. So if someone could help with this, that would be a great help. Thank you in advance.

How about this:

library(dplyr)

summarised_data <- your_data_here %>% 
  group_by(quater_hr = cut(DateTime, "15 min")) %>%
  summarise(mean(ActivePower),
            median(ActivePower),
            max(ActivePower))

There's a couple more for you to complete :D

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