You are on page 1of 2

Vector- it is the sequence of data elements of the same basic data types

C()- to create vector


C(h,l,r)
Draw<- C(h,l,r) ; is.vector(draw)- true
C(11,12,13) - but its hard to distinguish which are the labels to the integers.
So specify the labels.
Suits<- C(11,12,13)
Names(suits)<- draw
Remains<- (h=1,l=1,k=1) ; remains(h=1)
Apples<- 1; oranges<- six -> these are the vectors for single length
Is.vector(apples)- true
Length(apples)-> 1 ; length(draw)
Vectors are homogenous only hold the vector of same types. atomic vectors
List can hold data of different types.
Vectors perform coercion to make sure that it will be of same class
Names(poker)<- (days) ; poker ans
Names(poker)<- days

Lesson 2
Expenses<- c(10, 20, 30);
Earnings<- c(40, 10, 40) earning * 3 ; earning +4; earning/6 ;
earning^6
Earning Expeneses
Earning + c(10, 12, 19); bank<- Earning Expeneses; sum(bank)
Earning > Expeneses ;

Vector subset
Remain <- (h=7, k=9 , i=9 , p=9)
Remain[1]; remain[3] remain[h]; remain[c(4,1)]; remain[c(1,4)]
Remain[-1]; remain[-c(1,2)] ; -h is error
Remain[c(true,false,true,false)]; if you put t ,f it will repeat t,f,t,f.

You might also like