[R] facing problem in setting order of the levels in factor

Anant Saini anantsaini10 at gmail.com
Fri Aug 19 12:13:13 CEST 2016


Hi all,

I'm just a beginner in R. I have a pretty basic doubt. This is the actual
quote I wrote
> x<-factor(c("M","F","M","T","M","T"))
> levels(x)=c("M","F","T")
> x
[1] F M F T F T
Levels: M F T
> table(x)
x
M F T
1 3 2

Expectation: I just wanted to change my baselevel from F to M. with the
number of M and F remaining constant

What exactly happened: The values of F and M also get exchanged along with
the change of base level from F to M


​Best,​

-- 

*Anant Saini*
------------------------------
*Indian Institute of Technology Bombay*
*Mob: +91 - 9967687330 *
*LinkedIn* : *in.linkedin.com/in/anantsaini*
<http://in.linkedin.com/in/anantsaini>

	[[alternative HTML version deleted]]



More information about the R-help mailing list