Skip to content

Writing lgrindefs

5 messages · Friedrich Leisch, Uwe Ligges, Kjetil Kjernsmo

#
On Thu, 27 Apr 2000, Uwe Ligges wrote:

            
Yeah, that's the problem with both of those, that it doesn't only contain
functions.
Oh, I thought about it, but then I figured for this to work consistently,
every user would have to generate his own defs, depending on what packages
he has installed, which would be a bit bothersome I guess.
Perhaps, so I send this reply there, I sent the original post to r-help
because I figured it might be an easy question for most. I assume that
most of the R-devel members are on the R-help list so I do not resend my
original post. If this assumption doesn't hold, please let me know.  

Best,

Kjetil
#

        
KK> On Thu, 27 Apr 2000, Uwe Ligges wrote:
Finding out what is a function and what not is easy:

R> x<- ls("package:base")
R> x[40]
[1] ".lib.loc"
R> x[140]
[1] "anovalist.lm"

where the first is a vector and the second a function, which can
easily be traced:

R> sapply(x[c(40,140)],function(y){is.function(get(y))})
    .lib.loc anovalist.lm 
       FALSE         TRUE 

(don't know if this is the most elegant way of doing it). This leaves
all operators in the list as they are only functions allowing a
special syntax, hence if you want only ordinary functions, you could
simply discard those not starting with a dot or a letter.

Hope this helps,
Fritz
#

        
KK> On Thu, 27 Apr 2000, Uwe Ligges wrote:
FL> Finding out what is a function and what not is easy:

R> x<- ls("package:base")

sorry, forgot the all=TRUE here ...

.f
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
OK. Fritz has got it! And I feel stupid...

After thinking:
Only functions of the base package are not enough for some users,
on the other hand you will never be up to date with names of all
functions of all packages, I suppose.
Of course TeX cannot know names of R functions, if they are not
specified explicitly.

Suggestions:
1)
Another way is to write a R function, that generates "nice" TeX code.
Or a R function, that generates code to be interpreted by a TeX macro.
Such a function would know about loaded packages and their functions,
user specific functions, other objects in the users environment (as
needed).

2)
Providing names of functions of the most used packages (e.g. base,
ctest, ts, ...) would be enough, if the user could easily extend the
list of "known" functions (or other objects).
I think about a TeX command (defined in your macro), that could be used
as follows:
 \addrfunctionnames{myfunc1, myfunc2, myfunc3}


But maybe there are much better ideas?

Regards,
Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
1 day later
#
On Thu, 27 Apr 2000, Uwe Ligges wrote:

            
Both your suggestions are interesting, and should receive some attention I
guess. The good thing about lgrind is that it is in fairly common use, and
that definitions for many languages allready exist. When the time of
generating LaTeX code for my thesis approaches, I think I'll try to find a
newsgroup and ask about a few details.

Best,

Kjetil