[Rd] setClass with a slot of RODBC

2007-06-04 Thread adschai
 
Hi - I tried to get some answer before but there seems to have no one response. 
My question is that I have a class like below definition:
 
setClass("DBManager", 
   representation(channel="RODBC"))
 
My purpose of the conn slot is to hold a channel to database connection which 
is returned by a command like:
 
channel <- odbcConnect("DB", uid="user", pwd="password")
 
According to RODBC documentation, this channel is supposed to have a type of 
"RODBC". However, if I declare my class as above, R will complain that it does 
not know about "RODBC" type or class. Please clarify. Thank you.
 
- adschai 

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] HTML vignette browser

2007-06-04 Thread Deepayan Sarkar
On 6/4/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> Folks,
>
> I think this is a nice idea (and not very different to somethign I have
> bene playing with), but with lots of CHARSXP changes pending I'd
> like to come back to it next week or so.
>
> Sorry, Deepayan, you've happened to hit a very busy stage in R
> development.

No problem.

-Deepayan

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] HTML vignette browser

2007-06-04 Thread Prof Brian Ripley
Folks,

I think this is a nice idea (and not very different to somethign I have 
bene playing with), but with lots of CHARSXP changes pending I'd 
like to come back to it next week or so.

Sorry, Deepayan, you've happened to hit a very busy stage in R 
development.

Brian

On Mon, 4 Jun 2007, Deepayan Sarkar wrote:

> On 6/4/07, Seth Falcon <[EMAIL PROTECTED]> wrote:
>> Friedrich Leisch <[EMAIL PROTECTED]> writes:
>>> Looks good to me, and certainly something worth being added to R.
>>>
>>> 2 quick (related) comments:
>>>
>>> 1) I am not sure if we want to include links to the Latex-Sources by
>>>default, those might confuse unsuspecting novices a lot. Perhaps
>>>make those optional using an argument to browseVignettes(), which
>>>is FALSE by default?
>>
>> I agree that the Rnw could confuse folks.  But I'm not sure it needs
>> to be hidden or turned off by default...  If the .R file was also
>> included then it would be less confusing I suspect as the curious
>> could deduce what Rnw is about by triangulation.
>>
>>> 2) Instead links to .Rnw files we may want to include links to the R
>>>code -> should we R CMD INSTALL a tangled version of each vignette
>>>such that we can link to it? Of course it is redundant information
>>>given the .Rnw, but we also have the help pages in several formats
>>>ready.
>>
>> Including, by default, links to the tangled .R code seems like a
>> really nice idea.  I think a lot of users who find vignettes don't
>> realize that all of the code used to generate the entire document is
>> available to them -- I just had a question from someone who wanted to
>> know how to make a plot that appeared in a vignette, for example.
>
> I agree that having a Stangled .R file would be a great idea (among
> other things, it would have the complete code, which many PDFs will
> not).
>
> I don't have a strong opinion either way about linking to the .Rnw
> file. It should definitely be there if the PDF file is absent (e.g.
> for grid, and other packages installed with --no-vignettes, which I
> always do for local installation). Maybe we can keep them, but change
> the name to something more scary than "source", e.g. "LaTeX/Noweb
> source".
>
> -Deepayan
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] HTML vignette browser

2007-06-04 Thread Robert Gentleman


Deepayan Sarkar wrote:
> On 6/4/07, Seth Falcon <[EMAIL PROTECTED]> wrote:
>> Friedrich Leisch <[EMAIL PROTECTED]> writes:
>>> Looks good to me, and certainly something worth being added to R.
>>>
>>> 2 quick (related) comments:
>>>
>>> 1) I am not sure if we want to include links to the Latex-Sources by
>>>default, those might confuse unsuspecting novices a lot. Perhaps
>>>make those optional using an argument to browseVignettes(), which
>>>is FALSE by default?
>> I agree that the Rnw could confuse folks.  But I'm not sure it needs
>> to be hidden or turned off by default...  If the .R file was also
>> included then it would be less confusing I suspect as the curious
>> could deduce what Rnw is about by triangulation.
>>
>>> 2) Instead links to .Rnw files we may want to include links to the R
>>>code -> should we R CMD INSTALL a tangled version of each vignette
>>>such that we can link to it? Of course it is redundant information
>>>given the .Rnw, but we also have the help pages in several formats
>>>ready.
>> Including, by default, links to the tangled .R code seems like a
>> really nice idea.  I think a lot of users who find vignettes don't
>> realize that all of the code used to generate the entire document is
>> available to them -- I just had a question from someone who wanted to
>> know how to make a plot that appeared in a vignette, for example.
> 
> I agree that having a Stangled .R file would be a great idea (among
> other things, it would have the complete code, which many PDFs will
> not).
> 
> I don't have a strong opinion either way about linking to the .Rnw
> file. It should definitely be there if the PDF file is absent (e.g.
> for grid, and other packages installed with --no-vignettes, which I
> always do for local installation). Maybe we can keep them, but change
> the name to something more scary than "source", e.g. "LaTeX/Noweb
> source".

   I would very much prefer to keep the source, with some name, scary or 
not...

> 
> -Deepayan
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
PO Box 19024
Seattle, Washington 98109-1024
206-667-7700
[EMAIL PROTECTED]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] HTML vignette browser

2007-06-04 Thread Deepayan Sarkar
On 6/4/07, Seth Falcon <[EMAIL PROTECTED]> wrote:
> Friedrich Leisch <[EMAIL PROTECTED]> writes:
> > Looks good to me, and certainly something worth being added to R.
> >
> > 2 quick (related) comments:
> >
> > 1) I am not sure if we want to include links to the Latex-Sources by
> >default, those might confuse unsuspecting novices a lot. Perhaps
> >make those optional using an argument to browseVignettes(), which
> >is FALSE by default?
>
> I agree that the Rnw could confuse folks.  But I'm not sure it needs
> to be hidden or turned off by default...  If the .R file was also
> included then it would be less confusing I suspect as the curious
> could deduce what Rnw is about by triangulation.
>
> > 2) Instead links to .Rnw files we may want to include links to the R
> >code -> should we R CMD INSTALL a tangled version of each vignette
> >such that we can link to it? Of course it is redundant information
> >given the .Rnw, but we also have the help pages in several formats
> >ready.
>
> Including, by default, links to the tangled .R code seems like a
> really nice idea.  I think a lot of users who find vignettes don't
> realize that all of the code used to generate the entire document is
> available to them -- I just had a question from someone who wanted to
> know how to make a plot that appeared in a vignette, for example.

I agree that having a Stangled .R file would be a great idea (among
other things, it would have the complete code, which many PDFs will
not).

I don't have a strong opinion either way about linking to the .Rnw
file. It should definitely be there if the PDF file is absent (e.g.
for grid, and other packages installed with --no-vignettes, which I
always do for local installation). Maybe we can keep them, but change
the name to something more scary than "source", e.g. "LaTeX/Noweb
source".

-Deepayan

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] HTML vignette browser

2007-06-04 Thread Seth Falcon
Friedrich Leisch <[EMAIL PROTECTED]> writes:
> Looks good to me, and certainly something worth being added to R.
>
> 2 quick (related) comments:
>
> 1) I am not sure if we want to include links to the Latex-Sources by
>default, those might confuse unsuspecting novices a lot. Perhaps
>make those optional using an argument to browseVignettes(), which
>is FALSE by default?

I agree that the Rnw could confuse folks.  But I'm not sure it needs
to be hidden or turned off by default...  If the .R file was also
included then it would be less confusing I suspect as the curious
could deduce what Rnw is about by triangulation.

> 2) Instead links to .Rnw files we may want to include links to the R
>code -> should we R CMD INSTALL a tangled version of each vignette
>such that we can link to it? Of course it is redundant information
>given the .Rnw, but we also have the help pages in several formats
>ready.

Including, by default, links to the tangled .R code seems like a
really nice idea.  I think a lot of users who find vignettes don't
realize that all of the code used to generate the entire document is
available to them -- I just had a question from someone who wanted to
know how to make a plot that appeared in a vignette, for example.


+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] nls problems

2007-06-04 Thread Spencer Graves
Hi, All: 

 The following identifies apparent inconsistencies and proposed 
fixes between the documentation and the behavior of 'nls'. 

 Specifically, the help file says 'data' 'Can also be a list'.  
However, I got an error when I tried it with a list that could not be 
coerced to a data.frame.  This is documented in the first example below. 

 Also, the help file says 'data' is 'optional'.  Unfortunately, the 
second example below bombs, apparently while checking the wrong thing 
for parameters to estimate. 

 Attached is a version of 'nls' that fixes these problems and 
otherwise produces the same answers (per 'all.equal') as the current 
official version on the "Examples" in 'nls' help file.  What do you 
think about adopting these code changes and adding these examples to the 
'nls' help file (see the attached  'nls-new examples.R')? 

  I am using this in preparing for a presentation on the 'fda' 
package at UseR! in Ames (Aug. 8-10).  I am temporarily adding the 
attached version of 'nls' to the 'fda' package with a help file 
primarily consisting of a pointer to help(nls, package=stats) and the 
attached examples.  However, I'm hoping that someone will find the time 
to review this and either disabuse me of some of my deficiencies in this 
area or announce a plan to have something like this incorporated in a 
future version of R. 


 Thanks,
 Best Wishes,
 Spencer Graves
p.s.  How can I find the official source code for this?  I tried 
"https://svn.r-project.org/R-packages/trunk"; and found 'nlme' and other 
packages but not core R like 'stats'. 
#

##
## SLIGHT MODIFICATIONS TO CURRENT EXAMPLES
## THAT DON'T WORK (except with my modifications)
##
# Weighted Michaelis-Menten model
# with data = a list that can not be coerced to a data.frame
TreatIrreg <- with(Treated, list(conc1=conc[1], conc.1=conc[-1], rate=rate))

# Passing arguments using a list that can not be coerced to a data.frame
weighted.MM1 <- function(resp, conc1, conc.1, Vm, K){
 conc <- c(conc1, conc.1)
 resp <- TI$rate
#
 pred <- (Vm * conc)/(K + conc)
 (resp - pred) / sqrt(pred)
}
Pur.wt1 <- nls( ~ weighted.MM1(rate, conc1, conc.1, Vm, K), 
data=TreatIrreg,

  start = list(Vm = 200, K = 0.1), trace = TRUE)
##
## ERROR MESSAGE: 
## Error in data.frame(conc1 = 0.02, conc.1 = c(0.02, 0.06, 0.06, 0.11, 
0.11,  :

##arguments imply differing number of rows: 1, 11, 12
##

# Passing arguments via 'get'
weignted.MM0 <- function(Vm, K){ 
 TI <- get("TreatIrreg")

 conc <- with(TI, c(conc1, conc.1))
 resp <- TI$rate
#
 pred <- (Vm * conc)/(K + conc)
 (resp - pred) / sqrt(pred)
}
Pur.wt0 <- nls( ~ weighted.MM0(Vm, K), start = list(Vm = 200, K = 0.1),
  trace = TRUE)
##
## ERROR MESSAGE:
## Error in nls(~weighted.MM0(Vm, K), start = list(Vm = 200, K = 0.1), 
trace = TRUE) :

## no parameters to fit
##



nls <- 
function (formula, data = parent.frame(), start, control = nls.control(), 
algorithm = c("default", "plinear", "port"), trace = FALSE, 
subset, weights, na.action, model = FALSE, lower = -Inf, 
upper = Inf, ...) 
{
##
## 1.  Basic set up
##  
formula <- as.formula(formula)
algorithm <- match.arg(algorithm)
if (!is.list(data) && !is.environment(data)) 
stop("'data' must be a list or an environment")
mf <- match.call()
##
## 2.  Names of variables in model and parameters to be estimated
##
#   varNames = names of variables in the model 
varNames <- all.vars(formula)
mWeights <- missing(weights)
if (length(formula) == 2) {
formula[[3]] <- formula[[2]]
formula[[2]] <- 0
}
#   pnames = names of parameters to be estimated 
pnames <- {
  if (missing(start)) {
if (!is.null(attr(data, "parameters"))) {
  names(attr(data, "parameters"))
}
else {
  cll <- formula[[length(formula)]]
  func <- get(as.character(cll[[1]]))
  if (!is.null(pn <- attr(func, "pnames"))) 
as.character(as.list(match.call(func, call = cll))[-1][pn])
}
  }
  else names(start)
}
#   Confirm we have parameters to estimate
#   (This is intended to correct an apparent error below;
#s. Graves 2007.06.02) 
if (!length(pnames)) 
stop("no parameters to fit")
#   Delete parameters from varNames 
env <- environment(formula)
if (is.null(env)) 
env <- parent.frame()
if (length(pnames)) 
varNames <- varNames[is.na(match(varNames, pnames))]
#if (!length(varNames))stop("no parameters to fit")
##
## 3.  Get varNames
##
#  3.1.  get lengths of varNames  
lenVar <- function(var) tryCatch(length(eval(as.name(var), 
data, env)), error = function(e) -1)
n <- sapply(varNames, lenVar)
#  3.2.  any not found?  
if (any(not.there <- n == -1)) {
nnn <- names(n[not.there])
if (missing(start)) {
if (algorithm == "

Re: [Rd] HTML vignette browser

2007-06-04 Thread Friedrich Leisch
> On Fri, 1 Jun 2007 16:22:18 -0700,
> Deepayan Sarkar (DS) wrote:

  > Hi,
  > this is tangentially related to the recent discussion on vignettes.
  > vignette() currently produces a listing of available vignettes, but
  > these are not clickable. Since R has a browseURL() function, it seems
  > natural to have a version that produces HTML with clickable links.
  > Here's an attempt at that:

  > source("http://dsarkar.fhcrc.org/R/vignette-browser.R";)
  > browseVignettes()
  > browseVignettes(package = "grid")

  > etc. Perhaps some variant of this could be added to R.

  > Comments welcome.

Looks good to me, and certainly something worth being added to R.

2 quick (related) comments:

1) I am not sure if we want to include links to the Latex-Sources by
   default, those might confuse unsuspecting novices a lot. Perhaps
   make those optional using an argument to browseVignettes(), which
   is FALSE by default?

2) Instead links to .Rnw files we may want to include links to the R
   code -> should we R CMD INSTALL a tangled version of each vignette
   such that we can link to it? Of course it is redundant information
   given the .Rnw, but we also have the help pages in several formats
   ready.

.f

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Determinant function (PR#9715)

2007-06-04 Thread Petr Savicky
> The function ''det'' works improperly for a singular matrix and returns a
> non-zero value even if ''solve'' reports singularity. The matrix is very 
> simple
> as shown below.
>
> A <- diag(rep(c(64,8), c(8,8)))
> A[9:16,1] <- 8
> A[1,9:16] <- 8
> 
> det(A)
> #[1] -196608
> solve(A)
> #Error in solve.default(A) : system is computationally singular: reciprocal
> condition number = 2.31296e-18

The "det" function cannot work properly in the limited precision
of floating point numbers. May be, "det" could also do a test
of computational singularity and refuse to compute the value
similarly as "solve" does.

The eigen-values of your matrix are
  > eigen(A)$values
   [1]  7.20e+01  6.40e+01  6.40e+01  6.40e+01  6.40e+01
   [6]  6.40e+01  6.40e+01  6.40e+01  8.00e+00  8.00e+00
  [11]  8.00e+00  8.00e+00  8.00e+00  8.00e+00  8.00e+00
  [16] -2.023228e-15
The last value is not zero due to rounding. The determinant is the product
of eigenvalues, so we get something large.

The problem may also be seen as follows:
  > det(A/8)
  [1] -6.98492e-10
This is close to zero as it should be, however, det(A) = det(A/8)*8^16,
and this is what we really get:
  > det(A/8)*8^16
  [1] -196608
  > det(A)
  [1] -196608

There are even matrices closer to a diagonal matrix than A with
a similar problem:
  > B <- 20*diag(16); B[1:2,1:2] <- c(25,35,35,49); det(B);
  [1] 44565.24

All the best, Petr.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Determinant function (PR#9715)

2007-06-04 Thread krys
Full_Name: Krzysztof Podgorski
Version: R version 2.4.1 (2006-12-18)
OS: Windows XP
Submission from: (NULL) (130.235.3.79)


The function ''det'' works improperly for a singular matrix and returns a
non-zero value even if ''solve'' reports singularity. The matrix is very simple
as shown below.

A <- diag(rep(c(64,8), c(8,8)))
A[9:16,1] <- 8
A[1,9:16] <- 8

det(A)
#[1] -196608
solve(A)
#Error in solve.default(A) : system is computationally singular: reciprocal
condition number = 2.31296e-18

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel