Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
R Programming Fundamentals

You're reading from   R Programming Fundamentals Deal with data using various modeling techniques

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher
ISBN-13 9781789612998
Length 206 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Kaelen Medeiros Kaelen Medeiros
Author Profile Icon Kaelen Medeiros
Kaelen Medeiros
Arrow right icon
View More author details
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 $19.99/month. Cancel anytime