From ripley at stats.ox.ac.uk  Tue Feb 19 18:40:16 2008
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Tue, 19 Feb 2008 18:40:16 +0100 (CET)
Subject: [Rd] (PR#10799) Assigning a sub-matrix from a data frame to a
Message-ID: <20080219174016.12500282EFF6@mail.pubhealth.ku.dk>

Where precisely is the bug here?  If you assign a list (d[,1:2] is a list: 
it is the whole data frame) to a numeric matrix you coerce the latter to 
mode list, and that is what happened.

If we have the simpler version

d <- data.frame(v1=1:2,v2=3:4)
x <- matrix(0, 2, 2)
x[] <- d

it may be easier to see what happened.

I think the problem is in your subject line: d[,1:2] is _not_ a 
sub-matrix.

Reproting behaviour as 'strange' without explaining what you thought 
should have happened and why leaves us guessing as to what you think the 
'bug' might be.


On Tue, 19 Feb 2008, david at opsi.co.za wrote:

> See below:
>
>
>
>> d = data.frame(v1=1:2,v2=1:2)
>
>> x = matrix(0,2,2)
>
>> x[,1:2] = d[,1:2]
>
>> x
>
> [[1]]
>
> [1] 1 2
>
>
>
> [[2]]
>
> [1] 1 2
>
>
>
> [[3]]
>
> [1] 1 2
>
>
>
> [[4]]
>
> [1] 1 2
>
>
>
>>
>
>
>
> Thanks for all the work in R. Still love it.
>
>
>
> David
>
>
>
>
>
> David Lubinsky
>
> Director
>
> OPSI Systems
>
>
>
> Phone:  +27 11 880 7951
>
> Cell: +27 82 452 9556
>
> URL:  <http://www.opsi.co.za> www.opsi.co.za
>
> Email:  <mailto:david at opsi.co.za> david at opsi.co.za
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] (PR#10799) Assigning a sub-matrix from a data frame to a
ripley at stats.ox.ac.uk