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

roslinazairimah zakaria ro@||n@ump @end|ng |rom gm@||@com
Wed Jul 20 03:28:26 CEST 2022


Hi Jim,
Thanks, I'll take a look.

On Wed, Jul 20, 2022, 08:49 Jim Lemon <drjimlemon using gmail.com> wrote:

> 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 see what I am doing.
>
> Jim
>
> On Wed, Jul 20, 2022 at 1:18 AM roslinazairimah zakaria
> <roslinaump using gmail.com> wrote:
> >
> > 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: In order(c(as.numeric(dt$BCStartTime), as.numeric(dt$BCStopTime))) :
> >   NAs introduced by coercion
> > >
> numeric_time<-c(as.numeric(dt$BCStartTime),as.numeric(dt$BCStopTime))[obs_order]
> > Warning messages:
> > 1: NAs introduced by coercion
> > 2: NAs introduced by coercion
> > > nobs<-diff(range(numeric_time))/3600
> > > # find the linear approximation of charge state by hours
> > > hourly_SoC <- approx(numeric_time,
> > +
> c(dt$Starting_SoC_of_12,dt$Ending_SoC_of_12)[obs_order],n=nobs)
> > Error in approx(numeric_time, c(dt$Starting_SoC_of_12,
> dt$Ending_SoC_of_12)[obs_order],  :
> >   need at least two non-NA values to interpolate
> >
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list