[R] Odp: vector replacement 1/0 to P/A
Petr PIKAL
petr.pikal at precheza.cz
Tue Aug 18 14:45:15 CEST 2009
Hi
r-help-bounces at r-project.org napsal dne 17.08.2009 16:22:39:
> Hi,
> Can someone suggest an efficient way to substitute a vector/matrix
> which contains 1's and 0's to P's and A's (resp.)?
vec<-sample(0:1, 20, replace=T)
vec
[1] 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 0
vec<-ifelse(vec==0, "A", "P")
vec
[1] "P" "P" "A" "P" "A" "P" "A" "P" "A" "A" "P" "P" "A" "A" "A" "A" "A"
"A" "P" "A"
Regards
Petr
> Thanks,
> Lana
> ______________________________________________
> 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.
More information about the R-help
mailing list