[Rd] minor error in documentation of pmax in base (PR#2513)
Jonathan Baron
baron@cattell.psych.upenn.edu
Fri Jan 31 18:58:48 2003
In a way it is not surprising, but some functions that operate on
vectors will coerce their outputs into vectors and others won't.
For example, try
m1 <- array(1:24,c(2,3,4))
sort(m1)
order(m1)
It would be nice to say when each of these things will happen.
For example, in the documentaition for ifelse, it says, "returns
a value with the same shape as". This sort of language would be
helpful.
Jon
On 01/31/03 12:42, Liaw, Andy wrote:
>If I'm not mistaken, matrices and arrays are just vectors with dim
>attribute. so I'm not surprised that pmax and pmin work as they do. You
>get the same answer by the following:
>
>array(pmax(1:24, 24:1), c(2, 3, 4))
>array(pmin(1:24, 24:1), c(2, 3, 4))
>
>
>Cheers,
>Andy
>
>> -----Original Message-----
>> From: baron@cattell.psych.upenn.edu
>> [mailto:baron@cattell.psych.upenn.edu]
>> Sent: Friday, January 31, 2003 12:37 PM
>> To: r-devel@stat.math.ethz.ch
>> Cc: R-bugs@biostat.ku.dk
>> Subject: [Rd] minor error in documentation of pmax in base (PR#2513)
>>
>>
>> The documentation says, "pmax and pmin take several vectors as
>> arguments and return a single vector giving the parallel maxima
>> (or minima) of the vectors."
>>
>> I discovered that, if you use a matrix or array instead of a
>> vector, pmax returns a matrix or array, respectively.
>>
>> This makes pmax and pmin much more useful, and should not be left
>> to people to discover on their own!
>>
>> For example:
>> m1 <- array(1:24,c(2,3,4))
>> m2 <- array(24:1,c(2,3,4))
>> pmax(m1,m2)
>> pmin(m1,m2)
>>
>> Jon Baron
>>
>> ______________________________________________
>> R-devel@stat.math.ethz.ch mailing list
>> http://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>>
>
>------------------------------------------------------------------------------
>Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.
>
>==============================================================================
>
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Psychology webmaster: http://www.psych.upenn.edu/
R page: http://finzi.psych.upenn.edu/
Questionnaires: http://www.psych.upenn.edu/~baron/qs.html