File: ineq.Rd

package info (click to toggle)
r-cran-teachingdemos 2.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,168 kB
  • sloc: makefile: 2
file content (86 lines) | stat: -rw-r--r-- 2,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
\name{\%<\%}
\Rdversion{1.1}
\alias{\%<\%}
\alias{\%<=\%}
  %- Also NEED an '\alias' for EACH other topic documented here.
  \title{
Less than or Less than and equal operators that can be chained together.
}
\description{Comparison operators that can be chained together into
  something like 0 \%<\% x \%<\% 1 instead of 0 < x && x < 1. }
\usage{
x \%<\% y
x \%<=\% y
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{x,y}{Values to compare
}
}
\details{
These functions/operators allow chained inequalities.  To specify that
you want the values between two values (say 0 and 1) you can use \code{0
  \%<\% x \%<\% 1 } rather than \code{ 0 < x \&\& x < 1 }.
}
\value{
%%  ~Describe the value returned
%%  If it is a LIST, use
%%  \item{comp1 }{Description of 'comp1'}
%%  \item{comp2 }{Description of 'comp2'}
%% ...

A logical vector is returned that can be used for subsetting like
\code{<}, but the original values are included as attributes to be used
in additional comparisons.
}
%\references{
%% ~put references to the literature/web site here ~
%}
\author{
Greg Snow, \email{538280@gmail.com}
}
\note{
  %%  ~~further notes~~
This operator is not fully associative and has different precedence than
\code{<} and \code{<=}, so be careful with parentheses.
See the examples.
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

%\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
%}
\examples{

x <- -3:3

 -2 \%<\% x \%<\% 2
c( -2 \%<\% x \%<\% 2 )
x[ -2 \%<\% x \%<\% 2 ]
x[ -2 \%<=\% x \%<=\% 2 ]


x <- rnorm(100)
y <- rnorm(100)

x[ -1 \%<\% x \%<\% 1 ]
range( x[ -1 \%<\% x \%<\% 1 ] )


cbind(x,y)[ -1 \%<\% x \%<\% y \%<\% 1, ]
cbind(x,y)[ (-1 \%<\% x) \%<\% (y \%<\% 1), ]
cbind(x,y)[ ((-1 \%<\% x) \%<\% y) \%<\% 1, ]
cbind(x,y)[ -1 \%<\% (x \%<\% (y \%<\% 1)), ]
cbind(x,y)[ -1 \%<\% (x \%<\% y) \%<\% 1, ] # oops


3 %<% 1:10 %<% 2*3 # oops
3 %<% 1:10 %<% (2*3)  # meant this


}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ manip }
\keyword{ logic }% __ONLY ONE__ keyword per line