Analyzing a single data variable
If your dataset has a single variable, you have univariate data. When examining univariate data, you may describe the data distribution in terms of its value and spread. A good place to begin the exploration of univariate data is with the str()
function that you learned in
Chapter 2, Data Cleaning. Load the marketing dataset into R and run the str()
function:
marketing <- read.csv("./data/Ch3_marketing.csv", stringsAsFactors = TRUE) str(marketing)
We will get the following output:
'data.frame': 172 obs. of 7 variables: $ google_adwords : num 65.7 39.1 174.8 34.4 78.2 ... $ facebook : num 47.9 55.2 52 62 40.9 ... $ twitter : num 52.5 77.4 68 86.9 30.4 ... $ marketing_total: num 166 172 295 183 150 ... $ revenues : num 39.3 38.9 49.5 40.6 40.2 ... $ employees : int 5 7 11 7 9 3 10 6 6 4 ... $ pop_density : Factor w/ 3 levels "High","Low","Medium": 1 3 ...
You will...