Activity-R-Practice4

.pdf
School
University of Windsor **We aren't endorsed by this school
Course
BIOLOGY 2244
Subject
Accounting
Date
Oct 15, 2023
Pages
5
Uploaded by ProfessorTapir3726 on coursehero.com
R Practice 4-Review Mohammed Elamsy 12/10/2021 ################################# #pre-processing ################################# #importing data from csv file and save it in act4 object act4 <- read.csv( "actdata-1.csv" , header= TRUE, sep= "," ) #given pre-processing code computing the ratio & combining it to the act4 object as ratio ratio <- act4$second / act4$fourth act4 <- data.frame(cbind(act4, ratio)) ############################### #TASK 1 ############################### # I need to extract the different data categories according to their sex gender #followed by the assertiveness level # male and female samples Females <- act4[act4$sex== "F" ,] Males <- act4[act4$sex== "M" ,] #distribute females & males samples according to the level of assertiveness #female high FH FH <- Females[Females$assert== "high" ,]$ratio #female Low FL <- Females[Females$assert== "low" ,]$ratio #female Med FMe <- Females[Females$assert== "medium" ,]$ratio #Male high MH MH <- Males[Males$assert== "high" ,]$ratio #Male Low ML ML <- Males[Males$assert== "low" ,]$ratio #Male Med MMe <- Males[Males$assert== "medium" ,]$ratio 1
# Required Labels for x Axis label = c( "H/F" , "H/M" , "L/F" , "L/M" , "Me/F" , "Me/M" ) # boxplot the data boxplot(FH, MH, FL, ML, FMe, MMe, col = c( "yellow" , "blue" , "yellow" , "blue" , "yellow" , "blue" ), names= label, vertical= TRUE, xlab= "Level of assertiveness and sex of student" , ylab= "2D:4D ratio" , # setting the yaxis min and max scale values ylim= c( 0.6 , 1.4 )) H/F H/M L/F L/M Me/F Me/M 0.6 0.8 1.0 1.2 1.4 Level of assertiveness and sex of student 2D:4D ratio 2
############################### ###TASK 2 2 lines of code ############################### ### showing the summary of each data samples (second, fourth and ratio) c( "Second summary" ,summary(act4$second), " " , "Fourth Summary" , summary(act4$fourth), " " , "Ratios Summary" ,summary(act4$ratio), " " ) ## Min. 1st Qu. Median ## "Second summary" "5.4" "6.8" "7.1" ## Mean 3rd Qu. Max. ## "7.41068702290076" "7.8" "12.5" " " ## Min. 1st Qu. Median ## "Fourth Summary" "5" "6.75" "7.2" ## Mean 3rd Qu. Max. ## "7.32961832061069" "7.75" "13" " " ## Min. 1st Qu. Median ## "Ratios Summary" "0.769230769230769" "0.96407056798623" "1" ## Mean 3rd Qu. Max. ## "1.01367913781352" "1.0548048048048" "1.3" " " ### standard deviation for both females and males of fourth finger lengths c( "female sd:" ,sd(Females$fourth), "Male sd:" ,sd(Males$fourth)) ## [1] "female sd:" "0.869558735045117" "Male sd:" ## [4] "1.26913425388568" 3
Page1of 5
Uploaded by ProfessorTapir3726 on coursehero.com