[R] vector replacement 1/0 to P/A

jim holtman jholtman at gmail.com
Tue Aug 18 14:07:15 CEST 2009


Will this do it:

> x <- sample(0:1,10,TRUE)
> x
 [1] 1 0 0 1 0 1 0 0 0 0
> ifelse(x == 1, "P", "A")
 [1] "P" "A" "A" "P" "A" "P" "A" "A" "A" "A"
>


On Mon, Aug 17, 2009 at 10:22 AM, Lana Schaffer<schaffer at scripps.edu> wrote:
> 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.)?
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list