categorization

View: New views
2 Messages — Rating Filter:   Alert me  

categorization

by phoebe kong :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I have a dataset with a column named "Condition",


Sample   Condition
1            c20
2            c20
3            c10
4            c10
5            c9
6            c9
7            c5
8            c5
9            c20
10          c10

Could you let me know the fastest way to change c20->"AA", c20->"BB",
c9->"CC", c5->"DD" without using for loop?

Thanks
phoebe

        [[alternative HTML version deleted]]

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

Re: categorization

by Ista Zahn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't know if it's "the fastest" way, but you can get there with

as.character(factor(exData$Condition, levels=c("c20", "c10", "c9",
"c5"), labels=c("AA", "BB", "CC", "DD")))

-Ista

On Mon, Nov 9, 2009 at 2:06 PM, phoebe kong <sityeekong@...> wrote:

> Hi All,
>
> I have a dataset with a column named "Condition",
>
>
> Sample   Condition
> 1            c20
> 2            c20
> 3            c10
> 4            c10
> 5            c9
> 6            c9
> 7            c5
> 8            c5
> 9            c20
> 10          c10
>
> Could you let me know the fastest way to change c20->"AA", c20->"BB",
> c9->"CC", c5->"DD" without using for loop?
>
> Thanks
> phoebe
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@... 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.
>



--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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