[R] c(), or cat(), or paste(), all cause unwanted reordering

Sarah Goslee sarah.goslee at gmail.com
Thu Mar 25 20:15:34 CET 2010


cat() isn't doing what you think, and as.character()
is unnecessary here because paste() takes care of
that.

A couple of more elegant solutions have already
appeared, but here's one that parallels your version:

paste(c(
       rep( ".", 2 ),
       "a string",
       rep( ".", 3 )),
collapse=" ")



On Thu, Mar 25, 2010 at 2:53 PM, Jeff Brown <dopethatwantscash at yahoo.com> wrote:
>
> Hi,
>
> I would expect the following:
>
> paste(
>        as.character( cat( rep( ".", 2 ) ) ),
>        "a string",
>        as.character( cat( rep( ".", 3 ) ) )
> );
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list