Hi,
Using your code:
sub("[.]$",".1",sim.code)
#[1] "1.1234.1a.1" "1.1234.1a.2" "1.3245.2c.5" "4.6743.3c.1" "4.3254.6b.4"
#[6] "3.5463.2a.1"
A.K.
- Original Message -
From: chris201
To: r-help@r-project.org
Cc:
Sent: Friday, March 8, 2013 5:23 AM
Subject: [R] Substitute value
Hi,
I h
Hi,
try this:
sim.df<-data.frame(sim.code,sim.val,stringsAsFactors=FALSE)
sim.df[,1][-grep("\\d+$",sim.df[,1])]<-
paste(sim.df[,1][-grep("\\d+$",sim.df[,1])] , 1,sep="")
sim.df
# sim.code sim.val
#1 1.1234.1a.1 4
#2 1.1234.1a.2 5
#3 1.3245.2c.5 3
#4 4.6743.3c.1
On Fri, Mar 8, 2013 at 5:23 AM, chris201 wrote:
> Hi,
> I have a large data frame and within this there is one column which contains
> individual codes (eg. 1.1234.2a.2). I am splitting these codes into their 4
> components using strsplit (eg. "1", "1234", "2a", "2"). However there are
> some in
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of chris201
> Sent: Friday, March 08, 2013 11:23 AM
> To: r-help@r-project.org
> Subject: [R] Substitute value
>
> Hi,
> I have a large data frame and within this there is one c
4 matches
Mail list logo