Re: [R] fail in adding library in new version.

2005-07-12 Thread Henrik Bengtsson
I've prepared a Windows batch file that gives you a fresh Windows 
commando prompt setup for R. You can download it from:

   http://www.maths.lth.se/help/R/RCMDprompt.bat

It has instructions how and where to download necessary software such as 
'hhc'. The script setup the PATH assuming default installation of 
everything so with some luck you can build R packages right away. If 
not, follow the instructions and modify some of the variables.

/Henrik


On 7/13/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
 > If you start up a fresh batch console and run
 >   hhc
 > do you get the usage message?  If not you still have a path problem.
 > You only need hhc.exe so just copy that file into any directory on your
 > path -- issue the command:
 >
 > path
 >
 > to find out which directories you can copy it into (and also post the
 > output of the path command if you still have problem) -- with this
 > approach you won't have to set your path to the
 > HTML Help Workshop.
 >
 > On 7/12/05, Ivy_Li <[EMAIL PROTECTED]> wrote:
 > > Dear All,
 > >I have downloaded the htmlhelp.exe from InterNet. Install it 
into the path "C:\Program Files\HTML Help Workshop\". I add this path 
into the "Control Panel -> System -> Advanced -> Environment Variables 
-> Path -> Variable".
 > >But it still exist error.
 > >-- Making package example 
 > >  adding build stamp to DESCRIPTION
 > >  installing R files
 > >  installing data files
 > >  installing man source files
 > >  installing indices
 > >  not zipping data
 > >  installing help
 > > >>> Building/Updating help pages for package 'example'
 > > Formats: text html latex example chm
 > >  d texthtmllatex 
example
 > >  e texthtmllatex 
example
 > >  f texthtmllatex 
example
 > >  g texthtmllatex 
example
 > >hhc: not found
 > >cp: cannot stat 
`D:/PROGRA~1/R/rw2011/example/chm/example.chm': No such file or
 > >directory
 > >make[1]: *** [chm-example] Error 1
 > >make: *** [pkg-example] Error 2
 > >*** Installation of example failed ***
 > >
 > >Removing 'D:/PROGRA~1/R/rw2011/library/example'
 > >Restoring previous 'D:/PROGRA~1/R/rw2011/library/example'
 > >
 > > I don't know why it can not find the "hhc" file.
 > > Please tell me which step is wrong.
 > > Thank you for helping me!
 > > ^_^
 > >
 > > -原始邮件-
 > > 发件人: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
 > > 发送时间: 2005年7月13日 9:32
 > > 收件人: Ivy_Li
 > > 抄送: Duncan Murdoch; r-help@stat.math.ethz.ch
 > > 主题: Re: 答复: [R] fail in adding library in new version.
 > >
 > >
 > > hhc.exe is the Microsoft help compiler.  You have to download it 
and put
 > > it somewhere in your path.
 > >
 > > On 7/12/05, Ivy_Li <[EMAIL PROTECTED]> wrote:
 > > > Dear all,
 > > > I really appreciate your help. I think I have a little 
advancement. ^_^
 > > > Now I use the package.skeleton() function to create a template. I 
type:
 > > >f <- function(x,y) x+y
 > > >g <- function(x,y) x-y
 > > >d <- data.frame(a=1, b=2)
 > > >e <- rnorm(1000)
 > > >package.skeleton(list=c("f","g","d","e"), name="example")
 > > >
 > > > in R. I know it will create a folder named "example" in the path 
of "\R\rw2011\" I opened this folder, its format is similar as other 
library. Then I modify it "DESCRIPTION" file:
 > > >Package: example
 > > >Version: 1.0-1
 > > >Date: 2005-07-09
 > > >Title: My first function
 > > >Author: Ivy <[EMAIL PROTECTED]>
 > > >Maintainer: Ivy <[EMAIL PROTECTED]>
 > > >Description: simple sum and subtract
 > > >License: GPL version 2 or later
 > > >Depends: R (>= 1.9), stats, graphics, utils
 > > >
 > > > I don't whether I should modify other "README" file.
 > > > When I enter the Dos environment, at first, into the D:\>, I type 
the following code:
 > > >cd Program Files\R\rw2011\
 > > >bin\R CMD install /example
 > > >
 > > > Well, there appeared error:
 > > >-- Making package example 
 > > >  adding build stamp to DESCRIPTION
 > > >  installing R files
 > > >  installing data files
 > > >  installing man source files
 > > >  installing indices
 > > >  not zipping data
 > > >  installing help
 > > > >>> Building/Updating help pages for package 'example'
 > > > Formats: text html latex example chm
 > > >  d texthtmllatex 
   example chm
 > > >  e texthtmllatex 
   example chm
 > > >  f texthtmll

Re: [R] write.foreign, SPSS on Mac OS X

2005-07-12 Thread Prof Brian Ripley
On Tue, 12 Jul 2005, EJ Nikelski wrote:

> I have jut installed the foreign package (v 0.8-8) on my OS X
> machine, and have a bit of a problem writing out a data frame in SPSS
> format. Specifically, the code file (the .sps format file) seems to
> write 3 unprintable hex values instead of double quotes. For example, in
> the following output ...
>
> VALUE LABELS
> /
> immDel
> 1 ###1###
>  2 ###2###
>  3 ###3###
>
>  ... emacs tells me that the left-sided ### are the hex codes E2 80 9C,
> on the right we have E2 80 9D. I am supposing that I should be seeing
> double-quotes here? Interestingly, the data file, which also contains a
> quoted field, writes out the quotes without any problem. Does anyone
> have any ideas?

An idea. Those are left and right double quotes in UTF-8 and since MacOS X
is usually in a UTF-8 locale they should be printable.  However, I suspect 
that SPSS is expecting ASCII double quotation marks.

You haven't told us what you did, but I guess you used
write.foreign(package="SPSS").  That calls writeForeignSPSS which contains 
calls to dQuote(), and the latter are wrong if ASCII quotation marks are 
needed.

A quick workaround is to use a non-UTF-8 locale: how you do that on ypur 
OS depends on how you run R so please ask advice on the R-sig-mac list.

-- 
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


Re: [R] exact values for p-values

2005-07-12 Thread Stephen D. Weigand

On Jul 11, 2005, at 11:47 AM, S.O. Nyangoma wrote:

> Hi there,
> If I do an lm, I get p-vlues as
>
> p-value: < 2.2e-16
>
> Suppose am interested in exact value such as
>
> p-value = 1.6e-16 (note = and not <)
>
> How do I go about it?
>
> stephen
>

I think you're seeing a very small p-value after it has been formatted 
by format.pval.
Consider:

options(digits = 6)
format.pval(0)
# [1] "< 2.2e-16"

format.pval(0, eps = 1e-20)
# [1] "< 1e-20"

you could access the p-values you're interested following this example:

x <- 1:100
y <- x + rnorm(100, 0, 1)
f <- lm(y ~ x)
ff <- summary(f)
print(ff)
ff$coefficients
Pvals <- ff$coefficients[, 4]
print(Pvals, digits = 20)

Hope this helps,

Stephen

__
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


Re: 答复: 答复: [R] fail in add ing library in new version.

2005-07-12 Thread Gabor Grothendieck
If you start up a fresh batch console and run
  hhc
do you get the usage message?  If not you still have a path problem.  
You only need hhc.exe so just copy that file into any directory on your 
path -- issue the command:

path

to find out which directories you can copy it into (and also post the 
output of the path command if you still have problem) -- with this
approach you won't have to set your path to the 
HTML Help Workshop.

On 7/12/05, Ivy_Li <[EMAIL PROTECTED]> wrote:
> Dear All,
>I have downloaded the htmlhelp.exe from InterNet. Install it into the 
> path "C:\Program Files\HTML Help Workshop\". I add this path into the 
> "Control Panel -> System -> Advanced -> Environment Variables -> Path -> 
> Variable".
>But it still exist error.
>-- Making package example 
>  adding build stamp to DESCRIPTION
>  installing R files
>  installing data files
>  installing man source files
>  installing indices
>  not zipping data
>  installing help
> >>> Building/Updating help pages for package 'example'
> Formats: text html latex example chm
>  d texthtmllatex   example
>  e texthtmllatex   example
>  f texthtmllatex   example
>  g texthtmllatex   example
>hhc: not found
>cp: cannot stat `D:/PROGRA~1/R/rw2011/example/chm/example.chm': No 
> such file or
>directory
>make[1]: *** [chm-example] Error 1
>make: *** [pkg-example] Error 2
>*** Installation of example failed ***
> 
>Removing 'D:/PROGRA~1/R/rw2011/library/example'
>Restoring previous 'D:/PROGRA~1/R/rw2011/library/example'
> 
> I don't know why it can not find the "hhc" file.
> Please tell me which step is wrong.
> Thank you for helping me!
> ^_^
> 
> -原始邮件-
> 发件人: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
> 发送时间: 2005年7月13日 9:32
> 收件人: Ivy_Li
> 抄送: Duncan Murdoch; r-help@stat.math.ethz.ch
> 主题: Re: 答复: [R] fail in adding library in new version.
> 
> 
> hhc.exe is the Microsoft help compiler.  You have to download it and put
> it somewhere in your path.
> 
> On 7/12/05, Ivy_Li <[EMAIL PROTECTED]> wrote:
> > Dear all,
> > I really appreciate your help. I think I have a little advancement. ^_^
> > Now I use the package.skeleton() function to create a template. I type:
> >f <- function(x,y) x+y
> >g <- function(x,y) x-y
> >d <- data.frame(a=1, b=2)
> >e <- rnorm(1000)
> >package.skeleton(list=c("f","g","d","e"), name="example")
> >
> > in R. I know it will create a folder named "example" in the path of 
> > "\R\rw2011\" I opened this folder, its format is similar as other library. 
> > Then I modify it "DESCRIPTION" file:
> >Package: example
> >Version: 1.0-1
> >Date: 2005-07-09
> >Title: My first function
> >Author: Ivy <[EMAIL PROTECTED]>
> >Maintainer: Ivy <[EMAIL PROTECTED]>
> >Description: simple sum and subtract
> >License: GPL version 2 or later
> >Depends: R (>= 1.9), stats, graphics, utils
> >
> > I don't whether I should modify other "README" file.
> > When I enter the Dos environment, at first, into the D:\>, I type the 
> > following code:
> >cd Program Files\R\rw2011\
> >bin\R CMD install /example
> >
> > Well, there appeared error:
> >-- Making package example 
> >  adding build stamp to DESCRIPTION
> >  installing R files
> >  installing data files
> >  installing man source files
> >  installing indices
> >  not zipping data
> >  installing help
> > >>> Building/Updating help pages for package 'example'
> > Formats: text html latex example chm
> >  d texthtmllatex   example 
> > chm
> >  e texthtmllatex   example 
> > chm
> >  f texthtmllatex   example 
> > chm
> > missing link(s):  ~~fun~~
> >  g texthtmllatex   example 
> > chm
> > missing link(s):  ~~fun~~
> >hhc: not found
> >cp: cannot stat `D:/PROGRA~1/R/rw2011/example/chm/example.chm': No 
> > such file or
> >directory
> >make[1]: *** [chm-example] Error 1
> >make: *** [pkg-example] Error 2
> >*** Installation of example failed ***
> >
> >Removing 'D:/PROGRA~1/R/rw2011/library/example'
> >
> > That's it. I have to consult every R expert. Please help to solve this 
> > issue. Thank you very much!
> >
> >
> >
> >
> > -原始邮件-
> > 发件人: Duncan Murdoch [mailto:[EMAIL PROTECTED]
> > 发送时间: 2005年7月8日 19:34
> 

Re: [R] help: how to plot a circle on the scatter plot

2005-07-12 Thread Mulholland, Tom
You will find previous discussion about pairs in this list. There are limits on 
what has been included within the functionality, but you can write your own 
panel functions. Here's a starting point.

x <- runif(100)
dim(x) <- c(20,5)

panel.cor1 <- function(x,y,...){
  mycor<- cor(x,y)
  if (mycor > 0){
  points(x,y, pch = 20, col = "red",cex = 0.5)
  } else {
  points(x,y, pch = 20, col = "grey",cex = 0.5)
  }
}

panel.cor2 <- function(x,y,...){
  mycor<- cor(x,y)
  if (mycor > 0){
  points(x,y, pch = 20, col = "blue",cex = 0.5)
  hpts <- chull(x,y)
  hpts <- c(hpts, hpts[1])
  lines(x[hpts],y[hpts],col = "red")
  } else {
  points(x,y, pch = 20, col = "grey",cex = 0.5)
  }
}


pairs(x,lower.panel = panel.cor1,upper.panel = panel.cor2)


Tom

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of wu sz
> Sent: Wednesday, 13 July 2005 9:48 AM
> To: questions about R
> Subject: [R] help: how to plot a circle on the scatter plot
> 
> 
> Hello,
> 
> I have a data set with 15 variables, and use "pairs" to plot the
> scatterplot of this data set. Then I want to plot some circles on the
> small pictures with high correlation(e.g. > 0.9).
> 
> First, I use "cor" to obtain the corresponding correlation matrix (x)
> for this scatterplot.
> 
> Second, use "seq(along = x)[x > 0.9]" to find the positions of the
> small pictures with 0.9 correlation, but "seq" can just find the
> sequence position row by row for the matrix, not a real position (like
> "rowNumber, colNumber"). Is any function for that?
> 
> Third, use "Symbols" to plot the circle on these small pictures, but
> seems it can't do that. Also, I don't know how to adjust the thickness
> and radius of the circle plotted by "Symbols".
> 
> Please give me some ideas!
> 
> Thank you,
> Shengzhe
> 
> __
> 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
>

__
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


答复: 答复: [R] fail in adding library i n new version.

2005-07-12 Thread Ivy_Li
Dear All,
I have downloaded the htmlhelp.exe from InterNet. Install it into the 
path "C:\Program Files\HTML Help Workshop\". I add this path into the "Control 
Panel -> System -> Advanced -> Environment Variables -> Path -> Variable". 
But it still exist error.
-- Making package example 
  adding build stamp to DESCRIPTION
  installing R files
  installing data files
  installing man source files
  installing indices
  not zipping data
  installing help
 >>> Building/Updating help pages for package 'example'
 Formats: text html latex example chm
  d texthtmllatex   example
  e texthtmllatex   example
  f texthtmllatex   example
  g texthtmllatex   example
hhc: not found
cp: cannot stat `D:/PROGRA~1/R/rw2011/example/chm/example.chm': No such 
file or
directory
make[1]: *** [chm-example] Error 1
make: *** [pkg-example] Error 2
*** Installation of example failed ***

Removing 'D:/PROGRA~1/R/rw2011/library/example'
Restoring previous 'D:/PROGRA~1/R/rw2011/library/example'

I don't know why it can not find the "hhc" file. 
Please tell me which step is wrong.
Thank you for helping me!
^_^

-原始邮件-
发件人: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
发送时间: 2005年7月13日 9:32
收件人: Ivy_Li
抄送: Duncan Murdoch; r-help@stat.math.ethz.ch
主题: Re: 答复: [R] fail in adding library in new version.


hhc.exe is the Microsoft help compiler.  You have to download it and put
it somewhere in your path.

On 7/12/05, Ivy_Li <[EMAIL PROTECTED]> wrote:
> Dear all,
> I really appreciate your help. I think I have a little advancement. ^_^
> Now I use the package.skeleton() function to create a template. I type:
>f <- function(x,y) x+y
>g <- function(x,y) x-y
>d <- data.frame(a=1, b=2)
>e <- rnorm(1000)
>package.skeleton(list=c("f","g","d","e"), name="example")
> 
> in R. I know it will create a folder named "example" in the path of 
> "\R\rw2011\" I opened this folder, its format is similar as other library. 
> Then I modify it "DESCRIPTION" file:
>Package: example
>Version: 1.0-1
>Date: 2005-07-09
>Title: My first function
>Author: Ivy <[EMAIL PROTECTED]>
>Maintainer: Ivy <[EMAIL PROTECTED]>
>Description: simple sum and subtract
>License: GPL version 2 or later
>Depends: R (>= 1.9), stats, graphics, utils
> 
> I don't whether I should modify other "README" file.
> When I enter the Dos environment, at first, into the D:\>, I type the 
> following code:
>cd Program Files\R\rw2011\
>bin\R CMD install /example
> 
> Well, there appeared error:
>-- Making package example 
>  adding build stamp to DESCRIPTION
>  installing R files
>  installing data files
>  installing man source files
>  installing indices
>  not zipping data
>  installing help
> >>> Building/Updating help pages for package 'example'
> Formats: text html latex example chm
>  d texthtmllatex   example chm
>  e texthtmllatex   example chm
>  f texthtmllatex   example chm
> missing link(s):  ~~fun~~
>  g texthtmllatex   example chm
> missing link(s):  ~~fun~~
>hhc: not found
>cp: cannot stat `D:/PROGRA~1/R/rw2011/example/chm/example.chm': No 
> such file or
>directory
>make[1]: *** [chm-example] Error 1
>make: *** [pkg-example] Error 2
>*** Installation of example failed ***
> 
>Removing 'D:/PROGRA~1/R/rw2011/library/example'
> 
> That's it. I have to consult every R expert. Please help to solve this issue. 
> Thank you very much!
> 
> 
> 
> 
> -原始邮件-
> 发件人: Duncan Murdoch [mailto:[EMAIL PROTECTED]
> 发送时间: 2005年7月8日 19:34
> 收件人: Ivy_Li
> 抄送: r-help@stat.math.ethz.ch
> 主题: Re: [R] fail in adding library in new version.
> 
> 
> Ivy_Li wrote:
> > Dear all,
> >   I really appreciate your help. I think I have a little advancement. 
> > ^_^
> >
> >   When I enter the Dos environment, at first, into the D:\>, I type the 
> > following code:
> > cd Program Files\R\rw2011\
> > bin\R CMD install /example
> >
> > "example" is in the d:\, which include the R folder and "DESCRIPTION" file, 
> > But I wrote nothing in the "DESCRIPTION" file. Actually, I don't know what 
> > I should write in it.
> 
> Read the R Extensions manual for a detailed description.  You can use
> the package.skeleton() function 

Re: [R] How to use the function "plot" as Matlab?

2005-07-12 Thread Gabor Grothendieck
On 7/12/05, klebyn <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> How to use the function plot to produce graphs as Matlab?
> example in Matlab:
> 
> a = [1,2,5,3,6,8,1,7];
> b = [1,7,2,9,2,3,4,5];
> plot(a,'b')
> hold
> plot(b,'r')
> 
> 
> How to make the same in R-package ?
> 
> I am trying something thus:
> 
> a <- c(1,2,5,3,6,8,1,7)
> c(1,7,2,9,2,3,4,5) -> b
> 
> a;b
> 
> plot(a,t="l",col="blue")
> plot(b,t="l",col="red")
> 

In addition to the Intro manual and other usual sources (see the posting guide 
at the end of every post to this list) see:
   http://cran.r-project.org/doc/contrib/R-and-octave-2.txt

__
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


[R] How to use the function "plot" as Matlab?

2005-07-12 Thread klebyn
Hello,

How to use the function plot to produce graphs as Matlab?
example in Matlab:

a = [1,2,5,3,6,8,1,7];
b = [1,7,2,9,2,3,4,5];
plot(a,'b')
hold
plot(b,'r')


How to make the same in R-package ?

I am trying something thus:

a <- c(1,2,5,3,6,8,1,7)
c(1,7,2,9,2,3,4,5) -> b

a;b

plot(a,t="l",col="blue")
plot(b,t="l",col="red")

__
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


[R] help: how to plot a circle on the scatter plot

2005-07-12 Thread wu sz
Hello,

I have a data set with 15 variables, and use "pairs" to plot the
scatterplot of this data set. Then I want to plot some circles on the
small pictures with high correlation(e.g. > 0.9).

First, I use "cor" to obtain the corresponding correlation matrix (x)
for this scatterplot.

Second, use "seq(along = x)[x > 0.9]" to find the positions of the
small pictures with 0.9 correlation, but "seq" can just find the
sequence position row by row for the matrix, not a real position (like
"rowNumber, colNumber"). Is any function for that?

Third, use "Symbols" to plot the circle on these small pictures, but
seems it can't do that. Also, I don't know how to adjust the thickness
and radius of the circle plotted by "Symbols".

Please give me some ideas!

Thank you,
Shengzhe

__
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


Re: 答复: [R] fail in addin g library in new version.

2005-07-12 Thread Gabor Grothendieck
hhc.exe is the Microsoft help compiler.  You have to download it and put
it somewhere in your path.

On 7/12/05, Ivy_Li <[EMAIL PROTECTED]> wrote:
> Dear all,
> I really appreciate your help. I think I have a little advancement. ^_^
> Now I use the package.skeleton() function to create a template. I type:
>f <- function(x,y) x+y
>g <- function(x,y) x-y
>d <- data.frame(a=1, b=2)
>e <- rnorm(1000)
>package.skeleton(list=c("f","g","d","e"), name="example")
> 
> in R. I know it will create a folder named "example" in the path of 
> "\R\rw2011\" I opened this folder, its format is similar as other library. 
> Then I modify it "DESCRIPTION" file:
>Package: example
>Version: 1.0-1
>Date: 2005-07-09
>Title: My first function
>Author: Ivy <[EMAIL PROTECTED]>
>Maintainer: Ivy <[EMAIL PROTECTED]>
>Description: simple sum and subtract
>License: GPL version 2 or later
>Depends: R (>= 1.9), stats, graphics, utils
> 
> I don't whether I should modify other "README" file.
> When I enter the Dos environment, at first, into the D:\>, I type the 
> following code:
>cd Program Files\R\rw2011\
>bin\R CMD install /example
> 
> Well, there appeared error:
>-- Making package example 
>  adding build stamp to DESCRIPTION
>  installing R files
>  installing data files
>  installing man source files
>  installing indices
>  not zipping data
>  installing help
> >>> Building/Updating help pages for package 'example'
> Formats: text html latex example chm
>  d texthtmllatex   example chm
>  e texthtmllatex   example chm
>  f texthtmllatex   example chm
> missing link(s):  ~~fun~~
>  g texthtmllatex   example chm
> missing link(s):  ~~fun~~
>hhc: not found
>cp: cannot stat `D:/PROGRA~1/R/rw2011/example/chm/example.chm': No 
> such file or
>directory
>make[1]: *** [chm-example] Error 1
>make: *** [pkg-example] Error 2
>*** Installation of example failed ***
> 
>Removing 'D:/PROGRA~1/R/rw2011/library/example'
> 
> That's it. I have to consult every R expert. Please help to solve this issue. 
> Thank you very much!
> 
> 
> 
> 
> -原始邮件-
> 发件人: Duncan Murdoch [mailto:[EMAIL PROTECTED]
> 发送时间: 2005年7月8日 19:34
> 收件人: Ivy_Li
> 抄送: r-help@stat.math.ethz.ch
> 主题: Re: [R] fail in adding library in new version.
> 
> 
> Ivy_Li wrote:
> > Dear all,
> >   I really appreciate your help. I think I have a little advancement. 
> > ^_^
> >
> >   When I enter the Dos environment, at first, into the D:\>, I type the 
> > following code:
> > cd Program Files\R\rw2011\
> > bin\R CMD install /example
> >
> > "example" is in the d:\, which include the R folder and "DESCRIPTION" file, 
> > But I wrote nothing in the "DESCRIPTION" file. Actually, I don't know what 
> > I should write in it.
> 
> Read the R Extensions manual for a detailed description.  You can use
> the package.skeleton() function to create a template, but you need to
> edit it to make it acceptable.
> >
> > Well, there are still aother error:
> >
> >   -- Making package example 
> > adding build stamp to DESCRIPTION
> >   error happened.read_description(dfile) : file 
> > 'D:/example/DESCRIPTION' is not in valid DCF format
> 
> That's complaining about your bad DESCRIPTION file.
> 
> Duncan Murdoch
> >   Stop execute
> >   make[2]: *** [frontmatter] Error 1
> >   make[1]: *** [all] Error 2
> >   make: *** [pkg-example] Error 2
> >   *** Installation of example failed ***
> >   Removing 'D:/PROGRA~1/R/rw2011/library/example'
> >
> > Please tell me which step is wrong?
> > Thanks a lot!
> >
> > BG
> > Ivy_Li
> >
> >
> > -原始邮件-
> > 发件人: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
> > 发送时间: 2005年7月7日 20:57
> > 收件人: Uwe Ligges
> > 抄送: Ivy_Li; r-help@stat.math.ethz.ch
> > 主题: Re: 答复: 答复: [R] fail in adding library in new version.
> >
> >
> > On 7/7/05, Uwe Ligges <[EMAIL PROTECTED]> wrote:
> >
> >>Gabor Grothendieck wrote:
> >>
> >>
> >>>On 7/7/05, Uwe Ligges <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> Ivy_Li wrote:
> 
> 
> 
> >Dear all,
> > I have done every step as the previous mail.
> >1. unpack tools.zip into c:\cygwin
> >2. install Active perl in c:\Perl
> >3. install the mingw32 in c:\mingwin
> >4. add "c:\cygwin; c:\mingwin\bin" in "Control Panel -> System -> 
> >Advanced -> Environment Variables -> Path -> Variable" , and they are in 
> >the beginning of the "Path"
> 
>   ^
> such blanks are not allowed in the PATH variable
> 
> 
>

答复: [R] fail in adding library i n new version.

2005-07-12 Thread Ivy_Li
Dear all,
I really appreciate your help. I think I have a little advancement. ^_^
Now I use the package.skeleton() function to create a template. I type:
f <- function(x,y) x+y
g <- function(x,y) x-y
d <- data.frame(a=1, b=2)
e <- rnorm(1000)
package.skeleton(list=c("f","g","d","e"), name="example")

in R. I know it will create a folder named "example" in the path of 
"\R\rw2011\" I opened this folder, its format is similar as other library. Then 
I modify it "DESCRIPTION" file:
Package: example
Version: 1.0-1
Date: 2005-07-09
Title: My first function
Author: Ivy <[EMAIL PROTECTED]>
Maintainer: Ivy <[EMAIL PROTECTED]>
Description: simple sum and subtract
License: GPL version 2 or later
Depends: R (>= 1.9), stats, graphics, utils

I don't whether I should modify other "README" file.
When I enter the Dos environment, at first, into the D:\>, I type the following 
code:
cd Program Files\R\rw2011\
bin\R CMD install /example

Well, there appeared error:
-- Making package example 
  adding build stamp to DESCRIPTION
  installing R files
  installing data files
  installing man source files
  installing indices
  not zipping data
  installing help
 >>> Building/Updating help pages for package 'example'
 Formats: text html latex example chm
  d texthtmllatex   example chm
  e texthtmllatex   example chm
  f texthtmllatex   example chm
 missing link(s):  ~~fun~~
  g texthtmllatex   example chm
 missing link(s):  ~~fun~~
hhc: not found
cp: cannot stat `D:/PROGRA~1/R/rw2011/example/chm/example.chm': No such 
file or
directory
make[1]: *** [chm-example] Error 1
make: *** [pkg-example] Error 2
*** Installation of example failed ***

Removing 'D:/PROGRA~1/R/rw2011/library/example'

That's it. I have to consult every R expert. Please help to solve this issue. 
Thank you very much!




-原始邮件-
发件人: Duncan Murdoch [mailto:[EMAIL PROTECTED]
发送时间: 2005年7月8日 19:34
收件人: Ivy_Li
抄送: r-help@stat.math.ethz.ch
主题: Re: [R] fail in adding library in new version.


Ivy_Li wrote:
> Dear all,
>   I really appreciate your help. I think I have a little advancement. ^_^
>   
>   When I enter the Dos environment, at first, into the D:\>, I type the 
> following code:
> cd Program Files\R\rw2011\
> bin\R CMD install /example
> 
> "example" is in the d:\, which include the R folder and "DESCRIPTION" file, 
> But I wrote nothing in the "DESCRIPTION" file. Actually, I don't know what I 
> should write in it.

Read the R Extensions manual for a detailed description.  You can use 
the package.skeleton() function to create a template, but you need to 
edit it to make it acceptable.
> 
> Well, there are still aother error:
> 
>   -- Making package example 
> adding build stamp to DESCRIPTION
>   error happened.read_description(dfile) : file 'D:/example/DESCRIPTION' 
> is not in valid DCF format

That's complaining about your bad DESCRIPTION file.

Duncan Murdoch
>   Stop execute
>   make[2]: *** [frontmatter] Error 1
>   make[1]: *** [all] Error 2
>   make: *** [pkg-example] Error 2
>   *** Installation of example failed ***
>   Removing 'D:/PROGRA~1/R/rw2011/library/example'
> 
> Please tell me which step is wrong?
> Thanks a lot!
> 
> BG
> Ivy_Li
>  
> 
> -原始邮件-
> 发件人: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
> 发送时间: 2005年7月7日 20:57
> 收件人: Uwe Ligges
> 抄送: Ivy_Li; r-help@stat.math.ethz.ch
> 主题: Re: 答复: 答复: [R] fail in adding library in new version.
> 
> 
> On 7/7/05, Uwe Ligges <[EMAIL PROTECTED]> wrote:
> 
>>Gabor Grothendieck wrote:
>>
>>
>>>On 7/7/05, Uwe Ligges <[EMAIL PROTECTED]> wrote:
>>>
>>>
Ivy_Li wrote:



>Dear all,
> I have done every step as the previous mail.
>1. unpack tools.zip into c:\cygwin
>2. install Active perl in c:\Perl
>3. install the mingw32 in c:\mingwin
>4. add "c:\cygwin; c:\mingwin\bin" in "Control Panel -> System -> Advanced 
>-> Environment Variables -> Path -> Variable" , and they are in the 
>beginning of the "Path"

  ^
such blanks are not allowed in the PATH variable





> Because I install R in the D drive, so I set a fold "MyRpackages" in 
> the same drive. Into the "MyRpackages" folder I write a R library named 
> "example", include "DESCRIPTION" file and "R" folder. In the "R" folder, 
> the "example" file just content very simple code as the previous mail 
> said.
>  So in the Dos envi

[R] How to increase memory for R on Soliars 10 with 16GB and 64bit R

2005-07-12 Thread Dongseok Choi
Dear all,

  My machine is SUN Java Workstation 2100 with 2 AMD Opteron CPUs and 16GB RAM.
  R is compiled as 64bit by using SUN compilers. 
  I trying to fit quantile smoothing on my data and I got an message as below.

> fit1<-rqss(z1~qss(cbind(x,y),lambda=la1),tau=t1)
Error in as.matrix.csr(diag(n)) : cannot allocate memory block of size 
2496135168

  The lengths of vector x and y are both 17664.
  I tried and found that the same command ran with x[1:16008] and y[1:16008].
  So, it looks to me a memory related problem, but I'm not sure how I can 
allocate memory block.
   I read the command line option but not sure what do to with it.
   Could you help me on this?  

Thank you very much,



Dongseok Choi, Ph.D.
Assistant Professor
Division of Biostatistics
Department of Public Health & Preventive Medicine
Oregon Health & Science University
3181 SW Sam Jackson Park Road, CB-669
Portland, OR 97239-3098
TEL) 503-494-5336
FAX) 503-494-4981
[EMAIL PROTECTED]

__
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


Re: [R] Calling R from fortran

2005-07-12 Thread Duncan Murdoch
Michael Prager wrote:

> I don't know if R can easily read Fortran unformatted (sometimes called
> "binary") data, or how.  

Yes, it's fairly easy.  You would use a file() connection, and 
readBin().  The only tricky part might be figuring out exactly what is 
the R equivalent to what your fortran is writing.

Duncan Murdoch

__
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


Re: [R] Calling R from fortran

2005-07-12 Thread Michael Prager
Simon,

An hour's worth of contour plots (12) should be able to be saved in far
less than 1 Gb, depending on the detail desired.

Here is one way to do your task. There are other, and probably better, ones.

At each time step (5 mins), you could have the Fortran program write a
data file and then write and execute a script file.  The script file
would call R as a batch process to make a contour graph and save it (as
PNG perhaps), and then the script would delete the data file.  You might
want to have the generated script files omit the "delete" step once per
hour, just in case the R step should fail when you are not around to
observe the failure.

I don't know if R can easily read Fortran unformatted (sometimes called
"binary") data, or how.  That would speed up the Fortran I/O and
possibly reduce file size.  If you go with formatted output, consider
limiting the number of decimal places you write to save disk space.  In
most applications, you won't need great precision for simply making
graphs. Also, for writing large amounts of data, test various block
sizes on the Fortran OPEN statement to get best I/O speed.

Another possibility would be to use a Fortran library (like the free or
inexpensive DISLIN) that can make the contour plots directly, without
using R.

...Mike


simon wrote on 7/12/2005 4:02 PM:

>Hi,
>The following may sound stupid so please forgive my stupidness. I have a 
>question which I don't know how to name it so I have to start from the 
>beginning. In an attempt to gain better understand how a photochemical 
>air qaulity model works, I plotted hourly ozone concentration contour 
>from the model's standard output to observe the changes in simulation. 
>Because the model actually peroform simulation in time steps of 5 
>minutes, it will give a better resoultion if I can plot the ozone 
>concentration with time resolution close to the model. However, if I 
>modify the model to output data at every time step, it will be 
>impossible for the computer to store this much information( the hourly 
>standard output is close to 1gb). I was wondering if it is possible to 
>modify fortran to call R or something, which can just plot a contour at 
>every time step rather than put it as data. I am not sure about how to 
>call this act. Also, if this is possible, will output of a contour give 
>a smaller file size than data?
>Thanks in advance,
>simon
>
>  
>

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


[R] write.foreign, SPSS on Mac OS X

2005-07-12 Thread EJ Nikelski
Hi all,

 I have jut installed the foreign package (v 0.8-8) on my OS X 
machine, and have a bit of a problem writing out a data frame in SPSS 
format. Specifically, the code file (the .sps format file) seems to 
write 3 unprintable hex values instead of double quotes. For example, in 
the following output ...

VALUE LABELS
/
immDel
1 ###1###
  2 ###2###
  3 ###3###

  ... emacs tells me that the left-sided ### are the hex codes E2 80 9C, 
on the right we have E2 80 9D. I am supposing that I should be seeing 
double-quotes here? Interestingly, the data file, which also contains a 
quoted field, writes out the quotes without any problem. Does anyone 
have any ideas?

Thanks,

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


Re: [R] using its to import time series data with uneven dates

2005-07-12 Thread Gabor Grothendieck
On 7/12/05, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> On 7/12/05, Sheri Conner Gausepohl <[EMAIL PROTECTED]> wrote:
> > Good day:
> >
> > I am trying to use
> > readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M
> > %Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".")
> >
> > to read in a file (nwr_data_qc.txt)  that looks like this:
> >
> > Time Y  M   D  H   MinCO2
> > 2000.18790   2000.  3.  9. 18. 30.373.60
> > 2000.20156   2000.  3. 14. 18. 30.373.34
> > 2000.22609   2000.  3. 23. 18.  0.373.01
> >
> > and  R returns this:
> >
> > Y  M  D  H MinCO2
> >  2000  3  9 18  30 373.60
> >  2000  3 14 18  30 373.34
> >  2000  3 23 18   0 373.01
> >
> > I have tried every format option on the help page.  How can I read in
> > my decimal dates (e.g., 2000.18790)?
> >
> > Note that these data (CO2) are irregularly spaced in time (Time).
> >
> > Ultimately I would like to fit a trigonometric polynomial (first
> > harmonic) to these data in order to smooth them and obtain values
> > between measurements.  Any suggestions you can provide on how to do
> > this would be much appreciated.
> >
> > Thank you for your help.
> >
> > Sheri
> >
> > Sheri L. Conner Gausepohl
> > Graduate Research Assistant
> > Department of Atmospheric Science
> > Colorado State University
> 
> Try this:
> 
> library(its)
> dd <- read.table(myfile, header = TRUE)
> tt <- paste(dd$Y, "-", dd$M, "-", dd$D, " ", dd$H, ":", dd$Min, sep = "")
> co2 <- its(dd$CO2, as.POSIXct(tt))
> co2 # display co2
> 


or even easier use ISOdatetime:

library(its)
dd <- read.table(myfile, header = TRUE)
co2 <- with(dd, its(CO2, ISOdatetime(Y, M, D, H, Min, 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


Re: [R] using its to import time series data with uneven dates

2005-07-12 Thread Gabor Grothendieck
On 7/12/05, Sheri Conner Gausepohl <[EMAIL PROTECTED]> wrote:
> Good day:
> 
> I am trying to use
> readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M
> %Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".")
> 
> to read in a file (nwr_data_qc.txt)  that looks like this:
> 
> Time Y  M   D  H   MinCO2
> 2000.18790   2000.  3.  9. 18. 30.373.60
> 2000.20156   2000.  3. 14. 18. 30.373.34
> 2000.22609   2000.  3. 23. 18.  0.373.01
> 
> and  R returns this:
> 
> Y  M  D  H MinCO2
>  2000  3  9 18  30 373.60
>  2000  3 14 18  30 373.34
>  2000  3 23 18   0 373.01
> 
> I have tried every format option on the help page.  How can I read in
> my decimal dates (e.g., 2000.18790)?
> 
> Note that these data (CO2) are irregularly spaced in time (Time).
> 
> Ultimately I would like to fit a trigonometric polynomial (first
> harmonic) to these data in order to smooth them and obtain values
> between measurements.  Any suggestions you can provide on how to do
> this would be much appreciated.
> 
> Thank you for your help.
> 
> Sheri
> 
> Sheri L. Conner Gausepohl
> Graduate Research Assistant
> Department of Atmospheric Science
> Colorado State University

Try this:

library(its)
dd <- read.table(myfile, header = TRUE)
tt <- paste(dd$Y, "-", dd$M, "-", dd$D, " ", dd$H, ":", dd$Min, sep = "")
co2 <- its(dd$CO2, as.POSIXct(tt))
co2 # display co2

__
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


[R] Please help me.....

2005-07-12 Thread Fernando Espíndola
Hi user R,

I am try to calculate the spectrum function in two time series. But when plot a 
single serie, the labels in axes x is in the range 0.1 to 0.6 (frequency), but 
when calculate de spectrum with ts.union function, the labels x is in the range 
1 to 6. I not understand why change the labels, and not know that is 
ralationship. Samebody can hel me in this analysis.

Thank for all

fdo

Fernando Espindola R.
Division Investigacion Pesquera
Instituto de Fomento Pesquero
Blanco 839
Valparaiso - CHILE
fono: 32 - 322442
[EMAIL PROTECTED]


[[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


Re: [R] Complex plotting in R

2005-07-12 Thread Deepayan Sarkar
On 7/12/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi list,
> 
> I'm looking for a function or a combination of functions to do panel plotting 
> of mixed graph types with the same x axis.
> 
> I would like to construct a panel with 3 stacked windows with on top a 
> histogram, below that 2 cdf plots. They all have the same x axis value but 
> different y axis values. Is it possible to construct something like that?
> 
> I've looked into the lattice package but it doesn't seem to solve my problem 
> because I clearly want 1 x axis for all the graphs so not just a panel with 3 
> full graphs.
> 

Multiple graph types in lattice would need a lot of hacking. If you
are feeling adventurous, you might want to try using grid graphics
(the 'grid' package) directly.

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


Re: [R] unexpected behavior in bwplot

2005-07-12 Thread Deepayan Sarkar
On 7/12/05, Ritter, Christian C GSMCIL-GSTMS/2
<[EMAIL PROTECTED]> wrote:
> R-2.1.1 on windows XP
> 
> I just noticed something unpleasant when using bwplot (from lattice).
> 
> In order to satisfy a wish from a client, I needed to produce sets of 
> boxplots conditioned by another factor. My client didn't like the look of the 
> boxplots (by default, they have a star to mark the median, instead of the 
> commonly used line). I told him "no problem" dumped panel.bwplot, added a 
> line at the median, commented out the star, and sourced it back in as 
> panel.mybwplot.
> 
> Then I tried to call it with bwplot(...,panel="panel.mybwplot"), but this hit 
> two roadblocks. The first one was relatively easy: it didn't find the 
> function current.viewport (from grid). Explicitely loading the package grid 
> was sufficient (current.viewport is exported there). But then it stopped on 
> chooseFace. It was not obvious to find where chooseFace was (in lattice, but 
> not as an exported function in the namespace) and how to make it callable. I 
> finally clobbered it by defining chooseFace<-lattice:::chooseFace. This 
> certainly worked but is very inelegant. Could anyone point me to cleaner ways 
> to do this?
> 
> On the other hand, I would have preferred if panel.bwplot would not use 
> functions not exported to the outer namespace (or if lattice would make sure 
> that all functions called in the standard panel functions were exported to 
> the outer namespace). It is very common that we have to slightly modify 
> standard panel functions and it is quite annoying having to chase for 
> evenually hidden functions called by them. Comments?
> 

I agree that this is a problem, but I don't know what a good solution
is. I can certainly export more functions (writing documentation is
the only hard work). However, chooseFace is a hack which definitely
isn't worth exporting.

I think the best solution in this case is for me to rewrite
panel.bwplot using lattice wrappers line panel.points and panel.lines
(and panel.rect, which doesn't exist yet). That may take a little
time. Please let me know of other similar situations if you encounter
them.

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


Re: [R] using its to import time series data with uneven dates

2005-07-12 Thread Whit Armstrong
You would probably do better to read in your data and reformat the
dates.

What date format is 2000.18790?  The Its package uses POSIXct dates and
readcsvIts expects the formats to be "%Y-%m-%d" unless you've changed
the default format.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sheri Conner
Gausepohl
Sent: Tuesday, July 12, 2005 5:47 PM
To: r-help@stat.math.ethz.ch
Subject: [R] using its to import time series data with uneven dates

Good day:

I am trying to use
readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M
%Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".")

to read in a file (nwr_data_qc.txt)  that looks like this:

Time Y  M   D  H   MinCO2
2000.18790   2000.  3.  9. 18. 30.373.60
2000.20156   2000.  3. 14. 18. 30.373.34
2000.22609   2000.  3. 23. 18.  0.373.01

and  R returns this:

 Y  M  D  H MinCO2
 2000  3  9 18  30 373.60
 2000  3 14 18  30 373.34
 2000  3 23 18   0 373.01

I have tried every format option on the help page.  How can I read in my
decimal dates (e.g., 2000.18790)?

Note that these data (CO2) are irregularly spaced in time (Time).

Ultimately I would like to fit a trigonometric polynomial (first
harmonic) to these data in order to smooth them and obtain values
between measurements.  Any suggestions you can provide on how to do this
would be much appreciated.

Thank you for your help.

Sheri

Sheri L. Conner Gausepohl
Graduate Research Assistant
Department of Atmospheric Science
Colorado State University

__
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

__
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


[R] using its to import time series data with uneven dates

2005-07-12 Thread Sheri Conner Gausepohl
Good day:

I am trying to use 
readcsvIts("nwr_data_qc.txt",informat=its.format("%Y%m%d%h%M 
%Y"),header=TRUE,sep="",skip=0,row.names=NULL,as.is=TRUE,dec=".")

to read in a file (nwr_data_qc.txt)  that looks like this:

Time Y  M   D  H   MinCO2
2000.18790   2000.  3.  9. 18. 30.373.60
2000.20156   2000.  3. 14. 18. 30.373.34
2000.22609   2000.  3. 23. 18.  0.373.01

and  R returns this:

 Y  M  D  H MinCO2
 2000  3  9 18  30 373.60
 2000  3 14 18  30 373.34
 2000  3 23 18   0 373.01

I have tried every format option on the help page.  How can I read in 
my decimal dates (e.g., 2000.18790)?

Note that these data (CO2) are irregularly spaced in time (Time).

Ultimately I would like to fit a trigonometric polynomial (first 
harmonic) to these data in order to smooth them and obtain values 
between measurements.  Any suggestions you can provide on how to do 
this would be much appreciated.

Thank you for your help.

Sheri

Sheri L. Conner Gausepohl
Graduate Research Assistant
Department of Atmospheric Science
Colorado State University

__
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


Re: [R] simple question: reading lower triangular matrix

2005-07-12 Thread Rogério Rosa da Silva
Dear Adaikalavan and Marc,

Thanks for advices. The answer in R-help archives is exactly what I'm
needing.

Best regards,

Rogério


Adaikalavan Ramasamy wrote:

>This has been answered at the following URL
>
>http://tolstoy.newcastle.edu.au/~rking/R/help/04/11/6695.html
>
>
>On Tue, 2005-07-12 at 14:37 -0300, Rogério Rosa da Silva wrote:
>  
>

__
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

Re: [R] simple question: reading lower triangular matrix

2005-07-12 Thread Adaikalavan Ramasamy
This has been answered at the following URL

http://tolstoy.newcastle.edu.au/~rking/R/help/04/11/6695.html


On Tue, 2005-07-12 at 14:37 -0300, Rogério Rosa da Silva wrote:
> Dear list,
> 
> I will like to learn how to read a lower triangular matrix in R. The
> input file *.txt have the following format:
> 
>  A   B   C   D   E
> A   0   
> B   10
> C   250   
> D   3680  
> E   479   100
> 
> 
> How this can be done?
> 
> Thanks in advance for your help
> 
> Rogério
> 
> __
> 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
>

__
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

Re: [R] unexpected behavior in bwplot

2005-07-12 Thread Greg Snow
I had a similar problem when trying to modify a function from lattice. 
I second the opinion that it 
would be nice if lattice exported more things.  My soulution was to
give my function the same 
environment as the one I had copied, i.e. try:

environment(panel.mybwplot) <- environment(panel.bwplot)

I have included a line like this at the end of the script file that
defines my new/modified lattice
functions, and as long as lattice is loaded first (could wrap the above
in the body of an if 
statement that calls library or require) then everything works fine
(having the same environment
lets the new function find the non-exported functions).

Hope this helps,



Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

>>> "Ritter, Christian C GSMCIL-GSTMS/2" <[EMAIL PROTECTED]>
07/12/05 05:08AM >>>
R-2.1.1 on windows XP

I just noticed something unpleasant when using bwplot (from lattice). 

In order to satisfy a wish from a client, I needed to produce sets of
boxplots conditioned by another factor. My client didn't like the look
of the boxplots (by default, they have a star to mark the median,
instead of the commonly used line). I told him "no problem" dumped
panel.bwplot, added a line at the median, commented out the star, and
sourced it back in as panel.mybwplot. 

Then I tried to call it with bwplot(...,panel="panel.mybwplot"), but
this hit two roadblocks. The first one was relatively easy: it didn't
find the function current.viewport (from grid). Explicitely loading the
package grid was sufficient (current.viewport is exported there). But
then it stopped on chooseFace. It was not obvious to find where
chooseFace was (in lattice, but not as an exported function in the
namespace) and how to make it callable. I finally clobbered it by
defining chooseFace<-lattice:::chooseFace. This certainly worked but is
very inelegant. Could anyone point me to cleaner ways to do this? 

On the other hand, I would have preferred if panel.bwplot would not use
functions not exported to the outer namespace (or if lattice would make
sure that all functions called in the standard panel functions were
exported to the outer namespace). It is very common that we have to
slightly modify standard panel functions and it is quite annoying having
to chase for evenually hidden functions called by them. Comments? 

Thanks in advance,

Christian Ritter
Functional Specialist Statistics
Shell Coordination Centre S.A.
Monnet Centre International Laboratory, Avenue Jean Monnet 1, B-1348
Louvain-La-Neuve, Belgium

Tel: +32 10 477  349 Fax: +32 10 477 219
Email: [EMAIL PROTECTED] 
Internet: http://www.shell.com/chemicals 



[[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

__
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


Re: [R] Calculation of group summaries

2005-07-12 Thread Frank E Harrell Jr
See http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/SasByMeansExample
for one example.

Frank


[EMAIL PROTECTED] wrote:
> I know R has a steep learning curve, but from where I stand the slope
> looks like a sheer cliff.  I'm pawing through the available docs and
> have come across examples which come close to what I want but are
> proving difficult for me to modify for my use.
> 
> Calculating simple group means is fairly straight forward:
>   data(PlantGrowth)
>   attach(PlantGrowth)
>   stack(mean(unstack(PlantGrowth)))
> 
> I'd like to do something slightly more complex, using a data frame and
> groups identified by unique combinations of three id variables.  There
> may be thousands of such combinations in the data.  This is easy in SQL:
> 
>   select year,
>  site_id,
>  visit_no,
>  mean(undercut) AS meanUndercut,
>  count(undercut) AS nUndercut,
>  std(undercut) AS stdUndercut
>   from channelMorphology
>   group by year, site_id, visit_no
>   ;
> 
> Reading a CSV written by SAS and selecting only records expected to have
> values is also straight forward in R, but getting those summary values
> for each site visit is currently beyond me:
> 
>   sub<-read.csv('c:/data/channelMorphology.csv'
>,header=TRUE
>,na.strings='.'
>,sep=','
>,strip.white=TRUE
>)
> 
>   undercut<-subset(sub,
>   ,TRANSDIR %in% c('LF','RT')
> 
> ,select=c('YEAR','SITE_ID','VISIT_NO','TRANSECT','TRANSDIR'
>,'UNDERCUT'
>)
>   ,drop=TRUE
>   )
> 
> 
> Thanks all for your help.
> cur
> --
> Curt Seeliger, Data Ranger
> CSC, EPA/WED contractor
> 541/754-4638
> [EMAIL PROTECTED]
> 
> __
> 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
> 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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


[R] Calling R from fortran

2005-07-12 Thread simon
Hi,
The following may sound stupid so please forgive my stupidness. I have a 
question which I don't know how to name it so I have to start from the 
beginning. In an attempt to gain better understand how a photochemical 
air qaulity model works, I plotted hourly ozone concentration contour 
from the model's standard output to observe the changes in simulation. 
Because the model actually peroform simulation in time steps of 5 
minutes, it will give a better resoultion if I can plot the ozone 
concentration with time resolution close to the model. However, if I 
modify the model to output data at every time step, it will be 
impossible for the computer to store this much information( the hourly 
standard output is close to 1gb). I was wondering if it is possible to 
modify fortran to call R or something, which can just plot a contour at 
every time step rather than put it as data. I am not sure about how to 
call this act. Also, if this is possible, will output of a contour give 
a smaller file size than data?
Thanks in advance,
simon

__
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


Re: [R] interactive plot showing label

2005-07-12 Thread Sebastian Luque
mark salsburg <[EMAIL PROTECTED]> wrote:

[...]

> Mainly one that shows all the points, but when a point is clicked on
> it shows what gene_name it is

I think ?identify will help you.


-- 
Sebastian P. Luque

__
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


Re: [R] simple question: reading lower triangular matrix

2005-07-12 Thread Marc Schwartz (via MN)
On Tue, 2005-07-12 at 14:37 -0300, Rogério Rosa da Silva wrote:
> Dear list,
> 
> I will like to learn how to read a lower triangular matrix in R. The
> input file *.txt have the following format:
> 
>  A   B   C   D   E
> A   0   
> B   10
> C   250   
> D   3680  
> E   479   100
> 
> 
> How this can be done?
> 
> Thanks in advance for your help
> 
> Rogério


I don't know that this is the easiest way of doing it, but here is one
approach:

# I saved your data above in a file called "test.txt"

# Read the first line of test.txt to get the colnames as chars
col.names <- unlist(read.table("test.txt", nrow = 1, as.is = TRUE))

# now read the rest of the file using 'fill = TRUE' to pad lines
# with NAs 
# skip the first line
# set the row.names as the first column in the text file
# coerce to a matrix
df <- as.matrix(read.table("test.txt", fill = TRUE, skip = 1, 
row.names = 1))

# Now set the colnames of df
colnames(df) <- col.names

> df
  A  B  C  D  E
A 0 NA NA NA NA
B 1  0 NA NA NA
C 2  5  0 NA NA
D 3  6  8  0 NA
E 4  7  9 10  0

If you should further want to set the diagonal to NA:

> diag(df) <- NA

> df
   A  B  C  D  E
A NA NA NA NA NA
B  1 NA NA NA NA
C  2  5 NA NA NA
D  3  6  8 NA NA
E  4  7  9 10 NA


See ?read.table for more information on the file reading part.

HTH,

Marc Schwartz

__
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

Re: [R] getting panel.loess to use updated version of loess.smooth

2005-07-12 Thread Benjamin Tyner
A quick workaround, kudos to Deepayan Sarkar, is to use grid:: for both 
grid.lines AND gpar in panel.loess:

grid::grid.lines(x = smooth$x, y = smooth$y, default.units = 
"native",
gp = grid::gpar(col = col.line, lty = lty, lwd = lwd))

Then write a new panel function as you suggest (though the name can be 
the same), and to export this panel function in the package NAMESPACE 
file. loess.smooth and simpleLoess are separate functions, sorry if I 
didn't make that clear.

This works well enough that I don't require anything fancier for now. 
Thanks!

Ben

Sundar Dorai-Raj wrote:

>
>
> Benjamin Tyner wrote:
>
>> I'm updating the loess routines to allow for, among other things, 
>> arbitrary local polynomial degree and number of predictors. For now, 
>> I've given the updated package its own namespace. The trouble is, 
>> panel.loess still calls the original code in package:stats instead of 
>> the new loess package, regardless of whether package:loess or 
>> package:lattice comes first in the search list. If I export 
>> panel.loess from the new package, then it can't see grid.lines anymore.
>>
>> I've tried using fixInNamespace to change the loess.smooth in 
>> package:stats to point to the updated simpleLoess, but it is locked. 
>> At http://tolstoy.newcastle.edu.au/R/help/04/05/0428.html it was 
>> suggested to write a new panel function. However I still need to be 
>> able to access grid.lines, and getFromNamespace("grid.lines","grid") 
>> is not the way to do this.
>>
>> Any ideas? This seems simple but I'm stumped.
>>
>> Thanks,
>> Ben
>>
>
> Can you show us what you tried? It seems as simple as defining a new 
> panel function:
>
> panel.loess2 <- function (x, y, span = 2/3, degree = 1,
>   family = c("symmetric", "gaussian"),
>   evaluation = 50, lwd = add.line$lwd,
>   lty = add.line$lty, col,
>   col.line = add.line$col, ...) {
>   x <- as.numeric(x)
>   y <- as.numeric(y)
>   if (length(x) > 0) {
>   if (!missing(col)) {
>   if (missing(col.line))
>   col.line <- col
>   }
>   add.line <- trellis.par.get("add.line")
>   #smooth <- loess.smooth(x, y, span = span, family = family,
>   #   degree = degree, evaluation = evaluation)
>   smooth <- simpleLoess(x, y, span = span, family = family,
> degree = degree, evaluation = evaluation)
>   grid.lines(x = smooth$x, y = smooth$y, default.units = "native",
>  gp = gpar(col = col.line, lty = lty, lwd = lwd))
>   }
> }
>
>
> --sundar

__
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


Re: [R] getting panel.loess to use updated version of loess.smooth

2005-07-12 Thread Sundar Dorai-Raj


Benjamin Tyner wrote:
> I'm updating the loess routines to allow for, among other things, 
> arbitrary local polynomial degree and number of predictors. For now, 
> I've given the updated package its own namespace. The trouble is, 
> panel.loess still calls the original code in package:stats instead of 
> the new loess package, regardless of whether package:loess or 
> package:lattice comes first in the search list. If I export panel.loess 
> from the new package, then it can't see grid.lines anymore.
> 
> I've tried using fixInNamespace to change the loess.smooth in 
> package:stats to point to the updated simpleLoess, but it is locked. At 
> http://tolstoy.newcastle.edu.au/R/help/04/05/0428.html it was suggested 
> to write a new panel function. However I still need to be able to access 
> grid.lines, and getFromNamespace("grid.lines","grid") is not the way to 
> do this.
> 
> Any ideas? This seems simple but I'm stumped.
> 
> Thanks,
> Ben
> 

Can you show us what you tried? It seems as simple as defining a new 
panel function:

panel.loess2 <- function (x, y, span = 2/3, degree = 1,
   family = c("symmetric", "gaussian"),
   evaluation = 50, lwd = add.line$lwd,
   lty = add.line$lty, col,
   col.line = add.line$col, ...) {
   x <- as.numeric(x)
   y <- as.numeric(y)
   if (length(x) > 0) {
   if (!missing(col)) {
   if (missing(col.line))
   col.line <- col
   }
   add.line <- trellis.par.get("add.line")
   #smooth <- loess.smooth(x, y, span = span, family = family,
   #   degree = degree, evaluation = evaluation)
   smooth <- simpleLoess(x, y, span = span, family = family,
 degree = degree, evaluation = evaluation)
   grid.lines(x = smooth$x, y = smooth$y, default.units = "native",
  gp = gpar(col = col.line, lty = lty, lwd = lwd))
   }
}


--sundar

__
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


Re: [R] Calculation of group summaries

2005-07-12 Thread Francisco J. Zagmutt
Take a look at ?aggregate ?ave and ?tapply

Cheers

Francisco

>From: [EMAIL PROTECTED]
>To: R-Help 
>Subject: [R] Calculation of group summaries
>Date: Tue, 12 Jul 2005 10:51:03 -0700
>
>I know R has a steep learning curve, but from where I stand the slope
>looks like a sheer cliff.  I'm pawing through the available docs and
>have come across examples which come close to what I want but are
>proving difficult for me to modify for my use.
>
>Calculating simple group means is fairly straight forward:
>   data(PlantGrowth)
>   attach(PlantGrowth)
>   stack(mean(unstack(PlantGrowth)))
>
>I'd like to do something slightly more complex, using a data frame and
>groups identified by unique combinations of three id variables.  There
>may be thousands of such combinations in the data.  This is easy in SQL:
>
>   select year,
>  site_id,
>  visit_no,
>  mean(undercut) AS meanUndercut,
>  count(undercut) AS nUndercut,
>  std(undercut) AS stdUndercut
>   from channelMorphology
>   group by year, site_id, visit_no
>   ;
>
>Reading a CSV written by SAS and selecting only records expected to have
>values is also straight forward in R, but getting those summary values
>for each site visit is currently beyond me:
>
>   sub<-read.csv('c:/data/channelMorphology.csv'
>,header=TRUE
>,na.strings='.'
>,sep=','
>,strip.white=TRUE
>)
>
>   undercut<-subset(sub,
>   ,TRANSDIR %in% c('LF','RT')
>
>,select=c('YEAR','SITE_ID','VISIT_NO','TRANSECT','TRANSDIR'
>,'UNDERCUT'
>)
>   ,drop=TRUE
>   )
>
>
>Thanks all for your help.
>cur
>--
>Curt Seeliger, Data Ranger
>CSC, EPA/WED contractor
>541/754-4638
>[EMAIL PROTECTED]
>
>__
>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

__
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


Re: [R] Anything to replace Statistical Models in S ("the white book")?

2005-07-12 Thread Berton Gunter
MASS (MODERN APPLIED STATISTICS WITH S) by Venables and Ripley. 

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Marcus, Jeffrey
> Sent: Tuesday, July 12, 2005 11:10 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Anything to replace Statistical Models in S 
> ("the white book")?
> 
> Hello:
> 
>   I found that Amazon cannot find a copy of "Statistical 
> Models in S"? I am
> about to embark on some tree-based and perhaps ANOVA models and have
> following options:
> 
>  
> 
> (*) Find another book/online doc that covers this material 
> (perhaps one
> recommended on the R FAQ page)
> 
> (*) Use R documentation
> 
> (*) Try even harder to land the white book. 
> 
>  
> 
>I have a decent conceptual and programming understanding 
> of trees and
> ANOVA but I'd like something that might fill in details (best way to
> cross-validate, missing value handling, other gotchas). 
> 
>  
> 
>   Thanks for any opinions on this.
> 
>  
> 
>   Jeff
> 
>  
> 
>  
> 
> 
> 
> SpeechWorks solutions from ScanSoft. Inspired Applications, 
> Exceptional
> Results.
> 
> Jeff Marcus
> Manager, Speech Tools, SpeechWorks Division
> ScanSoft, Inc.
> p: 781.565.5281
> f: 781-565-5575
>   www.scansoft.com
> 
>  
> 
> 
>   [[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
>

__
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


Re: [R] Complex plotting in R

2005-07-12 Thread Francisco J. Zagmutt
First call par(mfrow = c(2,2)) to get four plots in one panel
then plot your top figures using
plot(x, xaxt="n")#this will generate the plot withoput displaying the x axis
and then plot your bottom figures keeping the axis (without using xaxt="n")

You may want to fix the x axis limits to match between figures using the 
argument xlim=c(min,max) within plot()

More details in your note would have been helpful to give you better 
guidance

Cheers

Francisco


>From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
>To: r-help@stat.math.ethz.ch
>Subject: [R] Complex plotting in R
>Date: Tue, 12 Jul 2005 14:51:18 +
>
>Hi list,
>
>I'm looking for a function or a combination of functions to do panel 
>plotting of mixed graph types with the same x axis.
>
>I would like to construct a panel with 3 stacked windows with on top a 
>histogram, below that 2 cdf plots. They all have the same x axis value but 
>different y axis values. Is it possible to construct something like that?
>
>I've looked into the lattice package but it doesn't seem to solve my 
>problem because I clearly want 1 x axis for all the graphs so not just a 
>panel with 3 full graphs.
>
>Something like this:
>
>http://www.ats.ucla.edu/stat/sas/faq/InfluencePlots6.gif
>
>(copyright to whom copyright is due...)
>
>but with the top and bottom graphs merged.
>
>Best regards,
>Koen Hufkens
>
>__
>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

__
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


[R] Anything to replace Statistical Models in S ("the white book")?

2005-07-12 Thread Marcus, Jeffrey
Hello:

  I found that Amazon cannot find a copy of "Statistical Models in S"? I am
about to embark on some tree-based and perhaps ANOVA models and have
following options:

 

(*) Find another book/online doc that covers this material (perhaps one
recommended on the R FAQ page)

(*) Use R documentation

(*) Try even harder to land the white book. 

 

   I have a decent conceptual and programming understanding of trees and
ANOVA but I'd like something that might fill in details (best way to
cross-validate, missing value handling, other gotchas). 

 

  Thanks for any opinions on this.

 

  Jeff

 

 



SpeechWorks solutions from ScanSoft. Inspired Applications, Exceptional
Results.

Jeff Marcus
Manager, Speech Tools, SpeechWorks Division
ScanSoft, Inc.
p: 781.565.5281
f: 781-565-5575
  www.scansoft.com

 


[[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


[R] getting panel.loess to use updated version of loess.smooth

2005-07-12 Thread Benjamin Tyner
I'm updating the loess routines to allow for, among other things, 
arbitrary local polynomial degree and number of predictors. For now, 
I've given the updated package its own namespace. The trouble is, 
panel.loess still calls the original code in package:stats instead of 
the new loess package, regardless of whether package:loess or 
package:lattice comes first in the search list. If I export panel.loess 
from the new package, then it can't see grid.lines anymore.

I've tried using fixInNamespace to change the loess.smooth in 
package:stats to point to the updated simpleLoess, but it is locked. At 
http://tolstoy.newcastle.edu.au/R/help/04/05/0428.html it was suggested 
to write a new panel function. However I still need to be able to access 
grid.lines, and getFromNamespace("grid.lines","grid") is not the way to 
do this.

Any ideas? This seems simple but I'm stumped.

Thanks,
Ben

__
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


[R] Calculation of group summaries

2005-07-12 Thread Seeliger . Curt
I know R has a steep learning curve, but from where I stand the slope
looks like a sheer cliff.  I'm pawing through the available docs and
have come across examples which come close to what I want but are
proving difficult for me to modify for my use.

Calculating simple group means is fairly straight forward:
  data(PlantGrowth)
  attach(PlantGrowth)
  stack(mean(unstack(PlantGrowth)))

I'd like to do something slightly more complex, using a data frame and
groups identified by unique combinations of three id variables.  There
may be thousands of such combinations in the data.  This is easy in SQL:

  select year,
 site_id,
 visit_no,
 mean(undercut) AS meanUndercut,
 count(undercut) AS nUndercut,
 std(undercut) AS stdUndercut
  from channelMorphology
  group by year, site_id, visit_no
  ;

Reading a CSV written by SAS and selecting only records expected to have
values is also straight forward in R, but getting those summary values
for each site visit is currently beyond me:

  sub<-read.csv('c:/data/channelMorphology.csv'
   ,header=TRUE
   ,na.strings='.'
   ,sep=','
   ,strip.white=TRUE
   )

  undercut<-subset(sub,
  ,TRANSDIR %in% c('LF','RT')

,select=c('YEAR','SITE_ID','VISIT_NO','TRANSECT','TRANSDIR'
   ,'UNDERCUT'
   )
  ,drop=TRUE
  )


Thanks all for your help.
cur
--
Curt Seeliger, Data Ranger
CSC, EPA/WED contractor
541/754-4638
[EMAIL PROTECTED]

__
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


[R] interactive plot showing label

2005-07-12 Thread mark salsburg
I have the following data:

gene_name microarray expression
A   2323
B   1983
.


I have about 10,000 observations.

I would like to know if there is a way to create an interactive plot..

Mainly one that shows all the points, but when a point is clicked on
it shows what gene_name it is

If not, does anyone recommend another way to output a plot (using
maybe bioconducter bc this is microarray expression) that is
informative about the gene_names.

__
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


[R] simple question: reading lower triangular matrix

2005-07-12 Thread Rogério Rosa da Silva
Dear list,

I will like to learn how to read a lower triangular matrix in R. The
input file *.txt have the following format:

 A   B   C   D   E
A   0   
B   10
C   250   
D   3680  
E   479   100


How this can be done?

Thanks in advance for your help

Rogério

__
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


[R] Course***R/Splus Advanced Programming *** Atlanta

2005-07-12 Thread sue
XSolutions Corp (www.xlsolutions-corp.com) is proud to announce
our "Advanced R/Splus programming" course taught by R Development
Core Team Guru!

www.xlsolutions-corp.com/Radv.htm

*Atlanta  July 28th-29th, 2005

Ask for group discount and reserve your seat Now  (payment due after
the class)

Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578


Course Outline:

- Overview of R/S fundamentals: Syntax and Semantics
- Class and Inheritance in R/S-Plus
- Concepts, Construction and good use of language objects
- Coercion and efficiency
- Object-oriented programming in R and S-Plus
- Advanced manipulation tools: Parse, Deparse, Substitute, etc.
- How to fully take advantage of Vectorization
- Generic and Method Functions; S4 (S-Plus 6)
- Search path, databases and frames Visibility
- Working with large objects
- Handling Properly Recursion and iterative calculations
- Managing loops; For (S-Plus) and for() loops
- Consequences of Lazy Evaluation
- Efficient Code practices for large computations
- Memory management and Resource monitoring
- Writing R/S-Plus functions to call compiled code
- Writing and debugging compiled code for R/S-Plus system
- Connecting R/S-Plus to External Data Sources
- Understanding the structure of model fitting functions in R/S-Plus
- Designing and Packaging efficiently a new model function

It'll also deal with lots of S-Plus efficiency issues and any special
topics
from participants is welcome.

Please let us know if you and your colleagues are interested in this
class
to take advantage of group discount. Over half of the seats in this
class
are currently reserved.  Register now to secure your seat in this
course!

Cheers,

Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.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


Re: [R] Installing RSPerl and Statistics::R

2005-07-12 Thread Gabor Grothendieck
On 7/12/05, Luc Vereecken <[EMAIL PROTECTED]> wrote:
> Hi list,
> 
> For my research, I started using R as a statistics engine, driven by
> perl scripts that manage my data and computational jobs. I recently
> upgraded my cluster to Suse 9.2, and obviously wanted to upgrade R to
> it's latest version, 2.1.1. Installation of R-2.1.1 went flawlessly
> thanks to the rpm's created by Detlef Steuer (see cran, thanks Detlef).
> 
> To interface perl and R, two packages are available: RSPerl and
> Statistics::R. Neither of the two installed out of the box, so I
> describe the problems here, as well as their solutions, for use by others.
> 
> 
> My scripts are based on a perl package Statistics::R, available from
> the perl CPAN in version 0.02. Installation of such a perl package is
> normally performed by doing:
> perl -MCPAN -e 'install Statistics::R'
> but the installation failed due to errors in the tests requiring me
> to ctrl-C the test program. I was able to force an install of this
> package by entering the CPAN shell:
> perl -MCPAN -e shell
> and executing a forced install:
> force install Statistics::R
> killing the test program halfway the install. Some investigation
> learned that Statistics::R as it is available at this time can not
> possible run as R is invoked as
> R --slave --vanilla --gui=none
> which used to work in older version of R, but the current versions no
> longer support --gui=none causing an error "ERROR: unknown GUI none".
> Strangely, invoking "R BATCH" sets the gui to none according to the
> manual, so either gui=none still exists internally but is simply no
> longer supported by the R script, or the R BATCH manual is not
> correctly updated.
> Statistics::R can be installed and made to work by using the forced
> install described above, and by editing the startup perl routines
> removing the gui=none option from the command line. This command line
> can be found in
> /usr/lib/perl5/site_perl/5.8.5/Statistics/R/Bridge/Linux.pm for my
> installation, it should be similar for other perl versions and
> library-locations.
> 
> 
> RSPerl 0.7, available from www.omagahat.org/RSPerl/ , gives on it's
> main page the command
> R INSTALL -c -l  RSPerl_0.7-0.tar.gz
> or
> R INSTALL -c -l  --configure-args='--with-in-perl'
> RSPerl_0.7-0.tar.gz
> as installation command. In the "calling R from perl" PDF document,
> the command given is:
> R CMD INSTALL -c -configure-args='-with-in-perl' RSPerl
> None of these commands work due to typo's.
> A working command line is:
> R CMD INSTALL -c -l 
> --configure-args='--with-in-perl' RSPerl_0.7-0.tar.gz
> 
> Hope this is of use to anyone,
> 
> Luc Vereecken

I don't know the answer to your question and do all my analyses on
Windows rather than UNIX but I used to use perl for data processing
and another software for statistical analysis and what I really liked
about moving to R was that it is sufficiently powerful that I could eliminate
all my data processing perl code and replace it with much easier to 
maintain R code so now everything is in one environment.  You might 
think about whether that is feasible for you too.

__
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


[R] Installing RSPerl and Statistics::R

2005-07-12 Thread Luc Vereecken
Hi list,

For my research, I started using R as a statistics engine, driven by 
perl scripts that manage my data and computational jobs. I recently 
upgraded my cluster to Suse 9.2, and obviously wanted to upgrade R to 
it's latest version, 2.1.1. Installation of R-2.1.1 went flawlessly 
thanks to the rpm's created by Detlef Steuer (see cran, thanks Detlef).

To interface perl and R, two packages are available: RSPerl and 
Statistics::R. Neither of the two installed out of the box, so I 
describe the problems here, as well as their solutions, for use by others.


My scripts are based on a perl package Statistics::R, available from 
the perl CPAN in version 0.02. Installation of such a perl package is 
normally performed by doing:
 perl -MCPAN -e 'install Statistics::R'
but the installation failed due to errors in the tests requiring me 
to ctrl-C the test program. I was able to force an install of this 
package by entering the CPAN shell:
 perl -MCPAN -e shell
and executing a forced install:
 force install Statistics::R
killing the test program halfway the install. Some investigation 
learned that Statistics::R as it is available at this time can not 
possible run as R is invoked as
 R --slave --vanilla --gui=none
which used to work in older version of R, but the current versions no 
longer support --gui=none causing an error "ERROR: unknown GUI none". 
Strangely, invoking "R BATCH" sets the gui to none according to the 
manual, so either gui=none still exists internally but is simply no 
longer supported by the R script, or the R BATCH manual is not 
correctly updated.
Statistics::R can be installed and made to work by using the forced 
install described above, and by editing the startup perl routines 
removing the gui=none option from the command line. This command line 
can be found in 
/usr/lib/perl5/site_perl/5.8.5/Statistics/R/Bridge/Linux.pm for my 
installation, it should be similar for other perl versions and 
library-locations.


RSPerl 0.7, available from www.omagahat.org/RSPerl/ , gives on it's 
main page the command
 R INSTALL -c -l  RSPerl_0.7-0.tar.gz
or
 R INSTALL -c -l  --configure-args='--with-in-perl' 
RSPerl_0.7-0.tar.gz
as installation command. In the "calling R from perl" PDF document, 
the command given is:
 R CMD INSTALL -c -configure-args='-with-in-perl' RSPerl
None of these commands work due to typo's.
A working command line is:
 R CMD INSTALL -c -l  
--configure-args='--with-in-perl' RSPerl_0.7-0.tar.gz

Hope this is of use to anyone,

Luc Vereecken

__
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


Re: [R] three par. fitting with fitdistr

2005-07-12 Thread Martin Maechler
> "Carsten" == Carsten Steinhoff <[EMAIL PROTECTED]>
> on Tue, 12 Jul 2005 17:49:34 +0200 writes:

Carsten> Hello,

Carsten> I want to fit a tree parameter distribution to
Carsten> given data. I tried it with sample data using the
Carsten> "fitdistr" function.
 
Carsten> Here my workflow that didn't had any result:
 
Carsten> I started with the generalized gamma distr, which is:
Carsten> r*dgamma(x^r,shape,rate)
 
Carsten> The R-function is: 
 
Carsten> ggamma = function (x,r,shape,rate) r*dgamma(x^r,shape,rate=rate)
 
Carsten> For the first step I assumed r = 1 and I generated
Carsten> random numbers with the "standard" Gamma distr.
 
Carsten> rn=rgamma(1000,10,5)
 
Carsten> In the last step I want to reconstruct the parameters from the 
dataset:
 
Carsten> library(MASS)
Carsten> fitdistr(rn, ggamma, list(r=1,shape=10,rate=5))
 
 
Carsten> But there is an error: Error in fitdistr(rn, ggamma, list(r = 1, 
shape = 10,
Carsten> rate = 5)) :  optimization failed
Carsten> although I should have a nearly model-made dataset.
 
Carsten> Where is the problem and how could it be solved?

ggamma() is not a density.
You need to provide the correct multiplication factor (a
function of 'r' at least) in the definition of ggamma() such
that it *does* integrate to 1.

Martin

 
Carsten> Carsten

Carsten> [[alternative HTML version deleted]]
 

please read the posting guide and learn how to not produce
the above !

__
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


[R] SOS Boosting

2005-07-12 Thread Kuhn, Max
>Hi,
>
>I am trying to implement the Adaboost.M1. algorithm as described in
>"The Elements of Statistical Learning" p.301
>I don't use Dtettling 's library "boost" because :
>  - I don't understande the difference beetween Logitboost and L2boost
>  - I 'd like to use larger trees than stumps.
>

It also doesn't have a predict function, which is why I don't use it much.

>By using option weights set to (1/n, 1/n, ..., 1/n) in rpart or tree
>function, the tree obtained is trivial (just root, no split) whereas
>without weight or for each weight >1,trees are just fine.
>
>So here is my question : how are weights taken into account in optimal
>tree's discovery ?
>Did someone implement boosting algorithm ?

Check out the gbm package. It is fairly close to MART in the reference 
you mentioned. To get to adaboost with stumps, you should look at the 
arguments 

  distribution = "adaboost"
  interaction.depth =  1

To get more information see ?gbm (if you have it installed) or the 
file gbm.pdf in the doc directory of the library.

Max

>
>Regards,
>
>Olivier Celhay   -  Student  -  Paris, France


LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{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


Re: [R] adding a factor column based on levels of another factor

2005-07-12 Thread Christoph Buser
Hi Karen 

I am not sure if I understand correctly your question. If no,
please ignore this answer.
Do you want a new factor "group" which contains the same
information like "species", just with other names, e.g
1,2,... or "A","B",... ?

If yes you can do it like this

## Your data.frame (without ht & diam)
dat <- data.frame(uniqueID = factor(1:8),
  species = c("sp2", "sp2", "sp3", "sp65", "sp43", "sp2",
"sp12", "sp3"),
  elev = c(3.5, 4.2, 3.2, 2.2, 5.4, 2.5, 1.1, 3.4))
str(dat)
## new factor group (copy of species)
dat[,"group"] <- dat[,"species"]
## rename the levels into "1", "2", ... or whatever you want:
levels(dat[,"group"]) <- list("3" = "sp12", "4" = "sp2", "2" = "sp3",
  "5" = "sp43", "1" = "sp65")
## control
dat[,"species"]
dat[,"group"]

Please be careful. This only changes the labels into 1,2,...
If you use for example 

as.numeric(dat[,"group"])

you will get the values that are behind the original
alphabetical ordering, meaning "sp12" is 1, "sp2" is 2, etc.
You can change this, too if necessary, using as.character() and
as.numeric() as well.

I hope this is helpful fro your problem.

Regards,

Christoph Buser

--
Christoph Buser <[EMAIL PROTECTED]>
Seminar fuer Statistik, LEO C13
ETH (Federal Inst. Technology)  8092 Zurich  SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/
--

Karen Kotschy writes:
 > Hi R users
 > 
 > Does anyone out there have a better/quicker way of adding a factor column
 > to a data frame based on levels of another factor?
 > 
 > I have a (large) data frame consisting of records for individual plants,
 > each represented by a unique ID number. The species of each plant is
 > indicated in the column "species", which is a factor column with many
 > different levels (species). There are multiple records for each species,
 > and there is no pattern to the order in which the species names appear in
 > the data frame.
 > 
 > e.g.
 >uniqueID species   elev   ht   diam
 > 1  1sp2   3.51.3  55
 > 2  2sp2   4.20.5  15
 > 3  3sp3   3.21.0  13
 > 4  4sp65  2.22.0  14
 > 5  5sp43  5.45.7  20
 > 6  6sp2   2.54.1  32
 > 7  7sp12  1.10.9  5
 > 8  8sp3   3.43.6  2
 > 
 > I would like to add a factor column to this data frame, indicating to
 > which group each individual belongs. All individuals of the same species
 > will belong to the same group.
 > 
 > Is there a quick way of saying "for all instances of species1, give the
 > value 5, for all instances of species2, give the value 4, etc" (where 5
 > and 4 are levels of a factor)?
 > 
 > The only way I can think of doing it is to split the data frame by
 > species, then add a column to each subset showing the group, then
 > re-join all the subsets. This seems clumsy and prone to errors. Anyone
 > know a better way?
 > 
 > I've looked at expand.grid and gl but they don't seem to do what I want.
 > 
 > Thanks!
 > 
 > Karen Kotschy
 > Centre for Water in the Environment
 > University of the Witwatersrand
 > Johannesburg
 > South Africa
 > 
 > __
 > 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

__
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


[R] three par. fitting with fitdistr

2005-07-12 Thread Carsten Steinhoff
Hello,
 
I want to fit a tree parameter distribution to given data. I tried it with
sample data using the "fitdistr" function.
 
Here my workflow that didn't had any result:
 
I started with the generalized gamma distr, which is:
r*dgamma(x^r,shape,rate)
 
The R-function is: 
 
ggamma = function (x,r,shape,rate) r*dgamma(x^r,shape,rate=rate)
 
For the first step I assumed r = 1 and I generated random numbers with the
"standard" Gamma distr.
 
rn=rgamma(1000,10,5)
 
In the last step I want to reconstruct the parameters from the dataset:
 
library(MASS)
fitdistr(rn, ggamma, list(r=1,shape=10,rate=5))
 
 
But there is an error: Error in fitdistr(rn, ggamma, list(r = 1, shape = 10,
rate = 5)) :  optimization failed
although I should have a nearly model-made dataset.
 
Where is the problem and how could it be solved?
 
Carsten

[[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


Re: [R] Determining response variable in a formula

2005-07-12 Thread ronggui
is it what you want?
>dat<-data.frame(x=rnorm(10),y=rnorm(10),z=rnorm(10))
> my.form <- as.formula(y ~ x + z)
> my.form
y ~ x + z
> m<-model.frame(my.form,data=dat)
> model.extract(m,"response")
 1  2  3  4  5  6  7 
-0.3434826  1.0145622 -0.4749584  0.4018080 -0.3039126 -0.8180650  0.5455521 
 8  9 10 
 1.1460328  0.8038568  1.1092655 

=== 2005-07-12 22:43:33 您在来信中写道:===

>I have a formula from which I want to deduce the name of the response
>variable. One way of doing so is as follows:
>
>> my.form <- as.formula("y ~ x + z")
>> all.vars(my.form)[1]
>[1] "y"
>> 
>
>Is there a better way and/or preferrred method of determining "y" from
>my.form than this one? In messing around with terms, I came up with:
>
>> all.vars(terms(my.form))[attr(terms(my.form), "response")]
>[1] "y"
>> 
>
>But that seems too ugly to be best.
>
>Thanks,
>
>Dave Kane
>
>> R.version
> _
>platform i686-pc-linux-gnu
>arch i686 
>os   linux-gnu
>system   i686, linux-gnu  
>status
>major2
>minor1.0  
>year 2005 
>month04   
>day  18   
>language R
>>
>
>__
>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

= = = = = = = = = = = = = = = = = = = =



 

2005-07-12

--
Deparment of Sociology
Fudan University

Blog:http://sociology.yculblog.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

[R] SOS Boosting

2005-07-12 Thread Olivier Celhay
Hi,

I am trying to implement the Adaboost.M1. algorithm as described in
"The Elements of Statistical Learning" p.301
I don't use Dtettling 's library "boost" because :
  - I don't understande the difference beetween Logitboost and L2boost
  - I 'd like to use larger trees than stumps.

By using option weights set to (1/n, 1/n, ..., 1/n) in rpart or tree
function, the tree obtained is trivial (just root, no split) whereas
without weight or for each weight >1,trees are just fine.

So here is my question : how are weights taken into account in optimal
tree's discovery ?
Did someone implement boosting algorithm ?

Regards,

Olivier Celhay   -  Student  -  Paris, France

__
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


Re: [R] Determining response variable in a formula

2005-07-12 Thread Sundar Dorai-Raj


David Kane wrote:
> I have a formula from which I want to deduce the name of the response
> variable. One way of doing so is as follows:
> 
> 
>>my.form <- as.formula("y ~ x + z")
>>all.vars(my.form)[1]
> 
> [1] "y"
> 
> 
> Is there a better way and/or preferrred method of determining "y" from
> my.form than this one? In messing around with terms, I came up with:
> 
> 
>>all.vars(terms(my.form))[attr(terms(my.form), "response")]
> 
> [1] "y"
> 
> 
> But that seems too ugly to be best.
> 
> Thanks,
> 
> Dave Kane
> 
> 
>>R.version
> 
>  _
> platform i686-pc-linux-gnu
> arch i686 
> os   linux-gnu
> system   i686, linux-gnu  
> status
> major2
> minor1.0  
> year 2005 
> month04   
> day  18   
> language R
> 
> 

David,

Using all.vars as you have might be dangerous if you ever encounter a 
one sided formula. For example,

all.vars(y ~ x)[1] # "y"
all.vars(~x)[1] # "x"

You might want to look at nlme::getResponseFormula or I wrote a function 
a while back:

parse.formula <- function(formula) {
   vars <- terms(as.formula(formula))
   y <- if(attr(vars, "response"))
 nlme::getResponseFormula(formula)
   x <- nlme::getCovariateFormula(formula)
   z <- nlme::getGroupsFormula(formula)
   list(response = all.vars(y),
covariates = all.vars(x),
groups = all.vars(z))
}

parse.formula(y ~ x)$response # "y"
parse.formula( ~ x)$response # character(0)


HTH,

--sundar

__
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


Re: [R] question for IF ELSE usage

2005-07-12 Thread ecoinfo
Marc,
 I see. Thanks. 
 Xiaohua
 On 7/12/05, Marc Schwartz (via MN) <[EMAIL PROTECTED]> wrote: 
> 
> On Tue, 2005-07-12 at 16:22 +0200, ecoinfo wrote:
> > Hi R users,
> > Maybe the question is too simple.
> > In a IF ... ELSE ... statement "if(cond) cons.expr else alt.expr", IF 
> and
> > ELSE should be at the same line?
> > For example,
> > if (x1==12)
> > {
> > y1 <- 5
> > }else
> > {
> > y1 <- 3
> > }
> > is right, while
> > if (x1==12)
> > {
> > y1 <- 5
> > }
> > else # Error: syntax error
> > {
> > y1 <- 3
> > }
> > is wrong?
> > Thanks
> 
> Note the following from the Details section of ?"if"
> 
> "Note that it is a common mistake to forget to put braces ({ .. })
> around your statements, e.g., after if(..) or for(). In particular,
> you should not have a newline between } and else to avoid a syntax error
> in entering a if ... else construct at the keyboard or via source. For
> that reason, one (somewhat extreme) attitude of defensive programming is
> to always use braces, e.g., for if clauses."
> 
> 
> One other approach is the following:
> 
> if (x1 == 12)
> {
> y1 <- 5
> } else {
> y1 <- 3
> }
> 
> Note the presence of both braces on the 'else' line.
> 
> HTH,
> 
> Marc Schwartz
> 
> 
> 


--

[[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


[R] Complex plotting in R

2005-07-12 Thread [EMAIL PROTECTED]
Hi list,

I'm looking for a function or a combination of functions to do panel plotting 
of mixed graph types with the same x axis.

I would like to construct a panel with 3 stacked windows with on top a 
histogram, below that 2 cdf plots. They all have the same x axis value but 
different y axis values. Is it possible to construct something like that?

I've looked into the lattice package but it doesn't seem to solve my problem 
because I clearly want 1 x axis for all the graphs so not just a panel with 3 
full graphs.

Something like this:

http://www.ats.ucla.edu/stat/sas/faq/InfluencePlots6.gif

(copyright to whom copyright is due...)

but with the top and bottom graphs merged.

Best regards,
Koen Hufkens

__
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


Re: [R] question for IF ELSE usage

2005-07-12 Thread Marc Schwartz (via MN)
On Tue, 2005-07-12 at 16:22 +0200, ecoinfo wrote:
> Hi R users,
>  Maybe the question is too simple.
>  In a IF ... ELSE ... statement "if(cond) cons.expr else alt.expr", IF and 
> ELSE should be at the same line? 
> For example,
>  if (x1==12)
> {
> y1 <- 5 
> }else
> {
> y1 <- 3
> }
>  is right, while
>  if (x1==12)
> {
> y1 <- 5 
> }
> else # Error: syntax error
> {
> y1 <- 3
> }
>  is wrong? 
>  Thanks

Note the following from the Details section of ?"if"

"Note that it is a common mistake to forget to put braces ({ .. })
around your statements, e.g., after if(..) or for(). In particular,
you should not have a newline between } and else to avoid a syntax error
in entering a if ... else construct at the keyboard or via source. For
that reason, one (somewhat extreme) attitude of defensive programming is
to always use braces, e.g., for if clauses."


One other approach is the following:

if (x1 == 12) 
{
  y1 <- 5 
} else {
  y1 <- 3
}

Note the presence of both braces on the 'else' line.

HTH,

Marc Schwartz

__
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


Re: [R] Off topic -2 Ln Lambda and Chi square

2005-07-12 Thread Conrad Halling
This is a theorem for maximum likelihood tests. See:

Theorem 12.2 (presented without proof), page 391,  in "John E. Freund's 
Mathematical Statistics with Applications", Seventh Edition, by Irwin 
Miller and Marylees Miller. Upper Saddle River, N.J.: Pearson Prentice 
Hall, 2004.

Theorem 12.2: For large n, the distribution of -2 ln Lambda 
approaches, under very general conditions, the chi-square distribution 
with 1 degree of freedom.

Theorem 6.3.1 (given with a proof), p. 335, in "Introduction to 
Mathematical Statistics", Sixth Edition, by RV Hogg, JW McKean, and AT 
Craig. 2005. Upper Saddle River, New Jersey: Pearson Prentice Hall.

Proofs are also given in:

Testing Statistical Hypotheses, Second Edition, by E. L. Lehmann. New 
York: John Wiley and Sons, Inc., 1986

and

Mathematical Statistics, by S. S. Wilkes. New York: John Wiley and Sons, 
Inc., 1962.

-- Conrad

Laura Holt wrote:

>Dear R :
>
>Sorry for the off topic question, but does anyone know the reference for
>the -2 Ln Lambda following a Chi Square distribution, please?
>
>Possibly one of Bartlett's?
>
>Thanks in advance!
>
>Sincerely,
>Laura Holt
>mailto: [EMAIL PROTECTED]
>
>__
>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
>
>  
>

-- 
Conrad Halling
[EMAIL PROTECTED]

__
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


[R] Determining response variable in a formula

2005-07-12 Thread David Kane
I have a formula from which I want to deduce the name of the response
variable. One way of doing so is as follows:

> my.form <- as.formula("y ~ x + z")
> all.vars(my.form)[1]
[1] "y"
> 

Is there a better way and/or preferrred method of determining "y" from
my.form than this one? In messing around with terms, I came up with:

> all.vars(terms(my.form))[attr(terms(my.form), "response")]
[1] "y"
> 

But that seems too ugly to be best.

Thanks,

Dave Kane

> R.version
 _
platform i686-pc-linux-gnu
arch i686 
os   linux-gnu
system   i686, linux-gnu  
status
major2
minor1.0  
year 2005 
month04   
day  18   
language R
>

__
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


Re: [R] vectorizaton

2005-07-12 Thread Liaw, Andy
Try:

mymat <- rowMeans(P, dims=2)

Andy

> From: Dimitri Joe
> 
> Hi,
> 
> I got 1000 NxN matrices grouped in one array. I want one 
> matrix in which p_ij is the average of all the 1000 matrices 
> in the array. Here's what I'm trying to do:
> 
> # P is the NxNx1000 array
> 
> for(i in 1:N)
> for(j in 1:N)
> for(k in 1: 1000)
> mymat[ i, j ] <- mean( P [i , j , k ]  )
> 
> Otherwise, I could have a NxNx1000 vector, and get the N^2 
> means of the 1+ (N^2)*(0: 999) elements. I don't know which 
> is more efficient, but I wouldn't know how to carry this last 
> solution out anyway. Any ideas on how to do this efficiently?
> 
> Thanks,
> 
> Dimitri
>   [[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
> 
> 
>

__
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


[R] vectorizaton

2005-07-12 Thread Dimitri Joe
Hi,

I got 1000 NxN matrices grouped in one array. I want one matrix in which p_ij 
is the average of all the 1000 matrices in the array. Here's what I'm trying to 
do:

# P is the NxNx1000 array

for(i in 1:N)
for(j in 1:N)
for(k in 1: 1000)
mymat[ i, j ] <- mean( P [i , j , k ]  )

Otherwise, I could have a NxNx1000 vector, and get the N^2 means of the 1+ 
(N^2)*(0: 999) elements. I don't know which is more efficient, but I wouldn't 
know how to carry this last solution out anyway. Any ideas on how to do this 
efficiently?

Thanks,

Dimitri
[[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


[R] question for IF ELSE usage

2005-07-12 Thread ecoinfo
Hi R users,
 Maybe the question is too simple.
 In a IF ... ELSE ... statement "if(cond) cons.expr else alt.expr", IF and 
ELSE should be at the same line? 
For example,
 if (x1==12)
{
y1 <- 5 
}else
{
y1 <- 3
}
 is right, while
 if (x1==12)
{
y1 <- 5 
}
else # Error: syntax error
{
y1 <- 3
}
 is wrong? 
 Thanks

-- 
Xiaohua Dai

Centre for Systems Research, Durban Institute of Technology
P.O.Box 953, Durban 4000, South Africa
Tel: +27-31-2042737(O) Fax: +27-31-2042736(O)
Mobile: +27-723682954

[[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


Re: [R] R: to the power

2005-07-12 Thread davidr
In general, x^y is evaluated as exp(y*log(x)). In your case, x is
negative, so log(x) is NaN. Note also that 1/3 is not represented
exactly in your computer anyway, so you would not get an exact cube root
this way; e.g.:

R> format((1234567891112^3)^(1/3),digits=16)
[1] "1234567891112.001"

(Probably a bad example, but you get the idea.)

In general, sign(x)*(abs(x)^(1/3)) is the way to go for cube roots.

David L. Reiner
 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:r-help-
> [EMAIL PROTECTED] On Behalf Of
> [EMAIL PROTECTED]
> Sent: Tuesday, July 12, 2005 8:54 AM
> To: Duncan Murdoch
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] R: to the power
> 
> hi all
> 
> i simply wanted to work with real numbers and thought that (-8)^(1/3)
> should
> work.
> 
> sorry for not making the question clearer.
> 
> /
> allan
> 
> Quoting Duncan Murdoch <[EMAIL PROTECTED]>:
> 
> > On 7/12/2005 9:29 AM, Robin Hankin wrote:
> > > Hi
> > >
> > > I find that one often needs to keep reals real and complexes
complex.
> > >
> > > Try this:
> > >
> > > "cuberooti" <-
> > >function (x)
> > > {
> > >if (is.complex(x)) {
> > >  return(sqrt(x + (0+0i)))
> > >}
> > >sign(x)*  abs(x)^(1/3)
> > > }
> > >
> > >
> > > best wishes
> > >
> > > [see that (0+0i) sitting there!]
> >
> > I don't understand this.
> >
> > 1.  I don't think you meant to use sqrt() there, did you??
> >
> > 2.  What effect does the 0+0i have?  x has already been determined
to be
> > complex.
> >
> > Duncan Murdoch
> >
> 
> __
> 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

__
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


Re: [R] R: to the power

2005-07-12 Thread Duncan Murdoch
On 7/12/2005 9:53 AM, [EMAIL PROTECTED] wrote:
> hi all
> 
> i simply wanted to work with real numbers and thought that (-8)^(1/3) should
> work.

It might work in an ideal world, but not in the R floating point world. 
  There's no way to express (1/3) exactly.   Since (-8)^(1/3 + epsilon) 
(restricted to the reals) is not defined for epsilon near zero but not 
exactly zero, it's really hopeless to expect R to give you what you wanted.

*You* know that you're taking an odd root of a negative number, but R 
doesn't.  You need to use your knowledge to rewrite that mathematical 
expression as the mathematically equivalent -(8^(1/3)) and then things 
will be fine.

Duncan Murdoch



> 
> sorry for not making the question clearer.
> 
> /
> allan
> 
> Quoting Duncan Murdoch <[EMAIL PROTECTED]>:
> 
>> On 7/12/2005 9:29 AM, Robin Hankin wrote:
>> > Hi
>> >
>> > I find that one often needs to keep reals real and complexes complex.
>> >
>> > Try this:
>> >
>> > "cuberooti" <-
>> >function (x)
>> > {
>> >if (is.complex(x)) {
>> >  return(sqrt(x + (0+0i)))
>> >}
>> >sign(x)*  abs(x)^(1/3)
>> > }
>> >
>> >
>> > best wishes
>> >
>> > [see that (0+0i) sitting there!]
>>
>> I don't understand this.
>>
>> 1.  I don't think you meant to use sqrt() there, did you??
>>
>> 2.  What effect does the 0+0i have?  x has already been determined to be
>> complex.
>>
>> Duncan Murdoch
>>
> 
> 
> 
> 
> 
> This message was sent using IMP, the Internet Messaging Program.

__
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


Re: [R] R: to the power

2005-07-12 Thread Robin Hankin

On 12 Jul 2005, at 14:51, Duncan Murdoch wrote:

> On 7/12/2005 9:29 AM, Robin Hankin wrote:
>

[bogus function snipped]

> I don't understand this.
>
> 1.  I don't think you meant to use sqrt() there, did you??
>
> 2.  What effect does the 0+0i have?  x has already been determined  
> to be
> complex.
>
> Duncan Murdoch
>

Er, guilty on all counts.  I plead the hot weather.

I intended to modify and post the following function
for cube roots.


"sqrti" <-
   function (x)
{
   if (is.complex(x)) {
 return(sqrt(x))
   }
   if (any(x < 0)) {
 return(sqrt(x + 0i))
   }
   return(sqrt(x))
}

[which deals with square roots in a consistent way, handling positive  
reals,
and negative reals, and complexes, in a nice way]

sorry about that




rksh


--
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


Re: [R] R: to the power

2005-07-12 Thread allan_sta_staff_sci_main_uct
hi all

i simply wanted to work with real numbers and thought that (-8)^(1/3) should
work.

sorry for not making the question clearer.

/
allan

Quoting Duncan Murdoch <[EMAIL PROTECTED]>:

> On 7/12/2005 9:29 AM, Robin Hankin wrote:
> > Hi
> >
> > I find that one often needs to keep reals real and complexes complex.
> >
> > Try this:
> >
> > "cuberooti" <-
> >function (x)
> > {
> >if (is.complex(x)) {
> >  return(sqrt(x + (0+0i)))
> >}
> >sign(x)*  abs(x)^(1/3)
> > }
> >
> >
> > best wishes
> >
> > [see that (0+0i) sitting there!]
>
> I don't understand this.
>
> 1.  I don't think you meant to use sqrt() there, did you??
>
> 2.  What effect does the 0+0i have?  x has already been determined to be
> complex.
>
> Duncan Murdoch
>

__
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


Re: [R] R: to the power

2005-07-12 Thread Duncan Murdoch
On 7/12/2005 9:29 AM, Robin Hankin wrote:
> Hi
> 
> I find that one often needs to keep reals real and complexes complex.
> 
> Try this:
> 
> "cuberooti" <-
>function (x)
> {
>if (is.complex(x)) {
>  return(sqrt(x + (0+0i)))
>}
>sign(x)*  abs(x)^(1/3)
> }
> 
> 
> best wishes
> 
> [see that (0+0i) sitting there!]

I don't understand this.

1.  I don't think you meant to use sqrt() there, did you??

2.  What effect does the 0+0i have?  x has already been determined to be 
complex.

Duncan Murdoch

__
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


Re: [R] elegant matrix creation

2005-07-12 Thread Robin Hankin
Gabor


I cannot begin to tell you how much value you have added to my research
with your observation.

A real "eureka" moment for me.

[oh, and it  answered my question as well]


kia ora


Robin


On 12 Jul 2005, at 13:35, Gabor Grothendieck wrote:

> On 7/12/05, Robin Hankin <[EMAIL PROTECTED]> wrote:
>
>> Hi
>>
>> I want to write a little function that takes a vector of arbitrary
>> length "n" and returns a matrix of size n+1 by n+1.
>>
>> I can't easily describe it, but the following function that works for
>> n=3 should convey what I'm trying to do:
>>
>>
>> f <- function(x){
>>   matrix(c(
>>1   ,   0  ,   0 , 0,
>> x[1]  ,   1  ,   0 , 0,
>> x[1]*x[2] , x[2] ,   1 , 0,
>> x[1]*x[2]*x[3], x[2]*x[3], x[3], 1
>> ),
>> 4,4, byrow=T)
>> }
>>
>> f(c(10,7,2))
>>  [,1] [,2] [,3] [,4]
>> [1,]1000
>> [2,]   10100
>> [3,]   70710
>> [4,]  140   1421
>>
>>>
>>>
>>
>>
>> As one goes down column "i", the entries get multiplied by successive
>> elements of x,  starting with x[i], after the first "1"
>>
>> As one goes along a row, one takes a product of the tail end of x,
>> until the zeroes kick in.
>>
>
> I have not checked this generally but at least for
> the 4x4 case its inverse is 0 except for 1s on the
> diagonal and -x on the subdiagonal.  We can use
> diff on a diagonal matrix to give a matrix with
> a diagonal and superdiagonal and then massage that
> into the required form, invert and round --
> leave off the rounding if the components of x
> are not known to be integer.
>
> round(solve(diag(4) - t(diff(diag(5))[,1:4])+diag(4) * c(0,x)))
>

--
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


Re: [R] R: to the power

2005-07-12 Thread Robin Hankin
Hi

I find that one often needs to keep reals real and complexes complex.

Try this:

"cuberooti" <-
   function (x)
{
   if (is.complex(x)) {
 return(sqrt(x + (0+0i)))
   }
   sign(x)*  abs(x)^(1/3)
}


best wishes

[see that (0+0i) sitting there!]

Robin



On 12 Jul 2005, at 14:11, [EMAIL PROTECTED]  
wrote:

> hi all
>
> why does R do this:
>
> (-8)^(1/3)=NaN
>
> the answer should be : -2
>
> a silly question but i kept on getting errors in some of my code  
> due to this
> problem.
>
> i solve the problem as follows:
>
> say we want : (-a)^(1/3)
>
> then : sign(a)*(a^(1/3)) works
>
> but there has to be a simpler way of soing such a simple  
> mathematical operation.
>
> thanking you
> /
> allan
>
> __
> 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
>

--
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


Re: [R] R: to the power

2005-07-12 Thread Sean O'Riordain
> (-8+0i)^(1/3)
[1] 1+1.732051i

ie complex...

On 12/07/05, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> hi all
> 
> why does R do this:
> 
> (-8)^(1/3)=NaN
> 
> the answer should be : -2
> 
> a silly question but i kept on getting errors in some of my code due to this
> problem.
> 
> i solve the problem as follows:
> 
> say we want : (-a)^(1/3)
> 
> then : sign(a)*(a^(1/3)) works
> 
> but there has to be a simpler way of soing such a simple mathematical 
> operation.
> 
> thanking you
> /
> allan
> 
> __
> 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
>

__
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


[R] Sample Datasets for binary classifiers

2005-07-12 Thread Eric Rodriguez
Hi,

I hope I'm not totally Off Topic, but I'm actually working on binary
classifier with probabilistic output [0 -> 1]. I tested my methods
with some sample datasets from UCI Database but I'm still in need of
some samples. Especially, I'm looking for binary datasets with a
probabilistic information of belonging to one of the two classes.
for example, not only values X_1..X_n  associated with a class Y = (C1
or C2) but rather the probability of belonging to class C2  (or
equivalently C1).
Maybe I could generate this probabilistic Y with some bayesian network
but I was wondering if there are other datasets or ideas that could
help me.

Thanks and don't hesitate to ask extra information if my request is
not understandable.

Eric

__
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


[R] : Re: Dispersion in glm (was (no subject))

2005-07-12 Thread Prof Brian Ripley
Actually, glm() does not estimate the dispersion at all, so you will need
to be more specific.

For example, summary.glm() and predict.glm() use the Pearson statistic if 
dispersion=NULL (the default) for most families.  You can supply any other 
value you choose, and the MASS package makes use of this for ML estimation 
of the dispersion parameter (related to the shape) of the gamma family.

There are rather good reasons (serious bias) not to use the deviance
estimate in the binomial and Poisson families (see the example plots in
MASS4), and good reasons not to use either in the gamma family.  As the
Pearson and deviance estimates agree for the gaussian, that does leave
begging the question of why you want to do this.  Further, McCullagh &
Nelder have general arguments why the Pearson estimate might always be
preferred to the deviance one.  So that `another statastical package' 
appears to need justification for its choice.


On Mon, 11 Jul 2005, Smit, R. (Robin) wrote:

> The estimate of glm dispersion can be based on the deviance or on the
> Pearson statistic.
> I have compared output from R glm() to another statastical package and
> it appears that R uses the Pearson statistic.
> I was wondering if it is possible to make use R the deviance instead by
> modifying the glm(...) function?
> Thanks for your attention.

-- 
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


[R] R: to the power

2005-07-12 Thread allan_sta_staff_sci_main_uct
hi all

why does R do this:

(-8)^(1/3)=NaN

the answer should be : -2

a silly question but i kept on getting errors in some of my code due to this
problem.

i solve the problem as follows:

say we want : (-a)^(1/3)

then : sign(a)*(a^(1/3)) works

but there has to be a simpler way of soing such a simple mathematical operation.

thanking you
/
allan

__
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


Re: [R] elegant matrix creation

2005-07-12 Thread Gabor Grothendieck
On 7/12/05, Robin Hankin <[EMAIL PROTECTED]> wrote:
> Hi
> 
> I want to write a little function that takes a vector of arbitrary
> length "n" and returns a matrix of size n+1 by n+1.
> 
> I can't easily describe it, but the following function that works for
> n=3 should convey what I'm trying to do:
> 
> 
> f <- function(x){
>   matrix(c(
>1   ,   0  ,   0 , 0,
> x[1]  ,   1  ,   0 , 0,
> x[1]*x[2] , x[2] ,   1 , 0,
> x[1]*x[2]*x[3], x[2]*x[3], x[3], 1
> ),
> 4,4, byrow=T)
> }
> 
> f(c(10,7,2))
>  [,1] [,2] [,3] [,4]
> [1,]1000
> [2,]   10100
> [3,]   70710
> [4,]  140   1421
>  >
> 
> 
> As one goes down column "i", the entries get multiplied by successive
> elements of x,  starting with x[i], after the first "1"
> 
> As one goes along a row, one takes a product of the tail end of x,
> until the zeroes kick in.

I have not checked this generally but at least for
the 4x4 case its inverse is 0 except for 1s on the 
diagonal and -x on the subdiagonal.  We can use
diff on a diagonal matrix to give a matrix with
a diagonal and superdiagonal and then massage that
into the required form, invert and round --
leave off the rounding if the components of x
are not known to be integer.

round(solve(diag(4) - t(diff(diag(5))[,1:4])+diag(4) * c(0,x)))

__
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


Re: [R] elegant matrix creation

2005-07-12 Thread Uwe Ligges
Robin Hankin wrote:


What about

foo <- function(a){
 n <- length(a)
 X <- diag(n+1)
 X[lower.tri(X)] <- unlist(lapply(seq(n),
 function(x) cumprod(c(1, a)[-seq(x)])))
 X
}

foo(c(10,7,2))


Uwe Ligges



> Hi
> 
> I want to write a little function that takes a vector of arbitrary
> length "n" and returns a matrix of size n+1 by n+1.
> 
> I can't easily describe it, but the following function that works for
> n=3 should convey what I'm trying to do:
> 
> 
> f <- function(x){
>matrix(c(
> 1   ,   0  ,   0 , 0,
> x[1]  ,   1  ,   0 , 0,
> x[1]*x[2] , x[2] ,   1 , 0,
> x[1]*x[2]*x[3], x[2]*x[3], x[3], 1
> ),
> 4,4, byrow=T)
> }
> 
> f(c(10,7,2))
>   [,1] [,2] [,3] [,4]
> [1,]1000
> [2,]   10100
> [3,]   70710
> [4,]  140   1421
>  >
> 
> 
> As one goes down column "i", the entries get multiplied by successive
> elements of x,  starting with x[i], after the first "1"
> 
> As one goes along a row, one takes a product of the tail end of x,
> until the zeroes kick in.
> 
> 
> Am I missing some clever solution?
> 
> 
> 
> --
> 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

__
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


Re: [R] Design: predict.lrm does not recognise lrm.fit object

2005-07-12 Thread Frank E Harrell Jr
Roy Sanderson wrote:
> Hello
> 
> I'm using logistic regression from the Design library (lrm), then fastbw to
> undertake a backward selection and create a reduced model, before trying to
> make predictions against an independent set of data using predict.lrm with
> the reduced model.  I wouldn't normally use this method, but I'm
> contrasting the results with an AIC/MMI approach.  The script contains:
> 
> # Determine full logistic regression
> lrm_logist = lrm(PresAbs ~ Size + X2ndpc + soil + AAR + tjan.jun,
> data=training)
> # Backward selection of variables in model
> lrm_stp = fastbw(lrm_logist, rule="p", sls=0.05)
> # Fit reduced model
> lrm_reduced = lrm.fit(training[,lrm_stp$parms.kept[-1]], training$PresAbs)
> # Predict using parameters from reduced model against a new dataset
> predict(lrm_reduced, testing, type="fitted.ind")

lrm.fit is used internally by lrm and related functions.  You'll need to 
use lrm.  Take lrm_stp$names.kept and create a formula - here is a first 
stab:

form <- as.formula(paste('PresAbs ~', 
paste(lrm_stp$names.kept,collapse='+')))
lrm_reduced <- lrm(form, ...)

This only works because you are forcing everything to be linear (highly 
  unlikely) and are not allowing any interactions.

Remember that is you use resampling to validate the model you need to 
start with the full list of candidate variables for each resample, 
having validate or calibrate functions repeat fastbw internally.

Frank

> 
> It is the last command that fails, reporting the error:
> Error in getOldDesign(fit): fit was not created with a Design library
> fitting function.
> 
> On further investigation, the class of the object from lrm.fit is only
> "lrm", whereas predict.lrm seems to be expecting objects with the class
> "lrm", "Design", "glm", judging from the examples on the predict.lrm help
> page.  Many of the attributes differ also.  Does anyone know a simple
> work-around for this problem?
> 
> Many thanks
> Roy
> 
> __
> 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
> 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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


Re: [R] bug in chdir option of source

2005-07-12 Thread Peter Dalgaard
[EMAIL PROTECTED] writes:

> I apologize for not having investigated enough.
> 
> However I want to bring up the point that upgrading can be a very
> tedious thing. I administer a cluster for which upgrading brings it to a
> halt for several hours stopping all calculations going on. At the moment
> I have no way to go from 2.1.0 to 2.1.1.

Hmm, I'll believe you, but the blame for that can be shifted in
various directions. 

> I just want to add this point to the release policy of R which
> historically has very quick release cycles which on the one hand is a
> very positive thing but on the other hand can be problematic with
> respect to some aspects.

Actually, we have quite slow release cycles compared to other
OpenSource projects. It's basically twice a year plus minor patches.
According to freshmeat.net, a project's "vitality" essentially drops
to zero a month after the latest release.

Now if only people would actually try the betas rather than reporting
errors after the release, we'd have a much better chance of avoiding
problems like yours...

-- 
   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


Re: [R] bug in chdir option of source

2005-07-12 Thread Duncan Murdoch
[EMAIL PROTECTED] wrote:
> I apologize for not having investigated enough.
> 
> However I want to bring up the point that upgrading can be a very
> tedious thing. I administer a cluster for which upgrading brings it to a
> halt for several hours stopping all calculations going on. At the moment
> I have no way to go from 2.1.0 to 2.1.1.

One simple solution is to test on a different system (e.g. a standalone 
one).  If the bug is present in 2.1.0 there but absent on 2.1.1, it's 
probably fixed on your cluster, too.

Another option which may or may not work is just to read the NEWS file 
for the newer releases.  It's not always obvious that a bug fix there 
fixes your own problem, but sometimes it is.
> 
> I just want to add this point to the release policy of R which
> historically has very quick release cycles which on the one hand is a
> very positive thing but on the other hand can be problematic with
> respect to some aspects.

It's hard to decide which versions to install.  On the one hand, if 
installs are difficult, you want to do it infrequently -- so maybe skip 
all the x.y.0 releases.  On the other hand, if you have unusual 
hardware, you are likely to see bugs that others don't see -- so 
installing the betas and the .0 releases will help to get your bugs fixed.

This is why it's useful to have two systems, one for "production", one 
for testing.  Then you can follow both policies.

Duncan Murdoch
> 
> Thanks again, Stefan
> 
> 
> On Tue, 2005-07-12 at 13:02, Prof Brian Ripley wrote:
> 
>>Please read the posting guide (as we do ask) and use the current version
>>as it asks to see if the `bug' has already been fixed.
>>
>>This was fixed a while ago, definitely in 2.1.1.
>>
>>On Tue, 12 Jul 2005 [EMAIL PROTECTED] wrote:
>>
>>
>>>I'm on R 2.1.0.
>>>
>>>In the "source" function there is a bug preventing the proper use of the
>>>chdir option (which simply doesn't work).
>>>
>>>The problem is that in the function the following line occurs:
>>>file <- file(file, "r", encoding = encoding)
>>>
>>>This overwrites the variable "file" and later causes the check
>>>   if (chdir && is.character(file) && (path <- dirname(file)) !=
>>>   ".")
>>>to fail.
> 
> 
> __
> 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

__
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


Re: [R] Puzzled at ifelse()

2005-07-12 Thread Prof Brian Ripley
This is working exactly as documented.  Nothing `breaks'!

What does the help page say?

  'ifelse' returns a value with the same shape as 'test' which is
  filled with elements selected from either 'yes' or 'no' depending
  on whether the element of 'test' is 'TRUE' or 'FALSE'.

'test' is of length one and true, so you got the first element of 'yes', 
which is a list as the first (and only) element of the answer.

On Tue, 12 Jul 2005, Ajay Narottam Shah wrote:

> I have a situation where this is fine:
>
>  > if (length(x)>15) {
>  clever <- rr.ATM(x, maxtrim=7)
>} else {
>  clever <- rr.ATM(x)
>}
>  > clever
>  $ATM
>  [1] 1848.929
>
>  $sigma
>  [1] 1.613415
>
>  $trim
>  [1] 0
>
>  $lo
>  [1] 1845.714
>
>  $hi
>  [1] 1852.143
>
> But this variant, using ifelse(), breaks:
>
>  > clever <- ifelse(length(x)>15, rr.ATM(x, maxtrim=7), rr.ATM(x))
>  > clever
>  [[1]]
>  [1] 1848.929
>
> What am I doing wrong?

-- 
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


Re: [R] bug in chdir option of source

2005-07-12 Thread Prof Brian Ripley
On Tue, 12 Jul 2005 [EMAIL PROTECTED] wrote:

> I apologize for not having investigated enough.
>
> However I want to bring up the point that upgrading can be a very
> tedious thing. I administer a cluster for which upgrading brings it to a
> halt for several hours stopping all calculations going on. At the moment
> I have no way to go from 2.1.0 to 2.1.1.
>
> I just want to add this point to the release policy of R which
> historically has very quick release cycles which on the one hand is a
> very positive thing but on the other hand can be problematic with
> respect to some aspects.

I really don't understand.  Just install the current R in a different 
place and try it.  If it works better, use it for newly-started jobs.
We too run a large cluster (and a few hundred loosely connected machines) 
and are able to upgrade pretty transparently even when long jobs are 
running.

For those who are reluctant to upgrade, I would suggest never installing a 
.0 release (of any software, not just R).

>
> Thanks again, Stefan
>
>
> On Tue, 2005-07-12 at 13:02, Prof Brian Ripley wrote:
>> Please read the posting guide (as we do ask) and use the current version
>> as it asks to see if the `bug' has already been fixed.
>>
>> This was fixed a while ago, definitely in 2.1.1.
>>
>> On Tue, 12 Jul 2005 [EMAIL PROTECTED] wrote:
>>
>>> I'm on R 2.1.0.
>>>
>>> In the "source" function there is a bug preventing the proper use of the
>>> chdir option (which simply doesn't work).
>>>
>>> The problem is that in the function the following line occurs:
>>> file <- file(file, "r", encoding = encoding)
>>>
>>> This overwrites the variable "file" and later causes the check
>>>if (chdir && is.character(file) && (path <- dirname(file)) !=
>>>".")
>>> to fail.
>
>

-- 
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


Re: [R] adding a factor column based on levels of another factor

2005-07-12 Thread Henrik Andersson
First create a dataframe with the translation you want, i.e.

one column with the species and another with the number you want in the end.

Then merge these two dataframes using 'merge' and voila..

I would start with looking at ?merge

Cheers, Henrik Andersson

Karen Kotschy wrote:
> Hi R users
> 
> Does anyone out there have a better/quicker way of adding a factor column
> to a data frame based on levels of another factor?
> 
> I have a (large) data frame consisting of records for individual plants,
> each represented by a unique ID number. The species of each plant is
> indicated in the column "species", which is a factor column with many
> different levels (species). There are multiple records for each species,
> and there is no pattern to the order in which the species names appear in
> the data frame.
> 
> e.g.
>uniqueID species   elev   ht   diam
> 1  1sp2   3.51.3  55
> 2  2sp2   4.20.5  15
> 3  3sp3   3.21.0  13
> 4  4sp65  2.22.0  14
> 5  5sp43  5.45.7  20
> 6  6sp2   2.54.1  32
> 7  7sp12  1.10.9  5
> 8  8sp3   3.43.6  2
> 
> I would like to add a factor column to this data frame, indicating to
> which group each individual belongs. All individuals of the same species
> will belong to the same group.
> 
> Is there a quick way of saying "for all instances of species1, give the
> value 5, for all instances of species2, give the value 4, etc" (where 5
> and 4 are levels of a factor)?
> 
> The only way I can think of doing it is to split the data frame by
> species, then add a column to each subset showing the group, then
> re-join all the subsets. This seems clumsy and prone to errors. Anyone
> know a better way?
> 
> I've looked at expand.grid and gl but they don't seem to do what I want.
> 
> Thanks!
> 
> Karen Kotschy
> Centre for Water in the Environment
> University of the Witwatersrand
> Johannesburg
> South Africa
> 
> __
> 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
> 


-- 
-
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577473
[EMAIL PROTECTED]
http://www.nioo.knaw.nl/ppages/handersson

__
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


Re: [R] elegant matrix creation

2005-07-12 Thread Arne Henningsen
Maybe not elegant, but I guess this function does what you want:

f <- function( x ) {
   n <- length( x ) + 1
   m <- matrix( 0, nrow = n, ncol = n )
   diag(m) <- 1
   for( j in 1:( n-1 ) ) {
  for( i in ( j+1 ):n ) {
 m[ i, j ] <- prod( x[ j:(i-1) ] )
  }
   }
   return( m )
}

Best wishes,
Arne

On Tuesday 12 July 2005 13:11, Robin Hankin wrote:
> Hi
>
> I want to write a little function that takes a vector of arbitrary
> length "n" and returns a matrix of size n+1 by n+1.
>
> I can't easily describe it, but the following function that works for
> n=3 should convey what I'm trying to do:
>
>
> f <- function(x){
>matrix(c(
> 1   ,   0  ,   0 , 0,
> x[1]  ,   1  ,   0 , 0,
> x[1]*x[2] , x[2] ,   1 , 0,
> x[1]*x[2]*x[3], x[2]*x[3], x[3], 1
> ),
> 4,4, byrow=T)
> }
>
> f(c(10,7,2))
>   [,1] [,2] [,3] [,4]
> [1,]1000
> [2,]   10100
> [3,]   70710
> [4,]  140   1421
>
>
>
> As one goes down column "i", the entries get multiplied by successive
> elements of x,  starting with x[i], after the first "1"
>
> As one goes along a row, one takes a product of the tail end of x,
> until the zeroes kick in.
>
>
> Am I missing some clever solution?
>
>
>
> --
> 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

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
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


Re: [R] bug in chdir option of source

2005-07-12 Thread usenet
I apologize for not having investigated enough.

However I want to bring up the point that upgrading can be a very
tedious thing. I administer a cluster for which upgrading brings it to a
halt for several hours stopping all calculations going on. At the moment
I have no way to go from 2.1.0 to 2.1.1.

I just want to add this point to the release policy of R which
historically has very quick release cycles which on the one hand is a
very positive thing but on the other hand can be problematic with
respect to some aspects.

Thanks again, Stefan


On Tue, 2005-07-12 at 13:02, Prof Brian Ripley wrote:
> Please read the posting guide (as we do ask) and use the current version
> as it asks to see if the `bug' has already been fixed.
>
> This was fixed a while ago, definitely in 2.1.1.
>
> On Tue, 12 Jul 2005 [EMAIL PROTECTED] wrote:
>
> > I'm on R 2.1.0.
> >
> > In the "source" function there is a bug preventing the proper use of the
> > chdir option (which simply doesn't work).
> >
> > The problem is that in the function the following line occurs:
> > file <- file(file, "r", encoding = encoding)
> >
> > This overwrites the variable "file" and later causes the check
> >if (chdir && is.character(file) && (path <- dirname(file)) !=
> >".")
> > to fail.

__
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


Re: [R] help: how to use tkevent.generate(...)

2005-07-12 Thread Peter Dalgaard
wu sz <[EMAIL PROTECTED]> writes:

> Hello,
> 
> I use package "tcltk" to do some GUI programming, and want to find a
> function which can do the operation "click a button", just like using
> a mouse to click. If tkevent.generate can do that? I tried it as
> below, but failed. Please give me a hint!
> 
> tt <- tktoplevel()
> tkwm.title(tt,"Simple Dialog")
> 
> onOK <- function(){print("OK")}
> onCancel <- function(){print("Cancel")}
> OK.but <- tkbutton(tt, text="  OK  ", command=onOK)
> Cancel.but <- tkbutton(tt, text="Cancel",command=onCancel)
> tkgrid(OK.but,Cancel.but)
> 
> tkevent.generate(tt, onOK)

That would never work: At the very least you need to send *events* and
to the right widget, not the toplevel. If you just wanted to run onOK,
there's an easier way: onOK(), or generically:

  tcl("eval", tkcget(OK.but, command=NULL))

to run the command associated with OK.but (whether it is an R callback
or not).

The right way to trigger a button press event turns out to be a bit
tricky, but Googling about (for the tcl/tk counterpart "event
generate") found the solution: You need not one, but three events:
Entering the button, pressing the mouse button, releasing the mouse
button, i.e.:

tkevent.generate(OK.but,"")
tkevent.generate(OK.but,"<1>")
tkevent.generate(OK.but,"")


for (e in c("","<1>",""))
   tkevent.generate(OK.but,e)






-- 
   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


Re: [R] R.oo static field

2005-07-12 Thread Henrik Bengtsson

Omar Lakkis wrote:

How can I define a static member of a class? not a static method,
rather a static field that would be accessed by all instances of the
class.


To define a static field in an Object class (the R.oo package), I 
recommend you to use a private field <.field> and then create a virtual 
field  by defining methods get() and setmethods should get and set the field <.field> of the _static_ instance 
of the class. Below is an example, which also modifies the static field 
already in the constructor something which otherwise may be tricky. I 
will add this example to the help pages of R.oo in the next release.


Hope it helps

Henrik Bengtsson (author of R.oo)

##
# Example illustrating how to "emulate" static fields using virtual
# fields, i.e. get- and set-methods.  Here we use a private static
# field '.count' of the static class instance 'MyClass', i.e.
# MyClass$.count.  Then we define a virtual field 'count' via method
# getCount() to access this static field.  This will make all queries
# for 'count' of any object to use the static field instead.  In the
# same way is assignment controlled via the setCount() method.  A
# side effect of this way of coding is that all MyClass instances will
# also have the private field '.count' (set to zero except for the
# static field that is).
##
library(R.oo)

setConstructorS3("MyClass", function(...) {
  # Create an instance (the static class instance included)
  this <- extend(Object(), "MyClass",
.count = 0
  )

  # In order for a static field to be updated in the
  # constructor it has to be done after extend().
  this$count <- this$count + 1;

  # Return the object
  this;
})


setMethodS3("as.character", "MyClass", function(this, ...) {
  paste(class(this)[1], ": Number of instances: ", this$count, sep="");
})


# Get virtual field 'count', e.g. obj$count.
setMethodS3("getCount", "MyClass", function(this, ...) {
  MyClass$.count;
})


# Set virtual field 'count', e.g. obj$count <- value.
setMethodS3("setCount", "MyClass", function(this, value, ...) {
  MyClass$.count <- value;
})


# Create four instances of class 'MyClass'
obj <- lapply(1:4, MyClass)
print(obj)
print(MyClass$count)
print(obj[[1]]$count)
##
# Example illustrating how to "emulate" static fields using virtual
# fields, i.e. get- and set-methods.  Here we use a private static 
# field '.count' of the static class instance 'MyClass', i.e. 
# MyClass$.count.  Then we define a virtual field 'count' via method
# getCount() to access this static field.  This will make all queries
# for 'count' of any object to use the static field instead.  In the
# same way is assignment controlled via the setCount() method.  A 
# side effect of this way of coding is that all MyClass instances will
# also have the private field '.count' (set to zero except for the
# static field that is).
##
library(R.oo)

setConstructorS3("MyClass", function(...) {
  # Create an instance (the static class instance included)
  this <- extend(Object(), "MyClass",
.count = 0
  )

  # In order for a static field to be updated in the 
  # constructor it has to be done after extend().
  this$count <- this$count + 1;

  # Return the object
  this;
})


setMethodS3("as.character", "MyClass", function(this, ...) {
  paste(class(this)[1], ": Number of instances: ", this$count, sep="");
})


# Get virtual field 'count', e.g. obj$count.
setMethodS3("getCount", "MyClass", function(this, ...) {
  MyClass$.count;
})


# Set virtual field 'count', e.g. obj$count <- value.
setMethodS3("setCount", "MyClass", function(this, value, ...) {
  MyClass$.count <- value;
})


# Create four instances of class 'MyClass'
obj <- lapply(1:4, MyClass)
print(obj)
print(MyClass$count)
print(obj[[1]]$count)
__
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

[R] elegant matrix creation

2005-07-12 Thread Robin Hankin
Hi

I want to write a little function that takes a vector of arbitrary
length "n" and returns a matrix of size n+1 by n+1.

I can't easily describe it, but the following function that works for
n=3 should convey what I'm trying to do:


f <- function(x){
   matrix(c(
1   ,   0  ,   0 , 0,
x[1]  ,   1  ,   0 , 0,
x[1]*x[2] , x[2] ,   1 , 0,
x[1]*x[2]*x[3], x[2]*x[3], x[3], 1
),
4,4, byrow=T)
}

f(c(10,7,2))
  [,1] [,2] [,3] [,4]
[1,]1000
[2,]   10100
[3,]   70710
[4,]  140   1421
 >


As one goes down column "i", the entries get multiplied by successive
elements of x,  starting with x[i], after the first "1"

As one goes along a row, one takes a product of the tail end of x,
until the zeroes kick in.


Am I missing some clever solution?



--
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


[R] unexpected behavior in bwplot

2005-07-12 Thread Ritter, Christian C GSMCIL-GSTMS/2
R-2.1.1 on windows XP

I just noticed something unpleasant when using bwplot (from lattice). 

In order to satisfy a wish from a client, I needed to produce sets of boxplots 
conditioned by another factor. My client didn't like the look of the boxplots 
(by default, they have a star to mark the median, instead of the commonly used 
line). I told him "no problem" dumped panel.bwplot, added a line at the median, 
commented out the star, and sourced it back in as panel.mybwplot. 

Then I tried to call it with bwplot(...,panel="panel.mybwplot"), but this hit 
two roadblocks. The first one was relatively easy: it didn't find the function 
current.viewport (from grid). Explicitely loading the package grid was 
sufficient (current.viewport is exported there). But then it stopped on 
chooseFace. It was not obvious to find where chooseFace was (in lattice, but 
not as an exported function in the namespace) and how to make it callable. I 
finally clobbered it by defining chooseFace<-lattice:::chooseFace. This 
certainly worked but is very inelegant. Could anyone point me to cleaner ways 
to do this? 

On the other hand, I would have preferred if panel.bwplot would not use 
functions not exported to the outer namespace (or if lattice would make sure 
that all functions called in the standard panel functions were exported to the 
outer namespace). It is very common that we have to slightly modify standard 
panel functions and it is quite annoying having to chase for evenually hidden 
functions called by them. Comments? 

Thanks in advance,

Christian Ritter
Functional Specialist Statistics
Shell Coordination Centre S.A.
Monnet Centre International Laboratory, Avenue Jean Monnet 1, B-1348 
Louvain-La-Neuve, Belgium

Tel: +32 10 477  349 Fax: +32 10 477 219
Email: [EMAIL PROTECTED]
Internet: http://www.shell.com/chemicals



[[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


Re: [R] what is the .Machine$double.xmin for a 64 bit machine?

2005-07-12 Thread Prof Brian Ripley
It's a floating-point quantity: `64 bit' refers to the pointer size 
(only).

Almost all current R platforms use IEC60559 arithmetic for real numbers 
and 32-bit integers for integers, so differ only in the way the compiler 
orders operations and stores to memory (thereby losing precision on some 
CPUs).

On Tue, 12 Jul 2005, S.O. Nyangoma wrote:

>
> I use a 32 bit machine. For those using 64 bit machines,
>
> what is the .Machine$double.xmin for for machines?
>
> regards. Stephen.
>
>
>
>
> - Original Message -
> From: Achim Zeileis <[EMAIL PROTECTED]>
> Date: Tuesday, July 12, 2005 10:51 am
> Subject: Re: [R] exact values for p-values - more information.
>
>> On Tue, 12 Jul 2005, S.O. Nyangoma wrote:
>>
 If they have the same degrees of freedom, use the test statistic
 and not
 the p value for comparing them.
 Z
>>>
>>> I appretiate your input to this discussion. Do you know of a
>> reference> to your statement above?
>>
>> ?? Any basic statistics book? Distribution functions tend to be
>> monotonous.
>>
>>> I had actually used the test-statistic which in my case is r-
> squared
>>> to compare them. This is in my view was adequate but I also
>> think it
>>> is more convincing to say something about the p-values
>>
>> Not really `more' convincing, it's all pretty equivalent when the
>> numberof estimated parameters is the same. You can also compare
>> the fitted
>> models via their associated residual sum of squares which I would
> find
>> most intuitive because that is the objective function you are
>> trying to
>> minimize via OLS.
>> Z
>>
>>> (difficulties
>>> in computing them, and hence the rationale of solely using the
>> test-
>>> stat).
>>>
>>> regards. Stephen.
>>>
>>>
>>>
>>
>
> __
> 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
>

-- 
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


Re: [R] bug in chdir option of source

2005-07-12 Thread Prof Brian Ripley
Please read the posting guide (as we do ask) and use the current version 
as it asks to see if the `bug' has already been fixed.

This was fixed a while ago, definitely in 2.1.1.

On Tue, 12 Jul 2005 [EMAIL PROTECTED] wrote:

> I'm on R 2.1.0.
>
> In the "source" function there is a bug preventing the proper use of the
> chdir option (which simply doesn't work).
>
> The problem is that in the function the following line occurs:
> file <- file(file, "r", encoding = encoding)
>
> This overwrites the variable "file" and later causes the check
>if (chdir && is.character(file) && (path <- dirname(file)) !=
>".")
> to fail.

-- 
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


Re: [R] how to generate argument from a vector automatically

2005-07-12 Thread Adaikalavan Ramasamy
You can do it by subsetting the dataframe 

  df <- data.frame( y=rbinom(100, 1, prob=0.5), 
x1=rnorm(100), x2=rnorm(100), x3=rnorm(100),
z1=rnorm(100), z2=rnorm(100) )
  names <- c("x1", "x2", "x3")
  tree( y ~ . , data = df[ , c("y", names) ] )

This solution is useless when you want to consider interactions between
some terms etc. Another more flexible solution is from last example from
help(formula) :

   xnam <- paste("x", 1:3, sep="")
   call <- as.formula(paste("y ~ ", paste(xnam, collapse= "+")))
   tree( call, df )

Regards, Adai



On Tue, 2005-07-12 at 09:53 +, zhihua li wrote:
> hi netters
> 
> i have a vector NAMES containing a series of variable names: 
> NAMES=c(x,r,z,m,st,qr,.nn).
> i wanna fit a regression tree by using the code:  
>my.tree<-tree(y~x+r+z+m+nn,my.dataframe)
> 
> but i don't want to type out "x+r+z+m++nn" one by one, as there are so 
> many variables. besides, sometimes i wanna put the code in a function. so i 
> need to have the argument "x+r+z+m++nn" generated from NAMES 
> automatically.
> 
> i've tried the code: paste(X,collpase="+") but it didn't work.
> 
> could anybody give me a hint?
> 
> __
> 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

__
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


[R] adding a factor column based on levels of another factor

2005-07-12 Thread Karen Kotschy
Hi R users

Does anyone out there have a better/quicker way of adding a factor column
to a data frame based on levels of another factor?

I have a (large) data frame consisting of records for individual plants,
each represented by a unique ID number. The species of each plant is
indicated in the column "species", which is a factor column with many
different levels (species). There are multiple records for each species,
and there is no pattern to the order in which the species names appear in
the data frame.

e.g.
   uniqueID species   elev   ht   diam
1  1sp2   3.51.3  55
2  2sp2   4.20.5  15
3  3sp3   3.21.0  13
4  4sp65  2.22.0  14
5  5sp43  5.45.7  20
6  6sp2   2.54.1  32
7  7sp12  1.10.9  5
8  8sp3   3.43.6  2

I would like to add a factor column to this data frame, indicating to
which group each individual belongs. All individuals of the same species
will belong to the same group.

Is there a quick way of saying "for all instances of species1, give the
value 5, for all instances of species2, give the value 4, etc" (where 5
and 4 are levels of a factor)?

The only way I can think of doing it is to split the data frame by
species, then add a column to each subset showing the group, then
re-join all the subsets. This seems clumsy and prone to errors. Anyone
know a better way?

I've looked at expand.grid and gl but they don't seem to do what I want.

Thanks!

Karen Kotschy
Centre for Water in the Environment
University of the Witwatersrand
Johannesburg
South Africa

__
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


Re: [R] how to generate argument from a vector automatically

2005-07-12 Thread Uwe Ligges
zhihua li wrote:

> hi netters
> 
> i have a vector NAMES containing a series of variable names: 
> NAMES=c(x,r,z,m,st,qr,.nn).
> i wanna fit a regression tree by using the code:
> my.tree<-tree(y~x+r+z+m+nn,my.dataframe)
> 
> but i don't want to type out "x+r+z+m++nn" one by one, as there are 
> so many variables. besides, sometimes i wanna put the code in a 
> function. so i need to have the argument "x+r+z+m++nn" generated 
> from NAMES automatically.
> 
> i've tried the code: paste(X,collpase="+") but it didn't work.

You have to construct it as.formula() from these characters,
or even better use short term formulas such as "y~.", if all variables
should be used anyway.

Uwe Ligges

> could anybody give me a hint?
> 
> 
> 
> 
> __
> 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

__
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


Re: [R] High resolution plots

2005-07-12 Thread Knut Krueger
Sorry i sent the answer not to the mailing list - here it is

Brian D Ripley schrieb:

>On Tue, 12 Jul 2005, Knut Krueger wrote:
>
>  
>
>>Prof Brian Ripley schrieb:
>>
>>
>>
>>>Please read carefully what `resolution' means for a png() device (and a
>>>PNG file).  It is a hint to the viewer in the file header (often ignored),
>>>as described in the R help file.
>>>
>>>  
>>>
>  
>
>>>On Tue, 12 Jul 2005, Knut Krueger wrote:
>>>
>>>
>>>
>>>  
>>>
Is there any possibility to get high resolution plots in a windows xp
system?
I tried it with the device function png(filename =
"c:/r/highresplot%d.png",pointsize=12, res=900)
but when I try to set: width = 480, height = 480 or   pointsize = 12,
the text is not scaled in the same way as the plots.


Ok first:
I do not want anybody to get angry and I am the first time in this group.
I will make any mistakes like sending you your own help file and I
apologize in advance for those mistakes.

>Not if you just include those arguments or not.  Yes if you include
>res=900 or not, but that is not what you said.
>  
>
I tried to include res=600 and res=300 there was no difference in the
file, both size was 4kb  480*480 Pixel and 150 dpi
png(filename = "c:/r/highresplot%d.png",width = 480, height =
480,pointsize=12, res=300)
png(filename = "c:/r/highresplot%d.png",width = 480, height =
480,pointsize=12, res=600)


second attempt was to increase width = 480, height = 480 to width = 960,
height = 960

png(filename = "c:/r/highresplot%d.png",width = 960, height =
960,pointsize=12, res=600)
png(filename = "c:/r/highresplot%d.png",width = 480, height =
480,pointsize=12, res=300)


both is the file size 8kb either with res=300 or res=600
double file size with double size of the device that's what i expected.

The letters are nearly unreadable because they are very small - ok
png(filename = "c:/r/highresplot%d.png",width = 480, height =
480,pointsize=24, res=300)
Letters are in the same size as
png(filename = "c:/r/highresplot%d.png",width = 480, height =
480,pointsize=12, res=300)
also that's what I expected, but the quality of the characters is as bad
as when I would extract the plot with any graphic application
and the small lines from boxplots are sometimes visible sometimes not.


>Why aer you sending me a help file I wrote, one which you seem to be
>unable to understand?  I am not the one failing to notice what it says.
>


But maybe you are right that I am not understanding the help file, but
I hope that clarifies my problems and my mistakes

with regards
Knut Krueger
http://www.biostatistic.de

__
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


Re: [R] what is the .Machine$double.xmin for a 64 bit machine?

2005-07-12 Thread Peter Dalgaard
"S.O. Nyangoma" <[EMAIL PROTECTED]> writes:

> I use a 32 bit machine. For those using 64 bit machines, 
> 
> what is the .Machine$double.xmin for for machines?
> 
> regards. Stephen.
> 

Depends on the FPU which is basically independent of the address mode:

PIII, Fedora Core 4:

>  .Machine$double.xmin
[1] 2.225074e-308

Opteron, Fedora Core 4:

> .Machine$double.xmin
[1] 2.225074e-308


-- 
   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


Re: [R] Puzzled at ifelse()

2005-07-12 Thread Duncan Murdoch
Ajay Narottam Shah wrote:
> I have a situation where this is fine:
> 
>   > if (length(x)>15) {
>   clever <- rr.ATM(x, maxtrim=7)
> } else {
>   clever <- rr.ATM(x)
> }
>   > clever
>   $ATM
>   [1] 1848.929
> 
>   $sigma
>   [1] 1.613415
> 
>   $trim
>   [1] 0
> 
>   $lo
>   [1] 1845.714
> 
>   $hi
>   [1] 1852.143
> 
> But this variant, using ifelse(), breaks:
> 
>   > clever <- ifelse(length(x)>15, rr.ATM(x, maxtrim=7), rr.ATM(x))
>   > clever
>   [[1]]
>   [1] 1848.929
> 
> What am I doing wrong?

if (test) expr1 else expr2

evaluates only one of expr1 or expr2 according to test, and returns that 
result.

ifelse(test, expr1, expr2)

executes all three of test, expr1, and expr2, and puts together a vector 
response where for each element of test that is true (non-zero), the 
corresponding element of one of the expr's is selected.

I'd guess your x is length 1, so your test is length 1, and only the 
first element of the result of rr.ATM is returned (which is not very 
useful).

To get what you want, you should write

clever <- if(length(x) > 15) rr.ATM(x, maxtrim=7) else rr.ATM(x);

Duncan Murdoch

__
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


[R] help: how to use tkevent.generate(...)

2005-07-12 Thread wu sz
Hello,

I use package "tcltk" to do some GUI programming, and want to find a
function which can do the operation "click a button", just like using
a mouse to click. If tkevent.generate can do that? I tried it as
below, but failed. Please give me a hint!

tt <- tktoplevel()
tkwm.title(tt,"Simple Dialog")

onOK <- function(){print("OK")}
onCancel <- function(){print("Cancel")}
OK.but <- tkbutton(tt, text="  OK  ", command=onOK)
Cancel.but <- tkbutton(tt, text="Cancel",command=onCancel)
tkgrid(OK.but,Cancel.but)

tkevent.generate(tt, onOK)


Thank you,
Shengzhe

__
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


[R] Design: predict.lrm does not recognise lrm.fit object

2005-07-12 Thread Roy Sanderson
Hello

I'm using logistic regression from the Design library (lrm), then fastbw to
undertake a backward selection and create a reduced model, before trying to
make predictions against an independent set of data using predict.lrm with
the reduced model.  I wouldn't normally use this method, but I'm
contrasting the results with an AIC/MMI approach.  The script contains:

# Determine full logistic regression
lrm_logist = lrm(PresAbs ~ Size + X2ndpc + soil + AAR + tjan.jun,
data=training)
# Backward selection of variables in model
lrm_stp = fastbw(lrm_logist, rule="p", sls=0.05)
# Fit reduced model
lrm_reduced = lrm.fit(training[,lrm_stp$parms.kept[-1]], training$PresAbs)
# Predict using parameters from reduced model against a new dataset
predict(lrm_reduced, testing, type="fitted.ind")

It is the last command that fails, reporting the error:
Error in getOldDesign(fit): fit was not created with a Design library
fitting function.

On further investigation, the class of the object from lrm.fit is only
"lrm", whereas predict.lrm seems to be expecting objects with the class
"lrm", "Design", "glm", judging from the examples on the predict.lrm help
page.  Many of the attributes differ also.  Does anyone know a simple
work-around for this problem?

Many thanks
Roy

__
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


Re: [R] bug in chdir option of source

2005-07-12 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:

> I'm on R 2.1.0.
> 
> In the "source" function there is a bug preventing the proper use of the
> chdir option (which simply doesn't work).
> 
> The problem is that in the function the following line occurs:
>  file <- file(file, "r", encoding = encoding)
> 
> This overwrites the variable "file" and later causes the check
> if (chdir && is.character(file) && (path <- dirname(file)) !=
> ".")
> to fail.
> 
> I have some generic files which are not yet a package that I regularly
> want to source into many other files. How do people handle situations like
> this right now?

They use R-2.1.1 where the bug has been fixed.

Uwe Ligges



> Thanks, Stefan
> 
> __
> 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

__
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


[R] Puzzled at ifelse()

2005-07-12 Thread Ajay Narottam Shah
I have a situation where this is fine:

  > if (length(x)>15) {
  clever <- rr.ATM(x, maxtrim=7)
} else {
  clever <- rr.ATM(x)
}
  > clever
  $ATM
  [1] 1848.929

  $sigma
  [1] 1.613415

  $trim
  [1] 0

  $lo
  [1] 1845.714

  $hi
  [1] 1852.143

But this variant, using ifelse(), breaks:

  > clever <- ifelse(length(x)>15, rr.ATM(x, maxtrim=7), rr.ATM(x))
  > clever
  [[1]]
  [1] 1848.929

What am I doing wrong?

-- 
Ajay Shah   Consultant
[EMAIL PROTECTED]  Department of Economic Affairs
http://www.mayin.org/ajayshah   Ministry of Finance, New Delhi

__
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


Re: [R] Boxplot philosophy {was "Boxplot in R"}

2005-07-12 Thread Renaud Lancelot
Martin Maechler a écrit :
>>"Spencer" == Spencer Graves <[EMAIL PROTECTED]>
>>on Mon, 11 Jul 2005 19:08:39 -0700 writes:
> 
> 
> Spencer> I'll bite:  How does one detect bimodalidty from a boxplot?
> 
> One does not,
> and that (whole area) was the main reason I mentioned  "violin
> plots" which do show features such as bimodality:
> 
> There's a simple violin plot in the (recommended and hence
> always available) package "lattice"
> 
>  library(lattice)
>  example(panel.vioplot)

Or rather

example(panel.violin)

Best,

Renaud


> 
> but for the sake of bimodality {and the version of violin plot
> that was in the 1998 Am.Stat. paper}
> 
>  install.packages("vioplot") # if needed
>  example(vioplot)
> 
> Both of these examples use the basic boxplot but *add* to it, so
> you can, e.g., clearly discern bimodality.
> 
> Martin Maechler
> 
> __
> 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
> 


-- 
Dr Renaud Lancelot, vétérinaire
Projet FSP régional épidémiologie vétérinaire
C/0 Ambassade de France - SCAC
BP 834 Antananarivo 101 - Madagascar

e-mail: [EMAIL PROTECTED]
tel.:   +261 32 40 165 53 (cell)
 +261 20 22 665 36 ext. 225 (work)
 +261 20 22 494 37 (home)

__
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


[R] bug in chdir option of source

2005-07-12 Thread usenet
I'm on R 2.1.0.

In the "source" function there is a bug preventing the proper use of the
chdir option (which simply doesn't work).

The problem is that in the function the following line occurs:
 file <- file(file, "r", encoding = encoding)

This overwrites the variable "file" and later causes the check
if (chdir && is.character(file) && (path <- dirname(file)) !=
".")
to fail.

I have some generic files which are not yet a package that I regularly
want to source into many other files. How do people handle situations like
this right now?

Thanks, Stefan

__
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


Re: [R] testing for significance in random-effect factors using lmer

2005-07-12 Thread Doran, Harold
The default output in lmer also includes goodness of fit statistics which can 
be used for this assessment. The anova() command invokes the likelihood ratio 
test and can be used to compare models (under certain conditions). 

The bVar slot in the lmer fitted model contains the posterior variance of the 
random effects and can be used as well. 

-Harold


-Original Message-
From:   [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
Sent:   Tue 7/12/2005 4:15 AM
To: r-help@stat.math.ethz.ch
Cc: 
Subject:[R] testing for significance in random-effect factors using lmer

Hi, I would like to know whether it is possible to obtain a value of 
significance for random effects when aplying the lme or related 
functions. The default output in R is just a variance and standard 
deviation measurement.

I feel it would be possible to obtain the significance of these random 
effects by comparing models with and without these effects. However, 
I'm not used to perform this in R and I would thank any easy guide or 
example.

Thanks.
--

Eduardo Moisés García Roger

Institut Cavanilles de Biodiversitat i Biologia
Evolutiva - ICBIBE.
Tel. +34963543664
Fax  +34963543670

__
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




[[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

[R] how to generate argument from a vector automatically

2005-07-12 Thread zhihua li

hi netters

i have a vector NAMES containing a series of variable names: 
NAMES=c(x,r,z,m,st,qr,.nn).
i wanna fit a regression tree by using the code:  
  my.tree<-tree(y~x+r+z+m+nn,my.dataframe)


but i don't want to type out "x+r+z+m++nn" one by one, as there are so 
many variables. besides, sometimes i wanna put the code in a function. so i 
need to have the argument "x+r+z+m++nn" generated from NAMES 
automatically.


i've tried the code: paste(X,collpase="+") but it didn't work.

could anybody give me a hint?

__
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

Re: [R] Boxplot philosophy {was "Boxplot in R"}

2005-07-12 Thread Ted Harding
On 12-Jul-05 Ted Harding wrote:
> On 12-Jul-05 Spencer Graves wrote:
>> I'll bite:  How does one detect bimodalidty from a boxplot?
>> 
>> spencer graves
>> 
>> Berton Gunter wrote:
>> [...]
>>> Finally, a tidbit for boxplot afficianados: how does one detect
>>> bimodality from a boxplot?
>>> 
>>> -- Bert Gunter
> 
> Not definitively detectable of course, but certainly suspectable.
> 
> Hint: What is the relationship between the distances from the "median"
> line to the extremes of the "box", and from the extremes of the "box"
> to the ends of the "whiskers", in the case of a uniform distribution?
> 
> 
> 
> If that doesn't trigger it, then:
> 
> Hint:
> 
>   unimod<-rnorm(1000,0,sqrt(26))
>   nomod<-sqrt(12*26)*runif(1000)
>   boxplot(data.frame(cbind(unimod,nomod,bimod)))

OOPS!! (cut-&-pasted the wrong lines):

  unimod<-rnorm(1000,0,sqrt(26))
  nomod<-sqrt(12*26)*(runif(1000)-0.5)
  bimod<-c(rnorm(500,-5,1),rnorm(500,5,1))
  boxplot(data.frame(cbind(unimod,nomod,bimod)))

> Best wishes,
> Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 12-Jul-05   Time: 10:24:34
-- 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


Re: [R] Boxplot philosophy {was "Boxplot in R"}

2005-07-12 Thread Ted Harding
On 12-Jul-05 Spencer Graves wrote:
> I'll bite:  How does one detect bimodalidty from a boxplot?
> 
> spencer graves
> 
> Berton Gunter wrote:
> [...]
>> Finally, a tidbit for boxplot afficianados: how does one detect
>> bimodality from a boxplot?
>> 
>> -- Bert Gunter

Not definitively detectable of course, but certainly suspectable.

Hint: What is the relationship between the distances from the "median"
line to the extremes of the "box", and from the extremes of the "box"
to the ends of the "whiskers", in the case of a uniform distribution?



If that doesn't trigger it, then:

Hint:

  unimod<-rnorm(1000,0,sqrt(26))
  nomod<-sqrt(12*26)*runif(1000)
  boxplot(data.frame(cbind(unimod,nomod,bimod)))

Best wishes,
Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 12-Jul-05   Time: 09:42:48
-- 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


  1   2   >