The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

RickOz (2) [Avatar] Offline
#1
When factors are introduced in 2.2.5, could you consider explaining why these are useful or needed.

Thanks
robert.kabacoff (170) [Avatar] Offline
#2
Re: Factors
Hi Rick,

I will review it and see what else I can add to make it clearer.

Thanks.

Sincerely,

Rob
peterbwest (41) [Avatar] Offline
#3
Re: Factors
2.2.5 Factors
In the discussion, you have

The statement status <- factor(status, ordered=TRUE) will encode the vector as (3, 2, 1, 3) and associate these values internally as 1=Excellent, 2=Improved, and 3=Poor.

In Listing 2.8 Using factors
> status <- factor(status, order=TRUE)

so presumably, order and ordered are synonymous in the factor function. Is this characteristic widespread, or limited to certain functions?

Does factor() rank the elements it encounters in reverse? This gives the slightly counter-intutive result that Excellent < Improved < Poor.
peterbwest (41) [Avatar] Offline
#4
Re: Factors
2.2.5 Factors p 34

It clearly shows that diabetes is a factor and status in an order factor, along with how it is coded internally. #2 Note that the summary() function treats the variables differently.

Typo above.

What is the #2 a reference to?
peterbwest (41) [Avatar] Offline
#5
Re: Factors
Found the #2 reference in the listing above the discussion.