Muhammad Azam | 1 Dec 10:31
Favicon

request: how to assign alphabets to integer values

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.
Gabor Grothendieck | 1 Dec 12:46

Re: request: how to assign alphabets to integer values

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.
>
>
(Continue reading)

Muhammad Azam | 1 Dec 14:33
Favicon

Re: request: how to assign alphabets to integer values

Dear Gabor Grothendieck 
Thanks a lot for the help.

M. Azam

________________________________
From: Gabor Grothendieck <ggrothendieck <at> gmail.com>

Cc: R-help request <r-help-request <at> r-project.org>; R Help <r-help <at> r-project.org>
Sent: Monday, December 1, 2008 12:46:06 PM
Subject: Re: [R] request: how to assign alphabets to integer values

Try:

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

> 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
>
>
(Continue reading)


Gmane