Professional Documents
Culture Documents
Vector Arithmetic
Vector Arithmetic
Vector Arithmetic
Vector Arithmetic
Vector Arithmetic
The first two arguments specify the beginning and end of the sequence,
and if these are the only two arguments given, the result is the same as
the colon operator i.e seq(2,10) is the same vector as 2:10.
The parameters to seq(), and to many other functions can also be given
in named form, in which case the order in which they appear is irrelevant.
The first two parameters may be named from=value and to=value; thus
seq(1,30) and seq(from=1,to=30) and seq(to=30,from=1) are all
the same as 1:30
The first two arguments specify the beginning and end of the sequence,
and if these are the only two arguments given, the result is the same as
the colon operator i.e seq(2,10) is the same vector as 2:10.
The parameters to seq(), and to many other functions can also be given
in named form, in which case the order in which they appear is irrelevant.
The first two parameters may be named from=value and to=value; thus
seq(1,30) and seq(from=1,to=30) and seq(to=30,from=1) are all
the same as 1:30
The first two arguments specify the beginning and end of the sequence,
and if these are the only two arguments given, the result is the same as
the colon operator i.e seq(2,10) is the same vector as 2:10.
The parameters to seq(), and to many other functions can also be given
in named form, in which case the order in which they appear is irrelevant.
The first two parameters may be named from=value and to=value; thus
seq(1,30) and seq(from=1,to=30) and seq(to=30,from=1) are all
the same as 1:30
The first two arguments specify the beginning and end of the sequence,
and if these are the only two arguments given, the result is the same as
the colon operator i.e seq(2,10) is the same vector as 2:10.
The parameters to seq(), and to many other functions can also be given
in named form, in which case the order in which they appear is irrelevant.
The first two parameters may be named from=value and to=value; thus
seq(1,30) and seq(from=1,to=30) and seq(to=30,from=1) are all
the same as 1:30
Logical vectors
For example
> temp <- x>13
[1] FALSE FALSE FALSE FALSE TRUE
In addition if a and b are logical expressions, then ab is their intersection
(”and”), a|b is their union (”or”) and !a is the negation of a.
Logical vectors
For example
> temp <- x>13
[1] FALSE FALSE FALSE FALSE TRUE
In addition if a and b are logical expressions, then ab is their intersection
(”and”), a|b is their union (”or”) and !a is the negation of a.
Logical vectors
For example
> temp <- x>13
[1] FALSE FALSE FALSE FALSE TRUE
In addition if a and b are logical expressions, then ab is their intersection
(”and”), a|b is their union (”or”) and !a is the negation of a.
Logical vectors
For example
> temp <- x>13
[1] FALSE FALSE FALSE FALSE TRUE
In addition if a and b are logical expressions, then ab is their intersection
(”and”), a|b is their union (”or”) and !a is the negation of a.
Logical vectors
For example
> temp <- x>13
[1] FALSE FALSE FALSE FALSE TRUE
In addition if a and b are logical expressions, then ab is their intersection
(”and”), a|b is their union (”or”) and !a is the negation of a.
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12
Simple Manipulations
Logical vectors
For example,
> w <- x>10
>w
[1] TRUE FALSE FALSE FALSE TRUE
> z <- x<=10
>z
[1] FALSE TRUE TRUE TRUE FALSE
The intersection of w and z is;
> w&z
[1] FALSE FALSE FALSE FALSE FALSE
The union of w and z is;
> w|z
[1] TRUE TRUE TRUE TRUE TRUE
The negation of w
> !w
[1] FALSE TRUE TRUE TRUE FALSE
Ms. Beryl Ang’iro August 21, 2020 12 / 12