rdiscrete in e1071 fails when n==1 (PR#1716)

jaitchis@hwy.com.au jaitchis@hwy.com.au
Fri, 28 Jun 2002 07:52:46 +0200 (MET DST)


# Your mailer is set to "none" (default on Windows),
# hence we cannot send the bug report directly from R.
# Please copy the bug report (after finishing it) to
# your favorite email program and send it to
#
#       r-bugs@r-project.org
#
######################################################





<<insert bug report here>>


in e0171 the routine rdiscrete fails when n==1

the first few lines of code make it obvious why

> rdiscrete
function (n, probs, values = 1:length(probs), method = "inverse", 
    aliasmatrix = NULL) 
{
    if (length(probs) != length(values)) 
        stop("rdiscrete: probs and values must have the same 
length.")
    if (sum(probs < 0) > 0) 
        stop("rdiscrete: probs must not contain negative values.")
    if (n == 1) 
        return(values[sum(runif(1) > p) + 1])   ???? p is undefined at 
this point
    else {




--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = x86
 os = Win32
 system = x86, Win32
 status = 
 major = 1
 minor = 4.1
 year = 2002
 month = 01
 day = 30
 language = R

Windows 98 SE 4.10 (build 2222)  A 

Search Path:
 .GlobalEnv, package:e1071, package:ctest, Autoloads, 
package:base


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._