SCM

[#2159] dlapply failing where it shouldn't

Date:
2012-07-24 17:02
Priority:
4
State:
Open
Submitted by:
Steve Walker (walker)
Assigned to:
Steve Walker (walker)
Hardware:
None
Product:
None
Operating System:
None
Component:
None
Version:
None
Severity:
None
Resolution:
None
URL:
Summary:
dlapply failing where it shouldn't

Detailed description
Example:

set.seed(1)

Y <- matrix(runif(10), 5, 2)
X <- runif(5)
Z <- runif(2)

dl <- data.list(Y, X, Z)

This works (as it should):
dlapply(dl, 1, sum)

But this doesn't (even though it should):
dlapply(dl, 2, sum)


The problem seems to be linked to the '+' operator for data lists not working when one of the elements being added is NULL. See the call to Reduce at the end of dlapply.

Comments:

Message  ↓
Date: 2012-07-24 17:16
Sender: Steve Walker

Changed the '+' operator method to check for null summands. The test above is now passed, in that both dlapply calls return what is expected. In particular;

> dlapply(dl, 1, sum)
omitting Z because it is not replicated along MARGIN
Y:
-
1 2 3 4 5
1.1638983 1.3167992 1.2336512 1.5373218 0.2634682
Replicated along: || D1 ||


X:
-
1 2 3 4 5
0.2059746 0.1765568 0.6870228 0.3841037 0.7698414
Replicated along: || D1 ||


REPLICATION DIMENSIONS:
D1
5
> dlapply(dl, 2, sum)
omitting X because it is not replicated along MARGIN
Y:
-
1 2
2.320376 3.194763
Replicated along: || D2 ||


Z:
-
1 2
0.4976992 0.7176185
Replicated along: || D2 ||


REPLICATION DIMENSIONS:
D2
2



*However*, I still need to check more generally whether this breaks anything else (e.g. JSS manuscript). Added a test.

Attached Files:

Changes

No Changes Have Been Made to This Item

Thanks to:
Vienna University of Economics and Business Powered By FusionForge