Hi Simon,
On 11-04-08 01:05 PM, Simon Urbanek wrote:
On Apr 8, 2011, at 2:55 PM, Hervé Pagès wrote:
Hi Duncan, Marc,
On 11-04-05 11:15 AM, Duncan Murdoch wrote:
On 05/04/2011 1:51 PM, Marc Carlson wrote:
Hi,
I have seen several packages that with the most recent version of R are
giving a warning like this:
Assignments in \usage in documentation object 'marginalData-methods':
marginalData(object) = value
I assume that this is to prevent people from making assignments in their
usage statements (which seems completely understandable). But what
about the case above? This is a person who just wants to show the
proper usage for a replacement method. IOW they just want to write
something that looks like what you actually do when you use a
replacement method. They just want to show users how to do something
like this:
replacementMethod(object)<- newValue
So is that really something that should not be allowed in a usage
statement?
If replacementMethod was a replacement function, then
replacementMethod(object)<- newValue
is supposed to be fine.
Yes, 'replacementMethod(object)<- newValue' vorks indeed, but
not 'replacementMethod(object) = newValue'.
But if it is an S3 method, it should be
\method{replacementMethod}{class}(object)<- newValue
and if it is an S4 method I think it should be
\S4method{replacementMethod}{signature_list}(object)<- newValue
In the case reported by Marc, replacementMethod was both: a
replacement (generic) function and a replacement method. And the
man page had an alias for both. Marc replaced
replacementMethod(object) = newValue
with
\S4method{replacementMethod}{signature_list}(object)<- newValue
and that solved the problem. But replacing '=' with '<-' solves it too.
Shouldn't 'R CMD check' treat the 2 assignment operators the same way
since they are equivalent?
They are not equivalent (you can't use = in many places where you can use<-).
I tried to lower the chance of getting a comment like this by saying
"the 2 *assignment* operators are equivalent" but apparently I
failed :-/
Seems to me that the places where I can't replace <- by = are exactly
the places where I would be replacing an assignment operator by
something that is not an assignment operator anymore.
Also my understanding is that it is considered bad practice by some to use = as
assignment outside of the command prompt (interactive use) -- but opinions vary
and I don't want to start a flame war here ;).
I agree with you. I like to be able to directly copy/paste
a <- foo()
into
system.time(... paste it here ...)
and press <return> and have it work. But as you said, opinions may
vary...
Anyway, if 'R CMD check' wants to encourage good practice, fine with
me, but then the warning for 'replacementMethod(object) = newValue'
should be something else and also maybe for consistency the code in
the examples and in the vignette should be checked to detect when =
is used instead of <-
Otherwise, 'R CMD check' should just treat
replacementMethod(object) = newValue
the same way it treats
replacementMethod(object) <- newValue
Thanks,
H.
Cheers,
Simon
Thanks!
H.
(though the manual suggests using the S3 style, I'm not sure how
literally to take it).
Duncan Murdoch
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Hervé Pagès
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpa...@fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Hervé Pagès
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpa...@fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel