make.unique rbind examples

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

make.unique rbind examples

Jonathan Carroll-2
The final two examples in ?make.unique do not appear to be relevant to
that function, namely

rbind(data.frame(x = 1), data.frame(x = 2), data.frame(x = 3))
rbind(rbind(data.frame(x = 1), data.frame(x = 2)), data.frame(x = 3))

both producing

  x
1 1
2 2
3 3

(identically) on R 3.4.3 and 3.5.1. Following a brief discussion on
Twitter, Rich FitzJohn [1] identified that under R 1.8.0 (circa 2003,
around the time these examples were added) the rownames for the output
of these lines was c("1", "11", "12"). This suggests that perhaps the
example was added to demonstrate behaviour which is no longer
supported.

A more relevant example might be

data.frame(x = 1, x = 2, x = 3)

producing

  x x.1 x.2
1 1   2   3

or, perhaps more in keeping with the original intention,

rbind(data.frame(x = 1, row.names = "a"), data.frame(x = 2, row.names
= "a"), data.frame(x = 3, row.names = "a"))

producing output with rownames c("a", "a1", "a2").

Regards,

- Jonathan.

[1] https://twitter.com/rgfitzjohn/status/1094885131532275712

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: make.unique rbind examples

Jonathan Carroll-2
Entirely by coincidence I just now discovered that this issue was raised in
2013 [1] with similar suggestions for improvements. My search did not
initially uncover this message, so apologies for the repost which was
actually a nearly 16 year later "bump" posting.

[1] https://stat.ethz.ch/pipermail/r-devel/2013-May/066727.html

Regards,

- Jonathan.

On Mon, 11 Feb. 2019, 9:19 pm Jonathan Carroll, <[hidden email]>
wrote:

> The final two examples in ?make.unique do not appear to be relevant to
> that function, namely
>
> rbind(data.frame(x = 1), data.frame(x = 2), data.frame(x = 3))
> rbind(rbind(data.frame(x = 1), data.frame(x = 2)), data.frame(x = 3))
>
> both producing
>
>   x
> 1 1
> 2 2
> 3 3
>
> (identically) on R 3.4.3 and 3.5.1. Following a brief discussion on
> Twitter, Rich FitzJohn [1] identified that under R 1.8.0 (circa 2003,
> around the time these examples were added) the rownames for the output
> of these lines was c("1", "11", "12"). This suggests that perhaps the
> example was added to demonstrate behaviour which is no longer
> supported.
>
> A more relevant example might be
>
> data.frame(x = 1, x = 2, x = 3)
>
> producing
>
>   x x.1 x.2
> 1 1   2   3
>
> or, perhaps more in keeping with the original intention,
>
> rbind(data.frame(x = 1, row.names = "a"), data.frame(x = 2, row.names
> = "a"), data.frame(x = 3, row.names = "a"))
>
> producing output with rownames c("a", "a1", "a2").
>
> Regards,
>
> - Jonathan.
>
> [1] https://twitter.com/rgfitzjohn/status/1094885131532275712
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel