[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    Re: [Rd] bug in rbind?
From:       Joshua Ulrich <josh.m.ulrich () gmail ! com>
Date:       2017-01-21 17:58:18
Message-ID: CAPPM_gRThYFANgAwxb-9fa4=X4qRE80gH3SGESnxWEe-DzVRqg () mail ! gmail ! com
[Download RAW message or body]

I'm not sure whether or not this is a bug, but I did isolate the line
where the error is thrown:
src/library/base/R/dataframe.R:1395.
https://github.com/wch/r-source/blob/01374c3c367fa12f555fd354f735a6e16e5bd98e/src/library/base/R/dataframe.R#L1395


The error is thrown because the line attempts to set a subset of the
rownames to NULL, which fails.

R> options(error = recover)
R> rbind(dfm.names, dfm)
Error in rownames(value[[jj]])[ri] <- rownames(xij) :
  replacement has length zero

Enter a frame number, or 0 to exit

1: rbind(dfm.names, dfm)
2: rbind(deparse.level, ...)

Selection: 2
Called from: top level
Browse[1]> rownames(value[[jj]])
[1] "a" "b" "c" NA  NA  NA
Browse[1]> rownames(xij)
NULL
Browse[1]> ri
[1] 4 5 6
Browse[1]> rownames(value[[jj]])[ri]
[1] NA NA NA


On Mon, Jan 16, 2017 at 7:50 PM, Krzysztof Banas <krzysztof@nus.edu.sg> wrote:
> I suspect there may be a bug in base::rbind.data.frame
> 
> Below there is minimal example of the problem:
> 
> m <- matrix (1:12, 3)
> dfm <- data.frame (c = 1 : 3, m = I (m))
> str (dfm)
> 
> m.names <- m
> rownames (m.names) <- letters [1:3]
> dfm.names <- data.frame (c = 1 : 3, m = I (m.names))
> str (dfm.names)
> 
> rbind (m, m.names)
> rbind (m.names, m)
> rbind (dfm, dfm.names)
> 
> #not working
> rbind (dfm.names, dfm)
> 
> Error in rbind(deparse.level, ...) : replacement has length zero
> 
> rbind (dfm, dfm.names)$m
> 
> 
> [,1] [,2] [,3] [,4]
> 
> <NA>    1    4    7   10
> 
> <NA>    2    5    8   11
> 
> <NA>    3    6    9   12
> 
> a       1    4    7   10
> 
> b       2    5    8   11
> 
> c       3    6    9   12
> 
> 
> 
> ________________________________
> 
> Important: This email is confidential and may be privileged. If you are not the \
> intended recipient, please delete it and notify us immediately; you should not copy \
> or use it for any purpose, nor disclose its contents to any other person. Thank \
> you. 
> [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic