Message-ID: <CO1PR11MB5107BF11B76A4D313F9863D5D2869@CO1PR11MB5107.namprd11.prod.outlook.com>
Date: 2021-02-17T21:21:23Z
From: Richard M. Heiberger
Subject: [External] Concatenation?
In-Reply-To: <BN7PR08MB41140EDAD4307517B81D8825D0869@BN7PR08MB4114.namprd08.prod.outlook.com>
> paste(c("A","B","C"), c(1,2,3), sep="")
[1] "A1" "B2" "C3"
in your example
paste(site, depth, sep="")
________________________________________
From: R-help <r-help-bounces at r-project.org> on behalf of Parkhurst, David <parkhurs at indiana.edu>
Sent: Wednesday, February 17, 2021 4:09 PM
To: r-help at r-project.org
Subject: [External] [R] Concatenation?
If I have a vector of site abbreviations and a vector of depths in those water bodies, is there a simple way in R to combine them to make a third vector?
Examples:
site depth desired
MU 0 MU0
MU 1 MU1
MU 2 MU2
MC 0 MC0
MC 1 MC1
MC 2 MC2
The dataset has many more lines than this. I can see how to do this with lots of if statements, but does R have magic that can make it happen easily? I guess this would be called concatenation.
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.