Re: [R] detecting a key press

2010-08-14 Thread Greg Snow
The playSudoku function in the Sudoku package reacts to keypresses using 
windows or Tk, you can use that as an example.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Martin Teicher
 Sent: Friday, August 13, 2010 8:27 PM
 To: r-help@r-project.org
 Subject: [R] detecting a key press
 
 Hi Folks,
 
 I'm relatively new to r.  I'd like to have a user respond by pressing a
 1 or a 2 and determining their choice and the time of response.
 Previous postings have indicated that keyboard responses can be
 processed using scan and readline but both seem to wait for the user to
 also press return.  Is there a way to detect the initial key press
 without requiring them to hit return?
 
 Thank you so much.
 
 Martin H. Teicher
 Department of Psychiatry
 McLean Hospital / Harvard Medical School
 Belmont, MA USA
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] is it possible to map 2 plots(c and d) in a single output plot?

2010-08-14 Thread newbie_2010

is it possible to map 2 plots(c and d) in a single output plot?

library(ggplot2)
c - ggplot(mtcars, aes(qsec, wt))
d - ggplot (mtcars, aes(qsec, wt))
c + stat_smooth(fill=darkgrey, colour=blue, size=2, alpha = 0.2)
d + stat_smooth(fill=darkgrey, colour=red, size=2, alpha = 0.2)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/is-it-possible-to-map-2-plots-c-and-d-in-a-single-output-plot-tp2325023p2325023.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to perform a substitution in a loop?

2010-08-14 Thread Saji Ren

Hello all:

I have a data series of 500 data, and I want to limit the value of it to be
less than 1.
Below is my code:

for (i in 1:500)
+if( x[i]  1)
+x[i] = 1

but the system told me it's wrong. Can anyone told me the reason?


-
--
Saji Ren
from Shanghai China
GoldenHeart Investment Group
--
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325048.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Learning ANOVA

2010-08-14 Thread JesperHybel



how to plot 4 graphs simultaneously?  

Depends on what graphs were talking about: A Side-by-side boxplot containing
fx 4 boxplots can be generated by a single plot() command. However often you
use a primary command that activivates 
the plot window and plots one graph, then afterwards you use secondary
commands to add new graphical objects to the same graph/window:

x-c(1,2,3,4)
y-c(1,2,3,4)
plot(x,y) #primary graphical command activates plot window
abline(-1,3) # adds line
points(c(1,2),c(2,2),col=red,pch=16) #adds points


Also how to save InsectSprays.aov?  I think I can only save it as 
InsectSprays.csv.  I can't find write.aov command. 

InsectSprays.aov is an object - in this case probably a list. If you make
an assignment using 
the assignment operator '-' to an object not already existing in you're
current work session
R will create that object. 
Or to put it differently: InsectSprays.aov is only a name you might as
well have called it
HomeGrownMagic or McDonalds - the aov in the name is not to be
mistaken for a file
extension. The name only surves the purpose to remind you what it is a
container of namely 
an ANOVA output of the variables Insect and Spray, that helps you not youre
computer.

There are different ways to save: You can store the whole worksession,
thereby storing all the
objects you have created during worksession and have not removed. Or you can
sink particular objects

I recommend that you have a look at:
http://cran.r-project.org/doc/contrib/Verzani-SimpleR.pdf

Very well written, want tell you all you want to know but will not drown you
in computer lingo
and tie you down with details. Gives you some hands on experience handling
the most basic plots
and objects in R. If you later want to buy Verzanis book grown from the
freely available notes you
go wrong there either, basically more of the same. 



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Learning-ANOVA-tp2323660p2325057.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How ti perform a substitution in a loop?

2010-08-14 Thread Berend Hasselman


Saji Ren wrote:
 
 ...
 I have a data series of 500 data, and I want to limit the value of it to
 be less than 1.
 Below is my code:
 
for (i in 1:500)
 +if( x[i]  1)
 +x[i] = 1
 
 but the system told me it's wrong. Can anyone told me the reason?
 

You don't show the error message.
Read the posting guide.

Try

?pmin

And

x - pmin(x,1)

will probably do what you require.

/Berend

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-ti-perform-a-substitution-in-a-loop-tp2325007p2325062.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread Peter Dalgaard
Saji Ren wrote:
 Hello all:
 
 I have a data series of 500 data, and I want to limit the value of it to be
 less than 1.
 Below is my code:
 
 for (i in 1:500)
 +if( x[i]  1)
 +x[i] = 1
 
 but the system told me it's wrong. Can anyone told me the reason?

Works for me, so there's something you're not telling us Possibly
that x is not a vector (a data frame, maybe?).

(And it's wrong is not one of the official error messages in any
language. Posting guide, reproducible code, etc.)

The whole thing is an inefficient way to do  x - pmin(x,1), though.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread JesperHybel

You need {}

for (i in 1:500){ ...commands...}


Like:


x-rep(c(0.8,1.2),250)

for (i in 1:500) {

if (x[i]1) x[i]=1

} 

BR
JEsper
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325073.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread Saji Ren

that's not a problem of {}.
By using {} you can put the command in one line.
Still you can put the command in several lines as well by pur enter.
That's why in the second line, the  becomes +

thank you for your reply though.

saji

-
--
Saji Ren
from Shanghai China
GoldenHeart Investment Group
--
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325075.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] is it possible to map 2 plots(c and d) in a single output plot?

2010-08-14 Thread Dennis Murphy
Hi:

Your example doesn't make much sense as stated, but is this what you had in
mind?

d - ggplot (mtcars, aes(qsec, wt)
d + geom_point() + stat_smooth(aes(colour = factor(cyl)),
   fill=darkgrey, size=2, alpha = 0.2) +
   scale_colour_discrete(No. cylinders)

In this case, the multiple plots were obtained by grouping on different
numbers of cylinders, which was coerced to a factor in order to use it as a
grouping variable. There are many ways to apply this 'grouping' trick in
ggplot2 using the companion plyr package, several of which can be found in
the ggplot2 list archives http://had.co.nz/ggplot2/ (look for Mailing List)
and in Hadley's book:
http://tinyurl.com/ggplot2-book.

HTH,
Dennis

On Fri, Aug 13, 2010 at 11:36 PM, newbie_2010 girishb...@gmail.com wrote:


 is it possible to map 2 plots(c and d) in a single output plot?

 library(ggplot2)
 c - ggplot(mtcars, aes(qsec, wt))
 d - ggplot (mtcars, aes(qsec, wt))
 c + stat_smooth(fill=darkgrey, colour=blue, size=2, alpha = 0.2)
 d + stat_smooth(fill=darkgrey, colour=red, size=2, alpha = 0.2)
 --
 View this message in context:
 http://r.789695.n4.nabble.com/is-it-possible-to-map-2-plots-c-and-d-in-a-single-output-plot-tp2325023p2325023.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] what is scaling in plot

2010-08-14 Thread elaine kuo
code

rm(list=ls())
library(vegan)
library(MASS)

data(varespec)
print(varespec)
str(varespec)


#PCA
vare.pca  -  rda(varespec)
vare.pca
plot(vare.pca)
sum(apply(varespec, 2, var))
biplot(vare.pca,  scaling  =  -1)

Elaine

On Sat, Aug 14, 2010 at 10:48 AM, Ben Bolker bbol...@gmail.com wrote:

 elaine kuo elaine.kuo.tw at gmail.com writes:

  Pls kindly advise what scaling is in plot.
  Sometime it could be negative but sometimes it might be positive
  .(I guess it is the proportion between the plot and the margin)

   Your question is unclear. Please give more context and/or details.

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


[[alternative HTML version deleted]]

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


Re: [R] Learning ANOVA

2010-08-14 Thread David Winsemius


On Aug 14, 2010, at 3:38 AM, JesperHybel wrote:




JH .how to plot 4 graphs simultaneously?


Depends on what graphs were talking about: A Side-by-side boxplot  
containing
fx 4 boxplots can be generated by a single plot() command. However  
often you

use a primary command that activivates
the plot window and plots one graph, then afterwards you use secondary
commands to add new graphical objects to the same graph/window:

x-c(1,2,3,4)
y-c(1,2,3,4)
plot(x,y) #primary graphical command activates plot window
abline(-1,3) # adds line
points(c(1,2),c(2,2),col=red,pch=16) #adds points




Apparently JesperHybel was writing in response to a question by  
Stephen Liu (aka satimis when viewed on Nabble) on Aug 13, 2010;  
11:04pm:


JH  Also how to save InsectSprays.aov?  I think I can only save it  
as

InsectSprays.csv.  I can't find write.aov command.


If you want to save an R object such as that returned by a function  
like aov, there are several ways. The save() function will create a  
compacted form that can then be read back into an R session with  
load(). The dump() and dput() functions will turn an object into an  
ASCII representation that can be saved as a text file. If you only  
want to have the text that is produced when you print it (and this  
is what you implicitly get when to just call the function at the  
console), then use sink() or capture.output().





InsectSprays.aov is an object - in this case probably a list.


Not probably; it is a list. Look at it with str if you have questions.


If you make
an assignment using
the assignment operator '-' to an object not already existing in  
you're

current work session
R will create that object.
Or to put it differently: InsectSprays.aov is only a name you  
might as

well have called it
HomeGrownMagic or McDonalds - the aov in the name is not to be
mistaken for a file
extension. The name only surves the purpose to remind you what it is a
container of namely
an ANOVA output of the variables Insect and Spray, that helps you  
not youre

computer.

There are different ways to save: You can store the whole worksession,
thereby storing all the
objects you have created during worksession and have not removed. Or  
you can

sink particular objects


No, you cannot sink objects. You sink console output.



I recommend that you have a look at:
http://cran.r-project.org/doc/contrib/Verzani-SimpleR.pdf

Very well written, want tell you all you want to know but will not  
drown you

in computer lingo
and tie you down with details. Gives you some hands on experience  
handling

the most basic plots
and objects in R. If you later want to buy Verzanis book grown from  
the

freely available notes you
go wrong there either, basically more of the same.


--
View this message in context: 
http://r.789695.n4.nabble.com/Learning-ANOVA-tp2323660p2325057.html
Sent from the R help mailing list archive at Nabble.com.


David Winsemius, MD
West Hartford, CT

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


Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread David Winsemius


On Aug 14, 2010, at 4:05 AM, Saji Ren wrote:


In response to JesperHybel,  saji wrote:



that's not a problem of {}.


Correct, as indicated by the continuation +


By using {} you can put the command in one line.


Actually the curly brackets are more often used to put a series of  
commands on successive lines. If you want to force a series of  
commands after an if() else construction then { will start the  
series and the interpreter will continue interpreting until it reaches  
the } possibly many lines later. If you want to put multiple  
commands on a single line the way to do it is to separate them by  
;'s and not hit enter until complete.



Still you can put the command in several lines as well by pur enter.
That's why in the second line, the  becomes +

thank you for your reply though.


You and JesperHybel would both be following recommended list behavior  
if you would both start copying the questions or response to which you  
are replying. It is acceptable practice to trim the questions but it  
is poor form to post naked replies without any context.


View this message in context: 
http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325075.html

--

David Winsemius, MD
West Hartford, CT

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


[R] cca biplot (vegan) failed in matplot

2010-08-14 Thread elaine kuo
Dear List,

I am trying to plot the result of cca using matplot but failed.
Pls kindly help and thanks.

Elaine

The error message was

error in xy.coords(x, y, xlabel, ylabel, log = log) :

  (list) object cannot be coerced to type 'double'


code

rm(list=ls())

library(vegan)

library(MASS)



# input richness

birdrich -read.csv(c:/migration/CCA_richness_20100814.csv,header=T,
row.names=1)



# input environment

# GID 1 row sum = 0 therefore deleted GID1 in birdenvi

birdenvi -read.csv(c:/migration/CCA_envi_20100815.csv,header=T,
row.names=1)



birdrich.cca  -  cca(birdrich  ~  .,  birdenvi)

birdrich.cca

matplot(birdrich.cca)

[[alternative HTML version deleted]]

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


Re: [R] creation package

2010-08-14 Thread anderson nuel
Dear r-help,

I run R CMD INSTALL :

c:\RpR CMD INSTALL namepackage

*installing to library'c:/PROGRA~1/R/R-210~1-1/library'
*installing *source* 'namepackage'...
**R
**preparing package for lazy loading
**help
Avis:./man/namepackage-package.Rd:25:'' inatttendue
**installing help indices
**building package indices
**MD5sums
*DONEnamepackage

best



2010/8/13, Uwe Ligges lig...@statistik.tu-dortmund.de:

 In my previous maiul I asked you to run R CMD INSTALL at first (rather than
 R CMD check).

 You could also look into the mentioned file
 C:/Rp/namepackage.Rcheck/00install.out

 But we really need that file to understand what is going on.

 Uwe Ligges






 On 13.08.2010 15:12, anderson nuel wrote:

 Dear r-help,
 I try this command R CMD INSTALL,but still there are errors.
 I look into the installation log file in the namepackage.Rcheck :
 * using log directory 'C:/Rp/namepackage.Rcheck'
 * using R version 2.10.1 (2009-12-14)
 * using session charset: ISO8859-1
 * checking for file 'namepackage/DESCRIPTION' ... OK
 * checking extension type ... Package
 * this is package 'namepackage' version '1.0'
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking for executable files ... OK
 * checking whether package 'namepackage' can be installed ... ERROR
 Installation failed.
 See 'C:/Rp/namepackage.Rcheck/00install.out' for details.
  From That , I do not know where is the error
 I have only one function RT, but I need several other functions within
 the RT function, while
 using package.skeleton() I put in the function list seulemnt RT or any
 other functions, or I shall all functions in the same page??
 Best



 2010/7/31, Uwe Ligges lig...@statistik.tu-dortmund.de
 mailto:lig...@statistik.tu-dortmund.de:



On 30.07.2010 15:44, anderson nuel wrote:

Dear r-help,

I create a package. When I installed this package (I use this
command : R
CMD check namepackage),I find an error: * checking whether package
'namepackage' can be installed ... ERROR
Installation failed.



Could you help me to find solution  for this error.




Well, either take a look into the installation log file in the
namepackage.Rcheck directory or start a bit more slowly by just
trying to install without a check in the first step by R CMD INSTALL.

Without seeing the installation log, we cannot help either.

Best,
Uwe Ligges


Best Regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailto:R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
http://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




[[alternative HTML version deleted]]

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


Re: [R] cca biplot (vegan) failed in matplot

2010-08-14 Thread Gavin Simpson
 Dear List,

 I am trying to plot the result of cca using matplot but failed.
 Pls kindly help and thanks.

There is no 'matplot' method for cca objects. Where did you get the idea
that there was one? If you want to plot the cca object, then ?plot.cca and
?ordiplot should help. Also look at the vignettes supplied with the
package as they contain examples of plotting ordination objects.

HTH

Gavin


 Elaine

 The error message was

 error in xy.coords(x, y, xlabel, ylabel, log = log) :

   (list) object cannot be coerced to type 'double'


 code

 rm(list=ls())

 library(vegan)

 library(MASS)



 # input richness

 birdrich -read.csv(c:/migration/CCA_richness_20100814.csv,header=T,
 row.names=1)



 # input environment

 # GID 1 row sum = 0 therefore deleted GID1 in birdenvi

 birdenvi -read.csv(c:/migration/CCA_envi_20100815.csv,header=T,
 row.names=1)



 birdrich.cca  -  cca(birdrich  ~  .,  birdenvi)

 birdrich.cca

 matplot(birdrich.cca)

   [[alternative HTML version deleted]]

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


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


[R] Stepwise Regression + entry/exit significance level

2010-08-14 Thread Shubha Vishwanath Karanth
Hi R,

 

Does the step function used to perform stepwise regression has the
option to specify the entry/exit significance levels for the independent
variables? (This is similar to the 'slentry' and 'slstay' option in
'Proc reg' of SAS.). Or do we have any other package which does the
above? Thanks.

 

 

Thanks and Regards,

Shubha

 

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

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


[R] Re : Difference in Monte Carlo calculation between chisq.test and fisher.test

2010-08-14 Thread Emilie Chary
Hello,
Any idea?





À : r-help@r-project.org
Envoyé le : Jeu 12 août 2010, 12h 17min 10s
Objet : [R] Difference in Monte Carlo calculation between chisq.test and 
fisher.test


Hello all,

I would like to know what the difference is between chisq.test and
fisher.test when using the Monte Carlo method with simulate.p.value=TRUE?

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Difference-in-Monte-Carlo-calculation-between-chisq-test-and-fisher-test-tp2322494p2322494.html

Sent from the R help mailing list archive at Nabble.com.

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



  
[[alternative HTML version deleted]]

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


Re: [R] cca biplot (vegan) failed in matplot

2010-08-14 Thread elaine kuo
Hello,

Thanks for the response.

matplot was tried for its function to distinguish assigned parts of a matrix
by letters,
for I wanna differentiate the dissimilar columns in a matrix.

Any suggestion based on the idea above will be highly appreciated, such as
points.

Elaine

On Sat, Aug 14, 2010 at 8:16 PM, Gavin Simpson gavin.simp...@ucl.ac.ukwrote:

  Dear List,
 
  I am trying to plot the result of cca using matplot but failed.
  Pls kindly help and thanks.

 There is no 'matplot' method for cca objects. Where did you get the idea
 that there was one? If you want to plot the cca object, then ?plot.cca and
 ?ordiplot should help. Also look at the vignettes supplied with the
 package as they contain examples of plotting ordination objects.

 HTH

 Gavin

 
  Elaine
 
  The error message was
 
  error in xy.coords(x, y, xlabel, ylabel, log = log) :
 
(list) object cannot be coerced to type 'double'
 
 
  code
 
  rm(list=ls())
 
  library(vegan)
 
  library(MASS)
 
 
 
  # input richness
 
  birdrich -read.csv(c:/migration/CCA_richness_20100814.csv,header=T,
  row.names=1)
 
 
 
  # input environment
 
  # GID 1 row sum = 0 therefore deleted GID1 in birdenvi
 
  birdenvi -read.csv(c:/migration/CCA_envi_20100815.csv,header=T,
  row.names=1)
 
 
 
  birdrich.cca  -  cca(birdrich  ~  .,  birdenvi)
 
  birdrich.cca
 
  matplot(birdrich.cca)
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 




[[alternative HTML version deleted]]

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


[R] color vector for green, red, blue

2010-08-14 Thread elaine kuo
Dear list,

I am plotting dots using distinct colors according to the species.
Like the style of topo.colors(18), please kindly advise if any color vector
exists for green, red, and blue.

Thank you

Elaine

[[alternative HTML version deleted]]

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


Re: [R] what is scaling in plot

2010-08-14 Thread Gavin Simpson
In an ordination such as this, you have two sets of scores; i) one
pertaining to the (dis)similarity of your samples in terms of species
composition, and ii) one pertaining to the species and which species
co-occur. You can't display both sets of information and retain the
meaning of the scores on the one plot. Scaling controls what relationships
are preserved (focussing on sites or species etc). Gabriel (forget the
citation now but is was in Biometrika) suggests that scaling 3 (symmetric
scaling) is optimal and to be preferred.

There is a discussion of the various scalings in the Design Decision
vignette that you should read. If this is too complex, then perhaps start
with Jan Leps and Petr Smilauer's book Multivariate analysis of
ecological data using Canoco, 2003, Cambridge University Press.

HTH

Gavin

 code

 rm(list=ls())
 library(vegan)
 library(MASS)

 data(varespec)
 print(varespec)
 str(varespec)


 #PCA
 vare.pca  -  rda(varespec)
 vare.pca
 plot(vare.pca)
 sum(apply(varespec, 2, var))
 biplot(vare.pca,  scaling  =  -1)

 Elaine

 On Sat, Aug 14, 2010 at 10:48 AM, Ben Bolker bbol...@gmail.com wrote:

 elaine kuo elaine.kuo.tw at gmail.com writes:

  Pls kindly advise what scaling is in plot.
  Sometime it could be negative but sometimes it might be positive
  .(I guess it is the proportion between the plot and the margin)

   Your question is unclear. Please give more context and/or details.

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


   [[alternative HTML version deleted]]

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


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


Re: [R] discerning species by color in cca biplot

2010-08-14 Thread Gavin Simpson
If you only have seven species, why not draw the label for the species
(the names() component of your data) at the species score, rather than a
colour?

plot(OBJ, display = c(sites,species), scaling = 3, type = n)
points(OBJ, display = sites, scaling = 3, type = p)
points(OBJ, display = species, scaling = 3, type = t)

Not tested, am away at the moment but heading home. If you are still
having trouble (and I see now why you wanted matplot) then email back and
I'll given a longer example illustrating who to build up plots by hand.

Gavin

 Dear List,

 I am running constrained correspondence analysis for abundance data of 7
 birds.

 However, I would like to check which bird prefers which environment
 gradient
 by showing the species with different colors of the dots in cca plot
 (package vegan).

 Please kindly help and thank you

 Elaine

   [[alternative HTML version deleted]]

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


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


Re: [R] color vector for green, red, blue

2010-08-14 Thread Henrique Dallazuanna
Take a look in RColorBrewer package.

On Sat, Aug 14, 2010 at 9:13 AM, elaine kuo elaine.kuo...@gmail.com wrote:

 Dear list,

 I am plotting dots using distinct colors according to the species.
 Like the style of topo.colors(18), please kindly advise if any color vector
 exists for green, red, and blue.

 Thank you

 Elaine

[[alternative HTML version deleted]]

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


Re: [R] discerning species by color in cca biplot

2010-08-14 Thread elaine kuo
Thanks

I wanna to add the species labels in a cca biplot
based on species and environment conditions (maybe sites are of less
relevance here).

1.
Gavin's suggestion worked but the dots previously displayed
using plot(birdrich.cca, scaling  =  -1) were gone. Pls advise how to retain
the dots.

2. orditorp
orditorp in vegan seems to fit my demand.
However, the axis seems to be changed after running the code below.
Please kindly explain why or recommend any references.

Thanks again.

# Now with orditorp and abbreviated species names
cnam - make.cepnames(names(birdrich))
plot(birdrich.cca, dis=sp, type=n)
stems - colSums(birdrich)
orditorp(birdrich.cca, sp, label = cnam, priority=stems, pch=+,
pcol=grey)


Elaine





original code

rm(list=ls())
plot.new()

library(vegan)
library(MASS)


# input richness
birdrich -read.csv(c:/migration/CCA_Mig_richness_20100814.csv,header=T,
row.names=1)

# input environment
birdenvi -read.csv(c:/migration/CCA_Mig_envi_20100815.csv,header=T,
row.names=1)

birdrich.cca  -  cca(birdrich  ~  .,  birdenvi)
birdrich.cca
plot(birdrich.cca, scaling  =  3, dis=sp, type=t)


On Sat, Aug 14, 2010 at 8:30 PM, Gavin Simpson gavin.simp...@ucl.ac.ukwrote:

 If you only have seven species, why not draw the label for the species
 (the names() component of your data) at the species score, rather than a
 colour?

 plot(OBJ, display = c(sites,species), scaling = 3, type = n)
 points(OBJ, display = sites, scaling = 3, type = p)
 points(OBJ, display = species, scaling = 3, type = t)

 Not tested, am away at the moment but heading home. If you are still
 having trouble (and I see now why you wanted matplot) then email back and
 I'll given a longer example illustrating who to build up plots by hand.

 Gavin




[[alternative HTML version deleted]]

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


Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread Saji Ren

Hello, Mr Dalgaard:

you're right about the problem.

Works for me, so there's something you're not telling us Possibly
that x is not a vector (a data frame, maybe?).

the mistake  message is below:
Error in if (track01[i]  1) track01[i] - 1 :
  missing value where TRUE/FALSE needed

the track01 above is my data, I've used a rnorm(500) data series instead,
and the code works!!

One thing I do know is that my track01 data has NaN data.
So I guess the system can not perform the code  if (track01[i]  1) when
track01[i]=NaN, or the result is missing value, thus it need a TRUE/FALSE

is there any command to replace the NaN value with 1 in an efficient way?

Saji

-
--
Saji Ren
from Shanghai China
GoldenHeart Investment Group
--
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325193.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Stepwise Regression + entry/exit significance level

2010-08-14 Thread Frank Harrell
The values of slentry and slstay that will avoid ruining the 
statistical properties of the result are slentry=1.0 and slstay=1.0.


Frank

Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

On Sat, 14 Aug 2010, Shubha Vishwanath Karanth wrote:


Hi R,



Does the step function used to perform stepwise regression has the
option to specify the entry/exit significance levels for the independent
variables? (This is similar to the 'slentry' and 'slstay' option in
'Proc reg' of SAS.). Or do we have any other package which does the
above? Thanks.





Thanks and Regards,

Shubha





This e-mail may contain confidential and/or privileged i...{{dropped:13}}

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



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


Re: [R] How to add lines to lattice plot produced by rms::bplot

2010-08-14 Thread Frank Harrell


Once you guys figure all this out, I'm glad to modify bplot to pass 
more arguments lattice if needed.


Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

On Fri, 13 Aug 2010, David Winsemius wrote:



On Aug 13, 2010, at 11:25 PM, Duncan Mackay wrote:


Hi David

I do not know if you have done something like this.


I had tried a few efforts like that, starting with an examination of
str(bp.plot) as you demonstrate.


I tried str(bp.plot) which gave the section about the regions (for
colours) as:
$ panel.args.common:List of 8
 ..$ x  : num [1:2500] 27 28 29 29.9 30.9 ...
 ..$ y  : num [1:2500] 141 141 141 141 141 ...
 ..$ z  : num [1:2500] -1.43 -1.41 -1.39 -1.36 -1.34 ...
 ..$ at : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
 ..$ region : logi FALSE
 ..$ zlab   :List of 3
 .. ..$ label: chr log odds
 .. ..$ rot  : num 90
 .. ..$ cex  : num 1
 ..$ labels : logi TRUE
 ..$ contour: logi TRUE


I tried (with a bplot object named bldLT40):

bldLT40$legend$right$args$key$at - c(-0.233, seq(.50, 2.25, by=0.25),
seq(2.5, 5.0, by=0.5), 6:10)

... and then tried

bldLT40$panel.args$at - c(-0.233, seq(.50, 2.25, by=0.25), seq(2.5,
5.0, by=0.5), 6:10)

Neither of these efforts changed the boundaries beteen colors in the
plot area. The first effort changed the legend scal,e but that just
created a misalignment of the colors of plot area and the legend. I
would be interested in either a strategy that lets one alter the color
level changes of the z variable (which in bplot-created objects is
zhat, or lets one specify the values at which contour lines are
drawn in contourplot.

Thanks for your efforts.

--
David.




I added the col.region and colours from a plot levelplot that I had
done to see what would occur to the trellis parameters. No colours
were produced when plotted.
bp.plot - bplot(p, lfun=contourplot, color.key = TRUE, col.regions
=
c
(#FF
,#00,#A9E2FF,#8080FF,#FF,#FFD18F,#FF) )

$ panel.args.common:List of 10
 ..$ x  : num [1:2500] 27 28 29 29.9 30.9 ...
 ..$ y  : num [1:2500] 141 141 141 141 141 ...
 ..$ z  : num [1:2500] -1.43 -1.41 -1.39 -1.36 -1.34 ...
 ..$ at : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
 ..$ region : logi FALSE
 ..$ color.key  : logi TRUE
 ..$ zlab   :List of 3
 .. ..$ label: chr log odds
 .. ..$ rot  : num 90
 .. ..$ cex  : num 1
 ..$ labels : logi TRUE
 ..$ contour: logi TRUE
 ..$ col.regions: chr [1:7] #FF #00 #A9E2FF
#8080FF ...

So it has been added to the panel.args.common, whether you can
access these are another matter.

I then tried
bp.plot - bplot(p, lfun=contourplot, par.settings = list(axis.text
= list(cex = 0.65)), color.key = TRUE, col.regions =
c
(#FF
,#00,#A9E2FF,#8080FF,#FF,#FFD18F,#FF) )

which changed the size of the axis text so it may be the case of
having to add the col.regions etc to the appropriate list in
par.settings

I'll leave you to amend and access the colours.
You may have to add values for the wireframe/levelplot arguments
like at  etc. and col.regions (I think that is the function) to
produce an appropriate colour range of your choice

It is a while since I have delved into these sorts of plots.
Need some sustenance.

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mac...@northnet.com.au



At 10:33 14/08/2010, you wrote:


I have a plot produced by function bplot (package = rms) that is
really a lattice plot (class=trellis). It is similar to this plot
produced by a very minor modification of the first example on the
bplot help page:

require(rms)
n - 1000# define sample size
set.seed(17) # so can reproduce the results
age- rnorm(n, 50, 10)
blood.pressure - rnorm(n, 120, 15)
cholesterol- rnorm(n, 200, 25)
sex- factor(sample(c('female','male'), n,TRUE))
label(age)- 'Age'  # label is in Hmisc
label(cholesterol)- 'Total Cholesterol'
label(blood.pressure) - 'Systolic Blood Pressure'
label(sex)- 'Sex'
units(cholesterol)- 'mg/dl'   # uses units.default in Hmisc
units(blood.pressure) - 'mmHg'

# Specify population model for log odds that Y=1
L - .4*(sex=='male') + .045*(age-50) +
 (log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y - ifelse(runif(n)  plogis(L), 1, 0)

ddist - datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')

fit - lrm(y ~ blood.pressure + sex * (age + rcs(cholesterol,4)),
  x=TRUE, y=TRUE)
p - Predict(fit, age, cholesterol, sex='male', np=50) # vary sex
last
bp.plot - bplot(p, lfun=contourplot)
bp.plot

I have tried a variety of efforts at using update (which I assume
is a
lattice function although I can find no help page for it. It does
appear in some of the lattice hep pages and my 

Re: [R] How to perform a substitution in a loop?

2010-08-14 Thread Peter Dalgaard
Saji Ren wrote:
 Hello, Mr Dalgaard:
 
 you're right about the problem.
 
 Works for me, so there's something you're not telling us Possibly
 that x is not a vector (a data frame, maybe?).
 
 the mistake  message is below:
 Error in if (track01[i]  1) track01[i] - 1 :
   missing value where TRUE/FALSE needed
 
 the track01 above is my data, I've used a rnorm(500) data series instead,
 and the code works!!
 
 One thing I do know is that my track01 data has NaN data.
 So I guess the system can not perform the code  if (track01[i]  1) when
 track01[i]=NaN, or the result is missing value, thus it need a TRUE/FALSE
 
 is there any command to replace the NaN value with 1 in an efficient way?

Usually, you'd safeguard the if with if (is.na(x[i]) || x[i]  1)...
or if (!is.na(...)  ...), depending on what you want.

BTW, notice also that pmin has an na.rm argument.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] Stepwise Regression + entry/exit significance level

2010-08-14 Thread Peter Dalgaard
Shubha Vishwanath Karanth wrote:
 Hi R,
 
  
 
 Does the step function used to perform stepwise regression has the
 option to specify the entry/exit significance levels for the independent
 variables? (This is similar to the 'slentry' and 'slstay' option in
 'Proc reg' of SAS.). Or do we have any other package which does the
 above? Thanks.
 

That procedure is considered unreliable (someone called Frank is likely
to chime in with a reference to a book on regression modeling
strategies). Cloning obsolete SAS functionality is not high on the
priority list. It is probably not massively hard to modify the step
function to do it, though; all the building blocks would seem to be there.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] Re : Difference in Monte Carlo calculation between chisq.test and fisher.test

2010-08-14 Thread Peter Dalgaard
Emilie Chary wrote:
 Hello,
 Any idea?

Different test statistic (chi^2 vs. table probability).

 
 
 
 
 À : r-help@r-project.org
 Envoyé le : Jeu 12 août 2010, 12h 17min 10s
 Objet : [R] Difference in Monte Carlo calculation between chisq.test and 
 fisher.test
 
 
 Hello all,
 
 I would like to know what the difference is between chisq.test and
 fisher.test when using the Monte Carlo method with simulate.p.value=TRUE?
 
 Thank you
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


[R] confidence Intervals for predictions in GLS

2010-08-14 Thread Camilo Mora

Hi everyone:

Is there a function in R to calculate the confidence intervals for the  
predictions of a GLS(Generalized Least Square) model?


The function predict gives confidence intervals for the predictions  
of other types of models (lm, glm, etc) but not gls.


Any input will be much appreciated,

Best,

Camilo

Camilo Mora, Ph.D.
Department of Biology
Dalhouisie University
Halifax, Canada
Phone: (902) 494-7720
http://as01.ucis.dal.ca/fmap/people.php?pid=53

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


Re: [R] How to add lines to lattice plot produced by rms::bplot

2010-08-14 Thread David Winsemius


On Aug 14, 2010, at 9:59 AM, Frank Harrell wrote:



Once you guys figure all this out, I'm glad to modify bplot to pass  
more arguments lattice if needed.


As always, Frank, I appreciate your support. In this case I think it's  
not needed. What seems to be needed is simply the correct use of the  
at argument. (I thought I had tried this before but apparently  
mucked it up somehow.)  This gives the desired color levels separation  
and labeling of the default levelplot version of bplot output:


  bldLT40 - bplot(mdl.pred , perim=boundaries, at=c(-0.233, seq(.50,  
2.25, by=0.25), seq(2.5, 5.0, by=0.5), 6:10) )

 bldLT40

And this produces the expected output with its contouplot version:

bldLT40c - bplot(mdl.pred , perim=boundaries, lfun=contourplot,  
at=c(-0.233, seq(.50, 2.25, by=0.25), seq(2.5, 5.0, by=0.5), 6:10) )

 bldLT40c

My only quibble with that last one was that the labels had three  
digits to the right of the decimal pt but that happily went away when  
I changed the low end to 0.25. All is good here.


--
David.


Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
Department of Biostatistics   Vanderbilt  
University


On Fri, 13 Aug 2010, David Winsemius wrote:



On Aug 13, 2010, at 11:25 PM, Duncan Mackay wrote:


Hi David

I do not know if you have done something like this.


I had tried a few efforts like that, starting with an examination of
str(bp.plot) as you demonstrate.


I tried str(bp.plot) which gave the section about the regions (for
colours) as:
$ panel.args.common:List of 8
..$ x  : num [1:2500] 27 28 29 29.9 30.9 ...
..$ y  : num [1:2500] 141 141 141 141 141 ...
..$ z  : num [1:2500] -1.43 -1.41 -1.39 -1.36 -1.34 ...
..$ at : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
..$ region : logi FALSE
..$ zlab   :List of 3
.. ..$ label: chr log odds
.. ..$ rot  : num 90
.. ..$ cex  : num 1
..$ labels : logi TRUE
..$ contour: logi TRUE


I tried (with a bplot object named bldLT40):

bldLT40$legend$right$args$key$at - c(-0.233, seq(.50, 2.25,  
by=0.25),

seq(2.5, 5.0, by=0.5), 6:10)

... and then tried

bldLT40$panel.args$at - c(-0.233, seq(.50, 2.25, by=0.25), seq(2.5,
5.0, by=0.5), 6:10)

Neither of these efforts changed the boundaries beteen colors in the
plot area. The first effort changed the legend scal,e but that just
created a misalignment of the colors of plot area and the legend. I
would be interested in either a strategy that lets one alter the  
color

level changes of the z variable (which in bplot-created objects is
zhat, or lets one specify the values at which contour lines are
drawn in contourplot.

Thanks for your efforts.

--
David.




I added the col.region and colours from a plot levelplot that I had
done to see what would occur to the trellis parameters. No colours
were produced when plotted.
bp.plot - bplot(p, lfun=contourplot, color.key = TRUE, col.regions
=
c
(#FF
,#00,#A9E2FF,#8080FF,#FF,#FFD18F,#FF) )

$ panel.args.common:List of 10
..$ x  : num [1:2500] 27 28 29 29.9 30.9 ...
..$ y  : num [1:2500] 141 141 141 141 141 ...
..$ z  : num [1:2500] -1.43 -1.41 -1.39 -1.36 -1.34 ...
..$ at : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
..$ region : logi FALSE
..$ color.key  : logi TRUE
..$ zlab   :List of 3
.. ..$ label: chr log odds
.. ..$ rot  : num 90
.. ..$ cex  : num 1
..$ labels : logi TRUE
..$ contour: logi TRUE
..$ col.regions: chr [1:7] #FF #00 #A9E2FF
#8080FF ...

So it has been added to the panel.args.common, whether you can
access these are another matter.

I then tried
bp.plot - bplot(p, lfun=contourplot, par.settings = list(axis.text
= list(cex = 0.65)), color.key = TRUE, col.regions =
c
(#FF
,#00,#A9E2FF,#8080FF,#FF,#FFD18F,#FF) )

which changed the size of the axis text so it may be the case of
having to add the col.regions etc to the appropriate list in
par.settings

I'll leave you to amend and access the colours.
You may have to add values for the wireframe/levelplot arguments
like at  etc. and col.regions (I think that is the function) to
produce an appropriate colour range of your choice

It is a while since I have delved into these sorts of plots.
Need some sustenance.

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mac...@northnet.com.au



At 10:33 14/08/2010, you wrote:


I have a plot produced by function bplot (package = rms) that is
really a lattice plot (class=trellis). It is similar to this plot
produced by a very minor modification of the first example on the
bplot help page:

require(rms)
n - 1000# define sample size
set.seed(17) # so can reproduce the results
age- rnorm(n, 50, 10)
blood.pressure - rnorm(n, 120, 15)
cholesterol- rnorm(n, 200, 25)
sex- factor(sample(c('female','male'), n,TRUE))
label(age)- 'Age'  # label is in Hmisc
label(cholesterol)- 

Re: [R] confidence Intervals for predictions in GLS

2010-08-14 Thread Frank Harrell


install.packages('rms')
require(rms)
?Gls
?plot.Predict

Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

On Sat, 14 Aug 2010, Camilo Mora wrote:


Hi everyone:

Is there a function in R to calculate the confidence intervals for the
predictions of a GLS(Generalized Least Square) model?

The function predict gives confidence intervals for the predictions
of other types of models (lm, glm, etc) but not gls.

Any input will be much appreciated,

Best,

Camilo

Camilo Mora, Ph.D.
Department of Biology
Dalhouisie University
Halifax, Canada
Phone: (902) 494-7720
http://as01.ucis.dal.ca/fmap/people.php?pid=53

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



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


Re: [R] How to add lines to lattice plot produced by rms::bplot

2010-08-14 Thread Frank Harrell



Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

On Sat, 14 Aug 2010, David Winsemius wrote:



On Aug 14, 2010, at 9:59 AM, Frank Harrell wrote:



Once you guys figure all this out, I'm glad to modify bplot to pass
more arguments lattice if needed.


As always, Frank, I appreciate your support. In this case I think it's
not needed. What seems to be needed is simply the correct use of the
at argument. (I thought I had tried this before but apparently
mucked it up somehow.)  This gives the desired color levels separation
and labeling of the default levelplot version of bplot output:

  bldLT40 - bplot(mdl.pred , perim=boundaries, at=c(-0.233, seq(.50,
2.25, by=0.25), seq(2.5, 5.0, by=0.5), 6:10) )
 bldLT40

And this produces the expected output with its contouplot version:

bldLT40c - bplot(mdl.pred , perim=boundaries, lfun=contourplot,
at=c(-0.233, seq(.50, 2.25, by=0.25), seq(2.5, 5.0, by=0.5), 6:10) )
 bldLT40c

My only quibble with that last one was that the labels had three
digits to the right of the decimal pt but that happily went away when
I changed the low end to 0.25. All is good here.

--
David.


Excellent.  Thanks David.  If you think of anything that would be a 
good addition to the examples or other parts of the help file, shoot 
me a few lines and I'll paste them in.


Frank



Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
Department of Biostatistics   Vanderbilt
University

On Fri, 13 Aug 2010, David Winsemius wrote:



On Aug 13, 2010, at 11:25 PM, Duncan Mackay wrote:


Hi David

I do not know if you have done something like this.


I had tried a few efforts like that, starting with an examination of
str(bp.plot) as you demonstrate.


I tried str(bp.plot) which gave the section about the regions (for
colours) as:
$ panel.args.common:List of 8
..$ x  : num [1:2500] 27 28 29 29.9 30.9 ...
..$ y  : num [1:2500] 141 141 141 141 141 ...
..$ z  : num [1:2500] -1.43 -1.41 -1.39 -1.36 -1.34 ...
..$ at : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
..$ region : logi FALSE
..$ zlab   :List of 3
.. ..$ label: chr log odds
.. ..$ rot  : num 90
.. ..$ cex  : num 1
..$ labels : logi TRUE
..$ contour: logi TRUE


I tried (with a bplot object named bldLT40):

bldLT40$legend$right$args$key$at - c(-0.233, seq(.50, 2.25,
by=0.25),
seq(2.5, 5.0, by=0.5), 6:10)

... and then tried

bldLT40$panel.args$at - c(-0.233, seq(.50, 2.25, by=0.25), seq(2.5,
5.0, by=0.5), 6:10)

Neither of these efforts changed the boundaries beteen colors in the
plot area. The first effort changed the legend scal,e but that just
created a misalignment of the colors of plot area and the legend. I
would be interested in either a strategy that lets one alter the
color
level changes of the z variable (which in bplot-created objects is
zhat, or lets one specify the values at which contour lines are
drawn in contourplot.

Thanks for your efforts.

--
David.




I added the col.region and colours from a plot levelplot that I had
done to see what would occur to the trellis parameters. No colours
were produced when plotted.
bp.plot - bplot(p, lfun=contourplot, color.key = TRUE, col.regions
=
c
(#FF
,#00,#A9E2FF,#8080FF,#FF,#FFD18F,#FF) )

$ panel.args.common:List of 10
..$ x  : num [1:2500] 27 28 29 29.9 30.9 ...
..$ y  : num [1:2500] 141 141 141 141 141 ...
..$ z  : num [1:2500] -1.43 -1.41 -1.39 -1.36 -1.34 ...
..$ at : num [1:10] -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
..$ region : logi FALSE
..$ color.key  : logi TRUE
..$ zlab   :List of 3
.. ..$ label: chr log odds
.. ..$ rot  : num 90
.. ..$ cex  : num 1
..$ labels : logi TRUE
..$ contour: logi TRUE
..$ col.regions: chr [1:7] #FF #00 #A9E2FF
#8080FF ...

So it has been added to the panel.args.common, whether you can
access these are another matter.

I then tried
bp.plot - bplot(p, lfun=contourplot, par.settings = list(axis.text
= list(cex = 0.65)), color.key = TRUE, col.regions =
c
(#FF
,#00,#A9E2FF,#8080FF,#FF,#FFD18F,#FF) )

which changed the size of the axis text so it may be the case of
having to add the col.regions etc to the appropriate list in
par.settings

I'll leave you to amend and access the colours.
You may have to add values for the wireframe/levelplot arguments
like at  etc. and col.regions (I think that is the function) to
produce an appropriate colour range of your choice

It is a while since I have delved into these sorts of plots.
Need some sustenance.

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mac...@northnet.com.au



At 10:33 14/08/2010, you wrote:


I have a plot produced by function bplot (package = rms) that is
really a lattice plot (class=trellis). It is similar to this plot
produced by a very minor modification of the first example on the

Re: [R] Bug in t.test?

2010-08-14 Thread Thomas Lumley

On Sat, 14 Aug 2010, ted.hard...@manchester.ac.uk wrote:


Hi Thomas,
I'm not too sure about your interpretation. Consider:


It seems hard to interpret The formula interface is only applicable for the 
2-sample tests. any other way



Johannes' original query was about differences when there
are NAs, corresponding to different settings of na.action.
It is perhaps possible that 'na.action=na.pass' and
'na.action=na.exclude' result in different pairings in the
case paired=TRUE. However, it seems to me that the differences
he observed are, shall we say, obscure!


No, they are perfectly straightforward.  Johannes's data had two missing 
values, one in each group, but not in the same pair.

With na.omit or na.exclude, model.frame() removes the NAs. If there are the 
same number of NAs in each group, this leaves the same number of observations 
in each group. t.test.formula() splits these according to the group variable 
and passes them to t.test.default. Because of the (invalid) paired=TRUE 
argument, t.test.default assumes these are nine pairs and gets bogus answers.

On the other hand with na.pass, model.frame() does not remove NAs. 
t.test.formula() passes two sets of ten observations (including missing 
observations) to t.test.default().  Because of the paired=TRUE argument, 
t.test.default() assumes these are ten pairs, which happens to be true in this 
case, and after deleting the two pairs with missing observations it gives the 
right answer.

Regardless of the details, however, t.test.formula() can't reliably work with 
paired=TRUE because the user interface provides no way to specify which 
observations are paired. It would be possible (though bad idea in my opinion) 
to specify that paired=TRUE is allowed and that the pairing is done in the 
order the observations appear in the data. The minimal change would be to stop 
doing missing-value removal in t.test.formula, although that would be 
undesirable if a user wanted to supply some sort of na.impute() option.

I would strongly prefer having an explicit indication of pairing, eg 
paired=variable.name, or even better, paired=~variable.name. Relying on data 
frame ordering seems a really bad idea.

   -thomas

Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle

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


[R] Creating list from a long vector

2010-08-14 Thread steven mosher
Stupid question, but its been a long night.

If I have a long vector how can I turn it into a list of the same length

x-rep(seq(1,100,by=1),each=10)

[[alternative HTML version deleted]]

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


Re: [R] Creating list from a long vector

2010-08-14 Thread Romain Francois


Le 14/08/10 18:22, steven mosher a écrit :


Stupid question, but its been a long night.

If I have a long vector how can I turn it into a list of the same length

x-rep(seq(1,100,by=1),each=10)


Perhaps as.list ?

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
|- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
`- http://bit.ly/aAyra4 : highlight 0.2-2

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


[R] Help with graphing impulse response functions

2010-08-14 Thread Musky Dee
Dear colleagues/contributors,

I'd be pleased if someone could provide insights on how to plot impulse 
response functions in a format that can easily be copied in a word document 
just as plotting time-series of variables. 

I had followed the outline suggested by Benhard Pfaff [see 
http://127.0.0.1:17693/library/vars/html/irf.html] but I am unable to get the 
impulse response functions in a single graphical format. I then tried this 
command, where each variable response to an impulse was plotted:

opar -par(mfrow = c(3,2), mar=c(4.2,4.2,1,1), oma=c(0,0,0,0))
plot(svec.irfT1,main=T-G, ylab=, xlab=)
plot(svec.irfT2, main=T-i,ylab=)
plot(svec.irfT3,main=T-Y,ylab=)
plot(svec.irfT4,main=T-T,ylab=)
plot(svec.irfT5,main=T-P,ylab=)
plot(svec.irfT,ylab=)
par(opar)

However the graphs still fail to appear in a three row, two column format that 
could be easily copied to word or pdf. Kind assistance will be welcome. 

Kind regards,
Faj
R: Impulse response function





  
[[alternative HTML version deleted]]

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


Re: [R] cacheSweave / pgfSweave driver for package vignette

2010-08-14 Thread baptiste auguie
Thank you everyone, I think I'll follow the technique used in Rcpp
(dummy vignettes + Makefile).
It would be great to have a mechanism to select the driver for
vignette generation though.

Also, as a side-note, the choice of a driver has its own shortcoming;
I cannot use the features of highlight and, say, pgfSweave in the same
document.

Sincerely,

baptiste

On 13 August 2010 11:10, Romain Francois romain.franc...@dbmail.com wrote:

 Hi,

 I've been meaning to ask the same question before.

 Le 13/08/10 11:01, baptiste auguie a écrit :

 Dear list,


 I wish to use a specific driver to process an sweave document in the
 inst/doc directory of a package. Specifically, I would like to use
 either cacheSweave or pgfSweave to speed up the creation of the
 vignette which requires lengthy computations. The same request would
 also apply to the highlight driver, to provide syntax highlighting of
 R chunks.

 In writing R extensions I see that during R CMD BUILD Sweave is run
 first, then optionally a makefile can be used to process any other
 files. It doesn't seem to leave room for a choice of Sweave engine, as
 far as I understand. One option I am thinking of is to change the
 extension of the source file to something like .Rnw2 so that Sweave
 ignores it altogether, and then use the appropriate command in a
 makefile.

 This is what we do in Rcpp to build our 7 vignettes (since we like to use
 the driver from highlight).

 One thing to have in mind is that R needs the .Rnw file to be present in doc
 once the package is installed, so that the vignette function works, hence
 some trickery in Rcpp.

 A way to control which sweave (and perhaps tangle) driver is to be used for
 a particular vignette would be very useful.

 Romain

 I have no experience in writing makefiles, so I'm hoping someone would
 already have solved this issue and could provide some advice.

 Sincerely,

 baptiste

 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
 |- http://bit.ly/aAyra4 : highlight 0.2-2
 `- http://bit.ly/94EBKx : inline 0.3.6




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


Re: [R] Creating list from a long vector

2010-08-14 Thread steven mosher
Thx, I see my problem. more sleep required

On Sat, Aug 14, 2010 at 9:25 AM, Romain Francois romain.franc...@dbmail.com
 wrote:


 Le 14/08/10 18:22, steven mosher a écrit :


 Stupid question, but its been a long night.

 If I have a long vector how can I turn it into a list of the same length

 x-rep(seq(1,100,by=1),each=10)


 Perhaps as.list ?

 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://bit.ly/bzoWrs : Rcpp svn revision 2000
 |- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
 `- http://bit.ly/aAyra4 : highlight 0.2-2




[[alternative HTML version deleted]]

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


Re: [R] cacheSweave / pgfSweave driver for package vignette

2010-08-14 Thread Romain Francois


Le 14/08/10 19:13, baptiste auguie a écrit :


Thank you everyone, I think I'll follow the technique used in Rcpp
(dummy vignettes + Makefile).


Cool. Let us (Rcpp team) know if you find better ways or if something is 
too much trickery.



It would be great to have a mechanism to select the driver for
vignette generation though.

Also, as a side-note, the choice of a driver has its own shortcoming;
I cannot use the features of highlight and, say, pgfSweave in the same
document.


It should be possible to create a new driver that combines both 
features. Let me (highlight team) know if I can do something in 
highlight to make this easier than it currently is.


Romain


Sincerely,

baptiste

On 13 August 2010 11:10, Romain Francoisromain.franc...@dbmail.com  wrote:


Hi,

I've been meaning to ask the same question before.

Le 13/08/10 11:01, baptiste auguie a écrit :


Dear list,


I wish to use a specific driver to process an sweave document in the
inst/doc directory of a package. Specifically, I would like to use
either cacheSweave or pgfSweave to speed up the creation of the
vignette which requires lengthy computations. The same request would
also apply to the highlight driver, to provide syntax highlighting of
R chunks.

In writing R extensions I see that during R CMD BUILD Sweave is run
first, then optionally a makefile can be used to process any other
files. It doesn't seem to leave room for a choice of Sweave engine, as
far as I understand. One option I am thinking of is to change the
extension of the source file to something like .Rnw2 so that Sweave
ignores it altogether, and then use the appropriate command in a
makefile.


This is what we do in Rcpp to build our 7 vignettes (since we like to use
the driver from highlight).

One thing to have in mind is that R needs the .Rnw file to be present in doc
once the package is installed, so that the vignette function works, hence
some trickery in Rcpp.

A way to control which sweave (and perhaps tangle) driver is to be used for
a particular vignette would be very useful.

Romain


I have no experience in writing makefiles, so I'm hoping someone would
already have solved this issue and could provide some advice.

Sincerely,

baptiste


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
|- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th
`- http://bit.ly/aAyra4 : highlight 0.2-2

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


Re: [R] Help with graphing impulse response functions

2010-08-14 Thread David Winsemius


On Aug 14, 2010, at 11:43 AM, Musky Dee wrote:


Dear colleagues/contributors,

I'd be pleased if someone could provide insights on how to plot  
impulse response functions in a format that can easily be copied in  
a word document just as plotting time-series of variables.


I had followed the outline suggested by Benhard Pfaff [see http://127.0.0.1:17693/library/vars/html/irf.html 
] but I am unable to get the impulse response functions in a single  
graphical format. I then tried this command, where each variable  
response to an impulse was plotted:


opar -par(mfrow = c(3,2), mar=c(4.2,4.2,1,1), oma=c(0,0,0,0))
plot(svec.irfT1,main=T-G, ylab=, xlab=)
plot(svec.irfT2, main=T-i,ylab=)
plot(svec.irfT3,main=T-Y,ylab=)
plot(svec.irfT4,main=T-T,ylab=)
plot(svec.irfT5,main=T-P,ylab=)
plot(svec.irfT,ylab=)
par(opar)

However the graphs still fail to appear in a three row, two column  
format that could be easily copied to word or pdf. Kind assistance  
will be welcome.


That's not too surprising. Look at the function that does the plotting :

 class(irf1)
[1] varirf
 getAnywhere(plot.varirf)
A single object matching ‘plot.varirf’ was found
It was found in the following places
  registered S3 method for plot from namespace vars
  namespace:vars
with value

function (x, plot.type = c(multiple, single), names = NULL,
main = NULL, sub = NULL, lty = NULL, lwd = NULL, col = NULL,
ylim = NULL, ylab = NULL, xlab = NULL, nc, mar.multi = c(0,
4, 0, 4), oma.multi = c(6, 4, 6, 4), adj.mtext = NA,
padj.mtext = NA, col.mtext = NA, ...)
{
op - par(no.readonly = TRUE)
on.exit(par(op))
.
.
 remainder of function deleted

plot.varirf does its own layout, after setting asside you par  
specifications and reloading them on exit, but if you look at the  
argument list, I think it is clear that there was provision made for  
adjustments to mar and oma arguments. I think you need to read the  
docemantion (and maybe the code as well)  more closely to see how the  
authors expected that function to be used.


--
David.




and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

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


Re: [R] Bug in t.test?

2010-08-14 Thread Ted Harding
On 14-Aug-10 16:07:14, Thomas Lumley wrote:
 On Sat, 14 Aug 2010, ted.hard...@manchester.ac.uk wrote:
 Hi Thomas,
 I'm not too sure about your interpretation. Consider:
 
 It seems hard to interpret The formula interface is only applicable
 for the 2-sample tests. any other way
 

 Johannes' original query was about differences when there
 are NAs, corresponding to different settings of na.action.
 It is perhaps possible that 'na.action=na.pass' and
 'na.action=na.exclude' result in different pairings in the
 case paired=TRUE. However, it seems to me that the differences
 he observed are, shall we say, obscure!
 
 No, they are perfectly straightforward.  Johannes's data had two
 missing values, one in each group, but not in the same pair.
 
 With na.omit or na.exclude, model.frame() removes the NAs. If there
 are the same number of NAs in each group, this leaves the same number
 of observations in each group. t.test.formula() splits these according
 to the group variable and passes them to t.test.default. Because of
 the (invalid) paired=TRUE argument, t.test.default assumes these are
 nine pairs and gets bogus answers.
 
 On the other hand with na.pass, model.frame() does not remove NAs.
 t.test.formula() passes two sets of ten observations (including missing
 observations) to t.test.default().  Because of the paired=TRUE
 argument, t.test.default() assumes these are ten pairs, which happens
 to be true in this case, and after deleting the two pairs with missing
 observations it gives the right answer.
 
 Regardless of the details, however, t.test.formula() can't reliably
 work with paired=TRUE because the user interface provides no way to
 specify which observations are paired. It would be possible (though
 bad idea in my opinion) to specify that paired=TRUE is allowed and
 that the pairing is done in the order the observations appear in the
 data. The minimal change would be to stop doing missing-value removal
 in t.test.formula, although that would be undesirable if a user wanted
 to supply some sort of na.impute() option.
 
 I would strongly prefer having an explicit indication of pairing,
 eg paired=variable.name, or even better, paired=~variable.name.
 Relying on data frame ordering seems a really bad idea.
 
 -thomas

Thanks, Thomas, for elucidating the mechanisms of what I had suspected.
Following the earlier correspondence, I did a little experimentation
which helps to visualise what goes on. I had been composing a draft
email about it (see below) when yours arrived. It ends with a view
on how things might be arranged to work more transparently.
Ted.

==
I previously wrote (in connection with how the parings take place):
 Johannes' original query was about differences when there are NAs,
 corresponding to different settings of na.action. It is perhaps
 possible that 'na.action=na.pass' and 'na.action=na.exclude'
 result in different pairings in the case paired=TRUE.

I have now tested the latter using Johannes Dietrich's example data.
Results below.

# Johannes' data:
testdata.A  - c(1.15, -0.2, NA,  1  , -2, -0.5, 0.1, 1.2, -1.4, 0.01)
testdata.B  - c(1.2 ,  1.1, 3 , -0.1,  3,  1.1, 0  , 1.3,  4  , NA  )

# Pairwise complete data:
testdata.A2 - c(1.15, -0.2,  1  , -2, -0.5, 0.1, 1.2, -1.4)
testdata.B2 - c(1.2 ,  1.1, -0.1,  3,  1.1, 0  , 1.3,  4  )

# Groupwise complete data:
testdata.A3 - c(1.15, -0.2,  1  , -2, -0.5, 0.1, 1.2, -1.4, 0.01)
testdata.B3 - c(1.2 ,  1.1, 3 , -0.1,  3,  1.1, 0  , 1.3,  4)

## Johannes:
t.test(testdata.A, testdata.B, paired=TRUE,  
   alternative=two.sided, na.action=na.exclude)
# Paired t-test # data:  testdata.A and testdata.B
# t = -1.7921, df = 7, p-value = 0.1162
# alternative hypothesis: true difference in means is not equal to 0
# 95 percent confidence interval: #  -3.5517017  0.4892017
# sample estimates: mean of the differences # -1.53125

## Johannes:
testdata  - c(testdata.A, testdata.B);
criterion - c(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1);

## Johannes:
# Formula-based, na.pass:
print(t.test(testdata ~ criterion, paired=TRUE,
  alternative=two.sided, na.action=na.pass))
# Paired t-test # data:  testdata by criterion
# t = -1.7921, df = 7, p-value = 0.1162
# alternative hypothesis: true difference in means is not equal to 0
# 95 percent confidence interval: #  -3.5517017  0.4892017
# sample estimates: mean of the differences # -1.53125

## Pairwise complete:
t.test(testdata.A2,testdata.B2,paired=TRUE)
# Paired t-test # data:  testdata.A2 and testdata.B2
# t = -1.7921, df = 7, p-value = 0.1162
# alternative hypothesis: true difference in means is not equal to 0
# 95 percent confidence interval: #  -3.5517017  0.4892017
# sample estimates: mean of the differences # -1.53125

## Johannes:
# Formula-based, na.exclude:
t.test(testdata ~ criterion, paired=TRUE,
   alternative=two.sided, na.action=na.exclude)
# Paired t-test # data:  testdata by criterion
# t = 

Re: [R] creation package

2010-08-14 Thread Uwe Ligges



On 14.08.2010 11:21, anderson nuel wrote:

Dear r-help,

I run R CMD INSTALL :

c:\RpR CMD INSTALL namepackage

*installing to library'c:/PROGRA~1/R/R-210~1-1/library'
*installing *source* 'namepackage'...
**R
**preparing package for lazy loading
**help
Avis:./man/namepackage-package.Rd:25:'' inatttendue
**installing help indices
**building package indices
**MD5sums
*DONEnamepackage

best



OK, but strange that checking the package fails now in its installation 
checks. Can you send us the file

C:/Rp/namepackage.Rcheck/00install.out
please.

Uwe Ligges





2010/8/13, Uwe Liggeslig...@statistik.tu-dortmund.de:


In my previous maiul I asked you to run R CMD INSTALL at first (rather than
R CMD check).

You could also look into the mentioned file
C:/Rp/namepackage.Rcheck/00install.out

But we really need that file to understand what is going on.

Uwe Ligges






On 13.08.2010 15:12, anderson nuel wrote:


Dear r-help,
I try this command R CMD INSTALL,but still there are errors.
I look into the installation log file in the namepackage.Rcheck :
* using log directory 'C:/Rp/namepackage.Rcheck'
* using R version 2.10.1 (2009-12-14)
* using session charset: ISO8859-1
* checking for file 'namepackage/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'namepackage' version '1.0'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'namepackage' can be installed ... ERROR
Installation failed.
See 'C:/Rp/namepackage.Rcheck/00install.out' for details.
  From That , I do not know where is the error
I have only one function RT, but I need several other functions within
the RT function, while
using package.skeleton() I put in the function list seulemnt RT or any
other functions, or I shall all functions in the same page??
Best



2010/7/31, Uwe Liggeslig...@statistik.tu-dortmund.de
mailto:lig...@statistik.tu-dortmund.de:



On 30.07.2010 15:44, anderson nuel wrote:

Dear r-help,

I create a package. When I installed this package (I use this
command : R
CMD check namepackage),I find an error: * checking whether package
'namepackage' can be installed ... ERROR
Installation failed.



Could you help me to find solution  for this error.




Well, either take a look into the installation log file in the
namepackage.Rcheck directory or start a bit more slowly by just
trying to install without a check in the first step by R CMD INSTALL.

Without seeing the installation log, we cannot help either.

Best,
Uwe Ligges


Best Regards

[[alternative HTML version deleted]]

__
R-help@r-project.orgmailto:R-help@r-project.org  mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
http://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.







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


[R] Simple problem with lm/predict

2010-08-14 Thread Nick Torenvliet
Hi all,

I've got an xts time series with monthly OHLC Dow Jones industrial index
data from 1980 to present, the data is in stored in x.

I've done an OLS fit on the data in 1982::1994 and stored it in extrapolate1
(x[,4] contains the closing value for the index).

 t3 - seq(1980,1994,length = length(x[1980::1994,4]))
 t4-t3^2
 extrapolate1 - lines(lm(x[1980::1994,4]~t3+t4)$fit)
 extrapolate1

Call:
lm(formula = x[1980::1994, 4] ~ t3 + t4)

Coefficients:
(Intercept)   t3   t4
  3.161e+07   -3.205e+048.125e+00

The plot comes up with the appropriate line fit for 1980::1994, so I can
safely say the model/fit is correct.

I want to plot the predicted response of extrapolate into 1995 and beyond
and after much googling have got about this close --

 new.t - seq(1995,len=2*12,by = 1/12)
 new.dat - data.frame(Time = new.t, Seas = rep(1:12,2))
 predict(extrapolate1,new.dat)[1:24]
   12345678
704.9639 714.5726 724.2807 734.0882 743.9951 754.0014 764.1071 774.3122
   9   10   11   12   13   14   15   16
784.6168 795.0207 805.5240 816.1267 826.8288 837.6303 848.5312 859.5315
  17   18   19   20   21   22   23   24
870.6313 881.8304 893.1289 904.5268 916.0241 927.6209 939.3170 951.1125
Warning message:
'newdata' had 24 rows but variable(s) found have 180 rows

This is straight from the net, the trouble is with how new.dat is set up but
I can't figure it out...

Regards,

Nick

[[alternative HTML version deleted]]

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


[R] Relation 1.5*IQR/Percentile in case of a normal Distribution

2010-08-14 Thread Johannes Graumann
Hi,

can someone point me at material to understand how in 
http://upload.wikimedia.org/wikipedia/commons/8/89/Boxplot_vs_PDF.png the 
fivenum-corresponding percentages might be calculated?

Thanks, Joh

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


Re: [R] Relation 1.5*IQR/Percentile in case of a normal Distribution

2010-08-14 Thread Peter Dalgaard
Johannes Graumann wrote:
 Hi,
 
 can someone point me at material to understand how in 
 http://upload.wikimedia.org/wikipedia/commons/8/89/Boxplot_vs_PDF.png the 
 fivenum-corresponding percentages might be calculated?

Looks like a pretty straightforward application of pnorm() and qnorm().

pnorm(4*qnorm(.75), lower=F) # Q3 + 1.5 IQR = 4 Q3 since IQR = 2 Q3

[1] 0.003488302

gives the tail probabilities of .35%, and the rest is by definition.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


[R] Unequal variance ANOVA using gls function in nlme

2010-08-14 Thread Samantha Patrick
Hi

I am trying to run an ANOVA on data with unequal variance.  I am new to nlme, 
but to my understanding I need to use the gls function.  I have single response 
variable (distance which is continuous) and the explanatory variable is 
individual ID (class variable: individuals differ in the variance in their 
distance values hence the need to using nlme).

So I would create a model Distance~Individual ID and then create a variance 
structure to add to the model.  However the variance structure is not a linear 
relationship, it is simply a series of variances linked to individual ID.  Can 
anyone guide me as to how to fit this into the model?  As the model is very 
simple, I think that the variance is the only component I need to estimate for 
the model, but perhaps I am mistaken?

Thanks

Sam


Dr Samantha Patrick
EU INTERREG Post Doc
Davy 618
Marine Biology  Ecology Research Centre
University of Plymouth
Plymouth
PL4 8AA

T: 01752 584699
M: 07740472719


[[alternative HTML version deleted]]

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


[R] incrementing matrix elements more efficiently

2010-08-14 Thread david h shanabrook
I need to increment cells of a matrix (collusionM).  The indexes to increment 
are in an index (matchIndex). This is some of the code

for (j in 1:(rows-1)) matchIndex[[j]] - which(mx[j]==mx)

for (j in 1:(rows-1)) collisionM[j,matchIndex[[j]]] - 
collisionM[j,matchIndex[[j]]] + 1

I could put them in the same loop but this is slower.  The first for statement 
is fine.  It finds the matches and creates a list of the matches.  The second 
is too slow, it increments the sparse matrix elements.  

Let me know if I need to put in more complete code to make this understandable.



[[alternative HTML version deleted]]

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


[R] Trouble loading saved Rdata

2010-08-14 Thread steven mosher
In the particular application I have I save test.Rdata to a sub directory
dir-Example
dir.create(dir)
test-data.frame(a=c(1,2,3),b=c(3,4,5)

full-file.path(dir,test.Rdata,fsep=.Platform$file.sep)
save(test,file=full)
load(full)
returns NULL

it works fine when the object is saved to the working directory, but fails
when saved to a sub directory.
The Rdata is there. Bytes are in it. but loading it doesnt work.

[[alternative HTML version deleted]]

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


Re: [R] Trouble loading saved Rdata

2010-08-14 Thread Joshua Wiley
That worked for me once I properly quoted test.RData on

 sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

If correcting the quoting does not help you, perhaps you can report
the results of sessionInfo()

Cheers,

Josh

On Sat, Aug 14, 2010 at 5:14 PM, steven mosher mosherste...@gmail.com wrote:
 In the particular application I have I save test.Rdata to a sub directory
 dir-Example
 dir.create(dir)
 test-data.frame(a=c(1,2,3),b=c(3,4,5)

 full-file.path(dir,test.Rdata,fsep=.Platform$file.sep)
 save(test,file=full)
 load(full)
 returns NULL

 it works fine when the object is saved to the working directory, but fails
 when saved to a sub directory.
 The Rdata is there. Bytes are in it. but loading it doesnt work.

        [[alternative HTML version deleted]]

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


[R] incrementing matrix elements more efficiently

2010-08-14 Thread david h shanabrook
 
I need to increment cells of a matrix (collusionM).  The indexes to increment 
are in an index (matchIndex). This is sample  code

   library(seqinr)
   library(Matrix)
   x - abcabcabc
   mx - s2c(x)
   collisionM - Matrix(0,nrow=10, ncol=10, sparse=TRUE)
   matchIndex - list()
   rows - length(mx)
   for (j in 1:(rows)) matchIndex[[j]] - which(mx[j]==mx)
   for (j in 1:(rows)) collisionM[j,matchIndex[[j]]] - 
collisionM[j,matchIndex[[j]]] + 1

  Works fine, except with my data (rows=32000) it is too slow.  The problem is 
the second for loop, where it increments the index of the sparse matrix; this 
needs to be rewritten so it is more efficient.  Any ideas?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] infinite recursion using anonymous function

2010-08-14 Thread Steven C. Bagley
In R 2.11.1 on Mac OS 10.6.4, the following code works, but if the print 
statement is removed or commented out, then an infinite recursion results. Can 
someone explain what is going on? Thanks. --Steve


foo2=function(f1, f2){
  print(f1)
  function(x){
f1(x) + f2(x) } }

foo=function(...) Reduce(foo2, list(...))

foo(sin, cos, tan)(1)

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


Re: [R] infinite recursion using anonymous function

2010-08-14 Thread David Winsemius


On Aug 14, 2010, at 6:23 PM, Steven C. Bagley wrote:

In R 2.11.1 on Mac OS 10.6.4, the following code works, but if the  
print statement is removed or commented out, then an infinite  
recursion results. Can someone explain what is going on? Thanks. -- 
Steve



foo2=function(f1, f2){
 print(f1)
 function(x){
   f1(x) + f2(x) } }

foo=function(...) Reduce(foo2, list(...))

foo(sin, cos, tan)(1)


?force

 foo2=function(f1, f2){
+  force(f1)
+  function(x){
+f1(x) + f2(x) } }

 foo=function(...) Reduce(foo2, list(...))

 foo(sin, cos, tan)(1)
[1] 3.956286

--
David.

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


Re: [R] Dealing with data

2010-08-14 Thread Jonathan Christensen
Your second fit makes no sense, as you can easily tell if you look at the
regression summaries. Fitting with spray as a categorical variable gives you
an overall p-value of less than 2.2e-16, while fitting with
as.numeric(spray) gives an overall p-value of .2118. The fit you've done
with as.numeric induces a completely invalid model, as others have tried to
point out.

Jonathan


On Fri, Aug 13, 2010 at 1:55 PM, TGS cran.questi...@gmail.com wrote:

 # I wasn't trying to do ANOVA. I was simply trying to figure out how
 regress count on sprays (this is after I saw another poster asking an
 unrelated question with the InsectSprays dataset).
 #
 # Anyhow, David clarified this but also, thanks for your explanation as
 well.

 rm(list = ls()); sprays - as.numeric(InsectSprays$spray)

 lm(formula = count ~ 0 + spray, data = InsectSprays)
 lm(formula = count ~ 0 + sprays, data = InsectSprays)

 # besides the point, in the ANOVA problem the degrees of freedom would be
 5, not 1.

 On Aug 13, 2010, at 12:27 PM, Greg Snow wrote:

 So you want 1 degree of freedom for InsectSprays?  You believe that the
 difference between A and B is exactly the same as between B and C which is
 exactly the same as between D and E (etc.)?  that seems an odd assumption,
 but you can get that by using as.numeric (as I and others have already
 stated).

 If on the other hand you want InsectSprays to be treated correctly with the
 correct number of degrees of freedom, but have the output on a single line
 testing the overall effect, then you want to use the aov function rather
 than lm (internally they do the same thing, but the default summary output
 for aov is 1 line per term).

 Hope this helps,

 --
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111


  -Original Message-
  From: TGS [mailto:cran.questi...@gmail.com]
  Sent: Friday, August 13, 2010 11:51 AM
  To: Greg Snow
  Cc: r-help@r-project.org
  Subject: Re: [R] Dealing with data
 
  # Greg, if R automatically does that then I don't know why it's
  treating each indicator
  # as a different regressor. In other words, I am interested in treating
  'spray' as one
  # independent variable.
  #
  # Erik, which book do you suggest I read? Thanks.
 
  data(InsectSprays)
  lm(InsectSprays$count ~ 0 + InsectSprays$spray)
 
  On Aug 13, 2010, at 10:34 AM, Greg Snow wrote:
 
  R/S does all of that automatically for you, you do not need to manually
  create the indicator variables.
 
  If you do something like:
 
  fit - lm( Sepal.Width ~ Species, data=iris, x=TRUE)
 
  Then look at the matrix actually used:
 
  fit$x
 
  Or the output:
 
  summary(fit)
 
  You will see that Species was automatically converted into indicator
  variables and those were used in the regression.
 
  If you really need the indicator variables yourself, look at the
  model.matrix function, e.g.:
 
  model.matrix( ~Species, data=iris )
 
  Or
 
  model.matrix( ~Species - 1, data=iris )
 
  If you really want 1 for A, 2 for B, etc. then look at as.numeric on a
  factor variable (e.g. as.numeric(iris$Species) ).
 
  Hope this helps,
 
  --
  Gregory (Greg) L. Snow Ph.D.
  Statistical Data Center
  Intermountain Healthcare
  greg.s...@imail.org
  801.408.8111
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of TGS
  Sent: Friday, August 13, 2010 11:22 AM
  To: David Winsemius
  Cc: r-help@r-project.org
  Subject: Re: [R] Dealing with data
 
  To clarify, I'd like to create a column of indicators for the
  respective letters so that I could maybe do regression on indicators,
  etc.
 
  For instance, A gets 1, B gets 2, and so on.
 
  On Aug 13, 2010, at 10:19 AM, David Winsemius wrote:
 
 
  On Aug 13, 2010, at 1:03 PM, TGS wrote:
 
  # how would I code in R to look at the letter of the alphabet
  # in the second column and create a indicator column for the
  # corresponding letter?
 
  data(InsectSprays)
  InsectSprays$spray
 
  It's already what most people mean when they say indicator column,
  i.e., a factor variable (and not a character vector)  so,  what
  do
  _you_ mean?
 
 
 
  --
 
  David Winsemius, MD
  West Hartford, CT
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
  guide.html
  and provide commented, minimal, self-contained, reproducible code.

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


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read 

[R] band pass filter

2010-08-14 Thread nuncio m
Hello list,
  Is there any way to bandpass filter in R
thanks
nuncio

-- 
Nuncio.M
Research Scientist
National Center for Antarctic and Ocean research
Head land Sada
Vasco da Gamma
Goa-403804

[[alternative HTML version deleted]]

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


Re: [R] band pass filter

2010-08-14 Thread Dennis Murphy
Try this:

library(sos)
findFn('bandpass')

If necessary, install the package first. I got 24 hits in eight packages.
Hopefully one or more of them will be suitable.

HTH,
Dennis

On Sat, Aug 14, 2010 at 8:52 PM, nuncio m nunci...@gmail.com wrote:

 Hello list,
  Is there any way to bandpass filter in R
 thanks
 nuncio

 --
 Nuncio.M
 Research Scientist
 National Center for Antarctic and Ocean research
 Head land Sada
 Vasco da Gamma
 Goa-403804

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] 64 bit RSQLite

2010-08-14 Thread Seth Falcon
Hi Stephen,

On 8/12/10 7:10 PM, Stephen Liu wrote:
 Hi folks,
 
 Ubuntu 10.04 64 bit
 
 Where can I find 64 bit RSQLite?
 
 It seems not there;
 RSQLite: SQLite interface for R
 http://cran.r-project.org/web/packages/RSQLite/index.html

You should be able to install the RSQLite source package to obtain a 64
bit package.

install.packages(RSQLite, type=source)

+ seth

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