Try this:

f <- factor(sample(c("Engineer", "Doctor", "Teacher"), 50, rep = TRUE))
levels(f)[levels(f) %in% c('Doctor', 'Teacher')] <-
paste(abbreviate(c('Doctor', 'Teacher'), 5), collapse = " & ")


On Mon, Jan 3, 2011 at 9:18 AM, Iasonas Lamprianou <lamprianou@yahoo.com>wrote:

> Dear all
> I have a factor variable which holds values like "Engineer", "Doctor",
> "Teacher"
> etc. I would like to collapse those categories so that Teachers and
> Sociologists
> form one category named "Teach & Soc" etc. However, I do not know how I can
> do
> it. Recoding does not seem to work.
>
> Thank you
>  Dr. Iasonas Lamprianou
>
>
>
>
> Assistant Professor (Educational Research and Evaluation)
> Department of Education Sciences
> European University-Cyprus
> P.O. Box 22006
> 1516 Nicosia
> Cyprus
> Tel.: +357-22-713178
> Fax: +357-22-590539
>
>
>
>
> Honorary Research Fellow
> Department of Education
> The University of Manchester
> Oxford Road, Manchester M13 9PL, UK
> Tel. 0044  161 275 3485
> iasonas.lamprianou@manchester.ac.uk
>
>
>
>
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

