Skip to Content
R Programming Fundamentals
book

R Programming Fundamentals

by Kaelen Medeiros
September 2018
Beginner
206 pages
4h 27m
English
Packt Publishing
Content preview from R Programming Fundamentals

Activity: Creating and Manipulating Factor Variables

Scenario

You will not be able to avoid using factor variables in your work programming with R, so you set out to learn the best ways to create and manipulate them.

Aim

To recognize, create, and manipulate factor variables.

Prerequisites

Make sure you have R and RStudio installed on your machine.

Steps for Completion

  1. Load the datasets library using library(datasets).

  2. Load the diamonds dataset:
    • Examine the dataset with str().
    • How many factors are present, and what type are they?
    • Verify with class() that they are of the class shown.
  1. Load the midwest dataset if it is not already loaded in your environment:
    • Examine the dataset with str().

    • Turn all of the character variables into factor ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

R Programming Fundamentals

R Programming Fundamentals

Samik Sen, Marcin Dubel
Python for Programmers

Python for Programmers

Paul Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781789612998Supplemental Content