Skip to content
Back to formatted view

Raw Message

Message-ID: <3D879875-E506-4126-BCE5-46330B4A12BA@comcast.net>
Date: 2011-12-03T14:33:17Z
From: David Winsemius
Subject: replace values
In-Reply-To: <1322919667580-4153301.post@n4.nabble.com>

On Dec 3, 2011, at 8:41 AM, syrvn wrote:

> Hello,
>
>
> imagine the following data.frame:
>
> ID name
> 1 *_A
> 2 *_A
> 3 *_B
> 4 *_B
>
> * = can be any pattern
>
> I want to replace every row which ends with _A by 1 and every row  
> which ends
> by _B with a 0

You can use grep(patt, x, value=TRUE) to return vlaues that can be  
used in the prior answers to your earlier question today.

I would have worked it out and tested the strategy, but you continue  
to fail to produce workable examples.... and then apologize that  
people are "confused" by them. We are NOT confused... only annoyed ...  
that you fail to use dput() or code for constructing workable code.

-- 
David.
>
> so that the data.frame looks like the following:
>
> ID name
> 1 1
> 2 1
> 3 0
> 4 0
>
>
> Which function do I use best to achieve this?
>
> Cheers,
> Syrvn
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/replace-values-tp4153301p4153301.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.

David Winsemius, MD
West Hartford, CT