Professional Documents
Culture Documents
G.BHUVANESWARI
20BCE1126
library(MASS)
survey[rowSums(is.na(survey))>0,]
#3. Create a data frame ‘newsurvey’ that contains the survey data after removing the
na values. Use it for answering further queries
newsurvey = na.omit(survey)
newsurvey
#4. How many male and female students participated in the survey?
length(which(newsurvey$Sex=='Male'))
length(which(newsurvey$Sex=='Female'))
#5. How many the left and right handers are there?
length(which(newsurvey$W.Hnd=='Right'))
length(which(newsurvey$W.Hnd=='Left'))
#6. Find the relative frequency distribution of left and right handers and display them
with the precision of two decimal places.
table(newsurvey$W.Hnd)/length(newsurvey$W.Hnd)
#7. Display the male left hander and female left hander in the column format.
men = subset(newsurvey,Sex=='Male')
leftmen = subset(men,W.Hnd=='Left')
leftmen
women = subset(newsurvey,Sex=='Female')
leftwomen = subset(women,W.Hnd=='Left')
leftwomen
no = length(which(leftmen$Smoke=='Never'))
p = (no/length(leftmen))*100
p
OUTPUT:
=================