Re: [R] Sum data according to date in sequence

2023-11-02 Thread roslinazairimah zakaria
Thank you very much for your help. It is very much appreciated. On Fri, Nov 3, 2023 at 7:23 AM roslinazairimah zakaria wrote: > Dear all, > > I have this set of data. I would like to sum the EnergykWh according date > sequences. > > > head(dt1,20) StationName date time

Re: [R] Sum data according to date in sequence

2023-11-02 Thread roslinazairimah zakaria
Hi all, This is the data: > dput(head(dt1,20))structure(list(StationName = c("PALO ALTO CA / CAMBRIDGE > #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1", "PALO ALTO CA / CAMBRIDGE #1",

Re: [R] Sum data according to date in sequence

2023-11-02 Thread jim holtman
How about send a 'dput' of some sample data. My guess is that your date is 'character' and not 'Date'. Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Thu, Nov 2, 2023 at 4:24 PM

Re: [R] Sum data according to date in sequence

2023-11-02 Thread Christopher W. Ryan via R-help
date appears to be a character variable, and R is treating it as such. str(dt1) might give you some insight. Or the dplyr equivalent glimpse(dt1) I think R did what you asked, but if you want to be able to order records by date, in temporal order, you need to tell R that it is a date:

[R] Sum data according to date in sequence

2023-11-02 Thread roslinazairimah zakaria
Dear all, I have this set of data. I would like to sum the EnergykWh according date sequences. > head(dt1,20) StationName date time EnergykWh 1 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 12:09 4.680496 2 PALO ALTO CA / CAMBRIDGE #1 1/14/2016 19:50 6.272414 3 PALO ALTO CA

Re: [R] Bug in print for data frames?

2023-11-02 Thread Ivan Krylov
В Wed, 25 Oct 2023 09:18:26 +0300 "Christian Asseburg" пишет: > > str(x) > 'data.frame': 1 obs. of 3 variables: > $ A: num 1 > $ B: num 1 > $ C:'data.frame': 1 obs. of 1 variable: > ..$ A: num 1 > > Why does the print(x) not show "C" as the name of the third element?

Re: [R] weights vs. offset (negative binomial regression)

2023-11-02 Thread peter dalgaard
I think it is more clear-cut than so, at least if the Poisson situation is something to go by. There, you can do either of these and get equivalent results > fit.lung <- glm(cases ~ age + city, offset=log(pop), + family=poisson, data=lungcancer) > fit.lung2 <- glm(cases/pop ~