Using Frames :
> mc<- c("Dhaka","Khulna")
> m.frame <- data.frame(m,mc)
> m.frame # [Frames are used in S language just to merge
two type of data with same patterns(usually in a column basis since S-plus / R
works with Columns unless specified otherwise).]
c1 c2 c3 mc
r1 1 2 3 Dhaka
r2 4 5 6 Khulna
> apply(m.frame[,1:3],2,max) # [applies “max” function in the given part of
frame]
c1 c2 c3
4 5 6
> c1
Error: Object "c1" not found
Dumped
> attach(m.frame) # [ gives columns of given frame the
respect of a vector]
> c1
r1 r2
1 4
> r2
Error: Object "r2" not found
Dumped
> detach() # [ takes away the respect of columns
]
> c1
Error: Object "c1" not found
Dumped
> m.frame$c1
[1] 1 4
> m.frame$r2
NULL
> m.frame[,"c1"]
[1] 1 4
> m.frame["r1",]
c1 c2 c3 mc
r1 1 2 3 Dhaka
> edit(data.frame(m.frame)) # [ See what happens]
c1 c2 c3 mc
r1 1 2 3 Dhaka
r2 4 5 6 Khulna