There is still the situation where **both** 'sep' and 'collapse' are specified:

  > paste(integer(0), "nth", sep="", collapse=",")
  [1] "nth"

In that case 'recycle0' should **not** be ignored i.e.

  paste(integer(0), "nth", sep="", collapse=",", recycle0=TRUE)

should return the empty string (and not character(0) like it does at the moment).

In other words, 'recycle0' should only control the first operation (the operation controlled by 'sep'). Which makes plenty of sense: the 1st operation is binary (or n-ary) while the collapse operation is unary. There is no concept of recycling in the context of unary operations.

H.

On 5/15/20 11:25, Gabriel Becker wrote:
Hi all,

This makes sense to me, but I would think that recycle0 and collapse should actually be incompatible and paste should throw an error if recycle0 were TRUE and collapse were declared in the same call. I don't think the value of recycle0 should be silently ignored if it is actively specified.

~G

On Fri, May 15, 2020 at 11:05 AM Hervé Pagès <hpa...@fredhutch.org <mailto:hpa...@fredhutch.org>> wrote:

    Totally agree with that.

    H.

    On 5/15/20 10:34, William Dunlap via R-devel wrote:
     > I agree: paste(collapse="something", ...) should always return a
    single
     > character string, regardless of the value of recycle0.  This would be
     > similar to when there are no non-NULL arguments to paste;
    collapse="."
     > gives a single empty string and collapse=NULL gives a zero long
    character
     > vector.
     >> paste()
     > character(0)
     >> paste(collapse=", ")
     > [1] ""
     >
     > Bill Dunlap
     > TIBCO Software
     > wdunlap tibco.com
    
<https://urldefense.proofpoint.com/v2/url?u=http-3A__tibco.com&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=cC2qctlVXd0qHMPvCyYvuVMqR8GU3DjTTqKJ0zjIFj8&s=rXIwWqf4U4HZS_bjUT3KfA9ARaV5YTb_kEcXWHnkt-c&e=>
     >
     >
     > On Thu, Apr 30, 2020 at 9:56 PM suharto_anggono--- via R-devel <
     > r-devel@r-project.org <mailto:r-devel@r-project.org>> wrote:
     >
     >> Without 'collapse', 'paste' pastes (concatenates) its arguments
     >> elementwise (separated by 'sep', " " by default). New in R devel
    and R
     >> patched, specifying recycle0 = FALSE makes mixing zero-length and
     >> nonzero-length arguments results in length zero. The result of
    paste(n,
     >> "th", sep = "", recycle0 = FALSE) always have the same length as
    'n'.
     >> Previously, the result is still as long as the longest argument,
    with the
     >> zero-length argument like "". If all og the arguments have
    length zero,
     >> 'recycle0' doesn't matter.
     >>
     >> As far as I understand, 'paste' with 'collapse' as a character
    string is
     >> supposed to put together elements of a vector into a single
    character
     >> string. I think 'recycle0' shouldn't change it.
     >>
     >> In current R devel and R patched, paste(character(0), collapse = "",
     >> recycle0 = FALSE) is character(0). I think it should be "", like
     >> paste(character(0), collapse="").
     >>
     >> paste(c("4", "5"), "th", sep = "", collapse = ", ", recycle0 =
    FALSE)
     >> is
     >> "4th, 5th".
     >> paste(c("4"     ), "th", sep = "", collapse = ", ", recycle0 =
    FALSE)
     >> is
     >> "4th".
     >> I think
     >> paste(c(        ), "th", sep = "", collapse = ", ", recycle0 =
    FALSE)
     >> should be
     >> "",
     >> not character(0).
     >>
     >> ______________________________________________
     >> R-devel@r-project.org <mailto:R-devel@r-project.org> mailing list
     >>
    
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=776IovW06eUHr1EDrabHLY7F47rU9CCUEItSDI96zc0&s=xN84DhkZeoxzn6SG0QTMpOGg2w_ThmjZmZymGUuD0Uw&e=
     >>
     >
     >       [[alternative HTML version deleted]]
     >
     > ______________________________________________
     > R-devel@r-project.org <mailto:R-devel@r-project.org> mailing list
     >
    
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwICAg&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=776IovW06eUHr1EDrabHLY7F47rU9CCUEItSDI96zc0&s=xN84DhkZeoxzn6SG0QTMpOGg2w_ThmjZmZymGUuD0Uw&e=
     >

-- 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: hpa...@fredhutch.org <mailto:hpa...@fredhutch.org>
    Phone:  (206) 667-5791
    Fax:    (206) 667-1319

    ______________________________________________
    R-devel@r-project.org <mailto:R-devel@r-project.org> mailing list
    https://stat.ethz.ch/mailman/listinfo/r-devel
    
<https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwMFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=cC2qctlVXd0qHMPvCyYvuVMqR8GU3DjTTqKJ0zjIFj8&s=COnDeGgHNnHJlLLZOznMlhcaFU1nIRlkaSbssvlrMvw&e=>


--
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: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to