Bug 7116 - Bug in cor() with named array and matrix
Bug in cor() with named array and matrix
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Analyses
old
ix86 (32-bit) Windows 32-bit
: P5 normal
Assigned To: Jitterbug compatibility account
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-07-20 02:12 UTC by Jitterbug compatibility account
Modified: 2004-07-20 18:51 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2004-07-20 02:12:59 UTC
From: jusung@andrew.cmu.edu
Full_Name: Ju-Sung Lee
Version: 1.9.1
OS: Windows XP
Submission from: (NULL) (128.2.79.102)


The following commands causes R to crash:
a = array(1:3)
dimnames(a)[[1]] = c('1','2','3')
cor(a,matrix(1:3))

not naming the array seems to work.



Comment 1 Jitterbug compatibility account 2004-07-20 18:51:04 UTC
From: Martin Maechler <maechler@stat.math.ethz.ch>
>>>>> "jusung" == jusung  <jusung@andrew.cmu.edu>
>>>>>     on Mon, 19 Jul 2004 23:13:01 +0200 (CEST) writes:

    jusung> Full_Name: Ju-Sung Lee
    jusung> Version: 1.9.1
    jusung> OS: Windows XP
    jusung> Submission from: (NULL) (128.2.79.102)


    jusung> The following commands causes R to crash:
    jusung> a = array(1:3)
    jusung> dimnames(a)[[1]] = c('1','2','3')
    jusung> cor(a,matrix(1:3))

    jusung> not naming the array seems to work.

yes, indeed.  
Thank you for the good bug report.

A shorter version is
   cor(as.array(c(a=1, b=2)), cbind(1:2))

The internals assume to have either a matrix or a vector when
the other argument is a matrix.

I'm still thinking about where to fix the bug, in C or in R.
What I find is that R also excepts list()s as arguments to
cor(), cov(), etc. which I think should rather give an error, 
IMO.

Martin Maechler

Comment 2 Jitterbug compatibility account 2004-07-26 12:25:00 UTC
NOTES:
 Fixed in 1.9.1 patched
Comment 3 Jitterbug compatibility account 2004-07-26 14:22:42 UTC
Audit (from Jitterbug):
Mon Jul 26 09:22:42 2004	ripley	changed notes
Mon Jul 26 09:22:42 2004	ripley	moved from incoming to Analyses-fixed