Skip to content
Back to formatted view

Raw Message

Message-ID: <8f19db7b-5922-eb47-f70e-9b2a58c11508@math.uni-giessen.de>
Date: 2021-02-18T08:50:22Z
From: Gerrit Eichner
Subject: Concatenation?
In-Reply-To: <560ea145-101d-132a-2129-c9a3e73b662e@math.uni-giessen.de>

[I forgot to keep it on the list.]

-------- Weitergeleitete Nachricht --------
Betreff: Re: [R] Concatenation?
Datum: Wed, 17 Feb 2021 22:14:13 +0100
Von: Gerrit Eichner <gerrit.eichner at math.uni-giessen.de>
Organisation: JLU Gie?en
An: Parkhurst, David <parkhurs at indiana.edu>

Hi David,

checkout, e. g., base-R's

paste0(site, depth)

or, if stored as columns of a matrix or data frame X, e.g.,

apply(X, 1, paste0)

or, e.g., tidyr's

unite.

  Hth  --  Gerrit

---------------------------------------------------------------------
Dr. Gerrit Eichner                   Mathematical Institute, Room 212
gerrit.eichner at math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109            http://www.uni-giessen.de/eichner
---------------------------------------------------------------------

Am 17.02.2021 um 22:09 schrieb Parkhurst, David:
> 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.
>