Re: [R] How to replace zero with the character value- need help

2013-04-10 Thread arun
Hi, "  >Thank You, Arun Kirshna , for your efforts and time. >I also found an equivalent code:  >library(zoo) >dat[] <- lapply(dat, function(x){replace(x, x == 0, NA)}) >dat <-na.locf(dat) " No problem. If you have equal replications, you could also use: dat<- structure(list(val = c(-1.111068

Re: [R] How to replace zero with the character value- need help

2013-04-08 Thread PIKAL Petr
> project.org] On Behalf Of arun > Sent: Monday, April 08, 2013 3:10 PM > To: R help > Subject: [R] How to replace zero with the character value- need help > > Hi, > Not sure if you have only one "country" or not. > > > Try this: > dat<- data.frame(val

[R] How to replace zero with the character value- need help

2013-04-08 Thread arun
Hi, Not sure if you have only one "country" or not. Try this: dat<- data.frame(val,state,country,stringsAsFactors=FALSE) dat$country[dat$country==0]<-dat$country[1] #or #dat$country[dat$country==0]<- dat$country[dat$country!=0]   res<-do.call(rbind,lapply(split(dat,cumsum(grepl("[A-Za-z]",dat$