Re: [R] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread Jim Lemon
Hi Roslina, I think you have changed the code as "bc_start" in my code is "BCStartTime" in yours. When I run the attached code, I get a data frame "hourly_SoC" that looks right, and a matrix "result" (hour by SoC) that checks against the data frame. I have tried to comment the code so that you an s

Re: [R] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread Rui Barradas
Hello, There was a bug in the way I copied&pasted your data to my R session, hence the NA's. Here is a tidyverse way of doing what you want. Its output matches the expected output in your last post. The column names don't start at zero because there was no Starting_SoC_of_12 equal to 0. l

Re: [R] Extract time and state of charge (Start and End) and Count

2022-07-19 Thread roslinazairimah zakaria
Hi Jim, I tried to run your code and got this error. > # get the temporal order of observations > obs_order <- order(c(as.numeric(dt$BCStartTime),as.numeric(dt$BCStopTime))) Warning messages: 1: In order(c(as.numeric(dt$BCStartTime), as.numeric(dt$BCStopTime))) : NAs introduced by coercion 2: I

[R] Extract time and state of charge (Start and End) and Count

2022-07-17 Thread roslinazairimah zakaria
Dear all, I have data of Battery Electric vehicle (BEV). I would like to extract data from every hour starting from 0.00 to 0.59, 1:00-1:59 for SOC(state of charge) start to end. Some examples: I can extract data from SOC=0 and SOC=12 dt_2014[which(dt_2014$Starting_SoC_of_12==0 & dt_2014$Ending_S