You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<pclass="p3">Returns <spanclass="s2">T</span> if <b>all values are </b><spanclass="s2"><b>T</b></span> in <spanclass="s2">x</span> and in any other arguments supplied; if any value is <spanclass="s2">F</span>, returns <spanclass="s2">F</span><spanclass="s3">.</span><spanclass="Apple-converted-space"></span>All arguments must be of <spanclass="s2">logical</span> type.<spanclass="Apple-converted-space"></span>If all arguments are zero-length, <spanclass="s2">T</span> is returned.</p>
<pclass="p5">Returns <spanclass="s2">T</span> if <b>all pairs of values between </b><spanclass="s2"><b>x</b></span><b> and y are “close”</b>; if any pair of values is not close, returns <spanclass="s2">F</span>.<spanclass="Apple-converted-space"></span>The definition of “close” matches that used in the <spanclass="s2">isClose()</span> function; see that documentation for all further details, including the way that values in <spanclass="s2">x</span> and <spanclass="s2">y</span> are paired, as well as the meaning of the <spanclass="s2">rtol</span>, <spanclass="s2">atol</span>, and <spanclass="s2">equalNAN</span> parameters.<spanclass="Apple-converted-space"></span>This function is essentially equivalent to <spanclass="s2">all(isClose(x, y, rtol, atol, equalNAN))</span>, but is more efficient.</p>
<pclass="p3">Returns <spanclass="s2">T</span> if <b>any value is </b><spanclass="s2"><b>T</b></span> in <spanclass="s2">x</span> or in any other arguments supplied; if all values are <spanclass="s2">F</span>, returns <spanclass="s2">F</span><spanclass="s3">.</span><spanclass="Apple-converted-space"></span>All arguments must be of <spanclass="s2">logical</span> type.<spanclass="Apple-converted-space"></span>If all arguments are zero-length, <spanclass="s2">F</span> is returned.</p>
<pclass="p3">Returns the result of a <b>vector conditional</b> operation: a vector composed of values from <spanclass="s2">trueValues</span>, for indices where <spanclass="s2">test</span> is <spanclass="s2">T</span>, and values from <spanclass="s2">falseValues</span>, for indices where <spanclass="s2">test</span> is <spanclass="s2">F</span>.<spanclass="Apple-converted-space"></span>The lengths of <spanclass="s2">trueValues</span> and <spanclass="s2">falseValues</span> must either be equal to <spanclass="s2">1</span> or to the length of <spanclass="s2">test</span>; however, <spanclass="s2">trueValues</span> and <spanclass="s2">falseValues</span> don’t need to be the same length as each other.<spanclass="Apple-converted-space"></span>Furthermore, the type of <spanclass="s2">trueValues</span> and <spanclass="s2">falseValues</span> must be the same (including, if they are <spanclass="s2">object</span> type, their element type).<spanclass="Apple-converted-space"></span>The return will be of the same length as <spanclass="s2">test</span>, and of the same type as <spanclass="s2">trueValues</span> and <spanclass="s2">falseValues</span>.<spanclass="Apple-converted-space"></span>Each element of the return vector will be taken from the corresponding element of <spanclass="s2">trueValues</span> if the corresponding element of <spanclass="s2">test</span> is <spanclass="s2">T</span>, or from the corresponding element of <spanclass="s2">falseValues</span> if the corresponding element of <spanclass="s2">test</span> is <spanclass="s2">F</span>; if the vector from which the value is to be taken (i.e., <spanclass="s2">trueValues</span> or <spanclass="s2">falseValues</span>) has a length of <spanclass="s2">1</span>, that single value is used repeatedly, recycling the vector.<spanclass="s14"><spanclass="Apple-converted-space"></span>If </span><spanclass="s15">test</span><spanclass="s14">, </span><spanclass="s15">trueValues</span><spanclass="s14">, and/or </span><spanclass="s15">falseValues</span><spanclass="s14"> are matrices or arrays, that will be ignored by </span><spanclass="s15">ifelse()</span><spanclass="s14"><i>except</i> that the result will be of the same dimensionality as </span><spanclass="s15">test</span><spanclass="s14">.</span></p>
269
271
<pclass="p3">This is quite similar to a function in R of the same name; note, however, that Eidos evaluates all arguments to functions calls immediately, so <spanclass="s2">trueValues</span> and <spanclass="s2">falseValues</span> will be evaluated fully regardless of the values in <spanclass="s2">test</span>, unlike in R.<spanclass="Apple-converted-space"></span>Value expressions without side effects are therefore recommended.</p>
<pclass="p5">Returns a logical vector indicating <b>whether each pair of values in </b><spanclass="s2"><b>x</b></span><b> and </b><spanclass="s2"><b>y</b></span><b> are “close”</b>; if any pair of values is not close, returns <spanclass="s2">F</span>.<spanclass="Apple-converted-space"></span>See the <spanclass="s2">allClose()</span> function for an efficient way to test whether <i>all</i> pairs of values in <spanclass="s2">x</span> and <spanclass="s2">y</span> are close.</p>
274
+
<pclass="p5">A pair of values <spanclass="s2">a</span> and <spanclass="s2">b</span> is considered “close” according to the following criteria.<spanclass="Apple-converted-space"></span>If both <spanclass="s2">a</span> and <spanclass="s2">b</span> are finite, they are close if <spanclass="s2">abs(a − b) <= (atol + rtol * abs(b))</span>.<spanclass="Apple-converted-space"></span>If both <spanclass="s2">a</span> and <spanclass="s2">b</span> are infinite, they are close if they have the same sign.<spanclass="Apple-converted-space"></span>If both <spanclass="s2">a</span> and <spanclass="s2">b</span> are <spanclass="s2">NAN</span>, they are close if <spanclass="s2">equalNAN</span> is <spanclass="s2">T</span>.<spanclass="Apple-converted-space"></span>In all other cases, <spanclass="s2">a</span> and <spanclass="s2">b</span> are not close.<spanclass="Apple-converted-space"></span>For finite values, <spanclass="s2">rtol</span> thus defines a relative tolerance, and <spanclass="s2">atol</span> an absolute tolerance; the relative difference <spanclass="s2">rtol * abs(b)</span> and the absolute difference <spanclass="s2">atol</span> are added together and compared against the absolute difference between <spanclass="s2">a</span> and <spanclass="s2">b</span> to determine closeness.</p>
275
+
<pclass="p5">Note that the default value for <spanclass="s2">atol</span> is not appropriate when comparing numbers with magnitudes much smaller than one; be sure to select <spanclass="s2">atol</span> for the use case at hand, especially for defining the threshold below which a non-zero value <spanclass="s2">a</span> will be considered “close” to a very small or zero value <spanclass="s2">b</span>.<spanclass="Apple-converted-space"></span>Note also that <spanclass="s2">isClose()</span> is not symmetric in <spanclass="s2">a</span> and <spanclass="s2">b</span>; it assumes that b is the reference value for calculating the relative difference.</p>
276
+
<pclass="p5">Regarding how values in <spanclass="s2">x</span> and <spanclass="s2">y</span> are paired, three cases are supported.<spanclass="Apple-converted-space"></span>If <spanclass="s2">x</span> and <spanclass="s2">y</span> are the same length, then <spanclass="s2">x</span> and <spanclass="s2">y</span> are paired element-wise; if <spanclass="s2">x</span> is singleton, the single <spanclass="s2">x</span> value is paired with each value in <spanclass="s2">y</span>; or if <spanclass="s2">y</span> is singleton, each value in <spanclass="s2">x</span> is paired with the single <spanclass="s2">y</span> value.</p>
<pclass="p5"><spanclass="s5">Returns the <b>size</b> (e.g., length) of </span><spanclass="s9">x</span><spanclass="s5">: the number of elements contained in </span><spanclass="s9">x</span><spanclass="s5">.<spanclass="Apple-converted-space"></span>Note that </span><spanclass="s9">length()</span><spanclass="s5"> is a synonym for </span><spanclass="s9">size()</span><spanclass="s5">.</span></p>
0 commit comments