Message-ID: <CAN5afy-JsoE6gT-9+GkPRnz57UCdV2-AMh5qoHF=fUNz9ZX05g@mail.gmail.com>
Date: 2017-01-06T05:42:53Z
From: lily li
Subject: About concatenating strings
Hi R users,
I'm trying to concatenate two strings, while each string has numbers.
For example, strings1 = c(1.2, 1.31, 1.4, 1.51, etc), strings2= c(2.1,
2.22, 2.3, 2.44, etc). I want to have all decimals for the two strings,
such as: strings1= c(1.20, 1.31, 1.40, 1.51, etc), string2 = c(2.10, 2.22,
2.30, 2.44, etc).
After concatenating, they become c(1.20--2.10, 1.31--2.22, 1.40--2.30,
1.51--2.44, etc)
I use the code below, but after digits=2 in the parentheses, the length of
each string has one more. What is the problem and how to do it another way?
Thanks.
cons = paste(c(strings1, digits=2), c(strings2, digits=2), sep='-')
[[alternative HTML version deleted]]