You are on page 1of 4

Lab 6 Statistical Analysis of Qualitative data

G.BHUVANESWARI
20BCE1126

#Use the survey data in MASS package to do the following:

#1. Import the package MASS.

library(MASS)

#2. List the rows of data that has missing values.

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

#8. What percentage of male left handers never smokes

no = length(which(leftmen$Smoke=='Never'))
p = (no/length(leftmen))*100
p

OUTPUT:
=================

You might also like