[R] structure vs. matrix

Duncan Murdoch murdoch at stats.uwo.ca
Sun Nov 4 15:19:38 CET 2007


On 04/11/2007 7:43 AM, Mark Difford wrote:
> Hi Edna,
> 
>>> When creating a matrix, is it better to use the structure function or the
>>> matrix function...?
> 
> I hope you have a huge (empty) jar in the kitchen, and that your pantry is
> empty.
> 
> R isn't too difficult, except if you're trying to do stats (and don't know
> what you are doing --- though I am not suggesting that you don't know how to
> do stats;).
> 
> ## see
> ?structure
> ?matrix
> 
> A structure is not a matrix.  So, if you want to make a matrix, use
> matrix().  Easy.

But a matrix is a structure, so you could use structure() to create one. 
  I wouldn't normally do that, but there might be circumstances where it 
was appropriate.

Duncan Murdoch

> 
> HTH,
> Mark.
> 
> 
> Edna Bell wrote:
>> Hi R Gurus!
>>
>> When creating a matrix, is it better to use the structure function or
>> the matrix function, please?
>>
>> Thanks,
>> Edna Bell
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>



More information about the R-help mailing list