Hi
r-help-boun...@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@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.

______________________________________________
R-help@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.

Reply via email to