Experiment Lab-II
Experiment Lab-II
Creating vector:-
> empid
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
> age=c(30,37,45,32,50,60,35,32,34,43,32,30,43,50,60)
> age
[1] 30 37 45 32 50 60 35 32 34 43 32 30 43 50 60
> sex=c(0,1,0,1,1,1,0,0,1,0,0,1,1,0,0)
> sex
[1] 0 1 0 1 1 1 0 0 1 0 0 1 1 0 0
> status=c(1,1,2,2,1,1,1,2,2,1,2,1,2,1,2)
> status
[1] 1 1 2 2 1 1 1 2 2 1 2 1 2 1 2
> empinfo=data.frame(empid,age,sex,status)
> empinfo
> empinfo$sex=factor(empinfo$sex,labels=c("male","female"))
> empinfo$status=factor(empinfo$status,labels=c("staff","faculty"))
>empinfo
> summary(empinfo$age)
Min. 1st Qu. Median Mean 3rd Qu. Max.
30.00 32.00 37.00 40.87 47.50 60.00
2. For status
>plot(empinfo$age,type="l",main="age of
subjects",xlab="empid",ylab="age in years",col="blue")
Pie Chart:-
> table4<-table(empinfo$sex)
> pie(table4)
> table5=table(empinfo$sex,empinfo$status)
> barplot(table5,beside=T,xlim=c(1,15),ylim=c(0,5))
>legend("topright",legend=rownames(table5),fill=c('blue','red'),bty="n")
bty the type of box to be drawn around the legend. The allowed
values are "o" (the default) and "n".
BOXPLOT:-
boxplot(empinfo$age~empinfo$status,col=c("red","blue"))
Life_Data<-read.csv("C:\\Users\\aadmin\\Desktop\\mokesh\\data1.csv")
read.
# Printing the data
>Life__Data
>summary(Life_Data$IncomeC)
>summary(Life_Data$Income)
# creating labels
>Life_Data$Gender=factor(Life_Data$Gender,labels=c("male","female"))
>Life_Data$Married=factor(Life_Data$Married,labels=c("no","yes"))
>Life_Data$Smoke=factor(Life_Data$Smoke,labels=c("no","yes"))
>Life_Data$Finish=factor(Life_Data$Finish,labels=c("no","yes"))
table(Life_Data$Age)
table(Life_Data$Gender)
table(Life_Data$Married)
table(Life_Data$Smoke)
table(Life_Data$Finish)
table(Life_Data$Gender,Life_Data$Married)
table(Life_Data$Gender,Life_Data$Finish)
table(Life_Data$Gender,Life_Data$Finish,Life_Data$Married)
table(Life_Data$LifeSat,Life_Data$Smoke)
#generating Graphs
Create your own (Student Record) dataset and do the summary statistics
and graphs with interpretation. Use atleast 50 observations with five
variables.