From @te|@no@@o||@ @end|ng |rom reg|one@m@rche@|t Mon Aug 10 12:07:17 2026 From: @te|@no@@o||@ @end|ng |rom reg|one@m@rche@|t (Stefano Sofia) Date: Mon, 10 Aug 2026 10:07:17 +0000 Subject: [R] Problems with the function aggregate Message-ID: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> Dear R-list users, I've got problems to use the function aggregate. Here there is an example: mydf <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) mydf$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf$Data, "%Y")), data=mydf, cumsum)[2], use.names = FALSE) The column "yearly_sum" is the sum of the column "daily_mean" with a reset at the beginning of each year. If for my analysis I want to remove the 29th of February, "yearly_sum" does not work anymore: mydf1 <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] mydf1$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf1$Data, "%Y")), data=mydf1, cumsum)[2], use.names = FALSE) In this case the column "yearly_sum" does not sum the values, and honestly I do not understand what is happening. Why? Could somebody help me? I already spent a big amount of hours with no success. Thank you for your attention and you help Stefano (oo) --oOO--( )--OOo-------------------------------------- Stefano Sofia MSc, PhD Civil Protection Department - Marche Region - Italy Meteo Section Snow Section Via Colle Ameno 5 60126 Torrette di Ancona, Ancona (AN) Uff: +39 071 806 7743 E-mail: stefano.sofia at regione.marche.it ---Oo---------oO---------------------------------------- ________________________________ AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. Ai sensi dell'art. 2.4 dell'allegato 1 alla DGR n. 74/2021, si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. [[alternative HTML version deleted]] From er|cjberger @end|ng |rom gm@||@com Mon Aug 10 12:42:34 2026 From: er|cjberger @end|ng |rom gm@||@com (Eric Berger) Date: Mon, 10 Aug 2026 13:42:34 +0300 Subject: [R] Problems with the function aggregate In-Reply-To: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> References: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> Message-ID: I asked ChatGPT (5.5 Medium). Here is its analysis The problem is not Feb. 29 itself. The problem is that aggregate() changes its return structure depending on whether all groups have the same length. In your first version, years have different numbers of days: most have 365, leap years have 366. So aggregate(...) returns a grouped result where each year?s cumsum() is kept as a list element. Then this works by accident: unlist(...[2], use.names = FALSE) because it flattens the list year by year. But after you remove Feb. 29, every year has exactly 365 rows. Now aggregate() sees that every cumsum() result has the same length, so it ?simplifies? the result into a matrix-like structure. When you then unlist() it, the values are no longer flattened in the chronological order you expect. The clean fix is: do not use aggregate() for this. Use ave(). mydf1 <- data.frame( Data = seq( as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz = "Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz = "Etc/GMT-1"), by = "1 day" ), daily_mean = round(runif(7670, 0, 2), digits = 2) ) mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] mydf1$yearly_sum <- ave( mydf1$daily_mean, as.integer(format(mydf1$Data, "%Y")), FUN = cumsum ) You can also force your original aggregate() approach to behave more consistently by adding simplify = FALSE: tmp <- aggregate( daily_mean ~ as.integer(format(mydf1$Data, "%Y")), data = mydf1, FUN = cumsum, simplify = FALSE ) mydf1$yearly_sum <- unlist(tmp$daily_mean, use.names = FALSE) On Mon, Aug 10, 2026 at 1:07?PM Stefano Sofia via R-help wrote: > > Dear R-list users, > > I've got problems to use the function aggregate. > > > Here there is an example: > > > mydf <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > mydf$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf$Data, "%Y")), data=mydf, cumsum)[2], use.names = FALSE) > > > The column "yearly_sum" is the sum of the column "daily_mean" with a reset at the beginning of each year. > > If for my analysis I want to remove the 29th of February, "yearly_sum" does not work anymore: > > > mydf1 <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] > > mydf1$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf1$Data, "%Y")), data=mydf1, cumsum)[2], use.names = FALSE) > > > In this case the column "yearly_sum" does not sum the values, and honestly I do not understand what is happening. Why? > > Could somebody help me? I already spent a big amount of hours with no success. > > > Thank you for your attention and you help > > Stefano > > > > > (oo) > --oOO--( )--OOo-------------------------------------- > Stefano Sofia MSc, PhD > Civil Protection Department - Marche Region - Italy > Meteo Section > Snow Section > Via Colle Ameno 5 > 60126 Torrette di Ancona, Ancona (AN) > Uff: +39 071 806 7743 > E-mail: stefano.sofia at regione.marche.it > ---Oo---------oO---------------------------------------- > > ________________________________ > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. Ai sensi dell'art. 2.4 dell'allegato 1 alla DGR n. 74/2021, si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. > IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. From ru|pb@rr@d@@463 @end|ng |rom gm@||@com Mon Aug 10 12:51:32 2026 From: ru|pb@rr@d@@463 @end|ng |rom gm@||@com (Rui Barradas) Date: Mon, 10 Aug 2026 11:51:32 +0100 Subject: [R] Problems with the function aggregate In-Reply-To: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> References: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> Message-ID: Hello, The problem is that the first aggregate's second column is a list and the second aggregate's second column is a matrix. In the code below I have complicated it a bit so that the intermediate results are created and examined. mydf <- data.frame( Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) agg <- aggregate(daily_mean ~ as.integer(format(mydf$Data, "%Y")), data=mydf, cumsum) mydf$yearly_sum <- unlist(agg[2], use.names = FALSE) mydf1 <- data.frame( Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) dim(mydf1) #> [1] 7670 2 # this removes 5 rows from mydf1 i <- format(mydf1$Data, "%m-%d") != "02-29" mydf1 <- mydf1[i, ] dim(mydf1) #> [1] 7665 2 agg2 <- aggregate(daily_mean ~ as.integer(format(mydf1$Data, "%Y")), data=mydf1, cumsum) mydf1$yearly_sum <- unlist(agg2[2], use.names = FALSE) Now see what is in agg and in agg2. class(agg$daily_mean) #> [1] "list" # returns FALSE, 5 list members have length 366 all(lengths(agg$daily_mean) == 365) #> [1] FALSE lengths(agg$daily_mean) #> [1] 365 366 365 365 365 366 365 365 365 366 365 365 365 366 365 365 365 366 365 #> [20] 365 365 class(agg2$daily_mean) #> [1] "matrix" "array" ncol(agg2$daily_mean) == 365 #> [1] TRUE agg2's second column is a matrix where each row represents the year's cumulative sums. R stores matrices in column-first order so you have to transpose the matrix and then remove the dim attribute (for instance, with `c`), not `unlist` it. # after running the agg2 <- aggregate(...) above, run mydf1$yearly_sum <- c(t(agg2$daily_mean)) Hope this helps, Rui Barradas Stefano Sofia via R-help escreveu (segunda, 10/08/2026 ?(s) 11:07): > > Dear R-list users, > > I've got problems to use the function aggregate. > > > Here there is an example: > > > mydf <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > mydf$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf$Data, "%Y")), data=mydf, cumsum)[2], use.names = FALSE) > > > The column "yearly_sum" is the sum of the column "daily_mean" with a reset at the beginning of each year. > > If for my analysis I want to remove the 29th of February, "yearly_sum" does not work anymore: > > > mydf1 <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] > > mydf1$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf1$Data, "%Y")), data=mydf1, cumsum)[2], use.names = FALSE) > > > In this case the column "yearly_sum" does not sum the values, and honestly I do not understand what is happening. Why? > > Could somebody help me? I already spent a big amount of hours with no success. > > > Thank you for your attention and you help > > Stefano > > > > > (oo) > --oOO--( )--OOo-------------------------------------- > Stefano Sofia MSc, PhD > Civil Protection Department - Marche Region - Italy > Meteo Section > Snow Section > Via Colle Ameno 5 > 60126 Torrette di Ancona, Ancona (AN) > Uff: +39 071 806 7743 > E-mail: stefano.sofia at regione.marche.it > ---Oo---------oO---------------------------------------- > > ________________________________ > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. Ai sensi dell'art. 2.4 dell'allegato 1 alla DGR n. 74/2021, si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. > IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. From ru|pb@rr@d@@463 @end|ng |rom gm@||@com Mon Aug 10 13:01:20 2026 From: ru|pb@rr@d@@463 @end|ng |rom gm@||@com (Rui Barradas) Date: Mon, 10 Aug 2026 12:01:20 +0100 Subject: [R] Problems with the function aggregate In-Reply-To: References: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> Message-ID: Hello, I forgot to add that I don't find your unlist(agg[2], use.names = FALSE) the best way, `[` extracts a sub-data.frame, use `[[` instead. unlist(agg[[2]], use.names = FALSE) It may not make a difference, followed by unlist the results might be the same but it is conceptually better to extract the column, to use `[[`. See the difference between the two: str(agg[2]) str(agg[[2]]) Hope this helps, Rui Barradas Rui Barradas escreveu (segunda, 10/08/2026 ?(s) 11:51): > > Hello, > > The problem is that the first aggregate's second column is a list and > the second aggregate's second column is a matrix. > In the code below I have complicated it a bit so that the intermediate > results are created and examined. > > mydf <- data.frame( > Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", > tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", > tz="Etc/GMT-1"), by="1 day"), > daily_mean = round(runif(7670, 0, 2), digits=2)) > > agg <- aggregate(daily_mean ~ as.integer(format(mydf$Data, "%Y")), > data=mydf, cumsum) > > mydf$yearly_sum <- unlist(agg[2], use.names = FALSE) > > > mydf1 <- data.frame( > Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", > tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", > tz="Etc/GMT-1"), by="1 day"), > daily_mean = round(runif(7670, 0, 2), digits=2)) > dim(mydf1) > #> [1] 7670 2 > > # this removes 5 rows from mydf1 > i <- format(mydf1$Data, "%m-%d") != "02-29" > mydf1 <- mydf1[i, ] > dim(mydf1) > #> [1] 7665 2 > > agg2 <- aggregate(daily_mean ~ as.integer(format(mydf1$Data, "%Y")), > data=mydf1, cumsum) > mydf1$yearly_sum <- unlist(agg2[2], use.names = FALSE) > > > > Now see what is in agg and in agg2. > > > class(agg$daily_mean) > #> [1] "list" > # returns FALSE, 5 list members have length 366 > all(lengths(agg$daily_mean) == 365) > #> [1] FALSE > lengths(agg$daily_mean) > #> [1] 365 366 365 365 365 366 365 365 365 366 365 365 365 366 365 > 365 365 366 365 > #> [20] 365 365 > > class(agg2$daily_mean) > #> [1] "matrix" "array" > ncol(agg2$daily_mean) == 365 > #> [1] TRUE > > > agg2's second column is a matrix where each row represents the year's > cumulative sums. R stores matrices in column-first order so you have > to transpose the matrix and then remove the dim attribute (for > instance, with `c`), not `unlist` it. > > > # after running the agg2 <- aggregate(...) above, run > mydf1$yearly_sum <- c(t(agg2$daily_mean)) > > > Hope this helps, > > Rui Barradas > > > Stefano Sofia via R-help escreveu (segunda, > 10/08/2026 ?(s) 11:07): > > > > Dear R-list users, > > > > I've got problems to use the function aggregate. > > > > > > Here there is an example: > > > > > > mydf <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > > > mydf$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf$Data, "%Y")), data=mydf, cumsum)[2], use.names = FALSE) > > > > > > The column "yearly_sum" is the sum of the column "daily_mean" with a reset at the beginning of each year. > > > > If for my analysis I want to remove the 29th of February, "yearly_sum" does not work anymore: > > > > > > mydf1 <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > > > mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] > > > > mydf1$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf1$Data, "%Y")), data=mydf1, cumsum)[2], use.names = FALSE) > > > > > > In this case the column "yearly_sum" does not sum the values, and honestly I do not understand what is happening. Why? > > > > Could somebody help me? I already spent a big amount of hours with no success. > > > > > > Thank you for your attention and you help > > > > Stefano > > > > > > > > > > (oo) > > --oOO--( )--OOo-------------------------------------- > > Stefano Sofia MSc, PhD > > Civil Protection Department - Marche Region - Italy > > Meteo Section > > Snow Section > > Via Colle Ameno 5 > > 60126 Torrette di Ancona, Ancona (AN) > > Uff: +39 071 806 7743 > > E-mail: stefano.sofia at regione.marche.it > > ---Oo---------oO---------------------------------------- > > > > ________________________________ > > > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. Ai sensi dell'art. 2.4 dell'allegato 1 alla DGR n. 74/2021, si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. > > IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. From ggrothend|eck @end|ng |rom gm@||@com Mon Aug 10 14:25:20 2026 From: ggrothend|eck @end|ng |rom gm@||@com (Gabor Grothendieck) Date: Mon, 10 Aug 2026 08:25:20 -0400 Subject: [R] Problems with the function aggregate In-Reply-To: References: <469c3b88d7af4ddeb3f09242b451329f@regione.marche.it> Message-ID: The ave solution could be written as: transform(mydf1, yearly_sum = ave(daily_mean, cut(Data, "year"), FUN = cumsum)) On Mon, Aug 10, 2026 at 6:43?AM Eric Berger wrote: > > I asked ChatGPT (5.5 Medium). Here is its analysis > > The problem is not Feb. 29 itself. The problem is that aggregate() > changes its return structure depending on whether all groups have the > same length. > In your first version, years have different numbers of days: most have > 365, leap years have 366. So aggregate(...) > returns a grouped result where each year?s cumsum() is kept as a list element. > Then this works by accident: > unlist(...[2], use.names = FALSE) > because it flattens the list year by year. > But after you remove Feb. 29, every year has exactly 365 rows. Now > aggregate() sees that every cumsum() result has the same length, so it > ?simplifies? the result into a matrix-like structure. When you then > unlist() it, the values are no longer flattened in the chronological > order you expect. > The clean fix is: do not use aggregate() for this. Use ave(). > > mydf1 <- data.frame( > Data = seq( > as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz = "Etc/GMT-1"), > as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz = "Etc/GMT-1"), > by = "1 day" > ), > daily_mean = round(runif(7670, 0, 2), digits = 2) > ) > > mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] > > mydf1$yearly_sum <- ave( > mydf1$daily_mean, > as.integer(format(mydf1$Data, "%Y")), > FUN = cumsum > ) > > You can also force your original aggregate() approach to behave more > consistently by adding simplify = FALSE: > > tmp <- aggregate( > daily_mean ~ as.integer(format(mydf1$Data, "%Y")), > data = mydf1, > FUN = cumsum, > simplify = FALSE > ) > > mydf1$yearly_sum <- unlist(tmp$daily_mean, use.names = FALSE) > > > > > > > > On Mon, Aug 10, 2026 at 1:07?PM Stefano Sofia via R-help > wrote: > > > > Dear R-list users, > > > > I've got problems to use the function aggregate. > > > > > > Here there is an example: > > > > > > mydf <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > > > mydf$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf$Data, "%Y")), data=mydf, cumsum)[2], use.names = FALSE) > > > > > > The column "yearly_sum" is the sum of the column "daily_mean" with a reset at the beginning of each year. > > > > If for my analysis I want to remove the 29th of February, "yearly_sum" does not work anymore: > > > > > > mydf1 <- data.frame(Data=seq(as.POSIXct("2003-01-01", format = "%Y-%m-%d", tz="Etc/GMT-1"), as.POSIXct("2023-12-31", format = "%Y-%m-%d", tz="Etc/GMT-1"), by="1 day"), daily_mean = round(runif(7670, 0, 2), digits=2)) > > > > mydf1 <- mydf1[format(mydf1$Data, "%m-%d") != "02-29", ] > > > > mydf1$yearly_sum <- unlist(aggregate(daily_mean~as.integer(format(mydf1$Data, "%Y")), data=mydf1, cumsum)[2], use.names = FALSE) > > > > > > In this case the column "yearly_sum" does not sum the values, and honestly I do not understand what is happening. Why? > > > > Could somebody help me? I already spent a big amount of hours with no success. > > > > > > Thank you for your attention and you help > > > > Stefano > > > > > > > > > > (oo) > > --oOO--( )--OOo-------------------------------------- > > Stefano Sofia MSc, PhD > > Civil Protection Department - Marche Region - Italy > > Meteo Section > > Snow Section > > Via Colle Ameno 5 > > 60126 Torrette di Ancona, Ancona (AN) > > Uff: +39 071 806 7743 > > E-mail: stefano.sofia at regione.marche.it > > ---Oo---------oO---------------------------------------- > > > > ________________________________ > > > > AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. Ai sensi dell'art. 2.4 dell'allegato 1 alla DGR n. 74/2021, si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. > > IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com From k@t|e @end|ng |rom herr|c@ne@c@ Sun Aug 9 17:28:12 2026 From: k@t|e @end|ng |rom herr|c@ne@c@ (Katie) Date: Sun, 09 Aug 2026 11:28:12 -0400 Subject: [R] R User Groups in Canada? Message-ID: Hello all, I'm creating a list of Canadian user groups, and am wondering if anyone knows of any in Canada dedicated to R? Thanks, Katie From murdoch@dunc@n @end|ng |rom gm@||@com Tue Aug 11 17:40:39 2026 From: murdoch@dunc@n @end|ng |rom gm@||@com (Duncan Murdoch) Date: Tue, 11 Aug 2026 11:40:39 -0400 Subject: [R] R User Groups in Canada? In-Reply-To: References: Message-ID: <3c2d5883-5a2d-4ca3-8c43-6b7ce1fd21b7@gmail.com> On 2026-08-09 11:28 a.m., Katie wrote: > Hello all, > > I'm creating a list of Canadian user groups, and am wondering if anyone > knows of any in Canada dedicated to R? I don't know how many of them are still active, but there are 8 of them listed here: https://jumpingrivers.github.io/meetingsR/r-user-groups.html Duncan Murdoch From pro|jcn@@h @end|ng |rom gm@||@com Tue Aug 11 18:27:06 2026 From: pro|jcn@@h @end|ng |rom gm@||@com (J C Nash) Date: Tue, 11 Aug 2026 12:27:06 -0400 Subject: [R] R User Groups in Canada? In-Reply-To: <3c2d5883-5a2d-4ca3-8c43-6b7ce1fd21b7@gmail.com> References: <3c2d5883-5a2d-4ca3-8c43-6b7ce1fd21b7@gmail.com> Message-ID: Sadly, OGRUG has been dormant for a long time. The two of us (Joseph Potvin and I) couldn't get anyone to step up and talk about what they were doing. We'll be glad to hand over the reins (there was an R mailing list, and I think it still works) if anyone has energy. John Nash On 2026-08-11 11:40, Duncan Murdoch wrote: > On 2026-08-09 11:28 a.m., Katie wrote: >> Hello all, >> >> I'm creating a list of Canadian user groups, and am wondering if anyone >> knows of any in Canada dedicated to R? > I don't know how many of them are still active, but there are 8 of them listed here: > > ?https://jumpingrivers.github.io/meetingsR/r-user-groups.html > > Duncan Murdoch > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. From k@t|e @end|ng |rom herr|c@ne@c@ Tue Aug 11 18:50:53 2026 From: k@t|e @end|ng |rom herr|c@ne@c@ (Katie) Date: Tue, 11 Aug 2026 12:50:53 -0400 Subject: [R] R User Groups in Canada? In-Reply-To: References: <3c2d5883-5a2d-4ca3-8c43-6b7ce1fd21b7@gmail.com> Message-ID: <24838b28f7bb04a461da80d378996f74@herricane.ca> Hi John, I wonder if only the SAS-users discuss what they're doing? You know, the SAS users that "dominate" every organization in Canada (or at least scream the loudest). Bizarre! -Katie On 2026-08-11 12:27, J C Nash wrote: > Sadly, OGRUG has been dormant for a long time. The two of us (Joseph > Potvin and I) couldn't > get anyone to step up and talk about what they were doing. > > We'll be glad to hand over the reins (there was an R mailing list, and > I think it still works) > if anyone has energy. > > John Nash > > > On 2026-08-11 11:40, Duncan Murdoch wrote: >> On 2026-08-09 11:28 a.m., Katie wrote: >>> Hello all, >>> >>> I'm creating a list of Canadian user groups, and am wondering if >>> anyone >>> knows of any in Canada dedicated to R? >> I don't know how many of them are still active, but there are 8 of >> them listed here: >> >> ?https://jumpingrivers.github.io/meetingsR/r-user-groups.html >> >> Duncan Murdoch >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> https://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. From |@gogv @end|ng |rom d|@root@org Fri Aug 21 10:21:14 2026 From: |@gogv @end|ng |rom d|@root@org (iagogv) Date: Fri, 21 Aug 2026 10:21:14 +0200 Subject: [R] How to compute an exact Poisson model with R? Message-ID: <15fca7e36128374222c8307bebf36c1e@disroot.org> Hi all, Can an exact Poisson regression be computed with R, instead of using the standard (glm) Poisson using maximum likelihood? I am working with a collegue in a project, and I'd like to reproduce his method, if not his results. He uses Stata, particularly the expoisson function (https://www.stata.com/help.cgi?expoisson) in order to compute the exact Poisson regression, relevant for small samples. expoisson fits an exact Poisson regression model, which produces more accurate inference in small samples than standard maximum-likelihood-based Poisson regression I know about exact Poisson tests (https://stat.ethz.ch/R-manual/R-devel/RHOME/library/stats/html/poisson.test.html), but it does not allow to include offset. So, is there some way to reproduce exact Poisson regression with R? Thanks! Best, -- Iago [[alternative HTML version deleted]] From r@v|@v@r@dh@n @end|ng |rom jhu@edu Fri Aug 21 15:18:23 2026 From: r@v|@v@r@dh@n @end|ng |rom jhu@edu (Ravi Varadhan) Date: Fri, 21 Aug 2026 13:18:23 +0000 Subject: [R] R-help Digest, Vol 282, Issue 3 In-Reply-To: References: Message-ID: To my knowledge, there is no built?in function in R that exactly replicates Stata?s expoisson. The main issue is that it can be computationally heavy since it conditions on the sum of total counts (conditional MLE). It can only be practical in small samples. We should be able to get similar estimates using Firth's bias correction, for example, although I myself have not tested this claim. The brglm2 package implements Firth's bias reduction for GLMs. Ravi ________________________________ From: R-help on behalf of r-help-request at r-project.org Sent: Friday, August 21, 2026 06:00 To: r-help at r-project.org Subject: R-help Digest, Vol 282, Issue 3 External Email - Use Caution Send R-help mailing list submissions to r-help at r-project.org To subscribe or unsubscribe via the World Wide Web, visit https://stat.ethz.ch/mailman/listinfo/r-help or, via email, send a message with subject or body 'help' to r-help-request at r-project.org You can reach the person managing the list at r-help-owner at r-project.org When replying, please edit your Subject line so it is more specific than "Re: Contents of R-help digest..." Today's Topics: 1. How to compute an exact Poisson model with R? (iagogv) ---------------------------------------------------------------------- Message: 1 Date: Fri, 21 Aug 2026 10:21:14 +0200 From: iagogv To: R Help Subject: [R] How to compute an exact Poisson model with R? Message-ID: <15fca7e36128374222c8307bebf36c1e at disroot.org> Content-Type: text/plain; charset="utf-8" Hi all, Can an exact Poisson regression be computed with R, instead of using the standard (glm) Poisson using maximum likelihood? I am working with a collegue in a project, and I'd like to reproduce his method, if not his results. He uses Stata, particularly the expoisson function (https://www.stata.com/help.cgi?expoisson) in order to compute the exact Poisson regression, relevant for small samples. expoisson fits an exact Poisson regression model, which produces more accurate inference in small samples than standard maximum-likelihood-based Poisson regression I know about exact Poisson tests (https://stat.ethz.ch/R-manual/R-devel/RHOME/library/stats/html/poisson.test.html), but it does not allow to include offset. So, is there some way to reproduce exact Poisson regression with R? Thanks! Best, -- Iago [[alternative HTML version deleted]] ------------------------------ Subject: Digest Footer _______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ------------------------------ End of R-help Digest, Vol 282, Issue 3 ************************************** [[alternative HTML version deleted]] From ggrothend|eck @end|ng |rom gm@||@com Fri Aug 21 16:19:57 2026 From: ggrothend|eck @end|ng |rom gm@||@com (Gabor Grothendieck) Date: Fri, 21 Aug 2026 10:19:57 -0400 Subject: [R] How to compute an exact Poisson model with R? In-Reply-To: <15fca7e36128374222c8307bebf36c1e@disroot.org> References: <15fca7e36128374222c8307bebf36c1e@disroot.org> Message-ID: The offset is just the log of the exposure (I assume -- I have never used Stata) so if you can express your model in terms of exposure you can also express it in terms of offset. On Fri, Aug 21, 2026 at 4:21?AM iagogv via R-help wrote: > > Hi all, > > Can an exact Poisson regression be computed with R, instead of using the > standard (glm) Poisson using maximum likelihood? > > I am working with a collegue in a project, and I'd like to reproduce his > method, if not his results. He uses Stata, particularly the expoisson > function (https://www.stata.com/help.cgi?expoisson) in order to compute > the exact Poisson regression, relevant for small samples. > > expoisson fits an exact Poisson regression model, which produces more > accurate inference in small samples than standard > maximum-likelihood-based Poisson regression > > I know about exact Poisson tests > (https://stat.ethz.ch/R-manual/R-devel/RHOME/library/stats/html/poisson.test.html), > but it does not allow to include offset. > > So, is there some way to reproduce exact Poisson regression with R? > > Thanks! > > Best, > > -- > Iago > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com From peter@|@ng|e|der @end|ng |rom gm@||@com Fri Aug 21 18:01:30 2026 From: peter@|@ng|e|der @end|ng |rom gm@||@com (Peter Langfelder) Date: Sat, 22 Aug 2026 00:01:30 +0800 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames Message-ID: Hi all, when calling data.frame on other data frames and naming arguments, the way the 'names' of the result are formed seems to depend on whether the argument data frames have one or more columns. Specifically, consider this: > data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) A B 1 1 1 Here the column names are simply copied from column names of the arguments. In contrast, if the argument data frames have two (or more) columns, here's what happens: > data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) a.A a.C b.B b.D 1 1 1 1 1 The 'names' of the result are now . Is this behavior intended? Thanks, Peter From bgunter@4567 @end|ng |rom gm@||@com Fri Aug 21 18:37:35 2026 From: bgunter@4567 @end|ng |rom gm@||@com (Bert Gunter) Date: Fri, 21 Aug 2026 09:37:35 -0700 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames In-Reply-To: References: Message-ID: Don't know about "intended", but if the man pages do not satisfy, this seems like the sort of infelicity that has already been reported and/or that on which an internet query should yield info. As you are well aware I'm sure, one can see what a developer who designed this behavior was thinking; and also the possible negative consequences that the inconsistency might entail. Cheers, Bert On Fri, Aug 21, 2026 at 9:01?AM Peter Langfelder wrote: > Hi all, > > when calling data.frame on other data frames and naming arguments, the > way the 'names' of the result are formed seems to depend on whether > the argument data frames have one or more columns. Specifically, > consider this: > > > data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) > A B > 1 1 1 > > > Here the column names are simply copied from column names of the arguments. > In contrast, if the argument data frames have two (or more) columns, > here's what happens: > > > data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) > a.A a.C b.B b.D > 1 1 1 1 1 > > > The 'names' of the result are now . of the argument value> > > Is this behavior intended? > > Thanks, > > Peter > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] From jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@ Fri Aug 21 18:57:38 2026 From: jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@ (Jeff Newmiller) Date: Fri, 21 Aug 2026 09:57:38 -0700 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames In-Reply-To: References: Message-ID: <8E7E0B84-5B93-4CB4-89AF-3D08A142630B@dcn.davis.ca.us> Passing data frames as arguments to data.frame is not intended to work the way you seem to think it should. Try using cbind? a <- data.frame( A = 1, C = 1 ) b <- data.frame(B = 1, D = 1) cbind( a, b ) On August 21, 2026 9:01:30 AM PDT, Peter Langfelder wrote: >Hi all, > >when calling data.frame on other data frames and naming arguments, the >way the 'names' of the result are formed seems to depend on whether >the argument data frames have one or more columns. Specifically, >consider this: > >> data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) > A B >1 1 1 > > >Here the column names are simply copied from column names of the arguments. >In contrast, if the argument data frames have two (or more) columns, >here's what happens: > >> data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) > a.A a.C b.B b.D >1 1 1 1 1 > > >The 'names' of the result are now .of the argument value> > >Is this behavior intended? > >Thanks, > >Peter > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide https://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. [[alternative HTML version deleted]] From murdoch@dunc@n @end|ng |rom gm@||@com Fri Aug 21 19:39:02 2026 From: murdoch@dunc@n @end|ng |rom gm@||@com (Duncan Murdoch) Date: Fri, 21 Aug 2026 13:39:02 -0400 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames In-Reply-To: References: Message-ID: <6d63368a-3411-4cc3-ad08-96211fe2c3b6@gmail.com> On 2026-08-21 12:01 p.m., Peter Langfelder wrote: > Hi all, > > when calling data.frame on other data frames and naming arguments, the > way the 'names' of the result are formed seems to depend on whether > the argument data frames have one or more columns. Specifically, > consider this: > >> data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) > A B > 1 1 1 > > > Here the column names are simply copied from column names of the arguments. > In contrast, if the argument data frames have two (or more) columns, > here's what happens: > >> data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) > a.A a.C b.B b.D > 1 1 1 1 1 > > > The 'names' of the result are now . of the argument value> > > Is this behavior intended? It looks like it. From the help page: "For a named or unnamed matrix/list/data frame argument that contains a single column, the column name in the result is the column name in the argument." However, also note how that paragraph started: "How the names of the data frame are created is complex, and the rest of this paragraph is only the basic story." Duncan Murdoch From ru|pb@rr@d@@463 @end|ng |rom gm@||@com Sat Aug 22 09:06:58 2026 From: ru|pb@rr@d@@463 @end|ng |rom gm@||@com (Rui Barradas) Date: Sat, 22 Aug 2026 08:06:58 +0100 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames In-Reply-To: References: Message-ID: Hello, Yes, this is documented. From ?data.frame, section Value How the names of the data frame are created is complex, and the rest of this paragraph is only the basic story. [...] For a named matrix/list/data frame argument with more than one named column, the names of the columns are the name of the argument followed by a dot and the column name inside the argument: if the argument is unnamed, the argument's column names are used. [...] You can protect data.frame's arguments with I(). Compare the two calls below. df1 <- data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) str(df1) #> 'data.frame': 1 obs. of 4 variables: #> $ a.A: num 1 #> $ a.C: num 1 #> $ b.B: num 1 #> $ b.D: num 1 names(df1) #> [1] "a.A" "a.C" "b.B" "b.D" df2 <- data.frame(a = I(data.frame(A = 1, C = 1)), b = I(data.frame(B = 1, D = 1))) str(df2) #> 'data.frame': 1 obs. of 2 variables: #> $ a:Classes 'AsIs' and 'data.frame': 1 obs. of 2 variables: #> ..$ A: num 1 #> ..$ C: num 1 #> $ b:Classes 'AsIs' and 'data.frame': 1 obs. of 2 variables: #> ..$ B: num 1 #> ..$ D: num 1 names(df2) #> [1] "a" "b" df2 # the names come from the print method #> a.A a.C b.B b.D #> 1 1 1 1 1 Hope this helps, Rui Barradas Peter Langfelder escreveu (sexta, 21/08/2026 ?(s) 17:01): > > Hi all, > > when calling data.frame on other data frames and naming arguments, the > way the 'names' of the result are formed seems to depend on whether > the argument data frames have one or more columns. Specifically, > consider this: > > > data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) > A B > 1 1 1 > > > Here the column names are simply copied from column names of the arguments. > In contrast, if the argument data frames have two (or more) columns, > here's what happens: > > > data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) > a.A a.C b.B b.D > 1 1 1 1 1 > > > The 'names' of the result are now . of the argument value> > > Is this behavior intended? > > Thanks, > > Peter > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. From ggrothend|eck @end|ng |rom gm@||@com Sat Aug 22 13:22:27 2026 From: ggrothend|eck @end|ng |rom gm@||@com (Gabor Grothendieck) Date: Sat, 22 Aug 2026 07:22:27 -0400 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames In-Reply-To: References: Message-ID: That does seem odd although I gather from the other answers that it is intended. Note that we can avoid this by simply not naming the arguments in the first place. > data.frame(data.frame(A = 1), data.frame(B = 1)) A B 1 1 1 > data.frame(data.frame(A = 1, C = 1), data.frame(B = 1, D = 1)) A C B D 1 1 1 1 1 On Fri, Aug 21, 2026 at 12:01?PM Peter Langfelder wrote: > > Hi all, > > when calling data.frame on other data frames and naming arguments, the > way the 'names' of the result are formed seems to depend on whether > the argument data frames have one or more columns. Specifically, > consider this: > > > data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) > A B > 1 1 1 > > > Here the column names are simply copied from column names of the arguments. > In contrast, if the argument data frames have two (or more) columns, > here's what happens: > > > data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) > a.A a.C b.B b.D > 1 1 1 1 1 > > > The 'names' of the result are now . of the argument value> > > Is this behavior intended? > > Thanks, > > Peter -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com From peter@|@ng|e|der @end|ng |rom gm@||@com Sat Aug 22 16:41:51 2026 From: peter@|@ng|e|der @end|ng |rom gm@||@com (Peter Langfelder) Date: Sat, 22 Aug 2026 22:41:51 +0800 Subject: [R] Inconsistency in 'names' when calling data.frame on other data.frames In-Reply-To: References: Message-ID: Thanks all for pointing me to the help which I missed and it indeed explains it. It would be useful for my work if the data.frame function contained an additional argument allowing the user to force or disable the addition of the argument name. As a suggestion of what that might look like, I modified the dataframe.R source file in base package in that I added an argument composite.names with default value NULL which retains the current behavior; the user could also specify FALSE and TRUE to disable/enable the addition of the prefix irrespective of the number of columns in each argument. The diff result is below. Is that something the R core team would consider? (No big deal if not, I can always use my version of the data.frame function if needed, and apologies if this should be moved to the R-devel list...) The diff follows. diff dataframe.R dataframe.PL.R 424a425 > composite.names = NULL, 478a480,484 > if (!is.null(composite.names)) { > if (!is.logical(composite.names)) stop("'composite.names' must be logical."); > if (is.na(composite.names)) composite.names <- NULL; > } > doCompositeNames <- if (is.null(composite.names)) -1L else as.integer(0 + composite.names); 489c495 < if(ncols[i] > 1L) { --- > if ((ncols[i] > 1L && doCompositeNames!= 0L) || doCompositeNames==1) { Peter On Sat, Aug 22, 2026 at 7:23?PM Gabor Grothendieck wrote: > > That does seem odd although I gather from the other answers that it is intended. > Note that we can avoid this by simply not naming the arguments in the > first place. > > > data.frame(data.frame(A = 1), data.frame(B = 1)) > A B > 1 1 1 > > data.frame(data.frame(A = 1, C = 1), data.frame(B = 1, D = 1)) > A C B D > 1 1 1 1 1 > > On Fri, Aug 21, 2026 at 12:01?PM Peter Langfelder > wrote: > > > > Hi all, > > > > when calling data.frame on other data frames and naming arguments, the > > way the 'names' of the result are formed seems to depend on whether > > the argument data frames have one or more columns. Specifically, > > consider this: > > > > > data.frame(a = data.frame(A = 1), b = data.frame(B = 1)) > > A B > > 1 1 1 > > > > > > Here the column names are simply copied from column names of the arguments. > > In contrast, if the argument data frames have two (or more) columns, > > here's what happens: > > > > > data.frame(a = data.frame(A = 1, C = 1), b = data.frame(B = 1, D = 1)) > > a.A a.C b.B b.D > > 1 1 1 1 1 > > > > > > The 'names' of the result are now . > of the argument value> > > > > Is this behavior intended? > > > > Thanks, > > > > Peter > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at gmail.com From dw|n@em|u@ @end|ng |rom comc@@t@net Sun Aug 23 01:35:47 2026 From: dw|n@em|u@ @end|ng |rom comc@@t@net (David Winsemius) Date: Sat, 22 Aug 2026 16:35:47 -0700 Subject: [R] How to compute an exact Poisson model with R? In-Reply-To: <15fca7e36128374222c8307bebf36c1e@disroot.org> References: <15fca7e36128374222c8307bebf36c1e@disroot.org> Message-ID: The point estimates for regression should be the same although the CI's for the MCMC methods might be wider (more conservative if that is what you mean by "more accurate"). I I was able to install Brian Caffo's archived 'exactLoglinTest' package for my MacOS system with R 4.6.1 after adding: CPPFLAGS += -I/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include to my .R/Makevars file. That allows the compilation step to find PrtUtil.h from an earlier version of R since it has been folded into R 4.6.x rather than currently being exposed. The Notes that Caffo chose not to fix did not cause any errors, at least to my minimal testing with the package's examples. Best; David Winsemius, MD, MPH > On Aug 21, 2026, at 1:21?AM, iagogv via R-help wrote: > > Hi all, > > Can an exact Poisson regression be computed with R, instead of using the > standard (glm) Poisson using maximum likelihood? > > I am working with a collegue in a project, and I'd like to reproduce his > method, if not his results. He uses Stata, particularly the expoisson > function (https://www.stata.com/help.cgi?expoisson) in order to compute > the exact Poisson regression, relevant for small samples. > > expoisson fits an exact Poisson regression model, which produces more > accurate inference in small samples than standard > maximum-likelihood-based Poisson regression > > I know about exact Poisson tests > (https://stat.ethz.ch/R-manual/R-devel/RHOME/library/stats/html/poisson.test.html), > but it does not allow to include offset. > > So, is there some way to reproduce exact Poisson regression with R? > > Thanks! > > Best, > > -- > Iago > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. From dw|n@em|u@ @end|ng |rom comc@@t@net Sun Aug 23 04:37:06 2026 From: dw|n@em|u@ @end|ng |rom comc@@t@net (David Winsemius) Date: Sat, 22 Aug 2026 19:37:06 -0700 Subject: [R] How to compute an exact Poisson model with R? In-Reply-To: References: Message-ID: Sent from my iPhone > On Aug 22, 2026, at 4:38?PM, David Winsemius wrote: > > ?The point estimates for regression should be the same although the CI's for the MCMC methods might be wider (more conservative if that is what you mean by "more accurate"). I I was misinterpreting the summary output of mcexact. The glm coefficients are not supposed to be estimates. The function is only doing a gof test. David Winsemius > > I was able to install Brian Caffo's archived 'exactLoglinTest' package for my MacOS system with R 4.6.1 after adding: > > > CPPFLAGS += -I/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include > > to my .R/Makevars file. That allows the compilation step to find PrtUtil.h from an earlier version of R since it has been folded into R 4.6.x rather than currently being exposed. > > The Notes that Caffo chose not to fix did not cause any errors, at least to my minimal testing with the package's examples. > > Best; > > David Winsemius, MD, MPH > >> On Aug 21, 2026, at 1:21?AM, iagogv via R-help wrote: >> >> Hi all, >> >> Can an exact Poisson regression be computed with R, instead of using the >> standard (glm) Poisson using maximum likelihood? >> >> I am working with a collegue in a project, and I'd like to reproduce his >> method, if not his results. He uses Stata, particularly the expoisson >> function (https://www.stata.com/help.cgi?expoisson) in order to compute >> the exact Poisson regression, relevant for small samples. >> >> expoisson fits an exact Poisson regression model, which produces more >> accurate inference in small samples than standard >> maximum-likelihood-based Poisson regression >> >> I know about exact Poisson tests >> (https://stat.ethz.ch/R-manual/R-devel/RHOME/library/stats/html/poisson.test.html), >> but it does not allow to include offset. >> >> So, is there some way to reproduce exact Poisson regression with R? >> >> Thanks! >> >> Best, >> >> -- >> Iago >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. From r-p@ck@ge@ @end|ng |rom r-project@org Thu Aug 27 20:59:43 2026 From: r-p@ck@ge@ @end|ng |rom r-project@org (Manuel Koller via R-packages) Date: Thu, 27 Aug 2026 18:59:43 +0000 Subject: [R] [R-pkgs] jsslintr 1.1.0 on CRAN: style checker for JSS manuscripts Message-ID: <8848C9C8-4560-4825-8125-8AFEA6583D67@proton.me> jsslintr 1.1.0 is on CRAN. jsslintr checks a Journal of Statistical Software (JSS) format manuscript -- .tex, .Rnw, or .Rmd plus its .bib -- against 62 deterministic rules derived from the journal's published style guide: preamble macros, semantic markup (\proglang, \pkg, \code), citation conventions, capitalization, code formatting, and bibliography completeness. Violations are reported with source positions and fix suggestions; jssfix() applies the auto-fixable subset. install.packages("jsslintr") library(jsslintr) jsslint("paper.Rnw") jssfix("paper.Rnw") The rule set's accuracy is measured: precision is 97.2% over 20,060 adjudicated violation instances against a pinned corpus of 254 real JSS-format manuscripts, recall 80.7% against a hand-annotated ground-truth corpus. The same engine is also available as a command-line tool, Python package, VS Code extension, GitHub Action, and a fully client-side browser app: https://kollerma.github.io/jss-style-checker/ https://github.com/kollerma/jss-style-checker jsslintr is an independent project; it is not affiliated with or endorsed by the Journal of Statistical Software. Manuel Koller _______________________________________________ R-packages mailing list R-packages at r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages From n@re@h_gurbux@n| @end|ng |rom hotm@||@com Sat Aug 29 14:50:30 2026 From: n@re@h_gurbux@n| @end|ng |rom hotm@||@com (Naresh Gurbuxani) Date: Sat, 29 Aug 2026 08:50:30 -0400 Subject: [R] Ubuntu sources file for R packages Message-ID: I followed these instructions to install R on my new Ubuntu desktop. https://cran.r-project.org/bin/linux/ubuntu/ To install additional packages, I am following these instructions: https://cran.r-project.org/bin/linux/ubuntu/fullREADME.html For Ubuntu 26.04 (Resolute Racoon), /etc/apt/sources.list is deprecated.? It seems I need to create a file in /etc/apt/sources.list.d/.? I started a file "r-package.sources" and need entries for the last two fields.? My file: ## R package repository Types: deb URIs: https://cloud.r-project.org/bin/linux/ubuntu Suites: resolute-cran40 Components: Signed-By: It will also benefit other users if you can update the instructions in fullREADME.html Thanks, Naresh From ||@t@ @end|ng |rom dewey@myzen@co@uk Sat Aug 29 18:08:54 2026 From: ||@t@ @end|ng |rom dewey@myzen@co@uk (Michael Dewey) Date: Sat, 29 Aug 2026 17:08:54 +0100 Subject: [R] Ubuntu sources file for R packages In-Reply-To: References: Message-ID: <316f8fe2-0544-4090-988a-33cd593a670e@dewey.myzen.co.uk> Dear Naresh Perhaps you might get more answers on https://stat.ethz.ch/mailman/listinfo/r-sig-debian Michael On 29/08/2026 13:50, Naresh Gurbuxani wrote: > I followed these instructions to install R on my new Ubuntu desktop. > > https://cran.r-project.org/bin/linux/ubuntu/ > > > To install additional packages, I am following these instructions: > > https://cran.r-project.org/bin/linux/ubuntu/fullREADME.html > > > For Ubuntu 26.04 (Resolute Racoon), /etc/apt/sources.list is > deprecated.? It seems I need to create a file in /etc/apt/ > sources.list.d/.? I started a file "r-package.sources" and need entries > for the last two fields.? My file: > > ## R package repository > Types: deb > URIs: https://cloud.r-project.org/bin/linux/ubuntu > Suites: resolute-cran40 > Components: > Signed-By: > > It will also benefit other users if you can update the instructions in > fullREADME.html > > > Thanks, > > Naresh > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. -- Michael Dewey From |enn@rt@k@@@err@ @end|ng |rom gm@||@com Sat Aug 29 21:06:06 2026 From: |enn@rt@k@@@err@ @end|ng |rom gm@||@com (Lennart Kasserra) Date: Sat, 29 Aug 2026 21:06:06 +0200 Subject: [R] Ubuntu sources file for R packages In-Reply-To: <316f8fe2-0544-4090-988a-33cd593a670e@dewey.myzen.co.uk> References: <316f8fe2-0544-4090-988a-33cd593a670e@dewey.myzen.co.uk> Message-ID: Hi Naresh, the README you linked to points you to the r2u-project (https://github.com/eddelbuettel/r2u), which has setup scripts & instructions for how to setup binaries for CRAN packages and most recent R version on Ubuntu, including on 26.04 in the new format. Here is the script for 26.04 LTS: https://github.com/eddelbuettel/r2u/blob/master/inst/scripts/add_cranapt_resolute.sh, all instructions worked fine on my machines running Ubuntu 26.04 LTS. All the best, Lennart > Am 29.08.2026 um 18:09 schrieb Michael Dewey via R-help : > > ?Dear Naresh > > Perhaps you might get more answers on https://stat.ethz.ch/mailman/listinfo/r-sig-debian > > Michael > >> On 29/08/2026 13:50, Naresh Gurbuxani wrote: >> I followed these instructions to install R on my new Ubuntu desktop. >> https://cran.r-project.org/bin/linux/ubuntu/ >> To install additional packages, I am following these instructions: >> https://cran.r-project.org/bin/linux/ubuntu/fullREADME.html >> For Ubuntu 26.04 (Resolute Racoon), /etc/apt/sources.list is deprecated. It seems I need to create a file in /etc/apt/ sources.list.d/. I started a file "r-package.sources" and need entries for the last two fields. My file: >> ## R package repository >> Types: deb >> URIs: https://cloud.r-project.org/bin/linux/ubuntu >> Suites: resolute-cran40 >> Components: >> Signed-By: >> It will also benefit other users if you can update the instructions in fullREADME.html >> Thanks, >> Naresh >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide https://www.R-project.org/posting- guide.html >> and provide commented, minimal, self-contained, reproducible code. > > -- > Michael Dewey > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] From rmdor@z|o @end|ng |rom gm@||@com Sat Aug 29 16:01:24 2026 From: rmdor@z|o @end|ng |rom gm@||@com (Robert Dorazio) Date: Sat, 29 Aug 2026 07:01:24 -0700 Subject: [R] Ubuntu sources file for R packages In-Reply-To: References: Message-ID: Naresh, The instructions given at https://cran.r-project.org/bin/linux/ubuntu/ for installing R on Ubuntu work well. However, for installing R packages I recommend the following approach. 1. Download the shell script for your version of Ubuntu (e.g., add_cranapt_resolute.sh for Ubuntu 26.04) from the r2u website: https://github.com/eddelbuettel/r2u 2. Run the shell script from the terminal as follows: sudo su bash add_cranapt_resolute.sh exit Then you have two options for installing R packages from the fast, well-connected mirror r2u.stat.illinois.edu As an example, you can install the R package "sp" using either of the following options: 1. From the terminal: sudo apt install r-cran-sp 2. From R: install.packages("sp") A big advantage of using r2u is that all dependencies of each package are downloaded properly. Robert Dorazio On Sat, Aug 29, 2026 at 5:50?AM Naresh Gurbuxani < naresh_gurbuxani at hotmail.com> wrote: > I followed these instructions to install R on my new Ubuntu desktop. > > https://cran.r-project.org/bin/linux/ubuntu/ > > > To install additional packages, I am following these instructions: > > https://cran.r-project.org/bin/linux/ubuntu/fullREADME.html > > > For Ubuntu 26.04 (Resolute Racoon), /etc/apt/sources.list is > deprecated. It seems I need to create a file in > /etc/apt/sources.list.d/. I started a file "r-package.sources" and need > entries for the last two fields. My file: > > ## R package repository > Types: deb > URIs: https://cloud.r-project.org/bin/linux/ubuntu > Suites: resolute-cran40 > Components: > Signed-By: > > It will also benefit other users if you can update the instructions in > fullREADME.html > > > Thanks, > > Naresh > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] From n@re@h_gurbux@n| @end|ng |rom hotm@||@com Sat Aug 29 16:49:40 2026 From: n@re@h_gurbux@n| @end|ng |rom hotm@||@com (Naresh Gurbuxani) Date: Sat, 29 Aug 2026 10:49:40 -0400 Subject: [R] Ubuntu sources file for R packages In-Reply-To: References: Message-ID: This worked.? Thanks On 8/29/26 10:01, Robert Dorazio wrote: > Naresh, > > The instructions given at https://cran.r-project.org/bin/linux/ubuntu/ > for installing R on Ubuntu work well. > > However, for installing R packages?I recommend the following approach. > > 1. Download the shell script for your version of Ubuntu (e.g., > add_cranapt_resolute.sh for Ubuntu 26.04) from > the r2u website: https://github.com/eddelbuettel/r2u > > 2. Run the shell script from the terminal as follows: > sudo su > bash add_cranapt_resolute.sh > exit > > Then you have two options for installing R packages from the fast, > well-connected mirror r2u.stat.illinois.edu > > > As an example, you can install the R package "sp" using either of the > following options: > > 1. From the terminal:? sudo apt install r-cran-sp > > 2. From R:? install.packages("sp") > > A big advantage of using r2u is that all dependencies of each package > are downloaded properly. > > Robert Dorazio > > > > On Sat, Aug 29, 2026 at 5:50?AM Naresh Gurbuxani > wrote: > > I followed these instructions to install R on my new Ubuntu desktop. > > https://cran.r-project.org/bin/linux/ubuntu/ > > > To install additional packages, I am following these instructions: > > https://cran.r-project.org/bin/linux/ubuntu/fullREADME.html > > > For Ubuntu 26.04 (Resolute Racoon), /etc/apt/sources.list is > deprecated.? It seems I need to create a file in > /etc/apt/sources.list.d/.? I started a file "r-package.sources" > and need > entries for the last two fields.? My file: > > ## R package repository > Types: deb > URIs: https://cloud.r-project.org/bin/linux/ubuntu > Suites: resolute-cran40 > Components: > Signed-By: > > It will also benefit other users if you can update the > instructions in > fullREADME.html > > > Thanks, > > Naresh > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > https://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] From edd @end|ng |rom deb|@n@org Mon Aug 31 14:13:36 2026 From: edd @end|ng |rom deb|@n@org (Dirk Eddelbuettel) Date: Mon, 31 Aug 2026 07:13:36 -0500 Subject: [R] Ubuntu sources file for R packages In-Reply-To: References: Message-ID: <27285.28656.376922.235745@paul.eddelbuettel.com> Robert, Thanks for piping in. Much appreciated. Michael and I will still see that the README gets updated. On 29 August 2026 at 07:01, Robert Dorazio wrote: | Naresh, | | The instructions given at https://cran.r-project.org/bin/linux/ubuntu/ for | installing R on Ubuntu work well. | | However, for installing R packages I recommend the following approach. | | 1. Download the shell script for your version of Ubuntu (e.g., | add_cranapt_resolute.sh for Ubuntu 26.04) from | the r2u website: https://github.com/eddelbuettel/r2u | | 2. Run the shell script from the terminal as follows: | sudo su | bash add_cranapt_resolute.sh | exit | | Then you have two options for installing R packages from the fast, | well-connected mirror r2u.stat.illinois.edu | | As an example, you can install the R package "sp" using either of the | following options: | | 1. From the terminal: sudo apt install r-cran-sp My favourite here is to also install a few of the scripts from the littler package as the the r2u containers do because then you can say at the terminal install.r sp # littler script, calls install.packages because under an r2u setup with bspm (or rapt) this does the same. But is shorter, and uses the R package name internally switching to the binary. And yes, 'sf' is a great example due to the geospatial stack and its dependencies. It is so lovely to see this 'just' work, as it does for the other r2u payload. Dirk PS For example in the r2u container, after installing littler, I do [ initial steps skipped ] ## Install a number littler scripts && ln -s /usr/lib/R/site-library/littler/examples/build.r /usr/local/bin/build.r \ && ln -s /usr/lib/R/site-library/littler/examples/check.r /usr/local/bin/check.r \ && ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \ && ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \ && ln -s /usr/lib/R/site-library/littler/examples/installBioc.r /usr/local/bin/installBioc.r \ && ln -s /usr/lib/R/site-library/littler/examples/installDeps.r /usr/local/bin/installDeps.r \ && ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \ && ln -s /usr/lib/R/site-library/littler/examples/installRub.r /usr/local/bin/installRub.r \ && ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \ && ln -s /usr/lib/R/site-library/littler/examples/tt.r /usr/local/bin/tt.r \ && ln -s /usr/lib/R/site-library/littler/examples/tttf.r /usr/local/bin/tttf.r \ && ln -s /usr/lib/R/site-library/littler/examples/tttl.r /usr/local/bin/tttl.r \ && ln -s /usr/lib/R/site-library/littler/examples/update.r /usr/local/bin/update.r \ [ more skipped ] See https://github.com/rocker-org/r2u/blob/master/resolute/Dockerfile#L70-L83 | | 2. From R: install.packages("sp") | | A big advantage of using r2u is that all dependencies of each package are | downloaded properly. | | Robert Dorazio | | | | On Sat, Aug 29, 2026 at 5:50?AM Naresh Gurbuxani < | naresh_gurbuxani at hotmail.com> wrote: | | > I followed these instructions to install R on my new Ubuntu desktop. | > | > https://cran.r-project.org/bin/linux/ubuntu/ | > | > | > To install additional packages, I am following these instructions: | > | > https://cran.r-project.org/bin/linux/ubuntu/fullREADME.html | > | > | > For Ubuntu 26.04 (Resolute Racoon), /etc/apt/sources.list is | > deprecated. It seems I need to create a file in | > /etc/apt/sources.list.d/. I started a file "r-package.sources" and need | > entries for the last two fields. My file: | > | > ## R package repository | > Types: deb | > URIs: https://cloud.r-project.org/bin/linux/ubuntu | > Suites: resolute-cran40 | > Components: | > Signed-By: | > | > It will also benefit other users if you can update the instructions in | > fullREADME.html | > | > | > Thanks, | > | > Naresh | > | > ______________________________________________ | > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see | > https://stat.ethz.ch/mailman/listinfo/r-help | > PLEASE do read the posting guide | > https://www.R-project.org/posting-guide.html | > and provide commented, minimal, self-contained, reproducible code. | > | | [[alternative HTML version deleted]] | | ______________________________________________ | R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see | https://stat.ethz.ch/mailman/listinfo/r-help | PLEASE do read the posting guide https://www.R-project.org/posting-guide.html | and provide commented, minimal, self-contained, reproducible code. -- dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org