Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
R Programming Fundamentals

You're reading from  R Programming Fundamentals

Product type Book
Published in Sep 2018
Publisher
ISBN-13 9781789612998
Pages 206 pages
Edition 1st Edition
Languages
Author (1):
Kaelen Medeiros Kaelen Medeiros
Profile icon Kaelen Medeiros
Toc

Factor Variables

We discussed variable types in Chapter 1, Introduction to R, but did not include factor variables because they're a special type of variable in R that you must often create yourself. In this section, we'll learn what a factor variable is, when to use a factor variable, how to create one, what the levels of a factor are, and how to change the levels.

A factor variable in R is an explicitly declared categorical variable, or one that defines different categories or levels. Some common examples of factor variables include a variable describing sex, month, or one designating low/medium/high.

Recall our discussion of variable classes and types from Chapter 1, Introduction to R. A factor variable will always be of class factor, but can be any type: character, numeric, integer, or otherwise. For example, a variable indicating month can have the months as type...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime