Re: [Rd] `as.data.frame.matrix()` can produce a data frame without a `names` attribute
> Davis Vaughan via R-devel > on Thu, 21 Mar 2024 15:10:29 -0400 writes: > Hi all, > I recently learned that it is possible for > `as.data.frame.matrix()` to produce a data frame with 0 > columns that is also entirely missing a `names` attribute, > and I think this is a bug: > ``` # No `names`, weird! > attributes(as.data.frame(matrix(nrow = 0, ncol = 0))) #> > $class #> [1] "data.frame" > #> > #> $row.names #> integer(0) > # This is what I expected attributes(data.frame()) #> > $names #> character(0) > #> > #> $row.names #> integer(0) > #> > #> $class #> [1] "data.frame" ``` > In my experience, 0 column data frames should probably > still have a `names` attribute, and it should be set to > `character()`. I agree. A (very nice IMO) patch I'm currently testing is 317c317 < names(value) <- collabs --- > names(value) <- collabs %||% character() Martin > Some evidence to support my theory is that > OOB subsetting doesn't give the intended error with this > weird data frame: > ``` # Good OOB error df <- data.frame() df[1] #> Error in > `[.data.frame`(df, 1): undefined columns selected > # This is weird! df <- as.data.frame(matrix(nrow = 0, > ncol = 0)) df[1] #> NULL #> <0 rows> (or 0-length > row.names) ``` > The one exception to requiring a `names` attribute that I > can think of is `as.data.frame(optional = TRUE)`, mostly > for internal use by `data.frame()` on each of the columns, > but that doesn't seem to apply here. > Thanks, Davis Vaughan > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] `as.data.frame.matrix()` can produce a data frame without a `names` attribute
> Martin Maechler > on Fri, 22 Mar 2024 11:17:34 +0100 writes: > Davis Vaughan via R-devel > on Thu, 21 Mar 2024 15:10:29 -0400 writes: >> Hi all, >> I recently learned that it is possible for >> `as.data.frame.matrix()` to produce a data frame with 0 >> columns that is also entirely missing a `names` >> attribute, and I think this is a bug: >> ``` # No `names`, weird! >> attributes(as.data.frame(matrix(nrow = 0, ncol = 0))) #> >> $class #> [1] "data.frame" >> #> >> #> $row.names #> integer(0) >> # This is what I expected attributes(data.frame()) #> >> $names #> character(0) >> #> >> #> $row.names #> integer(0) >> #> >> #> $class #> [1] "data.frame" ``` >> In my experience, 0 column data frames should probably >> still have a `names` attribute, and it should be set to >> `character()`. > I agree. > A (very nice IMO) patch I'm currently testing is > 317c317 > < names(value) <- collabs > --- > > names(value) <- collabs %||% character() Commited to R's (R-devel) sources in svn rev 86169 .. to become R 4.4.0 soonish. Martin __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R Dev Day @ PLUS, Salzburg, Austria on Fri 12 July
Reminder that the deadline for applications to this event is end of day Sunday March 24 (anywhere on earth). On Wed, Feb 28, 2024, at 2:43 PM, Heather Turner wrote: > Dear All, > > Information is now up for the R Dev Day that will take place as a > satellite event to useR! 2024 on Friday 12 July: > https://contributor.r-project.org/r-dev-day-plus-2024 > > This will be an opportunity for contributors to work alongside members > of the R Core Team on contributions to base R. > > Places will be allocated via an application process, balancing across > experience levels and giving opportunity to members of historically > underrepresented groups. > > If you would like to attend, please apply by *Sunday March 24*. > > Best wishes, > > Heather > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel