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
> 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
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$
3 matches
Mail list logo