s-news
[Top] [All Lists]

Re: yaaq: yet another apply question

To: "Thompson, David (MNR)" <david.thompson@mnr.gov.on.ca>
Subject: Re: yaaq: yet another apply question
From: Tony Plate <tplate@blackmesacapital.com>
Date: Fri, 28 Jul 2006 11:10:32 -0600
Cc: s-news <s-news@lists.biostat.wustl.edu>
In-reply-to: <327C2434A3DA2D4CB61554D644BAE48B0605E387@LRCPSSMBMXMB001.lrc.ad.gov.on.ca>
References: <327C2434A3DA2D4CB61554D644BAE48B0605E387@LRCPSSMBMXMB001.lrc.ad.gov.on.ca>
User-agent: Mozilla Thunderbird 1.0.5 (Windows/20050711)
It's a little hard for me to understand exactly what you are trying to do because what I think you are trying to do doesn't work either (for example, at least on my system, library(help="splus") stops with an error.)

However, I think you are getting bitten by the non-standard evaluation rules for library(), rather than anything to do with apply(). library(help=x) thinks you are asking for help with section 'x', because it doesn't actually evaluate the variable given it, it just uses the unevaluated name (this is merely for convenience -- it allows people to omit the quotes when asking for help).

E.g., look at the different error messages from the following:

> library(help="splus")
Problem in library(help = "splus"): No README file for section "splus" in library "C:/PROGRAM FILES/INSIGHTFUL/sp
lus70\library"
Evaluation frames saved in object "last.dump", use debugger() to examine them
> xx <- "splus"
> library(help=xx)
Problem in library(help = xx): No section "xx" in the library directory: C:/PROGRAM FILES/INSIGHTFUL/splus70\libr
ary
Evaluation frames saved in object "last.dump", use debugger() to examine them
>

To get around this sort of thing, you can construct an appropriate call using substitute(), which will then produce an error message that is the same as what you get for library(help="splus")

> eval(substitute(library(help=x), list(x=xx)))
Problem in library(help = "splus"): No README file for section "splus" in library "C:/PROGRAM FILES/INSIGHTFUL/sp
lus70\library"
Evaluation frames saved in object "last.dump", use debugger() to examine them
>

You can use this expression (suitably modified) inside the apply().

-- Tony Plate


Thompson, David (MNR) wrote:
Hi,

I am trying to generate a listing of all functions available with:

xxx <- c('splus', 'stat', 'data', 'trellis', 'nlme3', 'menu', 'sgui',
'main', 'Design', 'Hmisc', 'chron', 'class', 'example5', 'examples',
'maps', 'MASS', 'missing', 'nlme2', 'nnet', 'robust', 'spatial',
'winjava', 'winspj')
lapply(xxx, function(x) library(help = x) )

Problem in library(help = x): No section "x" in the library directory:
D:/APPS/STATS/splus70\library

Apparently, I still do not understand the workings of the apply family.
Suggestions, please?

DaveT.
*********************************
Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
Sault Ste. Marie, Ontario, Canada
david.thompson@mnr.gov.on.ca
*********************************
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



<Prev in Thread] Current Thread [Next in Thread>