6.1 Data
6.1.1 Import
We will analyze data from a survey in which 60 consumers were asked to respond to six questions about toothpaste. These data were collected by the creators of Radiant, which is an R package for business analytics that we will use later on. Download the data here and import them into R:
library(tidyverse)
library(readxl)
<- read_excel("toothpaste.xlsx") toothpaste
6.1.2 Manipulate
# Check out the data toothpaste
The data set consists of one identifier, consumer
, and the respondent’s ratings of the importance of six toothpaste attributes: prevents_cavities
, shiny_teeth
, strengthens_gums
, freshens_breath
, decay_prevention_unimportant
, and attractive_teeth
. We also have the respondent’s age
and gender
.
Let’s factorize the identifier and gender
:
<- toothpaste %>%
toothpaste mutate(consumer = factor(consumer),
gender = factor(gender))
6.1.3 Recap: importing & manipulating
Here’s what we’ve done so far, in one orderly sequence of piped operations (download the data here):
library(tidyverse)
library(readxl)
<- read_excel("toothpaste.xlsx")
toothpaste mutate(consumer = factor(consumer),
gender = factor(gender))