Re: [Rd] [PATCH] suggestions for R-lang manual
On Mon, Mar 3, 2014 at 7:48 AM, Martin Maechler maech...@stat.math.ethz.ch wrote: Scott Kostyshak skost...@princeton.edu on Thu, 27 Feb 2014 16:43:02 -0500 writes: On Thu, Nov 21, 2013 at 1:17 AM, Scott Kostyshak skost...@princeton.edu wrote: Attached is a patch with suggestions for the R-lang manual at r64277. Below are a few comments (some are implemented in the patch): In the section Objects, there is a table introduced by The following table describes the possible values returned by typeof. One of the results is any. Can any be returned by typeof() ? ANYSXP is a valid internal type on the C level, and src/main/util.c will make typeof(ob) return any if you can get your hands at an R level object of that type. I'd guess you can only get it currently by using .Call() and using your own C code, .. but at least that way it must be possible. Interesting to know. Regarding the Recycling rules section, -One exception is that when adding vectors to matrices, a warning is not -given if the lengths are incompatible. -@c Is that a bug? - was this a bug that was fixed? I did not investigate in details, but yes, I vaguely remember we had fixed that. So indeed, it's fine you omitted the para in your patch. I see the following behavior: myvec - 1:3 mymat - matrix(1:12, ncol=2) myvec - 1:5 myvec + mymat [,1] [,2] [1,]29 [2,]4 11 [3,]6 13 [4,]8 15 [5,] 10 12 [6,]7 14 Warning message: In myvec + mymat : longer object length is not a multiple of shorter object length Regarding -The arguments in the call to the generic are rematched with the -arguments for the method using the standard argument matching mechanism. -The first argument, i.e.@: the object, will have been evaluated. - this information is duplicated. See a few paragraphs up When the method is invoked it is called... Scott Thank you, Scott. Indeed, I've finally carefully looked at the patch, and applied it - for R-devel, to become R 3.1.0 in April. Thanks, Martin! Scott -- Scott Kostyshak Economics PhD Candidate Princeton University Martin -- Scott Kostyshak Economics PhD Candidate Princeton University The patch still applies cleanly (one offset) on r65090. Best, Scott __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [PATCH] suggestions for R-lang manual
Scott Kostyshak skost...@princeton.edu on Thu, 27 Feb 2014 16:43:02 -0500 writes: On Thu, Nov 21, 2013 at 1:17 AM, Scott Kostyshak skost...@princeton.edu wrote: Attached is a patch with suggestions for the R-lang manual at r64277. Below are a few comments (some are implemented in the patch): In the section Objects, there is a table introduced by The following table describes the possible values returned by typeof. One of the results is any. Can any be returned by typeof() ? ANYSXP is a valid internal type on the C level, and src/main/util.c will make typeof(ob) return any if you can get your hands at an R level object of that type. I'd guess you can only get it currently by using .Call() and using your own C code, .. but at least that way it must be possible. Regarding the Recycling rules section, -One exception is that when adding vectors to matrices, a warning is not -given if the lengths are incompatible. -@c Is that a bug? - was this a bug that was fixed? I did not investigate in details, but yes, I vaguely remember we had fixed that. So indeed, it's fine you omitted the para in your patch. I see the following behavior: myvec - 1:3 mymat - matrix(1:12, ncol=2) myvec - 1:5 myvec + mymat [,1] [,2] [1,]29 [2,]4 11 [3,]6 13 [4,]8 15 [5,] 10 12 [6,]7 14 Warning message: In myvec + mymat : longer object length is not a multiple of shorter object length Regarding -The arguments in the call to the generic are rematched with the -arguments for the method using the standard argument matching mechanism. -The first argument, i.e.@: the object, will have been evaluated. - this information is duplicated. See a few paragraphs up When the method is invoked it is called... Scott Thank you, Scott. Indeed, I've finally carefully looked at the patch, and applied it - for R-devel, to become R 3.1.0 in April. Martin -- Scott Kostyshak Economics PhD Candidate Princeton University The patch still applies cleanly (one offset) on r65090. Best, Scott __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [PATCH] suggestions for R-lang manual
On Thu, Nov 21, 2013 at 1:17 AM, Scott Kostyshak skost...@princeton.edu wrote: Attached is a patch with suggestions for the R-lang manual at r64277. Below are a few comments (some are implemented in the patch): In the section Objects, there is a table introduced by The following table describes the possible values returned by typeof. One of the results is any. Can any be returned by typeof() ? Regarding the Recycling rules section, -One exception is that when adding vectors to matrices, a warning is not -given if the lengths are incompatible. -@c Is that a bug? - was this a bug that was fixed? I see the following behavior: myvec - 1:3 mymat - matrix(1:12, ncol=2) myvec - 1:5 myvec + mymat [,1] [,2] [1,]29 [2,]4 11 [3,]6 13 [4,]8 15 [5,] 10 12 [6,]7 14 Warning message: In myvec + mymat : longer object length is not a multiple of shorter object length Regarding -The arguments in the call to the generic are rematched with the -arguments for the method using the standard argument matching mechanism. -The first argument, i.e.@: the object, will have been evaluated. - this information is duplicated. See a few paragraphs up When the method is invoked it is called... Scott -- Scott Kostyshak Economics PhD Candidate Princeton University The patch still applies cleanly (one offset) on r65090. Best, Scott -- Scott Kostyshak Economics PhD Candidate Princeton University __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [PATCH] suggestions for R-lang manual
Attached is a patch with suggestions for the R-lang manual at r64277. Below are a few comments (some are implemented in the patch): In the section Objects, there is a table introduced by The following table describes the possible values returned by typeof. One of the results is any. Can any be returned by typeof() ? Regarding the Recycling rules section, -One exception is that when adding vectors to matrices, a warning is not -given if the lengths are incompatible. -@c Is that a bug? - was this a bug that was fixed? I see the following behavior: myvec - 1:3 mymat - matrix(1:12, ncol=2) myvec - 1:5 myvec + mymat [,1] [,2] [1,]29 [2,]4 11 [3,]6 13 [4,]8 15 [5,] 10 12 [6,]7 14 Warning message: In myvec + mymat : longer object length is not a multiple of shorter object length Regarding -The arguments in the call to the generic are rematched with the -arguments for the method using the standard argument matching mechanism. -The first argument, i.e.@: the object, will have been evaluated. - this information is duplicated. See a few paragraphs up When the method is invoked it is called... Scott -- Scott Kostyshak Economics PhD Candidate Princeton University Index: trunk/doc/manual/R-lang.texi === --- trunk/doc/manual/R-lang.texi(revision 64277) +++ trunk/doc/manual/R-lang.texi(working copy) @@ -1064,7 +1064,7 @@ @cindex function @cindex function arguments Function calls can have @emph{tagged} (or @emph{named}) arguments, as in -@code{plot(x, y, pch = 3)} arguments without tags are known as +@code{plot(x, y, pch = 3)}. Arguments without tags are known as @emph{positional} since the function must distinguish their meaning from their sequential positions among the arguments of the call, e.g., that @code{x} denotes the abscissa variable and @code{y} the ordinate. The @@ -1308,10 +1308,10 @@ ignored. If @var{value1} has any type other than a logical or a numeric vector an error is signalled. -If/else statements can be used to avoid numeric problems such as taking -the logarithm of a negative number. Because if/else statements are the -same as other statements you can assign the value of them. The two -examples below are equivalent. +@code{if}/@code{else} statements can be used to avoid numeric problems +such as taking the logarithm of a negative number. Because +@code{if}/@code{else} statements are the same as other statements you +can assign the value of them. The two examples below are equivalent. @example if( any(x = 0) ) y - log(1+x) else y - log(x) @@ -1327,7 +1327,7 @@ compound statement wrapped in braces, putting the @code{else} on the same line as the closing brace that marks the end of the statement. -If/else statements can be nested. +@code{if}/@code{else} statements can be nested. @example if ( @var{statement1} ) @{ @@ -1342,7 +1342,7 @@ One of the even numbered statements will be evaluated and the resulting value returned. If the optional @code{else} clause is omitted and all -the odd numbered @var{statement}'s evaluate to @code{FALSE} no statement +the odd numbered @var{statement}s evaluate to @code{FALSE} no statement will be evaluated and @code{NULL} is returned. The odd numbered @var{statement}s are evaluated, in order, until one @@ -1378,7 +1378,7 @@ of the loop (if there is one) is then executed. No statement below @code{next} in the current loop is evaluated. -The value returned by a loop statement statement is always @code{NULL} +The value returned by a loop statement is always @code{NULL} and is returned invisibly. @node repeat, while, Looping, Control structures @@ -1451,7 +1451,7 @@ where the elements of @var{list} may be named. First, @var{statement} is evaluated and the result, @var{value}, obtained. If @var{value} is a number between 1 and the length of @var{list} then the corresponding -element @var{list} is evaluated and the result returned. If @var{value} +element of @var{list} is evaluated and the result returned. If @var{value} is too large or too small @code{NULL} is returned. @example @@ -1530,10 +1530,6 @@ As from @R{} 1.4.0, any arithmetic operation involving a zero-length vector has a zero-length result. -One exception is that when adding vectors to matrices, a warning is not -given if the lengths are incompatible. -@c Is that a bug? - @node Propagation of names, Dimensional attributes, Recycling rules, Elementary arithmetic operations @subsection Propagation of names @cindex name @@ -1842,7 +1838,7 @@ matching. The most important example of a class method for @code{[} is that used -for data frames. It is not be described in detail here (see the help +for data frames. It is not described in detail here (see the help page for @code{[.data.frame}, but in broad terms, if two indices are supplied (even if one is empty) it creates matrix-like indexing for a structure that is