Re: [R] Embedding Audio Files in Interactive Graphs

2007-09-03 Thread Sam Ferguson
Thanks for your reply Bruno.

No - as I said, I know how to do that - the movie15 and the  
multimedia package are basically the same, and it is relatively  
straightforward to get an audio file into a pdf with them. However,  
real interactivity is not easily achieved in latex IMO (as it's not  
its purpose). At least I'm hoping for a bit more flexibility.

R seems like a better place to do interactivity, and with the field  
of information visualisation pointing out that interactivity is a  
very useful element for investigation of data it seems that clicking  
around graphical displays may become more and more popular in time.  
In my field I'm interested in audio data, and so simple interactive  
visual and auditory displays would be great. A (very useful) start  
would be 5 separate waveform plots that would play their appropriate  
sounds when clicked. More complex figures could plot in a 2d space  
and allow selection of data points or ranges perhaps.

I love R for graphics and for Sweave though, and would like to use it  
if possible - ideally it would be to produce a figure that included  
the appropriate audiofiles and interactive scripts, which could then  
be incorporated into a latex document \includegraphics. However, from  
the deafening silence on this list it seems like I may be attempting  
to push a square block through a round hole unfortunately. Seems I am  
back to Matlab and handle graphics - but it won't do this properly  
either.

Cheers
Sam


On 03/09/2007, at 5:39 PM, Bruno C.. wrote:

> Are you asking on how to include an  audio file into a pdf?
> This is already feasible via latex and the movie 15 package ;)
>
> Ciao
>
>> Hi R-ers,
>>
>> I'm wondering if anyone has investigated a method for embedding audio
>> files in R graphs (pdf format), and allowing their playback to be
>> triggered interactively (by clicking on a graph element for  
>> instance).
>>
>> I know how to do this in latex pdfs with the multimedia package, but
>> it seems that R would provide a more appropriate platform for many
>> reasons.
>>
>> Thanks for any help you can provide.
>> Sam Ferguson
>> Faculty of Architecture, Design and Planning
>> The University of Sydney
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting- 
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
> --
> Leggi GRATIS le tue mail con il telefonino i-mode™ di Wind
> http://i-mode.wind.it/
>

--
Sam Ferguson
Faculty of Architecture
The University of Sydney
[EMAIL PROTECTED]
+61 2 93515910
0410 719535

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Efficient sampling from a discrete distribution in R

2007-09-03 Thread Issac Trotts
Thanks to you and Burwin for helping.  My simulation seems faster now
(btw, is there some easy way to time things in R?) but not as fast as
I was hoping.  Here's the top level function.  Any ideas on how to
make it faster?

# Sample from a Chinese Restaurant Process
#
# size: number of samples to draw
# a: alpha.  If large then there will tend to be more categories.
#
rchinese = function(size, a) {
  stopifnot(length(a) == 1)
  samples = c()
  new.category = 1
  for (i in 1:size) {
denom = i - 1 + a
p.new = a / denom
ci =
  if (runif(1) < p.new) {
new.category = new.category + 1;
new.category - 1
  }
  else {
counts = unname(table(factor(samples, levels = 1:(i-1
pmf = counts / sum(counts)
rdiscrete(1, pmf)
  }
samples = c(samples, ci)
  }
  samples
}



On 9/3/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> On Mon, 3 Sep 2007, Issac Trotts wrote:
>
> > Hello r-help,
> >
> > As far as I've seen, there is no function in R dedicated to sampling
> > from a discrete distribution with a specified mass function.  The
> > standard library doesn't come with anything called rdiscrete or rpmf,
> > and I can't find any such thing on the cheat sheet or in the
> > Probability Distributions chapter of _An Introduction to R_.  Googling
> > also didn't bring back anything.  So, here's my first attempt at a
> > solution.  I'm hoping someone here knows of a more efficient way.
>
> It's called sample().
>
> There are much more efficient algorithms than the one you used, and
> sample() sometimes uses one of them (Walker's alias method): see any good
> book on simulation (including my 'Stochastic Simulation, 1987).
>
> > # Sample from a discrete distribution with given probability mass function
> > rdiscrete = function(size, pmf) {
> >  stopifnot(length(pmf) > 1)
> >  cmf = cumsum(pmf)
> >  icmf = function(p) {
> >min(which(p < cmf))
> >  }
> >  ps = runif(size)
> >  sapply(ps, icmf)
> > }
> >
> > test.rdiscrete = function(N = 1) {
> >  err.tol = 6.0 / sqrt(N)
> >  xs = rdiscrete(N, c(0.5, 0.5))
> >  err = abs(sum(xs == 1) / N - 0.5)
> >  stopifnot(err < err.tol)
> >  list(e = err, xs = xs)
> > }
> >
> > Thanks,
> > Issac
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> --
> 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-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Efficient sampling from a discrete distribution in R

2007-09-03 Thread Prof Brian Ripley
On Mon, 3 Sep 2007, Issac Trotts wrote:

> Hello r-help,
>
> As far as I've seen, there is no function in R dedicated to sampling
> from a discrete distribution with a specified mass function.  The
> standard library doesn't come with anything called rdiscrete or rpmf,
> and I can't find any such thing on the cheat sheet or in the
> Probability Distributions chapter of _An Introduction to R_.  Googling
> also didn't bring back anything.  So, here's my first attempt at a
> solution.  I'm hoping someone here knows of a more efficient way.

It's called sample().

There are much more efficient algorithms than the one you used, and 
sample() sometimes uses one of them (Walker's alias method): see any good 
book on simulation (including my 'Stochastic Simulation, 1987).

> # Sample from a discrete distribution with given probability mass function
> rdiscrete = function(size, pmf) {
>  stopifnot(length(pmf) > 1)
>  cmf = cumsum(pmf)
>  icmf = function(p) {
>min(which(p < cmf))
>  }
>  ps = runif(size)
>  sapply(ps, icmf)
> }
>
> test.rdiscrete = function(N = 1) {
>  err.tol = 6.0 / sqrt(N)
>  xs = rdiscrete(N, c(0.5, 0.5))
>  err = abs(sum(xs == 1) / N - 0.5)
>  stopifnot(err < err.tol)
>  list(e = err, xs = xs)
> }
>
> Thanks,
> Issac
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Rory Winston
Hi guys

Thanks for all the fantastic suggestions! I didnt realise you could extract
the body of a function in that manner. It looks like R always has many ways
to solve a particular problem.

Cheers
Rory

On 9/4/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
>
> And if f has brace brackets surrounding the body then do this:
>
> f <- function(x) { x*x }
> deriv(body(f)[[2]], "x", func = TRUE)
>
> If you are writing a general function you can do this:
>
> e <- if (identical(body(f)[[1]], as.name("{"))) body(f)[[2]] else body(f)
> deriv(e, "x", func = TRUE)
>
>
> On 9/3/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > One improvement.  This returns a function directly without having
> > to create a template and filling in its body:
> >
> > deriv(body(f), "x", func = TRUE)
> >
> > On 9/3/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > > The problem is that brace brackets are not in the derivatives table.
> > > Make sure you don't have any.
> > >
> > > On 9/3/07, Alberto Vieira Ferreira Monteiro <[EMAIL PROTECTED]>
> wrote:
> > > > Gabor Grothendieck wrote:
> > > > >
> > > > > Actually in thinking about this its pretty easy to do it without
> Ryacas
> > > > > too:
> > > > >
> > > > > Df <- f
> > > > > body(Df) <- deriv(body(f), "x")
> > > > > Df
> > > > >
> > > > This is weird.
> > > >
> > > > f <- function(x) { x^2 + 2*x+1 }
> > > > Df <- f
> > > > body(Df) <- deriv(body(f), "x") # error
> > > >
> > > > Also:
> > > >
> > > > f <- function(x) x^2 + 2 * x + 1
> > > > Df <- f
> > > > body(Df) <- deriv(body(f), "x") # ok
> > > > D2f <- f
> > > > body(D2f) <- deriv(body(Df), "x") # error
> > > >
> > > > Alberto Monteiro
> > > >
> > >
> >
>

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Efficient sampling from a discrete distribution in R

2007-09-03 Thread Issac Trotts
Hello r-help,

As far as I've seen, there is no function in R dedicated to sampling
from a discrete distribution with a specified mass function.  The
standard library doesn't come with anything called rdiscrete or rpmf,
and I can't find any such thing on the cheat sheet or in the
Probability Distributions chapter of _An Introduction to R_.  Googling
also didn't bring back anything.  So, here's my first attempt at a
solution.  I'm hoping someone here knows of a more efficient way.

# Sample from a discrete distribution with given probability mass function
rdiscrete = function(size, pmf) {
  stopifnot(length(pmf) > 1)
  cmf = cumsum(pmf)
  icmf = function(p) {
min(which(p < cmf))
  }
  ps = runif(size)
  sapply(ps, icmf)
}

test.rdiscrete = function(N = 1) {
  err.tol = 6.0 / sqrt(N)
  xs = rdiscrete(N, c(0.5, 0.5))
  err = abs(sum(xs == 1) / N - 0.5)
  stopifnot(err < err.tol)
  list(e = err, xs = xs)
}

Thanks,
Issac

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Package installation

2007-09-03 Thread Matias Bordese
We are working in a new release that would solve the problem
mentioned; in the current source tarball available it could be manage
as Uwe said, adding the line in the DESCRIPTION file:
ZipData: no

By the way, besides the RTools needed to compile any package in
Windows, you will need to install the libjpeg and libtiff libraries
and follow the instructions in the README file.

Sorry for the delayed answer. I hope you can use the package. In a few
weeks we think we are going to release an improved version, with more
functionalities. Any feedback will be welcome.

Best,
Matías Bordese.

On 8/24/07, Uwe Ligges <[EMAIL PROTECTED]> wrote:
>
>
> Antje wrote:
> > Hello,
> >
> > I'm running R with windows. Could anybody help me how to install the package
> > biOps (http://cran.mirroring.de/src/contrib/Descriptions/biOps.html) ?
> > I cannot find it at any mirror provided by the GUI; I just found it as 
> > "tar.gz"
> > which cannot be installed with the installation method...
> > Maybe, I simply do something wrong?
>
> The Windows binary is not available on CRAN, because it still fail its
> checks under Windows. I already asked the package maintainer (CCing
> again) to fix the package by simply adding one line:
>ZipData: no
> to its DESCRIPTION file.
>
> Uwe Ligges
>
>
>
> > Thanks for any hint!
> >
> > Antje
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Row-Echelon Form

2007-09-03 Thread John Fox
Dear Peter,

Some time ago, I posted a function RREF to r-help that computes the reduced
row-echelon form of a matrix. Just last week, Scott Hyde posted a revised
version of this function to r-help (see
https://stat.ethz.ch/pipermail/r-help/2007-September/139923.html). My
original function didn't work correctly in some cases, and in response to
Scott's message, I tried to post a newer version to r-help, but it doesn't
seem to have gotten through (perhaps because I attached the function in a
file). I append the function below, along with some other simple
linear-algebra functions.

I hope this helps,
 John

- snip -

# Last modified 9 July 2007 by J. Fox

GaussianElimination <- function(A, B, tol=sqrt(.Machine$double.eps), 
verbose=FALSE, fractions=FALSE){
# A: coefficient matrix
# B: right-hand side vector or matrix
# tol: tolerance for checking for 0 pivot
# verbose: if TRUE, print intermediate steps
# fractions: try to express nonintegers as rational numbers
# If B is absent returns the reduced row-echelon form of A.
# If B is present, reduces A to RREF carrying B along.
if (fractions) {
mass <- require(MASS)
if (!mass) stop("fractions=TRUE needs MASS package")
}
if ((!is.matrix(A)) || (!is.numeric(A)))
stop("argument must be a numeric matrix")
n <- nrow(A)
m <- ncol(A)
if (!missing(B)){
B <- as.matrix(B)
if (!(nrow(B) == nrow(A)) || !is.numeric(B))
  stop("argument must be numeric and must match the number of row of
A")
A <- cbind(A, B)
}
i <- j <- 1
while (i <= n && j <= m){
while (j <= m){
currentColumn <- A[,j]
currentColumn[1:n < i] <- 0
# find maximum pivot in current column at or below current row
which <- which.max(abs(currentColumn))
pivot <- currentColumn[which]
if (abs(pivot) <= tol) { # check for 0 pivot
j <- j + 1
next
} 
if (which > i) A[c(i, which),] <- A[c(which, i),]  # exchange
rows
A[i,] <- A[i,]/pivot# pivot
row <- A[i,]
A <- A - outer(A[,j], row)  # sweep
A[i,] <- row# restore current row
if (verbose) if (fractions) print(fractions(A))
else print(round(A, round(abs(log(tol,10)
j <- j + 1
break
}
i <- i + 1
}
 # 0 rows to bottom
zeros <- which(apply(A[,1:m], 1, function(x) max(abs(x)) <= tol))
if (length(zeros) > 0){
zeroRows <- A[zeros,]
A <- A[-zeros,]
A <- rbind(A, zeroRows)
}
rownames(A) <- NULL
if (fractions) fractions (A) else round(A, round(abs(log(tol, 10
}

matrixInverse <- function(X, tol=sqrt(.Machine$double.eps), ...){
# returns the inverse of nonsingular X
if ((!is.matrix(X)) || (nrow(X) != ncol(X)) || (!is.numeric(X))) 
stop("X must be a square numeric matrix")
n <- nrow(X)
X <- GaussianElimination(X, diag(n), tol=tol, ...) # append identity
matrix
# check for 0 rows in the RREF of X:
if (any(apply(abs(X[,1:n]) <= sqrt(.Machine$double.eps), 1, all)))
stop ("X is numerically singular")
X[,(n + 1):(2*n)]  # return inverse
}

RREF <- function(X, ...) GaussianElimination(X, ...)
# returns the reduced row-echelon form of X

Ginv <- function(A, tol=sqrt(.Machine$double.eps), verbose=FALSE, 
fractions=FALSE){
# return an arbitrary generalized inverse of the matrix A
# A: a matrix
# tol: tolerance for checking for 0 pivot
# verbose: if TRUE, print intermediate steps
# fractions: try to express nonintegers as rational numbers
m <- nrow(A)
n <- ncol(A)
B <- GaussianElimination(A, diag(m), tol=tol, verbose=verbose, 
fractions=fractions)
L <- B[,-(1:n)]
AR <- B[,1:n]
C <- GaussianElimination(t(AR), diag(n), tol=tol, verbose=verbose, 
fractions=fractions)
R <- t(C[,-(1:m)])
AC <- t(C[,1:m])
ginv <- R %*% t(AC) %*% L
if (fractions) fractions (ginv) else round(ginv, round(abs(log(tol,
10
}

cholesky <- function(X, tol=sqrt(.Machine$double.eps)){
# returns the Cholesky square root of the nonsingular, symmetric matrix
X
# tol: tolerance for checking for 0 pivot
# algorithm from Kennedy & Gentle (1980)
if (!is.numeric(X)) stop("argument is not numeric")
if (!is.matrix(X)) stop("argument is not a matrix")
n <- nrow(X)
if (ncol(X) != n) stop("matrix is not square")
if (max(abs(X - t(X))) > tol) stop("matrix is not symmetric")
D <- rep(0, n)
L <- diag(n)
i <- 2:n
D[1] <- X[1, 1]
if (abs(D[1]) < tol) stop("matrix is numerically singular")
L[i, 1] <- X[i, 1]/D[1]
for (j in 2:(n - 1)){
k <- 1:(j - 1)
D[j] <- X[j, j] - sum((L[j, k]^2) * D[k])
   

Re: [R] Different behavior of mtext

2007-09-03 Thread Sébastien
Thanks for the information on gridBase, I could solve my problem using 
the 'baseViewports' function and by replacing mtext by grid.text (with 
coordinates adjustments).

Sebastien

Prof Brian Ripley a écrit :
> On Mon, 3 Sep 2007, Sébastien wrote:
>
>> Ok, the problem is clear now. I did not get that 'user-coordinates' 
>> was refering to par("usr"), when I read the help of mtext. If I may 
>> ask you some additional questions:
>> - you mentioned a missing unit() call ; at which point should it be 
>> done in my code examples ?
>
> Before it is used.  The problem is that I believe more than one 
> package has a unit() function.
>
>> - could you give me some advices or helpful links about how to set up 
>> a grid viewport ? - and finally, probably a stupid question: is a 
>> gridview automatically set up when a plotting function is called ?
>
> If you want to mix grid and base graphics, you need package gridBase, 
> but really I would not advise a beginner to be using grid directly 
> (that is, not via lattice to ggplot*).
>
>
>> Sebastien
>>
>> PS: To answer to your final question, my goal is to center a block of 
>> legend text on the device but to align the text to the left of this 
>> block.
>>
>> Prof Brian Ripley a écrit :
>>> On Sun, 2 Sep 2007, Sébastien wrote:
>>>
 Dear R Users,

 I am quite surprised to see that mtext gives different results when it
 is used with 'pairs' and with "plot'. In the two following codes, it
 seems that the 'at' argument in mtext doesn't consider the same 
 unit system.
>>>
>>> It is stated to be in 'user coordinates'.  Your code does not work 
>>> because unit() is missing.  If you mean the one from package grid, 
>>> "npc" is not user coordinates (and refers to a grid viewport which 
>>> you have not set up and coincidentally is the same as the initial 
>>> user coordinate system to which pairs() has reverted).
>>>
>>> Try par("usr") after your pairs() and plot() calls to see the 
>>> difference.
>>> Plotting a 2x2 array of plots _is_ different from plotting one, so 
>>> this should be as expected.
>>>
>>> Since centring is the default for 'adj', it is unclear what you are 
>>> trying to achieve here.
>>>
 I would appreciate your comments on this issue.

 Sebastien

 # Pairs

 mydata<-data.frame(x=1:10,y=1:10)

 par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
mar=c(5 + 5,4,4,2)+0.1)

 pairs(mydata,oma=c(5 + 5,4,4,2))

 mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
 mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], 
 "figure")

 for (i in 1:4) {
 mtext(text=mylegend[i],
side = 1,
line = 3+i,
at = unit((1-mylegend.width)/2,"npc"),# centers the
 legend at the bottom
adj=0,
padj=0)}

 # plot

 mydata<-data.frame(x=1:10,y=1:10)

 par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
mar=c(5 + 5,4,4,2)+0.1)

 plot(mydata,oma=c(5 + 5,4,4,2))

 mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
 mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], 
 "figure")

 for (i in 1:4) {
 mtext(text=mylegend[i],
side = 1,
line = 3+i,
at = unit((1-mylegend.width)/2,"npc"),# should
 center the legend at the bottom but doesn't do it !
adj=0,
padj=0)}
>>>
>>
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The quadprog package

2007-09-03 Thread Moshe Olshansky
Hi Thomas,

On my computer the solution is (0,0,1,0,0,0,0) (within
machine accuracy) and it satisfies the constraints.

--- [EMAIL PROTECTED] wrote:

> Hi everybody,
> 
> I'm using Windows XP Prof, R 2.5.1 and a Pentium 4
> Processor.
> Now, I want to solve a quadratic optimization
> program (Portfolio Selection) with the quadprog
> package
> 
> I want to minimize (\omega'%*%\Sigma%*%\omega)
> Subject to
>   (1) \iota' %*% \omega = 1 (full investment)
>   (2) R'%*%\omega = \mu (predefined expectation
> value)
>   (3) \omega \ge 0 (no short sales).
> 
> Where 
>   \omega is a Nx1 vector of the weights invested in
> each asset
>   \Sigma is the NxN variance-covariance matrix
>   \iota is a 1xN vector of 1's
>   R' is a Nx1 vector of the expected returns
>   and
>   \mu is a number, the postualted return of the
> investor
> 
> I've done the following code but it doesn't make
> what I want it to do. The weights aren't all
> positive and the \mu isn't reached. What's wrong
> with my code?
> 
> Require(quadprog)
> Dmat<-diag(1,7,7)
> # muss als quadratische Matrix eingegeben werden
> Dmat
> dvec<-matrix(0,7,1) # muss als Spaltenvektor
> eingegeben werden
> dvec
> mu<-0 # (in Mio. €)
> bvec<-c(1,mu,matrix(0,7,1)) # muss als Spaltenvektor
> eingegeben werden
> bvec
> mu_r<-c(19.7,33.0,0.0,49.7, 82.5, 39.0,11.8)  
>
Amat<-matrix(c(matrix(1,1,7),7*mu_r,diag(1,7,7)),9,7,byrow=T)
> 
> # muss als Matrix angegeben werden, wie sie wirklich
> ist
> Amat
> meq<-2
>
loesung<-solve.QP(Dmat,dvec,Amat=t(Amat),bvec=bvec,meq=2)
> loesung
> 
> # Überprüfen, ob System richtig gelöst wurde
> loesung$solution %*% mu_r
> sum(loesung$solution)
> for (i in 1:7){
>   a<-loesung$solution[i]>=0
>   print(a)
> }
> 
> Thanks in advance for your answers.
> 
> __
> 
> Thomas Schwander
> 
> MVV Energie
> Konzern-Risikocontrolling
> 
> Telefon 0621 - 290-3115
> Telefax 0621 - 290-3664
> 
> E-Mail: [EMAIL PROTECTED] .  Internet:
> www.mvv.de
> MVV Energie AG . Luisenring 49 . 68159 Mannheim
> Handelsregister-Nr. HRB 1780, Amtsgericht Mannheim
> Vorsitzender des Aufsichtsrates: Herr Dr. Peter Kurz
> Vorstand: Dr. Rudolf Schulten (Vorsitzender) . 
> Matthias Brückmann . Dr. Werner Dub . Hans-Jürgen
> Farrenkopf 
> 
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> > __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
And if f has brace brackets surrounding the body then do this:

f <- function(x) { x*x }
deriv(body(f)[[2]], "x", func = TRUE)

If you are writing a general function you can do this:

e <- if (identical(body(f)[[1]], as.name("{"))) body(f)[[2]] else body(f)
deriv(e, "x", func = TRUE)


On 9/3/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> One improvement.  This returns a function directly without having
> to create a template and filling in its body:
>
> deriv(body(f), "x", func = TRUE)
>
> On 9/3/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > The problem is that brace brackets are not in the derivatives table.
> > Make sure you don't have any.
> >
> > On 9/3/07, Alberto Vieira Ferreira Monteiro <[EMAIL PROTECTED]> wrote:
> > > Gabor Grothendieck wrote:
> > > >
> > > > Actually in thinking about this its pretty easy to do it without Ryacas
> > > > too:
> > > >
> > > > Df <- f
> > > > body(Df) <- deriv(body(f), "x")
> > > > Df
> > > >
> > > This is weird.
> > >
> > > f <- function(x) { x^2 + 2*x+1 }
> > > Df <- f
> > > body(Df) <- deriv(body(f), "x") # error
> > >
> > > Also:
> > >
> > > f <- function(x) x^2 + 2 * x + 1
> > > Df <- f
> > > body(Df) <- deriv(body(f), "x") # ok
> > > D2f <- f
> > > body(D2f) <- deriv(body(Df), "x") # error
> > >
> > > Alberto Monteiro
> > >
> >
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to compute cross correlation

2007-09-03 Thread Moshe Olshansky
The simlest answer is that X and Y are two vectors of
length n then (un-normalized) cross correlation
between X and Y is sum(i=1 to n)
{X(i)-Xbar)*(Y(i)-Ybar)} where Xbar and Ybar are the
means of X and Y respectively.

You may need something different, so could you be more
specific? What do you mean by ASCII - they are in an
ASCII files?

Regards,

Moshe.

--- Yogesh Tiwari <[EMAIL PROTECTED]> wrote:

> Hello R Users,
> 
> How to compute cross correlation between two time
> series. Data is in ASCII
> format. I am using R on windows.
> 
> Many thanks,
> 
> Regards,
> Yogesh
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
One improvement.  This returns a function directly without having
to create a template and filling in its body:

deriv(body(f), "x", func = TRUE)

On 9/3/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> The problem is that brace brackets are not in the derivatives table.
> Make sure you don't have any.
>
> On 9/3/07, Alberto Vieira Ferreira Monteiro <[EMAIL PROTECTED]> wrote:
> > Gabor Grothendieck wrote:
> > >
> > > Actually in thinking about this its pretty easy to do it without Ryacas
> > > too:
> > >
> > > Df <- f
> > > body(Df) <- deriv(body(f), "x")
> > > Df
> > >
> > This is weird.
> >
> > f <- function(x) { x^2 + 2*x+1 }
> > Df <- f
> > body(Df) <- deriv(body(f), "x") # error
> >
> > Also:
> >
> > f <- function(x) x^2 + 2 * x + 1
> > Df <- f
> > body(Df) <- deriv(body(f), "x") # ok
> > D2f <- f
> > body(D2f) <- deriv(body(Df), "x") # error
> >
> > Alberto Monteiro
> >
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting predicted curves with log scale in lattice

2007-09-03 Thread Deepayan Sarkar
On 9/3/07, Ken Knoblauch <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was taken off guard by the following behavior in a lattice plot.
> I frequently want to add a predicted curve defined at more
> points than in the formula expression of xyplot.  There have
> been numerous examples of how to do this on r-help, but I
> still often struggle to make this work.  I just realized that
> specifying one of the axes on a log scale does not guarantee
> that the added data for a curve will automatically take that
> into account.  I don't know if this should be called a bug,

More like a possibly desirable feature that's missing.

> I haven't picked up an indication that would lead me to
> expect this in the documentation.

Yes, the documentation is a bit vague. I've changed it to the
following, which is hopefully clearer.

  'log' Controls whether the corresponding variable ('x' or
   'y') will be log transformed before being passed to the
   panel function.  Defaults to 'FALSE', in which case the
   data are not transformed.  Other possible values are any
   number that works as a base for taking logarithm, 'TRUE'
   (which is equivalent to 10), and '"e"' (for the natural
   logarithm).  As a side effect, the corresponding axis is
   labeled differently.  Note that this is a transformation
   of the data, not the axes.  Other than the axis
   labeling, using this feature is no different than
   transforming the data in the formula; e.g.,
   'scales=list(x = list(log = 2))' is equivalent to 'y ~
   log2(x)'.

-Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] element wise opertation between a vector and a list

2007-09-03 Thread Moshe Olshansky
Hi,

Getting your e is not a problem:

> a<- list(c(1,3),c(1,2),c(2,3))
>  b<-c(10,20,30)
> aa<-matrix(unlist(a),nrow=2)
> ee<-aa+rbind(b,b)
> e<-apply(ee,2,"sum")
> e
[1] 24 43 65
> 

But this will not work if different list members have
different number of elements.

--- Yongwan Chun <[EMAIL PROTECTED]> wrote:

> I want to try to get a result of element wise
> addition between a
> vector and a list. It can be done with "for
> statement." In order to
> reducing computing time, I have tried to avoid "for
> state." If anybody
> give me an idea, I would apprecite it much.
> 
> for example, with a & b as below lines,
> 
> a<- list(c(1,3),c(1,2),c(2,3))
> b<-c(10,20,30)
> 
> I would like to have a list (like "d") or a vector
> (like "e") as below.
> 
>
d<-list(c((1+10),(3+10)),c((1+20),(2+20)),c((2+30),(3+30)))
> e<- c((1+10)+(3+10),(1+20)+(2+20),(2+30)+(3+30))
> 
> Thanks,
> 
> 
> Yongwan Chun
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Ted Harding
On 03-Sep-07 21:45:40, Alberto Monteiro wrote:
> Rory Winston wrote:
>> 
>> I am currently (for pedagogical purposes) writing a simple numerical
>> analysis library in R. I have come unstuck when writing a simple
>> Newton-Raphson implementation, that looks like this:
>> 
>> f <- function(x) { 2*cos(x)^2 + 3*sin(x) +  0.5  }
>> 
>> root <- newton(f, tol=0.0001, N=20, a=1)
>> 
>> My issue is calculating the symbolic derivative of f() inside the 
>> newton() function. 
>>
> If it's pedagogical, maybe returning to basics could help.
> 
> What is f'(x)?
> 
> It's the limit of (f(x + h) - f(x)) / h when h tends to zero.
> 
> So, do it numerically: take a sufficiently small h and
> compute the limit. h must be small enough
> that h^2 f''(x) is much smaller than h f'(x), but big
> enough that f(x+h) is not f(x)
> 
> numerical.derivative <- function(f, x, h = 0.0001)
> {
>   # test something
>   (f(x + h) - f(x)) / h
> }
> 
> Ex:
> 
> numerical.derivative(cos, pi) = 5e-05 # should be -sin(pi) = 0
> numerical.derivative(sin, pi) = -1# ok
> numerical.derivative(exp, 0) = 1.5 # close enough
> numerical.derivative(sqrt, 0) = 100 # should be Inf
> 
> Alberto Monteiro

If you want to "go back to basics", it's worth noting that
for a function which has a derivative at x (which excludes
your sqrt(x) at x=0, despite the result you got above,
since only the 1-sided limit as h-->0+ exists):

   (f(x+h/2) - f(h-h/2))/h

is generally a far better approximation to f'(x) than is

   (f(x+h) - f(x))/h

since the term in   h^2 * f''(x)   in the expansion is
automatically eliminated! So the accuracy is O(h^2), not
O(h) as with yur definition.

num.deriv<-function(f,x,h=0.001){(f(x + h/2) - f(x-h/2))/h}

num.deriv(cos, pi)
## [1] 0

num.deriv(sin, pi)
[1] -1

but of course num.deriv(sqrt,0) won't work, since it requires
evaluation of sqrt(-h/2).

Hovever, other comparisons with your definition are possible:

numerical.derivative(sin,pi/3)-0.5
##[1] -4.33021e-05

num.deriv(sin,pi/3)-0.5
##[1] -2.083339e-08

Best wishes,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 04-Sep-07   Time: 00:10:42
-- XFMail --

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
The problem is that brace brackets are not in the derivatives table.
Make sure you don't have any.

On 9/3/07, Alberto Vieira Ferreira Monteiro <[EMAIL PROTECTED]> wrote:
> Gabor Grothendieck wrote:
> >
> > Actually in thinking about this its pretty easy to do it without Ryacas
> > too:
> >
> > Df <- f
> > body(Df) <- deriv(body(f), "x")
> > Df
> >
> This is weird.
>
> f <- function(x) { x^2 + 2*x+1 }
> Df <- f
> body(Df) <- deriv(body(f), "x") # error
>
> Also:
>
> f <- function(x) x^2 + 2 * x + 1
> Df <- f
> body(Df) <- deriv(body(f), "x") # ok
> D2f <- f
> body(D2f) <- deriv(body(Df), "x") # error
>
> Alberto Monteiro
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Alberto Vieira Ferreira Monteiro
Gabor Grothendieck wrote:
>
> Actually in thinking about this its pretty easy to do it without Ryacas
> too:
>
> Df <- f
> body(Df) <- deriv(body(f), "x")
> Df
>
This is weird.

f <- function(x) { x^2 + 2*x+1 }
Df <- f
body(Df) <- deriv(body(f), "x") # error

Also:

f <- function(x) x^2 + 2 * x + 1
Df <- f
body(Df) <- deriv(body(f), "x") # ok
D2f <- f
body(D2f) <- deriv(body(Df), "x") # error

Alberto Monteiro

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
Actually in thinking about this its pretty easy to do it without Ryacas too:

Df <- f
body(Df) <- deriv(body(f), "x")
Df


On 9/3/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> The Ryacas package can do that (but the function must be one line
> and it can't have brace brackets).  The first yacas call below registers f 
> with
> yacas, then we set up a function to act as a template to hold the
> derivative and then we set its body calling yacas again to take the
> derivative.
>
> library(Ryacas)
> f <- function(x)  2*cos(x)^2 + 3*sin(x) +  0.5
> yacas(f) # register f with yacas
> Df <- f
> body(Df) <- yacas(expression(deriv(f(x[[1]]
> Df
>
> Here is the output:
>
> > library(Ryacas)
> > f <- function(x)  2*cos(x)^2 + 3*sin(x) +  0.5
> > yacas(f)
> [1] "Starting Yacas!"
> expression(TRUE)
> > Df <- f
> > body(Df) <- yacas(expression(deriv(f(x[[1]]
> > Df
> function (x)
> 2 * (-2 * sin(x) * cos(x)) + 3 * cos(x)
>
> Also see:
>
> demo("Ryacas-Function")
>
> and the other demos, vignette and home page:
>   http://ryacas.googlecode.com
>
>
>
> On 9/3/07, Rory Winston <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > I am currently (for pedagogical purposes) writing a simple numerical
> > analysis library in R. I have come unstuck when writing a simple
> > Newton-Raphson implementation, that looks like this:
> >
> > f <- function(x) { 2*cos(x)^2 + 3*sin(x) +  0.5  }
> >
> > root <- newton(f, tol=0.0001, N=20, a=1)
> >
> > My issue is calculating the symbolic derivative of f() inside the newton()
> > function. I cant seem to get R to do this...I can of course calculate the
> > derivative by calling D() with an expression object containing the inner
> > function definition, but I would like to just define the function once and
> > then compute the derivative of the existing function. I have tried using
> > deriv() and as.call(), but I am evidently misusing them, as they dont do
> > what I want. Does anyone know how I can define a function, say foo, which
> > manipulates one or more arguments, and then refer to that function later in
> > my code in order to calculate a (partial) derivative?
> >
> > Thanks
> > Rory
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Gabor Grothendieck
The Ryacas package can do that (but the function must be one line
and it can't have brace brackets).  The first yacas call below registers f with
yacas, then we set up a function to act as a template to hold the
derivative and then we set its body calling yacas again to take the
derivative.

library(Ryacas)
f <- function(x)  2*cos(x)^2 + 3*sin(x) +  0.5
yacas(f) # register f with yacas
Df <- f
body(Df) <- yacas(expression(deriv(f(x[[1]]
Df

Here is the output:

> library(Ryacas)
> f <- function(x)  2*cos(x)^2 + 3*sin(x) +  0.5
> yacas(f)
[1] "Starting Yacas!"
expression(TRUE)
> Df <- f
> body(Df) <- yacas(expression(deriv(f(x[[1]]
> Df
function (x)
2 * (-2 * sin(x) * cos(x)) + 3 * cos(x)

Also see:

demo("Ryacas-Function")

and the other demos, vignette and home page:
   http://ryacas.googlecode.com



On 9/3/07, Rory Winston <[EMAIL PROTECTED]> wrote:
> Hi
>
> I am currently (for pedagogical purposes) writing a simple numerical
> analysis library in R. I have come unstuck when writing a simple
> Newton-Raphson implementation, that looks like this:
>
> f <- function(x) { 2*cos(x)^2 + 3*sin(x) +  0.5  }
>
> root <- newton(f, tol=0.0001, N=20, a=1)
>
> My issue is calculating the symbolic derivative of f() inside the newton()
> function. I cant seem to get R to do this...I can of course calculate the
> derivative by calling D() with an expression object containing the inner
> function definition, but I would like to just define the function once and
> then compute the derivative of the existing function. I have tried using
> deriv() and as.call(), but I am evidently misusing them, as they dont do
> what I want. Does anyone know how I can define a function, say foo, which
> manipulates one or more arguments, and then refer to that function later in
> my code in order to calculate a (partial) derivative?
>
> Thanks
> Rory
>
>[[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Derivative of a Function Expression

2007-09-03 Thread Alberto Monteiro
Rory Winston wrote:
> 
> I am currently (for pedagogical purposes) writing a simple numerical
> analysis library in R. I have come unstuck when writing a simple
> Newton-Raphson implementation, that looks like this:
> 
> f <- function(x) { 2*cos(x)^2 + 3*sin(x) +  0.5  }
> 
> root <- newton(f, tol=0.0001, N=20, a=1)
> 
> My issue is calculating the symbolic derivative of f() inside the 
> newton() function. 
>
If it's pedagogical, maybe returning to basics could help.

What is f'(x)?

It's the limit of (f(x + h) - f(x)) / h when h tends to zero.

So, do it numerically: take a sufficiently small h and
compute the limit. h must be small enough
that h^2 f''(x) is much smaller than h f'(x), but big
enough that f(x+h) is not f(x)

numerical.derivative <- function(f, x, h = 0.0001)
{
  # test something
  (f(x + h) - f(x)) / h
}

Ex:

numerical.derivative(cos, pi) = 5e-05 # should be -sin(pi) = 0
numerical.derivative(sin, pi) = -1# ok
numerical.derivative(exp, 0) = 1.5 # close enough
numerical.derivative(sqrt, 0) = 100 # should be Inf

Alberto Monteiro

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Derivative of a Function Expression

2007-09-03 Thread Rory Winston
Hi

I am currently (for pedagogical purposes) writing a simple numerical
analysis library in R. I have come unstuck when writing a simple
Newton-Raphson implementation, that looks like this:

f <- function(x) { 2*cos(x)^2 + 3*sin(x) +  0.5  }

root <- newton(f, tol=0.0001, N=20, a=1)

My issue is calculating the symbolic derivative of f() inside the newton()
function. I cant seem to get R to do this...I can of course calculate the
derivative by calling D() with an expression object containing the inner
function definition, but I would like to just define the function once and
then compute the derivative of the existing function. I have tried using
deriv() and as.call(), but I am evidently misusing them, as they dont do
what I want. Does anyone know how I can define a function, say foo, which
manipulates one or more arguments, and then refer to that function later in
my code in order to calculate a (partial) derivative?

Thanks
Rory

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to compute cross correlation

2007-09-03 Thread Yogesh Tiwari
Hello R Users,

How to compute cross correlation between two time series. Data is in ASCII
format. I am using R on windows.

Many thanks,

Regards,
Yogesh

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fitting Pattern-Mixture Models

2007-09-03 Thread Abdus Sattar
Dear R-user:
 
Do you know any R package that could be use for fitting a Pattern-Mixture 
models (PMM) please? I would appreciate if you could suggest me a R package for 
fitting PMM. 
 
Thank you very much, 
 
Sincerely, 
 
Sattar


   

Moody friends. Drama queens. Your life? Nope! - their life, your story. Pla

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ADV: Support and Services for R from Random Technologies, LLC.

2007-09-03 Thread Gregory R. Warnes

"The Power of Open-source R. The Confidence of Enterprise-Grade
 Support and Services."


Hello Rusers!

I am pleased to announce the immediate availability of the RStat  
Statistical
Software System from Random Technologies, LLC.

RStat couples the tremendous functionality and flexibility of the R
statistical software system with enterprise-level validation,  
documentation,
software support, and consulting services from Random Technologies, LLC.
RStat is available in several versions for a variety of needs:

 * RStat Personal - Personal and educational use on a single  
computer,
includes 90-day installation support - starting at $59.95

 * RStat Professional - Professional use on a single workstation,
   includes 1 full year of installation and usage technical support
   - Single user starting at $599.95

 * RStat Enterprise - Professional use in mission critical and  
regulated
   contexts, includes full technical support, sotware lifecycle
   documentation, testing scripts and validation templates. -  
Contact us
   for pricing and availability

and a range of system types:

 * Personal Computer - 32 bit Microsoft Windows
 * Workstation - 32 bit Microsoft Windows, 32 and 64 bit Linux,
Mac OS X (ppc and x86), and Solaris
 * Multi-user Server - 32 bit Microsoft Windows, 32 and 64 bit
Linux, Mac OS X Server, and Solaris
 * Multi-node Computational Cluster - Linux, Solaris

All versions include a binary installers of RStat, an integrated editor,
an extended set of supported packages, binary installers for all of the
compilers, build tools, and libraries necessary for developing and
building source R packages, and the complete set of contributed
packages from CRAN.

 

** Introductory Special: 20% Discount for orders placed before  
2007-09-15 **
 


Complete information on RStat and our other software packages  
(include RPy
for RStat, RSOAP for RStat, and BioConductor for RStat) is available  
at our
web site:

http://random-technologies-llc.com

or contact our sales team at:

[EMAIL PROTECTED]
USA & Canada Toll Free: 1-877-813-3266
Outside the USA & Canada: 1-585-419-6853


Cordially,

-Greg
Gregory R. Warnes, Ph.D.
Chief Scientist
Random Technologies, LLC.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Row-Echelon Form

2007-09-03 Thread Peter Danenberg
I was looking for an R-package that would reduce matrices to
row-echelon form, but Google was not my friend; any leads?

If not, I wonder if the problem could be expressed in terms of
constraint satisfaction...

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] match help

2007-09-03 Thread Dimitris Rizopoulos
try this:

x <- c(NA, NA, 1, NA, NA, NA, NA, 2, NA, NA)

na.ind <- is.na(x)
x[na.ind] <- rnorm(sum(na.ind))
x


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting [EMAIL PROTECTED]:

> In my code, I would like to replace entries in t with
> entries from a random normal distribution.
>
> n<-10
>> nl<-round(1.5+rexp(1,rate=2)
> rate=2))
>> nl
> [1] 2
>> r<-1:n
>> s<-sort(sample(r,nl))
>> t<-match(r,s)
>> r
>  [1]  1  2  3  4  5  6  7  8  9 10
>> s
> [1] 3 8
>> t
>  [1] NA NA  1 NA NA NA NA  2 NA NA
>
> t.random<-function(x) {for(i in 1:n) ifelse(x[i]!=NA,   
> x[i]<-rnorm(1), x[i]<-NA}
>
> t.random(t)
>
> t
>  [1] NA NA  1 NA NA NA NA  2 NA NA
>
>
>
> Thank you for your time,
>
>
> Diana Verzi
> Associate Professor of Mathematics
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] match help

2007-09-03 Thread dverzi
In my code, I would like to replace entries in t with 
entries from a random normal distribution.  

n<-10
> nl<-round(1.5+rexp(1,rate=2)
rate=2))
> nl
[1] 2
> r<-1:n 
> s<-sort(sample(r,nl))
> t<-match(r,s)
> r
 [1]  1  2  3  4  5  6  7  8  9 10
> s
[1] 3 8
>t
 [1] NA NA  1 NA NA NA NA  2 NA NA

t.random<-function(x) {for(i in 1:n) ifelse(x[i]!=NA, x[i]<-rnorm(1), x[i]<-NA}

t.random(t)

t
 [1] NA NA  1 NA NA NA NA  2 NA NA



Thank you for your time, 


Diana Verzi
Associate Professor of Mathematics

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Shame on me ...

2007-09-03 Thread Ptit_Bleu

I  read again "R pour les débutants" (for another problem) and I found the
answer to my question.
Sorry .
Have a nice week,
Ptiti Bleu.

Felix Andrews wrote:
> 
> x[[1]][4]
> 
> On 8/31/07, Ptit_Bleu <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I read the posts for 2 hours and ?list and tried many comninations but I
>> haven't found the answer to this basic question. So I decided to post my
>> question even if it is a silly one ...
>>
>> What is the instruction to retrieve, for example, the "D" of the first
>> list
>> ?
>> Thanks in advance,
>> Ptit Bleu.
>>
>>
>> > x<-list(LETTERS[1:5], LETTERS[10:20])
>> > x
>> [[1]]
>> [1] "A" "B" "C" "D" "E"
>>
>> [[2]]
>>  [1] "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T"
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-of-vocabulary-%3A-retrieve-element-of-a-list-of-a-list-tf4358872.html#a12422479
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> -- 
> Felix Andrews / 安福立
> PhD candidate
> Integrated Catchment Assessment and Management Centre
> The Fenner School of Environment and Society
> The Australian National University (Building 48A), ACT 0200
> Beijing Bag, Locked Bag 40, Kingston ACT 2604
> http://www.neurofractal.org/felix/
> voice:+86_1051404394 (in China)
> mobile:+86_13522529265 (in China)
> mobile:+61_410400963 (in Australia)
> xmpp:[EMAIL PROTECTED]
> 3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-of-vocabulary-%3A-retrieve-element-of-a-list-of-a-list-tf4358872.html#a12457151
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fitting Pattern-Mixture Models

2007-09-03 Thread Abdus Sattar
Dear R-user:
 
Do you know any R package that could be use for fitting a Pattern-Mixture model 
please? I would appreciate if you could suggest me a R package. 
 
Thank you very much, 
 
Sincerely, 
 
Sattar


   


that gives answers, not web links. 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different behavior of mtext

2007-09-03 Thread Prof Brian Ripley

On Mon, 3 Sep 2007, Sébastien wrote:

Ok, the problem is clear now. I did not get that 'user-coordinates' was 
refering to par("usr"), when I read the help of mtext. If I may ask you some 
additional questions:
- you mentioned a missing unit() call ; at which point should it be done in 
my code examples ?


Before it is used.  The problem is that I believe more than one package 
has a unit() function.


- could you give me some advices or helpful links about how to set up a grid 
viewport ? - and finally, probably a stupid question: is a gridview 
automatically set up when a plotting function is called ?


If you want to mix grid and base graphics, you need package gridBase, but 
really I would not advise a beginner to be using grid directly (that is, 
not via lattice to ggplot*).




Sebastien

PS: To answer to your final question, my goal is to center a block of legend 
text on the device but to align the text to the left of this block.


Prof Brian Ripley a écrit :

On Sun, 2 Sep 2007, Sébastien wrote:


Dear R Users,

I am quite surprised to see that mtext gives different results when it
is used with 'pairs' and with "plot'. In the two following codes, it
seems that the 'at' argument in mtext doesn't consider the same unit 
system.


It is stated to be in 'user coordinates'.  Your code does not work because 
unit() is missing.  If you mean the one from package grid, "npc" is not 
user coordinates (and refers to a grid viewport which you have not set up 
and coincidentally is the same as the initial user coordinate system to 
which pairs() has reverted).


Try par("usr") after your pairs() and plot() calls to see the difference.
Plotting a 2x2 array of plots _is_ different from plotting one, so this 
should be as expected.


Since centring is the default for 'adj', it is unclear what you are trying 
to achieve here.



I would appreciate your comments on this issue.

Sebastien

# Pairs

mydata<-data.frame(x=1:10,y=1:10)

par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
   mar=c(5 + 5,4,4,2)+0.1)

pairs(mydata,oma=c(5 + 5,4,4,2))

mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], "figure")

for (i in 1:4) {
mtext(text=mylegend[i],
   side = 1,
   line = 3+i,
   at = unit((1-mylegend.width)/2,"npc"),# centers the
legend at the bottom
   adj=0,
   padj=0)}

# plot

mydata<-data.frame(x=1:10,y=1:10)

par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
   mar=c(5 + 5,4,4,2)+0.1)

plot(mydata,oma=c(5 + 5,4,4,2))

mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], "figure")

for (i in 1:4) {
mtext(text=mylegend[i],
   side = 1,
   line = 3+i,
   at = unit((1-mylegend.width)/2,"npc"),# should
center the legend at the bottom but doesn't do it !
   adj=0,
   padj=0)}






--
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-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] using temporary arrays in R

2007-09-03 Thread Gabor Grothendieck
You can do it in a local, in a function or explicitly remove it.  Also
if you never assign it to a variable then it will be garbage collected as well

# 1
local({
print(gc())
x <- matrix(NA, 1000, 1000)
print(gc())
})
gc()

# 2
f <- function() {
print(gc())
x <- matrix(NA, 1000, 1000)
print(gc())
}
f()
gc()

# 3
gc()
x <- matrix(NA, 1000, 1000)
gc()
rm(x)
gc()

# 4
gc()
sum(matrix(1, 1000, 1000))
gc()



On 9/3/07, dxc13 <[EMAIL PROTECTED]> wrote:
>
> useR's,
>
> Is there a way to create a temporary array (or matrix) in R to hold values,
> then drop or delete that temporary array from memory once I do not need it
> anymore?
>
> I am working with multidimensional arrays/matrices and I frequently perform
> multiple operations on the same matrix and rename it to be another object.
> I want to be able to delete the older versions of the array/matrix to free
> up space.
>
> Thank you.
> --
> View this message in context: 
> http://www.nabble.com/using-temporary-arrays-in-R-tf4372367.html#a12462219
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different behavior of mtext

2007-09-03 Thread Sébastien
Ok, the problem is clear now. I did not get that 'user-coordinates' was 
refering to par("usr"), when I read the help of mtext. If I may ask you 
some additional questions:
- you mentioned a missing unit() call ; at which point should it be done 
in my code examples ?
- could you give me some advices or helpful links about how to set up a 
grid viewport ? 
- and finally, probably a stupid question: is a gridview automatically 
set up when a plotting function is called ?

Sebastien

PS: To answer to your final question, my goal is to center a block of 
legend text on the device but to align the text to the left of this block.

Prof Brian Ripley a écrit :
> On Sun, 2 Sep 2007, Sébastien wrote:
>
>> Dear R Users,
>>
>> I am quite surprised to see that mtext gives different results when it
>> is used with 'pairs' and with "plot'. In the two following codes, it
>> seems that the 'at' argument in mtext doesn't consider the same unit 
>> system.
>
> It is stated to be in 'user coordinates'.  Your code does not work 
> because unit() is missing.  If you mean the one from package grid, 
> "npc" is not user coordinates (and refers to a grid viewport which you 
> have not set up and coincidentally is the same as the initial user 
> coordinate system to which pairs() has reverted).
>
> Try par("usr") after your pairs() and plot() calls to see the difference.
> Plotting a 2x2 array of plots _is_ different from plotting one, so 
> this should be as expected.
>
> Since centring is the default for 'adj', it is unclear what you are 
> trying to achieve here.
>
>> I would appreciate your comments on this issue.
>>
>> Sebastien
>>
>> # Pairs
>>
>> mydata<-data.frame(x=1:10,y=1:10)
>>
>> par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
>>mar=c(5 + 5,4,4,2)+0.1)
>>
>> pairs(mydata,oma=c(5 + 5,4,4,2))
>>
>> mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
>> mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], 
>> "figure")
>>
>> for (i in 1:4) {
>> mtext(text=mylegend[i],
>>side = 1,
>>line = 3+i,
>>at = unit((1-mylegend.width)/2,"npc"),# centers the
>> legend at the bottom
>>adj=0,
>>padj=0)}
>>
>> # plot
>>
>> mydata<-data.frame(x=1:10,y=1:10)
>>
>> par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
>>mar=c(5 + 5,4,4,2)+0.1)
>>
>> plot(mydata,oma=c(5 + 5,4,4,2))
>>
>> mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
>> mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], 
>> "figure")
>>
>> for (i in 1:4) {
>> mtext(text=mylegend[i],
>>side = 1,
>>line = 3+i,
>>at = unit((1-mylegend.width)/2,"npc"),# should
>> center the legend at the bottom but doesn't do it !
>>adj=0,
>>padj=0)}
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] using temporary arrays in R

2007-09-03 Thread dxc13

useR's,

Is there a way to create a temporary array (or matrix) in R to hold values,
then drop or delete that temporary array from memory once I do not need it
anymore?

I am working with multidimensional arrays/matrices and I frequently perform
multiple operations on the same matrix and rename it to be another object. 
I want to be able to delete the older versions of the array/matrix to free
up space. 

Thank you. 
-- 
View this message in context: 
http://www.nabble.com/using-temporary-arrays-in-R-tf4372367.html#a12462219
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Legend issue with ggplot2

2007-09-03 Thread hadley wickham
Yes - all this stuff is currently rather undocumented.  Hopefully that
will change in the near future!

Hadley

On 9/3/07, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote:
> Thanks Hadley,
>
> I've been struggling with this all afternoon. But now it's working
> again. Since I'm using it in a script, the few extra lines don't bother
> me that much.
>
> Thierry
>
> 
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> [EMAIL PROTECTED]
> www.inbo.be
>
> Do not put your faith in what statistics say until you have carefully
> considered what they do not say.  ~William W. Watt
> A statistical analysis, properly conducted, is a delicate dissection of
> uncertainties, a surgery of suppositions. ~M.J.Moroney
>
>
>
> > -Oorspronkelijk bericht-
> > Van: hadley wickham [mailto:[EMAIL PROTECTED]
> > Verzonden: maandag 3 september 2007 15:15
> > Aan: ONKELINX, Thierry
> > CC: r-help@stat.math.ethz.ch
> > Onderwerp: Re: [R] Legend issue with ggplot2
> >
> > On 9/3/07, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote:
> > > Dear useRs,
> > >
> > > I'm struggling with the new version of ggplot2. In the previous
> > > version I did something like this. But now this yield an
> > error (object "fill"
> > > not found).
> > >
> > > library(ggplot2)
> > > dummy <- data.frame(x = rep(1:10, 4), group = gl(4, 10)) dummy$y <-
> > > dummy$x * rnorm(4)[dummy$group] + 5 * rnorm(4)[dummy$group]
> > dummy$min
> > > <- dummy$y - 5 dummy$max <- dummy$y + 5 ggplot(data =
> > dummy, aes(x =
> > > x, max = max, min = min, fill = group)) +
> > > geom_ribbon() + geom_line(aes(y = max, colour = fill)) +
> > > geom_line(aes(y = min, colour = fill))
> >
> > Strange - I'm not sure why that ever worked.
> >
> > > When I adjust the code to the line below, it works again. But this
> > > time with two legend keys for "group". Any idea how to display only
> > > one legend key for group? The ggplot-code aboved yielded
> > only on legend key.
> > >
> > > ggplot(data = dummy, aes(x = x, max = max, min = min,
> > colour = group,
> > > fill = group)) + geom_ribbon() + geom_line(aes(y = max)) +
> > > geom_line(aes(y = min))
> >
> > You can manually turn off one of the legends:
> >
> > sc <- scale_colour_discrete()
> > sc$legend <- FALSE
> > .last_plot + sc
> >
> > It's not very convenient though, so I'll think about how to
> > do this automatically.  The legends need to be more
> > intelligent about only displaying the minimum necessary.
> >
> > Hadley
> >
>


-- 
http://had.co.nz/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting predicted curves with log scale in lattice

2007-09-03 Thread hadley wickham
Hi Ken,

Alternatively, you could use ggplot2:

install.packages("ggplot2")
library(ggplot2)

qplot(LL, RR, data=ds1, facets = . ~ FF) + geom_line(data=ds2) + scale_x_log10()

It is very hard to get transformed scales working correctly, and it's
something I had to spend a lot of time on in between ggplot 1 and 2.

Hadley


On 9/3/07, Ken Knoblauch <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was taken off guard by the following behavior in a lattice plot.
> I frequently want to add a predicted curve defined at more
> points than in the formula expression of xyplot.  There have
> been numerous examples of how to do this on r-help, but I
> still often struggle to make this work.  I just realized that
> specifying one of the axes on a log scale does not guarantee
> that the added data for a curve will automatically take that
> into account.  I don't know if this should be called a bug,
> I haven't picked up an indication that would lead me to
> expect this in the documentation.  I admit that if I had a
> deeper understanding of lattice and/or grid, it might be
> clearer why...  Here is a toy example illustrating the behavior
> (there may be a more efficient way to do this),
>
> ds1 <- data.frame( RR = rep(seq(0, 1, len = 5)^2, 2) +
> rnorm(10, sd = 0.1),
>LL = rep(10^seq(1, 5), 2),
>FF = factor(rep(letters[1:2], each = 5))
>)
> ds2 <- data.frame(RR = rep(seq(0, 1, len = 20)^2, 2),
>   LL = rep(10^seq(1, 5, len = 20), 2),
>FF = factor(rep(letters[1:2], each = 20))
>)
> library(lattice)
> xyplot(RR ~ LL | FF, ds1,
> scales = list(x = list(log = TRUE)),
> aspect = "xy",
> subscripts = TRUE,
> ID = ds2$FF,
> panel = function(x, y, subscripts, ID, ...) {
> w <- unique(ds1$FF[subscripts])
> llines(log10(ds2$LL[ID == w]), ds2$RR[ID == w], ...)
> panel.xyplot(x, y, ...)
> }
> )
>
> Note that the x-variable of llines must be logged to plot the correct values
> and so the scales argument seems to apply only to the x, y arguments
> passed to the panel function.
>
> Thank you.
>
> best,
>
> Ken
>
>
> --
> Ken Knoblauch
> Inserm U846
> Institut Cellule Souche et Cerveau
> Département Neurosciences Intégratives
> 18 avenue du Doyen Lépine
> 69500 Bron
> France
> tel: +33 (0)4 72 91 34 77
> fax: +33 (0)4 72 91 34 61
> portable: +33 (0)6 84 10 64 10
> http://www.lyon.inserm.fr/846/english.html
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
http://had.co.nz/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Legend issue with ggplot2

2007-09-03 Thread ONKELINX, Thierry
Thanks Hadley,

I've been struggling with this all afternoon. But now it's working
again. Since I'm using it in a script, the few extra lines don't bother
me that much.

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

 

> -Oorspronkelijk bericht-
> Van: hadley wickham [mailto:[EMAIL PROTECTED] 
> Verzonden: maandag 3 september 2007 15:15
> Aan: ONKELINX, Thierry
> CC: r-help@stat.math.ethz.ch
> Onderwerp: Re: [R] Legend issue with ggplot2
> 
> On 9/3/07, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote:
> > Dear useRs,
> >
> > I'm struggling with the new version of ggplot2. In the previous 
> > version I did something like this. But now this yield an 
> error (object "fill"
> > not found).
> >
> > library(ggplot2)
> > dummy <- data.frame(x = rep(1:10, 4), group = gl(4, 10)) dummy$y <- 
> > dummy$x * rnorm(4)[dummy$group] + 5 * rnorm(4)[dummy$group] 
> dummy$min 
> > <- dummy$y - 5 dummy$max <- dummy$y + 5 ggplot(data = 
> dummy, aes(x = 
> > x, max = max, min = min, fill = group)) +
> > geom_ribbon() + geom_line(aes(y = max, colour = fill)) + 
> > geom_line(aes(y = min, colour = fill))
> 
> Strange - I'm not sure why that ever worked.
> 
> > When I adjust the code to the line below, it works again. But this 
> > time with two legend keys for "group". Any idea how to display only 
> > one legend key for group? The ggplot-code aboved yielded 
> only on legend key.
> >
> > ggplot(data = dummy, aes(x = x, max = max, min = min, 
> colour = group, 
> > fill = group)) + geom_ribbon() + geom_line(aes(y = max)) + 
> > geom_line(aes(y = min))
> 
> You can manually turn off one of the legends:
> 
> sc <- scale_colour_discrete()
> sc$legend <- FALSE
> .last_plot + sc
> 
> It's not very convenient though, so I'll think about how to 
> do this automatically.  The legends need to be more 
> intelligent about only displaying the minimum necessary.
> 
> Hadley
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Legend issue with ggplot2

2007-09-03 Thread hadley wickham
On 9/3/07, ONKELINX, Thierry <[EMAIL PROTECTED]> wrote:
> Dear useRs,
>
> I'm struggling with the new version of ggplot2. In the previous version
> I did something like this. But now this yield an error (object "fill"
> not found).
>
> library(ggplot2)
> dummy <- data.frame(x = rep(1:10, 4), group = gl(4, 10))
> dummy$y <- dummy$x * rnorm(4)[dummy$group] + 5 * rnorm(4)[dummy$group]
> dummy$min <- dummy$y - 5
> dummy$max <- dummy$y + 5
> ggplot(data = dummy, aes(x = x, max = max, min = min, fill = group)) +
> geom_ribbon() + geom_line(aes(y = max, colour = fill)) + geom_line(aes(y
> = min, colour = fill))

Strange - I'm not sure why that ever worked.

> When I adjust the code to the line below, it works again. But this time
> with two legend keys for "group". Any idea how to display only one
> legend key for group? The ggplot-code aboved yielded only on legend key.
>
> ggplot(data = dummy, aes(x = x, max = max, min = min, colour = group,
> fill = group)) + geom_ribbon() + geom_line(aes(y = max)) +
> geom_line(aes(y = min))

You can manually turn off one of the legends:

sc <- scale_colour_discrete()
sc$legend <- FALSE
.last_plot + sc

It's not very convenient though, so I'll think about how to do this
automatically.  The legends need to be more intelligent about only
displaying the minimum necessary.

Hadley

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Graphic representation of model results

2007-09-03 Thread Guillaume Brutel
Apologies for cross-posting but I think my previous mail was in HTML 
(which is inadvisable for the help mailing list).


Dear list members,

I am facing difficulties in making a graphics that could show visually 
results of a model.

I have tested the effects of 4 quantitative variables (Z1, Z2, Z3, Z4) 
on a variable Y using a weighted mixed effects GLM with weights W (using 
the glmmPQL function). I applied a blocking approach using factor F2 
nested in factor F1 as a grouping structure on a random intercept in the 
GLMM . The fixed effect are the 4 independent variables simultaneously 
fitted in the inferential model (Z1, ..., Z4).

Three out of the four variables have a significant effect on Y (Z1, Z2, 
Z3).

My problem is that I want to show graphically my results. If I plot Y 
according to the Z1, this won't take into account the effect of e.g. Z2 
and the fact that the analysis was weighted by W (same with adding a 
weighted lowess). If I add a regression line with the estimate for Z1 
obtained from the weighted mixed effect GLM, this doesn't not properly 
reflect the analysis (since they were obtained with simultaneously 
fitting Z2 and Z3). Making various 3D figures don't help because the 
various plots are too difficult to read. A conditional plot wouldn't 
show the trends analyzed by the weighted model...

Any advice (about the conceptual way of making the figure and the 
function(s) that can be used) is welcome.
Thank you very much,
Regards,

Guillaume Brutel.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Ask alpha cronbach and Hoyt method

2007-09-03 Thread Doran, Harold
Hoyt's ANOVA and Cronbach's alpha are the same statistic. I think there is an 
example in Nunnally and Bernstein. I have no idea what a W statistic is. Can 
you explain that?


-Original Message-
From: [EMAIL PROTECTED] on behalf of thamrin hm
Sent: Mon 9/3/2007 3:37 AM
To: R-help@stat.math.ethz.ch
Subject: [R] Ask alpha cronbach and Hoyt method
 
Dear all, i need help about comparing 2 alpha cronbach. How to derive W 
statistic. Are alpha cronbach and Hoyt's method using ANOVA identical? Thank 
you for your help.

Regards

   
-
Luggage? GPS? Comic books? 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Graphic representation of model results

2007-09-03 Thread Guillaume Brutel
Dear list members,

I am facing difficulties in making a graphics that could show visually 
results of a model.

I have tested the effects of 4 quantitative variables (Z1, Z2, Z3, Z4) 
on a variable Y using a weighted mixed effects GLM with weights W (using 
the glmmPQL function). I applied a blocking approach using factor F2 
nested in factor F1 as a grouping structure on a random intercept in the 
GLMM . The fixed effect are the 4 independent variables simultaneously 
fitted in the inferential model (Z1, ..., Z4).

Three out of the four variables have a significant effect on Y (Z1, Z2, Z3).

My problem is that I want to show graphically my results. If I plot Y 
according to the Z1, this won't take into account the effect of e.g. Z2 
and the fact that the analysis was weighted by W (same with adding a 
weighted lowess). If I add a regression line with the estimate for Z1 
obtained from the weighted mixed effect GLM, this doesn't not properly 
reflect the analysis (since they were obtained with simultaneously 
fitting Z2 and Z3). Making various 3D figures don't help because the 
various plots are too difficult to read.

Any advice (about the conceptual way of making the figure and the 
function(s) that can be used) is welcome.
Thank you very much,
Regards,

Guillaume Brutel.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting predicted curves with log scale in lattice

2007-09-03 Thread Ken Knoblauch
Excuse me for forgetting sessionInfo (below)
Ken Knoblauch  lyon.inserm.fr> writes:
> I was taken off guard by the following behavior in a lattice plot.
> I frequently want to add a predicted curve defined at more
> points than in the formula expression of xyplot.  There have
> been numerous examples of how to do this on r-help, but I
> still often struggle to make this work.  I just realized that
> specifying one of the axes on a log scale does not guarantee
> that the added data for a curve will automatically take that
> into account.  I don't know if this should be called a bug,
> I haven't picked up an indication that would lead me to
> expect this in the documentation.  I admit that if I had a
> deeper understanding of lattice and/or grid, it might be
> clearer why...  Here is a toy example illustrating the behavior
> (there may be a more efficient way to do this),
> 
> ds1 <- data.frame( RR = rep(seq(0, 1, len = 5)^2, 2) +
>   rnorm(10, sd = 0.1),
>  LL = rep(10^seq(1, 5), 2),
>  FF = factor(rep(letters[1:2], each = 5))
>  )
> ds2 <- data.frame(RR = rep(seq(0, 1, len = 20)^2, 2),
> LL = rep(10^seq(1, 5, len = 20), 2),
>  FF = factor(rep(letters[1:2], each = 20))
>  )
> library(lattice)
> xyplot(RR ~ LL | FF, ds1,
>   scales = list(x = list(log = TRUE)),
>   aspect = "xy",
>   subscripts = TRUE,
>   ID = ds2$FF,
>   panel = function(x, y, subscripts, ID, ...) {
>   w <- unique(ds1$FF[subscripts])
>   llines(log10(ds2$LL[ID == w]), ds2$RR[ID == w], ...)
>   panel.xyplot(x, y, ...)
>   }
>   )
> 
> Note that the x-variable of llines must be logged to plot the correct values
> and so the scales argument seems to apply only to the x, y arguments
> passed to the panel function.
R version 2.5.1 Patched (2007-08-26 r42657) 
i386-apple-darwin8.10.1 

locale:
C

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"  "methods"  
[7] "base" 

other attached packages:
 lattice 
"0.16-3" 

but this also occurs for
R version 2.6.0 Under development (unstable) (2007-08-26 r42657) 
i386-apple-darwin8.10.1 

locale:
C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

other attached packages:
[1] lattice_0.16-3

loaded via a namespace (and not attached):
[1] grid_2.6.0

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] NAs in indices

2007-09-03 Thread Jim Lemon
Muenchen, Robert A (Bob) wrote:
> Hi All,
> 
> I'm fiddling with an program to read a text file containing periods that
> SAS uses for missing values. I know that if I had the original SAS data
> set instead of a text file, R would handle this conversion for me. 
> 
> Data frames do not allow missing values in their indices but vectors do.
> Why is that? A search of the error message points out the problem and
> solution but not why they differ. A simplified program that demonstrates
> the issue is below.
> 
> Thanks,
> Bob
> 
> # Here's a data frame that has both periods and NAs.
> # I want sex to remain character for now.
> 
> sex=c("m","f",".",NA)
> x=c(1,2,3,NA)
> myDF <- data.frame(sex,x,stringsAsFactors=F)
> rm(sex,x)
> myDF
> 
> # Substituting NA into data frame does not work
> # due to NAs in the indices. The error message is:
> # missing values are not allowed in subscripted assignments of data
> frames
> 
> myDF[ myDF$sex==".", "sex" ] <- NA
> myDF
> 
Hi Bob,
What happens is that you don't get FALSE when you ask if something==NA, 
you get NA. However, if you use the "which" function, it cleans up the 
NAs for you and the result of that should do what you want.

myDF[which(myDF$sex=="."),"sex"]<-NA

Jim

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Legend issue with ggplot2

2007-09-03 Thread ONKELINX, Thierry
Dear useRs,

I'm struggling with the new version of ggplot2. In the previous version
I did something like this. But now this yield an error (object "fill"
not found).

library(ggplot2)
dummy <- data.frame(x = rep(1:10, 4), group = gl(4, 10))
dummy$y <- dummy$x * rnorm(4)[dummy$group] + 5 * rnorm(4)[dummy$group]
dummy$min <- dummy$y - 5
dummy$max <- dummy$y + 5
ggplot(data = dummy, aes(x = x, max = max, min = min, fill = group)) +
geom_ribbon() + geom_line(aes(y = max, colour = fill)) + geom_line(aes(y
= min, colour = fill))

When I adjust the code to the line below, it works again. But this time
with two legend keys for "group". Any idea how to display only one
legend key for group? The ggplot-code aboved yielded only on legend key.

ggplot(data = dummy, aes(x = x, max = max, min = min, colour = group,
fill = group)) + geom_ribbon() + geom_line(aes(y = max)) +
geom_line(aes(y = min))

Thanks,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plotting a table under a dendrogram

2007-09-03 Thread Daniel Brewer
Dear all,
I have produced a dendrogram using hclust and I would like to plot it
with a table of data associated with each sample aligned with the
"leaves" of the tree.  Is there a reasonable way to do this in R, or am
I better lining it up in a image program.

Many thanks

-- 
**
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addre...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to sub-sample a variable on another file coordinates

2007-09-03 Thread Paul Hiemstra
Dear Yogesh,

This question seems more appropriate for the r-sig-geo mailing list 
(https://stat.ethz.ch/mailman/listinfo/r-sig-geo).

The sampling of the netcdf files can be done by using the overlay 
function from the sp-package (available on CRAN). You would have to read 
both the netcdf file and the ASCII file into the spatial classes 
presented by sp (SpatialGrid for the CO2 data (I assume that it is a 
grid) and SpatialPoints for the ASCII data). This could be done using 
the rgdal-package.

good luck!

Paul

Yogesh Tiwari schreef:
>  Hello 'R' Users,
>
> I have a monthly mean CO2 necdf data file defined on 1x1 lat by lon
> coordinate. I want to sub-sample this variable CO2 on the coordinates
> of another ASCII data file. The coordinates of another ASCII data file are
> as:
>
>-24.01 152.06 -18.58 150.19 -13.46 148.35 -8.29 147.03 -3.14 146.19 1.53
> 145.59 7.08 145.33 12.25 145.02 17.46 144.31 22.44 142.35 27.53 141.26 33.04
> 140.15 -23.49 152.07 -18.56 150.18 -13.41 150.14 -8.24 150.04 -3.07 149.21
> 2.05 148.31 7.19 147.45 12.37 147.03 17.53 146.21 22.56 144.47 28.04 143.38
> 32.54 142.26
>
> Kindly anybody can help on this.
>
> Many thanks,
>
> Cheers,
> Yogesh
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: element wise opertation between a vector and a list

2007-09-03 Thread Petr PIKAL
Hi

 mapply("+", a, b)

Regards
Petr

[EMAIL PROTECTED] napsal dne 03.09.2007 08:36:10:

> I want to try to get a result of element wise addition between a
> vector and a list. It can be done with "for statement." In order to
> reducing computing time, I have tried to avoid "for state." If anybody
> give me an idea, I would apprecite it much.
> 
> for example, with a & b as below lines,
> 
> a<- list(c(1,3),c(1,2),c(2,3))
> b<-c(10,20,30)
> 
> I would like to have a list (like "d") or a vector (like "e") as below.
> 
> d<-list(c((1+10),(3+10)),c((1+20),(2+20)),c((2+30),(3+30)))
> e<- c((1+10)+(3+10),(1+20)+(2+20),(2+30)+(3+30))
> 
> Thanks,
> 
> 
> Yongwan Chun
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] plotting predicted curves with log scale in lattice

2007-09-03 Thread Ken Knoblauch
Hi,

I was taken off guard by the following behavior in a lattice plot.
I frequently want to add a predicted curve defined at more
points than in the formula expression of xyplot.  There have
been numerous examples of how to do this on r-help, but I
still often struggle to make this work.  I just realized that
specifying one of the axes on a log scale does not guarantee
that the added data for a curve will automatically take that
into account.  I don't know if this should be called a bug,
I haven't picked up an indication that would lead me to
expect this in the documentation.  I admit that if I had a
deeper understanding of lattice and/or grid, it might be
clearer why...  Here is a toy example illustrating the behavior
(there may be a more efficient way to do this),

ds1 <- data.frame( RR = rep(seq(0, 1, len = 5)^2, 2) +
rnorm(10, sd = 0.1),
   LL = rep(10^seq(1, 5), 2),
   FF = factor(rep(letters[1:2], each = 5))
   )
ds2 <- data.frame(RR = rep(seq(0, 1, len = 20)^2, 2),
  LL = rep(10^seq(1, 5, len = 20), 2),
   FF = factor(rep(letters[1:2], each = 20))
   )
library(lattice)
xyplot(RR ~ LL | FF, ds1,
scales = list(x = list(log = TRUE)),
aspect = "xy",
subscripts = TRUE,
ID = ds2$FF,
panel = function(x, y, subscripts, ID, ...) {
w <- unique(ds1$FF[subscripts])
llines(log10(ds2$LL[ID == w]), ds2$RR[ID == w], ...)
panel.xyplot(x, y, ...)
}
)

Note that the x-variable of llines must be logged to plot the correct values
and so the scales argument seems to apply only to the x, y arguments
passed to the panel function.

Thank you.

best,

Ken


-- 
Ken Knoblauch
Inserm U846
Institut Cellule Souche et Cerveau
Département Neurosciences Intégratives
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.lyon.inserm.fr/846/english.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The quadprog package

2007-09-03 Thread Berwin A Turlach
G'day Thomas,

On Mon, 3 Sep 2007 10:08:08 +0200
<[EMAIL PROTECTED]> wrote:

> What's wrong with my code?
> 
> Require(quadprog)

library(quadprog) ? :)

> Dmat<-diag(1,7,7)
> # muss als quadratische Matrix eingegeben werden
> Dmat
> dvec<-matrix(0,7,1) # muss als Spaltenvektor eingegeben werden
> dvec
> mu<-0 # (in Mio. €)
> bvec<-c(1,mu,matrix(0,7,1)) # muss als Spaltenvektor eingegeben werden
> bvec
> mu_r<-c(19.7,33.0,0.0,49.7, 82.5, 39.0,11.8)  
> Amat<-matrix(c(matrix(1,1,7),7*mu_r,diag(1,7,7)),9,7,byrow=T) 
> # muss als Matrix angegeben werden, wie sie wirklich ist
> Amat
> meq<-2
> loesung<-solve.QP(Dmat,dvec,Amat=t(Amat),bvec=bvec,meq=2)

With the commands above, I get on my system:

> loesung<-solve.QP(Dmat,dvec,Amat=t(Amat),bvec=bvec,meq=2)
Error in solve.QP(Dmat, dvec, Amat = t(Amat), bvec = bvec, meq = 2) : 
constraints are inconsistent, no solution!

Which is a bit strange, since Dmat is the identity matrix, so there
should be little room for numerical problems.

OTOH, it is known that the Goldfarb-Idnani algorithm can have problem
in rare occasions if the problem is "ill-scaled"; see the work of
Powell. 

Changing the definition of Amat to

> Amat<-matrix(c(matrix(1,1,7),mu_r,diag(1,7,7)),9,7,byrow=T) 

leads to a successful call to solve.QP.  And since mu=0, I really
wonder why you scaled up the vector mu_r by a factor of 7 when putting
it into Amat :)

> loesung<-solve.QP(Dmat,dvec,Amat=t(Amat),bvec=bvec,meq=2)

Now, with the solution I obtained the rest of your commands show:

> loesung$solution %*% mu_r
 [,1]
[1,] 6.068172e-15
> sum(loesung$solution)
[1] 1
> for (i in 1:7){
a<-loesung$solution[i]>=0
print(a)
}
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] FALSE
[1] FALSE
[1] TRUE
 
But:

>  for (i in 1:7){
a<-loesung$solution[i]>=- .Machine$double.eps*1000
print(a)
}

[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE
[1] TRUE

>  for (i in 1:7) print(loesung$solution[i])
[1] 0
[1] 0
[1] 1
[1] 0
[1] -4.669169e-17
[1] -1.436586e-17
[1] 8.881784e-16

This is a consequence of finite precision arithmetic.  Just as you
should not compare to numeric numbers directly for equality but rather
that the absolute value of their difference is smaller than an
appropriate chosen threshold, you should not check whether a number is
bigger or equal to zero, but whether it is bigger or equal to an
appropriately chosen negative threshold.  More information are given in
FAQ 7.31.

HTH.

Cheers,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability+65 6515 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore 
6 Science Drive 2, Blk S16, Level 7  e-mail: [EMAIL PROTECTED]
Singapore 117546http://www.stat.nus.edu.sg/~statba

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] some problems with "linebuffer"; was: Bug?

2007-09-03 Thread Uwe Ligges


Johanna Hasmats wrote:
> Ok, attaching all files. You need to run it in the following order:
> 
> parse.RData
> 
> Korrelation.RData   I have reduced this script to only include the error
> part.
> 
> 
> Input files are in the following order:
> 
> oligo.prest.out for parse.RData to work. Produces the next input file 
> 
> oligolista for Korrelation.RData to work, which also needs the input file
> 
> 8_SkBr _13433630.gpr. 
> 
> 
> The function GenePixData can be found in the aroma package.
> 
> Thank you for your help,


1. Package kth is unavailable for us.

2. I do not know anything about a package called "aroma", it is neither 
on CRAN nor in the BioC repositories.

3. Can you please also try to make your example smaller?

4. The convention is to save R objects in .Rdata files, but to have R 
code in .R files.


Uwe Ligges




> Johanna
> 
> 
> 
> 
> 
> 
> 
> 
> ***
> Johanna Hasmats
> Royal Institute of Technology 
> AlbaNova University Center 
> Stockholm Center for Physics, Astronomy and Biotechnology 
> School of Molecular Biotechnology 
> Department of Gene Technology 
> Visiting address: 
> Roslagstullsbacken 21, Floor 3 
> 106 91 Stockholm, Sweden 
> Delivering address: 
> Roslagsvägen 30 B
> 104 06 Stockholm, Sweden 
> Phone (office) +46 8 553 783 44 
> Fax + 46 8 553 784 81 
> ** 
> 
> -Original Message-
> From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 31, 2007 8:12 PM
> To: Uwe Ligges
> Cc: Johanna Hasmats; r-help@stat.math.ethz.ch
> Subject: Re: [R] Bug?
> 
> On 8/31/07, Uwe Ligges <[EMAIL PROTECTED]> wrote:
>>
>> Johanna Hasmats wrote:
>>> Hi!
>>>
>>>
>>>
>>> How can I get around in R 2.5.1 in Windows:
>>>
>>>
>>>
>>> Error in strsplit(linebuffer, "") : object "linebuffer" not found
>>
>> Why should this be a bug in R, if you have no object named "linebuffer"
>> in the environments that are on the search path.
> 
> This sounds like it could have something to do with the command
> completion mechanism through package rcompgen (which does use an
> internal variable called 'linebuffer'). Since this doesn't seem to be
> a common problem, you need to give us instructions on how to reproduce
> it.
> 
> -Deepayan

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] by group problem

2007-09-03 Thread Petr PIKAL
Hi

now I understand better what you want

topN.2 <- function(data,n=5) data[order(data[,3], decreasing=T),][1:n]

# I presume data is data frame with 3 columns and the third is percent

lapply(split(data,data$state), topN.2)

Regards

Petr

[EMAIL PROTECTED]

"Cory Nissen" <[EMAIL PROTECTED]> napsal dne 31.08.2007 17:21:01:

> That didn't work for me...
> 
> Here's some data to help with a solution.
> 
> data <- NULL
> data$state <- c(rep("Illinois", 10), rep("Wisconsin", 10))
> data$county <- c("Adams", "Brown", "Bureau", "Cass", "Champaign", 
>  "Christian", "Coles", "De Witt", "Douglas", "Edgar",
>  "Adams", "Ashland", "Barron", "Bayfield", "Buffalo", 
>  "Burnett", "Chippewa", "Clark", "Columbia", "Crawford")
> data$percentOld <- c(17.554849, 16.826594, 18.196593, 17.139242, 
8.743823,
>  17.862746, 13.747967, 16.626302, 15.258940, 
18.984435,
>  19.347022, 17.814436, 16.903067, 17.632781, 
16.659305,
>  20.337817, 14.293354, 17.252820, 15.647179, 
16.825596)
> 
> return something like this...
> $Illinois
> "Edgar"
> 18.984435
> "Bureau"
> 18.196593
> ...
> $Wisconsin
> "Burnett"
> 20.33782
> "Adams"
> 19.34702
> ...
> 
> My Solution gives...
> topN <- function(column, n=5)
>   {
> column <- sort(column, decreasing=T)
> return(column[1:n])
>   }
> tapply(data$percentOld, data$state, topN)
> 
> $Illinois
> [1] 18.98444 18.19659 17.86275 17.55485 17.13924
> $Wisconsin
> [1] 20.33782 19.34702 17.81444 17.63278 17.25282
> 
> I get an error with this try...
> aggregate(data$percentOld, list(data$state, data$county), topN)
> 
> Error in aggregate.data.frame(as.data.frame(x), ...) : 
>  'FUN' must always return a scalar
> 
> Thanks
> 
> cn
> 
> 
> 
> From: Petr PIKAL [mailto:[EMAIL PROTECTED]
> Sent: Fri 8/31/2007 8:15 AM
> To: Cory Nissen
> Cc: r-help@stat.math.ethz.ch
> Subject: Odp: [R] by group problem

> Hi
> 
> > I am working with census data.  My columns of interest are...
> >
> > PercentOld - the percentage of people in each county that are over 65
> > County - the county in each state
> > State - the state in the US
> >
> > There are about 3100 rows, with each row corresponding to a county
> within a state.
> >
> > I want to return the top five "PercentOld" by state.  But I want the
> County
> > and the Value.
> >
> > I tried this...
> >
> > topN <- function(column, n=5)
> >   {
> > column <- sort(column, decreasing=T)
> > return(column[1:n])
> >   }
> > top5PerState <- tapply(data$percentOld, data$STATE, topN)
> 
> Try
> 
> aggregate(data$PercentOld, list(data$State, data$County), topN)
> 
> Regards
> Petr
> 
> 
> >
> > But this only returns the value for "percentOld" per state, I also 
want
> the
> > corresponding County.
> >
> > I think I'm close, but I just can't get it...
> >
> > Thanks
> >
> > cn
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Incomplete Gamma function

2007-09-03 Thread Robin Hankin
Hello Ted


thanks for the comments below.

You point out below some less-than-perfect aspects of
some of my documentation (bizarrely, this is not the first time that  
this
has happened.  The real problem is  that *other people* insist on
reading the docs, when as everyone knows, the real purpose
of documentation is to remind the *developer* what he's done ;-).

The issue with the gsl_sf_ prefix is interesting.  I decided that
having an R function named "gsl_sf_gamma_inc()" would be
a bit long-winded, so I removed the prefix.  I did this elsewhere
too, notably Bessel.Rd, because I felt that the GSL naming scheme
was sufficiently distinct from R's in the case of Bessel functions to
obviate typing "gsl_sf_" every single time.

But as you point out, this is potentially confusing to a user; as a
developer, one tends to see the Rd file as one of a number of files
that one must edit, and in the case of  the gsl library, the R and C
code is very regimented and has adequate inline comments.  But
I'd lost sight of the fact that many users' sole source of documentation
is the Rd files.  And in the  case of gsl, the documentation is just a
pointer to ams-55 via gsl-ref [the GSL reference manual].  I now
suspect that my short function definitions have unnecessarily
obscured that audit trail.

What I think I'll do  (read "will add to my to-do-list")
is to (eg) define R function gsl_sf_gamma_inc()
and then define gamma_inc <- gsl_sf_gamma_inc
and add appropriate aliases to the docs.

Then I could deprecate gsl_inc(); and then possibly defunct them.

Anyone got any comments on this?  Do other package developers
have any experiences of making functions defunct that would be  
interesting?
How long do folk leave functions deprecated before defuncting them?

best wishes

Robin


On 1 Sep 2007, at 15:50, (Ted Harding) wrote:


[snip]

>
> In the documenation for the Gamma functions in the gsl package,
> it is simply stated
>
>   All functions [including gamma_inc()] as documented in the
>   GSL reference manual section 7.19.
>
> There is no function named "gamma_inc" in the GSL reference
> manual. See:
>
> http://www.gnu.org/software/gsl/manual/html_node/Function-Index.html
>
> All functions are named like "gsl_sf_gamma_inc", so
> presumably this is what is intended; in which case it computes
> "the unnormalized incomplete Gamma Function
>  \Gamma(a,x) = \int_x^\infty dt t^{a-1} \exp(-t)
>  for a real and x >= 0."
>
> And again that is clear enough -- once you track it down!
>
> In many places in the R documentation (including the "?" pages)
> people have taken the trouble to spell out mathematical definitions
> (where these can be given in reasonable space). Especially in cases
> like the Incomplete Gamma and Beta functions, where there can be
> dispute over what is meant (see above), it is surely wise to spell
> it out!
>
> Best wishes to all,
> Ted.
>
>>> On 31 Aug 2007, at 00:29, [EMAIL PROTECTED] wrote:
>>>
 Hello

 I am trying to evaluate an Incomplete gamma function
 in R. Library Zipfr gives the Igamma function. From
 Mathematica, I have:

 "Gamma[a, z] is the incomplete gamma function."

 In[16]: Gamma[9,11.1]
 Out[16]: 9000.5

 Trying the same in R, I get

> Igamma(9,11.1)
 [1] 31319.5
 OR
> Igamma(11.1,9)
 [1] 1300998

 I know I have to understand the theory and the math
 behind it rather than just ask for help, but while I
 am trying to do that (and only taking baby steps, I
 must admit), I was hoping someone could help me out.

 Regard

 Kris.
>
> 
> E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
> Fax-to-email: +44 (0)870 094 0861
> Date: 01-Sep-07   Time: 15:49:57
> -- XFMail --
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] The quadprog package

2007-09-03 Thread thomas.schwander
Hi everybody,

I'm using Windows XP Prof, R 2.5.1 and a Pentium 4 Processor.
Now, I want to solve a quadratic optimization program (Portfolio Selection) 
with the quadprog package

I want to minimize (\omega'%*%\Sigma%*%\omega)
Subject to
(1) \iota' %*% \omega = 1 (full investment)
(2) R'%*%\omega = \mu (predefined expectation value)
(3) \omega \ge 0 (no short sales).

Where 
\omega is a Nx1 vector of the weights invested in each asset
\Sigma is the NxN variance-covariance matrix
\iota is a 1xN vector of 1's
R' is a Nx1 vector of the expected returns
and
\mu is a number, the postualted return of the investor

I've done the following code but it doesn't make what I want it to do. The 
weights aren't all positive and the \mu isn't reached. What's wrong with my 
code?

Require(quadprog)
Dmat<-diag(1,7,7)
# muss als quadratische Matrix eingegeben werden
Dmat
dvec<-matrix(0,7,1) # muss als Spaltenvektor eingegeben werden
dvec
mu<-0 # (in Mio. €)
bvec<-c(1,mu,matrix(0,7,1)) # muss als Spaltenvektor eingegeben werden
bvec
mu_r<-c(19.7,33.0,0.0,49.7, 82.5, 39.0,11.8)
Amat<-matrix(c(matrix(1,1,7),7*mu_r,diag(1,7,7)),9,7,byrow=T) 
# muss als Matrix angegeben werden, wie sie wirklich ist
Amat
meq<-2
loesung<-solve.QP(Dmat,dvec,Amat=t(Amat),bvec=bvec,meq=2)
loesung

# Überprüfen, ob System richtig gelöst wurde
loesung$solution %*% mu_r
sum(loesung$solution)
for (i in 1:7){
a<-loesung$solution[i]>=0
print(a)
}

Thanks in advance for your answers.

__

Thomas Schwander

MVV Energie
Konzern-Risikocontrolling

Telefon 0621 - 290-3115
Telefax 0621 - 290-3664

E-Mail: [EMAIL PROTECTED] .  Internet: www.mvv.de
MVV Energie AG . Luisenring 49 . 68159 Mannheim
Handelsregister-Nr. HRB 1780, Amtsgericht Mannheim
Vorsitzender des Aufsichtsrates: Herr Dr. Peter Kurz
Vorstand: Dr. Rudolf Schulten (Vorsitzender) .  Matthias Brückmann . Dr. 
Werner Dub . Hans-Jürgen Farrenkopf 




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] adehabitat version 1.7

2007-09-03 Thread Clément Calenge
Dear all,

I have uploaded to CRAN the version 1.7 of the package 'adehabitat'. 
Significant changes are listed below:

* The Brownian bridge kernel estimation algorithm has been greatly 
improved. It now takes more than 80% less time than the previous 
version. A new function "liker" has also been added, which estimates the 
one of the two smoothing parameters of the bridge kernel using a maximum 
likelihood approach (recommended in Horn et al., Ecology, in press). 
Examples of the help page demonstrate the use and interest of this 
function. Comparison between kernelbb and the Visual basic algorithm 
provided in the paper of Horn et al. returned consistent results.

* The function kernelUD has also been improved. It now takes more than 
50% less time than the previous version. In addition the "grid" argument 
of this function, now also allows a list of objects of class "asc" to be 
passed as grid where the UD should be estimated.

Happy testing,

Clément Calenge.

-- 
Clément CALENGE
LBBE - UMR CNRS 5558 - Université Claude Bernard Lyon 1 - FRANCE
tel. (+33) 04.72.43.27.57
fax. (+33) 04.72.43.13.88

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Ask alpha cronbach and Hoyt method

2007-09-03 Thread thamrin hm
Dear all, i need help about comparing 2 alpha cronbach. How to derive W 
statistic. Are alpha cronbach and Hoyt's method using ANOVA identical? Thank 
you for your help.

Regards

   
-
Luggage? GPS? Comic books? 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different behavior of mtext

2007-09-03 Thread Prof Brian Ripley

On Sun, 2 Sep 2007, Sébastien wrote:


Dear R Users,

I am quite surprised to see that mtext gives different results when it
is used with 'pairs' and with "plot'. In the two following codes, it
seems that the 'at' argument in mtext doesn't consider the same unit system.


It is stated to be in 'user coordinates'.  Your code does not work because 
unit() is missing.  If you mean the one from package grid, "npc" is not 
user coordinates (and refers to a grid viewport which you have not set up 
and coincidentally is the same as the initial user coordinate system to 
which pairs() has reverted).


Try par("usr") after your pairs() and plot() calls to see the difference.
Plotting a 2x2 array of plots _is_ different from plotting one, so this 
should be as expected.


Since centring is the default for 'adj', it is unclear what you are trying 
to achieve here.



I would appreciate your comments on this issue.

Sebastien

# Pairs

mydata<-data.frame(x=1:10,y=1:10)

par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
   mar=c(5 + 5,4,4,2)+0.1)

pairs(mydata,oma=c(5 + 5,4,4,2))

mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], "figure")

for (i in 1:4) {
mtext(text=mylegend[i],
   side = 1,
   line = 3+i,
   at = unit((1-mylegend.width)/2,"npc"),# centers the
legend at the bottom
   adj=0,
   padj=0)}

# plot

mydata<-data.frame(x=1:10,y=1:10)

par(cex.main=1, cex.axis=1, cex.lab=1, lwd=1,
   mar=c(5 + 5,4,4,2)+0.1)

plot(mydata,oma=c(5 + 5,4,4,2))

mylegend<-c("mylegend A","mylegend B","mylegend C","mylegend test")
mylegend.width = strwidth(mylegend[which.max(nchar(mylegend))], "figure")

for (i in 1:4) {
mtext(text=mylegend[i],
   side = 1,
   line = 3+i,
   at = unit((1-mylegend.width)/2,"npc"),# should
center the legend at the bottom but doesn't do it !
   adj=0,
   padj=0)}


--
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-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] sin(pi)?

2007-09-03 Thread Prof Brian Ripley
On Mon, 3 Sep 2007, Nguyen Dinh Nguyen wrote:

> Dear all,
> I found something strange when calculating sin of pi value

What exactly?  Comments below on two guesses as to what.

> sin(pi)
> [1] 1.224606e-16

That is non-zero due to using finite-precision arithmetic.  The number 
stored as pi is not exactly the mathematics quantity, and so 
sin(representation of pi) should be non-zero (although there is also 
rounding error in calculating what it is).

Note that sin() is computed by your C runtime, so the exact result will 
depend on your OS, compiler and possibly CPU.

> pi
> [1] 3.141593

That is the printout of pi to the default 7 significant digits.  R knows 
pi to higher accuracy:

> print(pi, digits=16)
[1] 3.141592653589793
> sin(3.141592653589793)
[1] 1.224606e-16

but note that printing to 16 digits and reading back in might not have 
given the same number, but happens to for pi at least on my system:

> 3.141592653589793 == pi
[1] TRUE


> sin(3.141593)
> [1] -3.464102e-07
>
> Any help and comment should be appreciated.
> Regards
> Nguyen
>
> 
> Nguyen Dinh Nguyen
> Garvan Institute of Medical Research
> Sydney, Australia
>
>

-- 
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-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] sin(pi)?

2007-09-03 Thread Simon Blomberg
Umm. pi has been rounded to 6 decimal places in the second example. So
it isn't surprising that the results differ. sin(pi) is not zero, as it
also has been rounded, and you can't represent irrational numbers
exactly in a numerical form anyway. R agrees with Octave:

octave:1> sin(pi)
ans =  1.2246e-16
octave:2> sin(3.141593)
ans =  -3.4641e-07
octave:3> 

To paraphrase someone else on this list: I think it is strange that you
think it is strange.

Simon.

As someone On Mon, 2007-09-03 at 16:43 +1000, Nguyen Dinh Nguyen wrote:
> Dear all,
> I found something strange when calculating sin of pi value
> sin(pi)
> [1] 1.224606e-16
> 
>  pi
> [1] 3.141593
> 
>  sin(3.141593)
> [1] -3.464102e-07
> 
> Any help and comment should be appreciated. 
> Regards
> Nguyen
> 
> 
> Nguyen Dinh Nguyen
> Garvan Institute of Medical Research
> Sydney, Australia
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] sin(pi)?

2007-09-03 Thread Peter Dalgaard
Nguyen Dinh Nguyen wrote:
> Dear all,
> I found something strange when calculating sin of pi value
> sin(pi)
> [1] 1.224606e-16
>
>  pi
> [1] 3.141593
>
>  sin(3.141593)
> [1] -3.464102e-07
>
> Any help and comment should be appreciated. 
> Regards
> Nguyen
>   
Well, sin(pi) is theoretically zero, so you are just seeing zero at two 
different levels of precision.

The built-in pi has more digits than it displays:

 > pi
[1] 3.141593
 > pi - 3.141593
[1] -3.464102e-07
 > print(pi, digits=20)
[1] 3.141592653589793

> 
> Nguyen Dinh Nguyen
> Garvan Institute of Medical Research
> Sydney, Australia
>
>   
> 
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] sin(pi)?

2007-09-03 Thread Olivier Delaigue *

> sin(3.141592653589793)
[1] 1.224606e-16

Regards,

Olivier Delaigue



Nguyen Dinh Nguyen wrote:
> 
> Dear all,
> I found something strange when calculating sin of pi value
> sin(pi)
> [1] 1.224606e-16
> 
>  pi
> [1] 3.141593
> 
>  sin(3.141593)
> [1] -3.464102e-07
> 
> Any help and comment should be appreciated. 
> Regards
> Nguyen
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/sin%28pi%29--tf4370556.html#a12457181
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.