Displaying 20 results from an estimated 20000 matches similar to: "c(), or cat(), or paste(), all cause unwanted reordering"
2010 Feb 11
2
Suprising behavior of paste or cat?
I may be making a simple error, but I've looked at the str() of the
resulting objects and I can't see any obvious reason I'm having the
problem I am having, so I am reaching out to the R-help group. ?I am
generating a string in my code. ?When I make a slight modification
(add a comma at the end using my "lastcomma" function), I can no
longer successfully write that string to
2004 Jul 29
2
unwanted as.integer
> a <- sqlQuery(irrdb, "select count(field) from mytable where field = 1")
> print(a)
count(field)
1 8
> paste(a)
[1] "as.integer(8)"
Why the as.integer() representation? I later pass the result into this
write.html.table(), and what I get is rows of as.integer()... when all I
want is the integer itself.
as.integer(31) as.integer(21)
2020 May 24
2
paste(character(0), collapse="", recycle0=FALSE) should be ""
On 5/23/20 17:45, Gabriel Becker wrote:
> Maybe my intuition is just
> different?but when I collapse multiple character vectors together, I
> expect?all the characters from each of those vectors to be in the
> resulting collapsed one.
Yes I'd expect that too. But the **collapse** operation in paste() has
never been about collapsing **multiple** character vectors together.
2003 Aug 17
2
collapse argument on paste
One gets a different response when abbreviating collapse= in
paste? In the second case, it appears to be acting as if " + " is just
another argument to be pasted.
# expected response
> paste(c("X","Y"),1:4,sep="",collapse=" + ")
[1] "X1 + Y2 + X3 + Y4"
# different!
>
2013 Jan 27
2
Unexpected behavior with abbreviation of an argument to paste
R 2.15.1
OS X
Colleagues,
I encountered the following unexpected behavior today:
The following command yielded the expected result:
paste(c("TEXT1", "TEXT2"), collapse="|")
Result:
[1] "TEXT1|TEXT2"
However, abbreviating "collapse" by even one character:
paste(c("TEXT1", "TEXT2"), collaps="|")
yielded the
2020 May 15
2
paste(character(0), collapse="", recycle0=FALSE) should be ""
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
2020 May 01
4
paste(character(0), collapse="", recycle0=FALSE) should be ""
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
2004 Dec 01
1
split() and paste() a vector to get a multi line string
How can I get a multi line string from a vector of string tokens
in an easy manner (e.g. for the use as xlab of a plot)?
I have e.g.:
> tokens <- letters[1:5]
[1] "a" "b" "c" "d" "e"
I search:
[1] "a, b, c\nd, e"
I tried:
> nlines <- 2
> ntokens.line <- ceiling(length(tokens) / nlines)
> token.list <-
2020 May 26
2
paste(character(0), collapse="", recycle0=FALSE) should be ""
Hi Martin,
On 5/26/20 06:24, Martin Maechler wrote:
...
>
> What about remaining back-compatible, not only to R 3.y.z with
> default recycle0=FALSE, but also to R 4.0.0 with recycle0=TRUE
What back-compatibility with R 4.0.0 are we talking about? The
'recycle0' arg was added **after** the R 4.0.0 release and has never
been part of an official release yet. This is the time to
2004 Sep 17
1
controlling printing precision in paste()
Rene,
Look at ?format.
Sean
On Sep 17, 2004, at 9:21 AM, RenE J.V. Bertin wrote:
> Hello,
>
> I can't seem to find the way to modify the precision with which
> paste() prints its floating point numbers, more precisely the number
> of decimal digits printed. This is apparently not controlled by
> options( digits= ), and there is no appropriate argument to paste()
>
2020 May 24
2
paste(character(0), collapse="", recycle0=FALSE) should be ""
On 5/24/20 00:26, Gabriel Becker wrote:
>
>
> On Sat, May 23, 2020 at 9:59 PM Herv? Pag?s <hpages at fredhutch.org
> <mailto:hpages at fredhutch.org>> wrote:
>
> On 5/23/20 17:45, Gabriel Becker wrote:
> > Maybe my intuition is just
> > different?but when I collapse multiple character vectors together, I
> > expect?all the
2011 Feb 25
6
preventing repeat in "paste"
Hello!
s<-"start"; e<-"end"
middle<-as.character(c(1,2,3))
I would like to get the following result:
"start 123 end" or "start 1 2 3 end" or "start 1,2,3 end"
How can I avoide this (undesired) result:
paste(s,middle,e,sep=" ")
Thank you!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
2013 Mar 21
4
easy way of paste
Hello,
Is there a better way to use paste such as:
a = paste(colnames(list.indep)[1],colnames(list.indep)[2],colnames(list.indep)[3],colnames(list.indep)[4],colnames(list.indep)[5],sep="+")
> a
[1] "aa+dummy1+dummy2+bb+cc"
I tried
a = paste(colnames(list.indep)[1:5],sep="+")
> a
[1] "aa" "dummy1" "dummy2"
2009 May 07
1
paste with apply, spaces and NA
Hello everyone,
I've come up with a problem with using paste() inside apply() that I
can't seem to solve.
Briefly, if I'm using paste to collapse the rows of a data frame, AND
the data frame
contains strings with spaces, AND there are NA values in subsequent
columns, then
paste() introduces spaces. This only happens with that particular combination of
data values and commands. I have
2020 May 13
2
"cd" floating in the air in the man page for paste/paste0
Hi,
While reading about the new 'recycle0' argument of paste/paste0, I
spotted a mysterious "cd" floating in the air in the man page:
recycle0: ?logical? indicating if zero-length character arguments (and
all zero-length or no arguments when ?collapse? is not
?NULL?) should lead to the zero-length ?character(0)?.
cd
^^
This is in R
2005 Nov 06
2
Use of paste with apply()
I was surprised by:
> test <- matrix( as.character(1:4), 2)
> test
[,1] [,2]
[1,] "1" "3"
[2,] "2" "4"
> apply(test, 1, paste, sep="+")
[,1] [,2]
[1,] "1" "2"
[2,] "3" "4"
> apply(test, 1, paste, sep="*")
[,1] [,2]
[1,] "1" "2"
[2,]
2008 Feb 19
3
Incorrect paste() output (PR#10801)
Hello,
I am writing this message because of an incorrect output by paste().
Please try the following script to see if the evidence I collected is
reproducible:
x <- c(10152, 28177);
y <- c(9576, 26625);
d <- y - x;
d;
[1] -576 -1552
paste(d, collapse = ", ");
[1] "-576, -1552"
x <- x / 1000;
y <- y / 1000;
d <- y - x;
d;
[1] -0.576 -1.552
paste(d,
2001 Sep 25
1
paste
Just a quick question:
I tried
> paste(sort(x),collapse="\; ")
[1] "1; 1; 3; 4; 4; 7; 12; 19; 23"
> paste(sort(x),collapse="\\; ")
[1] "1\\; 1\\; 3\\; 4\\; 4\\; 7\\; 12\\; 19\\; 23"
How can I get the following?
[1] "1\; 1\; 3\; 4\; 4\; 7\; 12\; 19\; 23"
Thank you,
Giovanni
--
__________________________________________________
[
2010 Apr 10
1
str: how to use "no list" recursively?
Hi,
In the help file for str(), the following line appears: "no.list logical;
if true, no ?list of ...? nor the class are printed". However, that appears
to be true only on the top level; setting no.list to TRUE still leaves the
remaining levels with the `list of ...' statement intact:
> x <- list(
+ a = list(list()),
+ b = list(list())
+ );
> str(x)
List of 2
$
2009 Apr 01
1
paste to collapse vector to string
Hi,
I'm trying to collapse a character vector to strings, but I am getting
unexpected behaviors in list context:
A <- "a"
B <- c("b","c")
xx <- list(A=A, B=B)
lapply(xx, paste, collaplse=".")
$A
[1] "a ."
$B
[1] "b ." "c ."
paste(B, collapse=".")
[1] "b.c" # this is what