[R] request: how to assign alphabets to integer values

Gabor Grothendieck ggrothendieck at gmail.com
Mon Dec 1 12:46:06 CET 2008


Try:

transform(iris, Species = factor(Species, labels = letters[1:3]))

On Mon, Dec 1, 2008 at 4:35 AM, Muhammad Azam <mazam72 at yahoo.com> wrote:
> Dear R community
> I am trying to assign alphabets to integer values 1, 2, 3 etc. in y given below. Can any body suggest some simple way to do the same job?
>
> ds=iris; dl=nrow(ds)
> c1=ds[,1]; c2=ds[,2]; c3=ds[,3]; c4=ds[,4]; c5=ds[,5]; iris=cbind(c1,c2,c3,c4,c5)
> y=iris[,5]
> y1=which(y==1); y[y1] <- c("a"); y2=which(y==2); y[y2] <- c("b"); y3=which(y==3); y[y3] <- c("c");
> iris=cbind(c1,c2,c3,c4,y)
>
> Thnks and best regards
> M. Azam
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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