Module 9


Module 9 Remarks:

The above screenshots capture the immediate resultant tables, code, and console output for the code given for the module 9 assignment. You can watch as the assignment progresses the same processes that were introduced t the beginning are expanded upon and more engaging with a finer scope for editing, cleaning and manipulating data.


 Module 9 Code:

#Module 9 Assignment


#Question 1

assignment_data <- 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), Purchased=c("No","Yes","No","No","Yes", "Yes","No","Yes","No","Yes"))


#Question 2


assignment9 <- table(mtcars$gear, mtcars$cyl, dnn=c("gears"))


#Question 2.1


addmargins(assignment9)   


#Question 2.2


prop.table(assignment9)


#Question 2.3


prop.table(assignment9, margin = 1)


Console:
#Module 9 Assignment
> #Question 1
> assignment_data <- 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), Purchased=c("No","Yes","No","No","Yes", "Yes","No","Yes","No","Yes"))
> #Question 2
> assignment9 <- table(mtcars$gear, mtcars$cyl, dnn=c("gears"))
> #Question 2.1
> addmargins(assignment9)   
     NA
gears  4  6  8 Sum
  3    1  2 12  15
  4    8  4  0  12
  5    2  1  2   5
  Sum 11  7 14  32
> #Question 2.2
> prop.table(assignment9)
     NA
gears       4       6       8
    3 0.03125 0.06250 0.37500
    4 0.25000 0.12500 0.00000
    5 0.06250 0.03125 0.06250
> #Question 2.3
> prop.table(assignment9, margin = 1)
     NA
gears          4          6          8
    3 0.06666667 0.13333333 0.80000000
    4 0.66666667 0.33333333 0.00000000
    5 0.40000000 0.20000000 0.40000000
> View(assignment_data)



Comments

Popular posts from this blog

R Package: pfStat

Module 7 Assignment

The Tampa Feasibility Report featuring R based Visualizations