[Rd] Re: more experience with formulas
Martin Maechler <firstname.lastname@example.org>
Tue, 19 Sep 2000 18:40:43 +0200
>>>>> "WSt" == Werner Stahel <email@example.com> writes:
[to me privately]
WSt> I do not want to call this a bug, but it bugged me. Please try the
WSt> tform <- sqrt(RADAI) ~ sqrt(RADAI.e) + TAGE.ej + SPITAL + ARZT + DAS28 +
WSt> SJC + TJC + DGA + HAQ + PGA + PAIN + YEAR.SYM + YEAR.DIA +
WSt> ALTER + IndV + m.NSAIDs + m.Stereoids + DM.Cyclosp + DM.Penic
--> length-3 vector "~" "<LHS>" "<RHS>".
However, the end of <RHS> is TRUNCATED!
and that truncation of the third part is a bug in my opinion.
The fact that it returns a vector of the same length as its argument is
very consistent behavior even though it maybe unexpected to the casual R user.
I think you'd want to use format() instead.
There, we can see that format.default really uses deparse(x) when x is such
a language object.
One could argue that the optional "width.cutoff = 60" argument to deparse()
should also be settable from format(), in that case,
format(tform) == deparse(tform)
really returns a vector of "3 lines" instead of just one line
which we'd get by the result of
deparse(tfrom, width = 200)
WSt> paste(tform,collapse="")# "y ~ x" becomes "~yx" -- is S compatible
WSt> as.character(tform[])# again length-3 vector "+" "sqr..." "DM.Penic"
WSt> as.character.formula <- function(x, ...) paste(deparse(x),collapse="")
WSt> ## now ,
WSt> ## work, but
WSt> ## still does not, since it is of mode language, but not of class formula.
WSt> ## It would be better to write as.character.default such that is works for
WSt> ## mode language.
It *does* work; it just returns a vector of character, again
fulfilling the semantic that
y <- as.character(x)
y[i] == as.character(x[i])
WSt> PS: Thanks for your efforts in developping R.
WSt> Werner Stahel
Martin Maechler <firstname.lastname@example.org> http://stat.ethz.ch/~maechler/
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: email@example.com