[Rd] data.frame weirdness

Gabor Grothendieck ggrothend|eck @end|ng |rom gm@||@com
Tue Nov 14 15:40:55 CET 2023


Also why should that difference result in different behavior?

On Tue, Nov 14, 2023 at 9:38 AM Gabor Grothendieck
<ggrothendieck using gmail.com> wrote:
>
> In that case identical should be FALSE but  it is TRUE
>
> identical(a1, a2)
> ## [1] TRUE
>
>
> On Tue, Nov 14, 2023 at 8:58 AM Deepayan Sarkar
> <deepayan.sarkar using gmail.com> wrote:
> >
> > They differ in whether the row names are "automatic":
> >
> > > .row_names_info(a1)
> > [1] -3
> > > .row_names_info(a2)
> > [1] 3
> >
> > Best,
> > -Deepayan
> >
> > On Tue, 14 Nov 2023 at 08:23, Gabor Grothendieck
> > <ggrothendieck using gmail.com> wrote:
> > >
> > > What is going on here?  In the lines ending in #### the inputs and outputs
> > > are identical yet one gives a warning and the other does  not.
> > >
> > > a1 <- `rownames<-`(anscombe[1:3, ],  NULL)
> > > a2 <- anscombe[1:3, ]
> > >
> > > ix <- 5:8
> > >
> > > # input arguments to #### are identical in both cases
> > >
> > > identical(stack(a1[ix]), stack(a2[ix]))
> > > ## [1] TRUE
> > > identical(a1[-ix], a2[-ix])
> > > ## [1] TRUE
> > >
> > >
> > > res1 <- data.frame(stack(a1[ix]), a1[-ix]) ####
> > > res2 <- data.frame(stack(a2[ix]), a2[-ix]) ####
> > > ## Warning message:
> > > ## In data.frame(stack(a2[ix]), a2[-ix]) :
> > > ##   row names were found from a short variable and have been discarded
> > >
> > > # results are identical
> > > identical(res1, res2)
> > > ## [1] TRUE
> > >
> > >
> > > --
> > > Statistics & Software Consulting
> > > GKX Group, GKX Associates Inc.
> > > tel: 1-877-GKX-GROUP
> > > email: ggrothendieck at gmail.com
> > >
> > > ______________________________________________
> > > R-devel using r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-devel mailing list