rbind returns a zero row data frame when binding zero column data frames

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

rbind returns a zero row data frame when binding zero column data frames

Ant F
Dear all,

`rbind()` returns a zero row data frame when binding zero column data
frames, see example below:

``` r
# a data frame with 1 row and 0 column
x <- data.frame(row.names=1)
x
#> data frame with 0 columns and 1 row
rbind(x,x)
#> data frame with 0 columns and 0 rows
```

I would have expected in that case `data frame with 0 columns and 2 rows`.

`cbind()` on the other hand acts as I would expect, returning a 2 column
data frame from 2 one column data frames even if they have no row.

``` r
# a data frame with 0 row and 1 column
y <- data.frame(A = numeric(0))
y
#> [1] A
#> <0 rows> (or 0-length row.names)
cbind(y,y)
#> [1] A A
#> <0 rows> (or 0-length row.names)
```

        [[alternative HTML version deleted]]

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