Untitled

 avatar
unknown
plain_text
2 months ago
1.4 kB
2
Indexable
paste("First","Second","Third")
paste("First","Second","Third",sep=":")

a=c("red","green","yellow")
a
x=c(1,2,3)
x
length(x)

l=list(2,3,4,"a",21.2,"b",sin(30))
l


M=matrix(c(1,2,3,4,5,6),nrow=2,ncol=3,byrow=TRUE)
M

M=matrix(c(1,2,3,4,5,6),nrow=3,ncol=4,byrow=TRUE)
M

M=matrix(c(1,2,3,4,5,6),nrow=3,ncol=4,byrow=FALSE)
M

a=array(c("G","Y","B"),dim=c(3,3))
a

a=array(c("G","Y"),dim=c(3,3,2))
a

cols=c("green","green","yellow","red","red","green")
faccols=factor(cols)
faccols


d=data.frame(id=c('a','b','c','d','e','f','g','h','i','j'),x=1:10,y=11:20)
d

d=data.frame(gender=c("Male","Male","Female"),height=c(152,171.5,165),weight=c(81,93,78),age=c(42,38,26))
d


empid=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)
empid

age=c(30,45,67,54,86,23,12,17,29,37,23,10,65,75,32)
age

gender=c(0,1,0,1,0,1,1,1,1,0,0,1,1,0,1)
gender

status=c(1,2,1,2,1,2,1,1,2,1,2,1,2,1,2)
status

d=data.frame(empid,age,gender,status)
d

d$gender=factor(d$gender,labels=c("Male","Female"))
d

d$status=factor(d$status,labels=c("Staff","Faculty"))
d

female=subset(d,d$gender=="Female")
female

summary(d)
summary(gender)
summary(status)

table1=table(d$gender)
table1

table2=table(d$status,d$gender)
table2


plot(d$age,type='l',main="Age of employees",xlab="empid",ylab="age in years",col="blue")

pie(table2)


barplot(table2,beside=T,xlim=c(1,15),ylim=c(0,5),col=c("blue","red"))
legend("topright",legend=rownames(table2),fill=c("blue","red"),bty="n")
Leave a Comment