Module 9. Assignment:
R_Code:
Question A:
df <- data.frame(
country = c("France", "Spain", "Germany", "Spain", "Germany", "France", "Spain", "France", "Germany", "France"),
age = c(44, 27, 30, 38, 40, 35, 52, 48, 45, 37),
salary = c(6000, 5000, 7000, 4000, 8000, 6000, 5000, 7000, 4000, 8000),
purchased = c("No", "Yes", "No", "No", "Yes", "Yes", "No", "Yes", "No", "Yes")
)
A1: Generate a one-way table for "purchased"
A2: Generate a two-way table for "country" and "purchased."
Question B:
data(mtcars)
mtcars_df <- table(mtcars$gear, mtcars$cyl, dnn = c("Gears", "Cylinders"))B1: Add the addmargins() function to report on the sum totals of the rows and columns of "mtcars_df" tableB2: Add prop.tables() function, and report on the proportional weight of each value in the "mtcars_df" table




Comments
Post a Comment