Professional Documents
Culture Documents
Summary
Bar plot
# Split data by region, create new data frame
dataframe <- split(variable(A), variable(B)
barplot(dataframe,
col = "beige",
main = "Average Google Search Share of\n\"Data Visualization\" by
Region of US")
abline(h = 0)
Scatterplot
plot(variable(A), variable(B),
main = "Title of Scatterplot",
xlab = "X-axis label",
ylab = "Y-axis label",
pch = 20,
col = "grey")
Scatterplot Matrix
# Basic Scatterplot Matrix
pairs(~data_viz + degree + facebook + nba,
data = google,
pch = 20,
main = "Simple Scatterplot Matrix")
Linear Regression
lm(variable(A) ~ variable(B))
Correlations
Contingency Tables
table(dataframe$variable(A), dataframe$variable(B))
Marginal Frequencies
margin.table(table(dataframe$variable(A), dataframe$variable(B)),1)
row sum
margin.table(table(dataframe$variable(A), dataframe$variable(B)),2)
column sum
Proportion Table
# With rounding to get just 2 decimal places
round(prop.table(table(dataframe$variable(A),
dataframe$variable(B)), 2) # cell %
round(prop.table(table(dataframe$variable(A),
dataframe$variable(B)), 1), 2) # row %
round(prop.table(table(dataframe$variable(A),
dataframe$variable(B)), 2), 2) # column %