[R] Changing some values within a variable

Jannis bt_jannis at yahoo.de
Fri Jul 23 01:49:26 CEST 2010

Toni Pitcher schrieb:
> This works to some extent, all As have been changes to Cs, but the Bs 
> have also been changed, in this case to "2", instead of remaining as 
> their original values. How do I get the Bs to stay the same?
You should consult some introductory tutorial dealing with Rs way of 
treating vectors and especially indexing ("An untroduction to R" would 
be a good start). What kind of R object is data$Group ? 
(class(data$Group) ) ...If it is a character vector I would use logical 


> Second problems is similar;
> I need to change some of the Subject IDs. The required format is 3 
> numbers followed by 3 letters (999LLL). Some of the IDs have format 
> 999LLL-LL, Thus I need to delete the -LL from the IDs.
> How do I generically specify "find 999LLL-LL and replace with 999LLL"?
What do you mean by IDs? Rownames?

Generally charcter replacement works with:


> Many thanks in advance
> Toni

More information about the R-help mailing list