inaccurate description of 'init' argument in ?Reduce

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

inaccurate description of 'init' argument in ?Reduce

Hervé Pagès-2
Hello list,

In ?Reduce:

   init: an R object of the same kind as the elements of ‘x’.

Seems like "the same kind" is an unnecessary and artificial restriction.
Furthermore, there is no notion of "same kind" for heterogeneous lists:

   x <-  list(letters, c(TRUE, FALSE))

   Reduce(function(init, xx) {init + length(xx)}, x, init=100)
   # [1] 128

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: [hidden email]
Phone:  (206) 667-5791
Fax:    (206) 667-1319
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel