Re: [R] Help with makeClusters for Snow

2009-12-23 Thread SVM

Hi, 

Would it help if I was to install Ubuntu, and try loading it there? I've
seen quite a few comments about running rmpi on Linux, through google
search. 

Do you know if I have to install any specific packages/libraries before
trying to install RMpi?
I was recommended to install LAM 7.1 before proceeding with its
installation. Do you know if that is correct? 

Thanks for all your help. 

Steve




 

Patrick Connolly-4 wrote:
> 
> On Tue, 22-Dec-2009 at 09:38PM -0800, SVM wrote:
> 
> |> 
> []
> 
> |> 
> |> On top of that, I couldn't find the MPI/NWS/PVM libraries for windows.
> I've
> |> looked for them all over the internet but I can't seem to find any
> resources
> |> for it. I even tried installing them directly from R, (i.e.
> |> install.packages(rmpi) or install.packages(mpi)), they don't seem to
> exist
> |> in the repository any longer.
> 
> Did they ever exist?  According to the listing of Rmpi on CRAN would
> indicate that there is none, only the tar.gz file.  This is very OS
> specific sort of stuff.
> 
> best
> 
> Patrick
> 
> 
> 
> |> 
> |> Can anyone please help me with this. Also, where can I find them and
> how do
> |> I install the PVM, MPI, and NWS packages?
> |> 
> |> Any help would be greatly appreciated .
> 
> 
> 
> 
> |> 
> |> Steve
> |> -- 
> |> View this message in context:
> http://n4.nabble.com/Help-with-makeClusters-for-Snow-tp977592p977592.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.
> 
> -- 
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
>___Patrick Connolly   
>  {~._.~}   Great minds discuss ideas
>  _( Y )_   Average minds discuss events 
> (:_~*~_:)  Small minds discuss people  
>  (_)-(_). Eleanor Roosevelt
> 
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/Help-with-makeClusters-for-Snow-tp977592p978331.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] What is ".Machine$double.eps"?

2009-12-23 Thread Berend Hasselman


Saji Ren wrote:
> 
> Hello,everyone:
> 
> I met this notation when I read the original code of function
> "quantile".There is one sentence as below:
>>eps <- 100 * .Machine$double.eps
> 
> when I input ".Machine$double.eps" in R, it returns "[1] 2.220446e-16".
> Can anyone show me the exact meaning about that?
> 

In R, type

?.Machine

and you will have your answer

Berend
-- 
View this message in context: 
http://n4.nabble.com/What-is-Machine-double-eps-tp978309p978329.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] Innocentive challenge

2009-12-23 Thread Jim Lemon

Hi all,
Apologies if this is inappropriate, but I found this challenge on 
Innocentive:


http://click.email.innocentive.com/?ju=fe5c1c777563037c7717&ls=fe0417717764067b711d7075&m=fef91270706102&l=fe8815797c62037d72&s=fe1e16787c640d797c1371&jb=ffcf14&t=
Algorithms Optimized for Efficiency and Speed for
Exploring and Testing Large Model Spaces
(#9032888)
The Seeker is looking for Solvers to find an efficient and robust
statistical algorithm and computing tool that can detect significantly well
performing models based on 3 or more variables out of several hundred variables.
The primary innovation in this Challenge seeks to find new ways of searching
this tremendously large model space in order to find the most interesting and
useful models.
Deadline: March 25, 2010
Reward: $20,000

Can't be worse than writing grant apps...

Jim

__
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] What is ".Machine$double.eps"?

2009-12-23 Thread Saji Ren
Hello,everyone:

I met this notation when I read the original code of function "quantile".There 
is one sentence as below:
>eps <- 100 * .Machine$double.eps

when I input ".Machine$double.eps" in R, it returns "[1] 2.220446e-16".
Can anyone show me the exact meaning about that?

thanks

Saji from Shanghai
__
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] animated R plots

2009-12-23 Thread Yihui Xie
Hi,

saveSWF() (and other save*() functions) will only record the plots by
*high-level* plotting commands, and this is because most graphics
devices can only record high-level plots by default. In your animation
code, there is actually one plot generated, and the rest are produced
by low-level plotting commands like text() and points() - they will
not get recorded. So you have to draw the whole plot again by
plot(...) inside the loop. Here is a simple example:

x = runif(10)
y = runif(10)

# you can see the animation in the graphics window
# but only one image file is generated at last
plot(0:1, 0:1)
for (i in 1:10) {
points(x[i], y[i])
Sys.sleep(0.1)
}

# this is equivalent to the above animation
# but 10 image frames are generated in the end
for (i in 1:10) {
plot(0:1, 0:1)
points(x[1:i], y[1:i])
Sys.sleep(0.1)
}

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Wed, Dec 23, 2009 at 9:59 AM, Zd Gibbs  wrote:
>  Hi,
> I want to be able to save the following animated plot as a flash.  There are 
> ultimately 6 plots, but when I run this and save it as a flash all I get is 
> the last (6th) plot, not all six different plots in order by "year".  I’ve 
> tested the flash commands and they work; so it has to be my function code. I 
> am guessing that the problem has something to do with overlaying the plot 
> points, but I don’t know how to rewrite it and keep the animated elements.
> I am running R version 2..9.2 on Windows Vista.
>
> Data looks like this:
>
> service usage amount year
> transport 11.33105 15.75016 2004
> transport 11.38398 15.82374 2005
> transport 11.44057 15.90239 2005
>
> Thanks!
>
> ZdGibbs (I can provide a subset of the data as .txt if necessary).
>
> #order service year in ascending order and set frame options
> library(animation)
> library(lattice)
> service <- service[order(service$year), ]
> oopt = ani.options(interval = 1.0)
>
> # create the function
>
> Service <- function (...)
>      {
>
> interval = ani.options("interval")
> index <- unique(service$year)
>
> plot(amount~usage, data=service, type="n", xlab = " ", ylab = " ", bty="l", 
> ylim=c(0,500))
>
> legend("topright", legend=c("Transport", "Family", "Housing", "Substance 
> Use", "Medical", "Mental Health"), pch=c(19,19,19,19,19,19), col=c("#7FC97F", 
> "#BEAED4", "#FDC086", "#99", "#386CB0", "#F0027F"), bty="n", inset=.02)
>
> for (i in 1:length(index)) {
> rect(11.4, 425, 11.9, 500, col="white", border="red")
>
> year.service <- service[which(service$year==index[i]),]
>
> graphics <- year.service[year.service$service=="Graphics",]
>
>   trans <- year.service[year.service$service=="transport",]
>   fam <- year.service[year.service$service=="family",]
>   hous <- year.service[year.service$service=="housing",]
>   subuse <- year.service[year.service$service=="subuse",]
>   med <- year.service[year.service$service=="genhealth",]
>   menhlth <- year.service[year.service$service=="mental health",]
>
> text(mean(range(service$usage, na.rm=TRUE)), 455, index[i], col = rgb(0, 0, 
> 0, 0.5), cex = 4)
> points(amount~usage, data=trans, pch=19, col="#7FC97F")
> points(amount~usage, data=fam, pch=19, col="#BEAED4")
> points(amount~usage, data=hous, pch=19, col="#FDC086")
> points(amount~usage, data=subuse, pch=19, col="#99")
> points(amount~usage, data=med, pch=19, col="#386CB0")
> points(amount~usage, data=menhlth, pch=19, col="#F0027F")
>
>     Sys.sleep(interval)
>
> }
>
> }
> #run animation
> Service()
>
> #save as flash
> oopt = ani.options(nmax = 6, interval = 1.0)
> saveSWF(Service(), interval = 2.0, swfname="place.swf", dev = "pdf", 
> filename="Pplot", fmt = "%03d", outdir = getwd(), swftools="C:/Program 
> Files/SWFTools")
> ani.options(oopt)
>
>
>
>        [[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] how to create normal qqplot with the 95% confidence interval

2009-12-23 Thread CJ Rubio

thank you very much! this is just what my professor was asking for.



Walmes Zeviani wrote:
> 
> Rubio,
> 
> 
> Look at library(fBasics) the function qqnormPlot(). Below an example:
> 
> qqnormPlot(rnorm(100))
> 
> Best's
> 
> Walmes Zeviani, Brasil.
> 
> 
> 
> 
> 
> CJ Rubio wrote:
>> 
>> hi everyone!
>> 
>> season's greetings!
>> 
>> is there any way that i can create a normal qqplot showing, aside from
>> the qqline, the 95% confidence limits? thank you very much..
>> 
>> happy holidays!
>> 
> 
> 

-- 
View this message in context: 
http://n4.nabble.com/how-to-create-normal-qqplot-with-the-95-confidence-interval-tp977727p978298.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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Francesco Napolitano
On Thu, Dec 24, 2009 at 4:38 AM, Brian G. Peterson wrote:

>
> data <- matrix(rnorm(100), nrow=10)  # 10 x 10
> apply(data,2,cumsum)
>
> if you want to store the partial sums
> (that was an important bit of information you left out)
>
>
Thank you for your suggestion. However, I gave information only about what I
was interested in and I got my answer immediately.

Cheers,
Francesco.

[[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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Brian G. Peterson

Francesco Napolitano wrote:

Il giorno mer, 23/12/2009 alle 22.14 -0500, David Winsemius ha scritto:

for(i in 1:n){
   submat <- data[1:i,]
   C <- colSums(submat)
   }


In R the loop is not necessary, even confusing as you are demonstrating:

 > mat <- matrix(rnorm(100), nrow=10)  # 10 x 10
 > colSums(mat[1:5, ]) # sums of 1st 5 rows
  [1]  3.1735  0.86672248 -3.10971483  1.23620455 -0.31887421  
-0.50544837

  [7]  3.13636155  0.02175862 -2.18816961 -1.31760196


It would be unnecessary also in Matlab. In the real code I need to store
the partial sums (the example overwrites them, so it looks like wasted
loops).


try:

data <- matrix(rnorm(100), nrow=10)  # 10 x 10
apply(data,2,cumsum)

if you want to store the partial sums
(that was an important bit of information you left out)

__
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] Resent: colorkey: Placement of labels and ticks in center positions of "color key" of a levelplot ?

2009-12-23 Thread Deepayan Sarkar
On Wed, Dec 23, 2009 at 12:54 PM, Zia Ahmed  wrote:
> Is it possible to place  labels  and ticks  in center positions of each cut
> of  "color key" of levelplot ? Here is my code that I used to produce a map
> (see attachment). The two  labels and ticks  were  placed  in  left  sides
> each segment of the color key. I want to show them center of the cuts.

Your question is not clear to me, but if you mean to say that you want
the labels on top of the colored rectangles in the color key (i.e.,
overlapping them and not on one side), then no, that is not supported.

However, you could write your own legend function to do that, starting
from draw.colorkey as a template.

-Deepayan

> Help will be appreciated.
> Thanks
>
> Zia
>
> windows(width=4, height=5)
> jpeg( file="/Fig_1.jpg",
> units = "px", pointsize = 12, quality = 75, bg = "white",
> res = NA, restoreConsole = TRUE)
>
> levelplot(ffreq~x+y, aspect="iso",
>           xlab=list("E (m)",cex=.6), ylab="N (m)",
>           scales=list(y=list(draw=T,cex=.7,rot=90, tck= .35),x=list(draw=T,
> cex=.7,tck= .35)),
>            colorkey = list(space="right",tick.number=1,height=1, width=1.5,
>            labels = list(at = seq(1,2,length=2),cex=.7,rot=90,
>            lab = c("annual", "2-5 years"))),
> # I want place above labels center of each cuts of colorkey"
>            as.data.frame(meuse.grid),
>            col.regions=gray.colors,cuts=1,
>            panel = function(...) {
>            panel.levelplot(...)
>            panel.grid(h=-1, v=-1, col="darkgrey")
>                }, )
> dev.off()
>
> __
> 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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Francesco Napolitano
Il giorno mer, 23/12/2009 alle 22.14 -0500, David Winsemius ha scritto:
> > for(i in 1:n){
> >submat <- data[1:i,]
> >C <- colSums(submat)
> >}
> >
> In R the loop is not necessary, even confusing as you are demonstrating:
> 
>  > mat <- matrix(rnorm(100), nrow=10)  # 10 x 10
>  > colSums(mat[1:5, ]) # sums of 1st 5 rows
>   [1]  3.1735  0.86672248 -3.10971483  1.23620455 -0.31887421  
> -0.50544837
>   [7]  3.13636155  0.02175862 -2.18816961 -1.31760196

It would be unnecessary also in Matlab. In the real code I need to store
the partial sums (the example overwrites them, so it looks like wasted
loops).

Francesco.

__
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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Francesco Napolitano
So I see from help([[) what's happening: thank you very much.

Il giorno mer, 23/12/2009 alle 18.59 -0800, Henrik Bengtsson ha scritto:
> Use
> 
>submat <- data[1:i,, drop=FALSE]
> 
> /H
> 
> On Wed, Dec 23, 2009 at 6:46 PM, Francesco Napolitano
>  wrote:
> > Hi all,
> >
> > I'm trying to learn R after years of Matlab's experience. Here is an
> > issue I couldn't solve today.
> >
> > Consider the following piece of code (written by memory):
> >
> > for(i in 1:n){
> >submat <- data[1:i,]
> >C <- colSums(submat)
> >}
> >
> > The problem is that at the first iteration, data[1:1,] reduces to a
> > vector and colSums returns an error. This sounds really strange to me
> > because a sum-over-columns operation should have no problem working with
> > columns of length 1. Matlab's "sum()" works just fine in such case.
> >
> > The error says that I need an at least 2D array. So I try using
> > matrix(data[1:i,]). Unfortunately this returns a column instead of a
> > row. So I could do t(matrix(data[1:i,])), but this would transpose the
> > also the sub-matrices from the 2nd iteration on. I could fix everything
> > with some "if" but it would be really terrible code :-/.
> >
> > I'm sure I'm missing something because my neurons stick with Matlab
> > behaviour. Can you help me to understand what's wrong with my reasoning?
> >
> > Thank you very much,
> > Francesco.
> >
> > __
> > 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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread David Winsemius


On Dec 23, 2009, at 9:46 PM, Francesco Napolitano wrote:


Hi all,

I'm trying to learn R after years of Matlab's experience. Here is an
issue I couldn't solve today.

Consider the following piece of code (written by memory):

for(i in 1:n){
   submat <- data[1:i,]
   C <- colSums(submat)
   }


In R the loop is not necessary, even confusing as you are demonstrating:

> mat <- matrix(rnorm(100), nrow=10)  # 10 x 10
> colSums(mat[1:5, ]) # sums of 1st 5 rows
 [1]  3.1735  0.86672248 -3.10971483  1.23620455 -0.31887421  
-0.50544837

 [7]  3.13636155  0.02175862 -2.18816961 -1.31760196



The problem is that at the first iteration, data[1:1,] reduces to a
vector and colSums returns an error. This sounds really strange to me
because a sum-over-columns operation should have no problem working  
with

columns of length 1. Matlab's "sum()" works just fine in such case.

The error says that I need an at least 2D array. So I try using
matrix(data[1:i,]). Unfortunately this returns a column instead of a
row. So I could do t(matrix(data[1:i,])), but this would transpose the
also the sub-matrices from the 2nd iteration on. I could fix  
everything

with some "if" but it would be really terrible code :-/.

I'm sure I'm missing something because my neurons stick with Matlab
behaviour. Can you help me to understand what's wrong with my  
reasoning?


Thank you very much,
Francesco.

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


David Winsemius, MD
Heritage Laboratories
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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Henrik Bengtsson
Use

   submat <- data[1:i,, drop=FALSE]

/H

On Wed, Dec 23, 2009 at 6:46 PM, Francesco Napolitano
 wrote:
> Hi all,
>
> I'm trying to learn R after years of Matlab's experience. Here is an
> issue I couldn't solve today.
>
> Consider the following piece of code (written by memory):
>
> for(i in 1:n){
>    submat <- data[1:i,]
>    C <- colSums(submat)
>    }
>
> The problem is that at the first iteration, data[1:1,] reduces to a
> vector and colSums returns an error. This sounds really strange to me
> because a sum-over-columns operation should have no problem working with
> columns of length 1. Matlab's "sum()" works just fine in such case.
>
> The error says that I need an at least 2D array. So I try using
> matrix(data[1:i,]). Unfortunately this returns a column instead of a
> row. So I could do t(matrix(data[1:i,])), but this would transpose the
> also the sub-matrices from the 2nd iteration on. I could fix everything
> with some "if" but it would be really terrible code :-/.
>
> I'm sure I'm missing something because my neurons stick with Matlab
> behaviour. Can you help me to understand what's wrong with my reasoning?
>
> Thank you very much,
> Francesco.
>
> __
> 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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Benilton Carvalho
replace data[1:i,] by data[1:i,drop=FALSE].

b

On Dec 24, 2009, at 12:46 AM, Francesco Napolitano wrote:

> Hi all,
> 
> I'm trying to learn R after years of Matlab's experience. Here is an
> issue I couldn't solve today.
> 
> Consider the following piece of code (written by memory):
> 
> for(i in 1:n){
>submat <- data[1:i,]
>C <- colSums(submat)
>}
> 
> The problem is that at the first iteration, data[1:1,] reduces to a
> vector and colSums returns an error. This sounds really strange to me
> because a sum-over-columns operation should have no problem working with
> columns of length 1. Matlab's "sum()" works just fine in such case.
> 
> The error says that I need an at least 2D array. So I try using
> matrix(data[1:i,]). Unfortunately this returns a column instead of a
> row. So I could do t(matrix(data[1:i,])), but this would transpose the
> also the sub-matrices from the 2nd iteration on. I could fix everything
> with some "if" but it would be really terrible code :-/.
> 
> I'm sure I'm missing something because my neurons stick with Matlab
> behaviour. Can you help me to understand what's wrong with my reasoning?
> 
> Thank you very much,
> Francesco.
> 
> __
> 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] Newbie: colSums() compared with Matlab's sum()

2009-12-23 Thread Francesco Napolitano
Hi all,

I'm trying to learn R after years of Matlab's experience. Here is an
issue I couldn't solve today.

Consider the following piece of code (written by memory):

for(i in 1:n){
submat <- data[1:i,]
C <- colSums(submat)
}

The problem is that at the first iteration, data[1:1,] reduces to a
vector and colSums returns an error. This sounds really strange to me
because a sum-over-columns operation should have no problem working with
columns of length 1. Matlab's "sum()" works just fine in such case.

The error says that I need an at least 2D array. So I try using
matrix(data[1:i,]). Unfortunately this returns a column instead of a
row. So I could do t(matrix(data[1:i,])), but this would transpose the
also the sub-matrices from the 2nd iteration on. I could fix everything
with some "if" but it would be really terrible code :-/.

I'm sure I'm missing something because my neurons stick with Matlab
behaviour. Can you help me to understand what's wrong with my reasoning?

Thank you very much,
Francesco.

__
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] Column naming issues using read.table

2009-12-23 Thread jim holtman
This reads in your posted data:

> x <- read.table(textConnection("Samplerate = 2 samps/sec
+   Nr   Cnt1X   Cnt1Y   Cnt2X   Cnt2Y  sec100  hour
+  153  84  43  2   22  12
+  290  155 74  0   72  12
+  390  155 74  0   121 12"), skip=1, header=TRUE)
> closeAllConnections()
>
> x
  Nr Cnt1X Cnt1Y Cnt2X Cnt2Y sec100 hour
1  1538443 2 22   12
2  290   15574 0 72   12
3  390   15574 0121   12


On Wed, Dec 23, 2009 at 8:31 PM, arthurbeer01 wrote:

>
> Hi, this is my first post so please be gentle.
> I quite new to R and using it for my biology degree.
>
> My problem is. Im trying to import data from a .csv file using the
> read.table command. The .csv file header starts on row 2 but is contained
> in
> column 1, i have 600 data files and for future ease would rather not edit
> each file seperatly. The data starts on row three and I only need the first
> 381 data points.
>
> The R error message using the code iv got so far is
>
> Error in read.table(file("s1-2c83.csv"), header = FALSE, sep = ",", quote =
> "",  :
>  more columns than column names
>
> The code I have so far is
>
> framename<-read.table(file ("s1-2c83.csv"),
> header = FALSE, # FLASE indicates headers are not included in input file
> sep = ",",# must have "," otherwise errors in table
> quote = "",
> dec = ".",
> row.names = 1, # must = 1 or extra column of row numbering is entered
> col.names = ("Nr2sec,Cnt1X,Cnt1Y,Cnt2X,Cnt2Y,sec100,hour"),
> as.is = FALSE,
> na.strings = "NA",
> colClasses = NULL,
> nrows = 381, # rows to stop data.table recording (not input file row
> number!)
> skip = 2,# number of rows to skp before reading data from input file
> strip.white = FALSE,
> comment.char = "")
>
> write.csv(framename, file = "s1-2c83-ok.csv")
>
> If I delete the line col.names, Iv manged to get the data read and saved to
> a new .csv file but cannot work out how to get the column headers renamed.
> The read.table (framename) displays the headers as v1,v2,v3 etc, this is
> what i cant change. Also it has the first column without a header (i think
> its the row number) which I dont want in the output file
>
> The read data file example s1-2c83.csv
>
> 1:Samplerate = 2 samps/sec
> 2:  Nr   Cnt1X   Cnt1Y   Cnt2X   Cnt2Y  sec100  hour
> 3: 153  84  43  2   22  12
> 4: 290  155 74  0   72  12
> 5: 390  155 74  0   121 12
>
> Any help will be greatly appreciated after the 5hrs Iv spent already on
> this
> problem.
>
> Many thanks in advance
>
>  Adam
>
>
>
> --
> View this message in context:
> http://n4.nabble.com/Column-naming-issues-using-read-table-tp978241p978241.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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[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] Column naming issues using read.table

2009-12-23 Thread arthurbeer01

Hi, this is my first post so please be gentle.
I quite new to R and using it for my biology degree.

My problem is. Im trying to import data from a .csv file using the
read.table command. The .csv file header starts on row 2 but is contained in
column 1, i have 600 data files and for future ease would rather not edit
each file seperatly. The data starts on row three and I only need the first
381 data points.

The R error message using the code iv got so far is

Error in read.table(file("s1-2c83.csv"), header = FALSE, sep = ",", quote =
"",  : 
  more columns than column names

The code I have so far is

framename<-read.table(file ("s1-2c83.csv"),
header = FALSE, # FLASE indicates headers are not included in input file
sep = ",",# must have "," otherwise errors in table
quote = "",
dec = ".",
row.names = 1, # must = 1 or extra column of row numbering is entered
col.names = ("Nr2sec,Cnt1X,Cnt1Y,Cnt2X,Cnt2Y,sec100,hour"),
as.is = FALSE,
na.strings = "NA",
colClasses = NULL,
nrows = 381, # rows to stop data.table recording (not input file row
number!)
skip = 2,# number of rows to skp before reading data from input file
strip.white = FALSE,
comment.char = "")

write.csv(framename, file = "s1-2c83-ok.csv")

If I delete the line col.names, Iv manged to get the data read and saved to
a new .csv file but cannot work out how to get the column headers renamed.
The read.table (framename) displays the headers as v1,v2,v3 etc, this is
what i cant change. Also it has the first column without a header (i think
its the row number) which I dont want in the output file

The read data file example s1-2c83.csv

1:Samplerate = 2 samps/sec  
2:  Nr   Cnt1X   Cnt1Y   Cnt2X   Cnt2Y  sec100  hour

3: 153  84  43  2   22  12
4: 290  155 74  0   72  12
5: 390  155 74  0   121 12

Any help will be greatly appreciated after the 5hrs Iv spent already on this
problem.

Many thanks in advance

 Adam



-- 
View this message in context: 
http://n4.nabble.com/Column-naming-issues-using-read-table-tp978241p978241.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] Unwanted association between a function and a namespace

2009-12-23 Thread Patrick Connolly
Tnanks for the help, Duncan.

On Wed, 23-Dec-2009 at 06:57PM -0500, Duncan Murdoch wrote:

> On 23/12/2009 6:08 PM, p_conno...@slingshot.co.nz wrote:

[...]

>> I thought I'd found a fix when I specifically loaded plyr and then
>> detached it with the unload = TRUE argument.  sessionInfo() seems to
>> show that I had gotten rid of the plyr by namespace, but I still get this:
>>
>> summarize
>> function(.data, ...) {
>>   eval(substitute(data.frame(...)), .data, parent.frame())
>> }
>> 
>>
>> Curiouser and curiouser as Alice would say.
>
>

> And where is that function?  find("summarize") should tell you.  The
> fact that it has the plyr namespace as its environment doesn't mean
> it is stored there.

Were one to believe what find("summarize") says, it's in the search
position where I put it.  However, what's in that position, ISN'T what
is returned when one types 'summarize' at the prompt.  Though, as I
indicated earlier, ESS gets the correct one if I wish to edit it.

The only way I found to get round the problem was to make an
additional function Summarize in the same place.  It involves editing
any old scripts/functions before they work, but work they do.

best

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] Unwanted association between a function and a namespace

2009-12-23 Thread Duncan Murdoch

On 23/12/2009 6:08 PM, p_conno...@slingshot.co.nz wrote:

Quoting Duncan Murdoch :


On 23/12/2009 3:36 PM, p_conno...@slingshot.co.nz wrote:

I can't understand how the plyr package is turning up here:



[...]


I can understand that lattice would be using grid without having that
package loaded, but I can't understand how plyr got there.

One way for this to happen is if you have a copy of a function from plyr
in your global environment.  The functions in plyr reference its
namespace, so you'd get it loaded that way.


I've never loaded the plyr package, except for when I used the reshape
package.  It's possible at that time, I had occasion to use a function
I have of the same name as one in the plyr package, but I would not
have saved a copy of either function in the global environment.


It wouldn't matter if that namespace hadn't become associated somehow
with a function I have somewhere else on the search path (thereby
rendering the function unfindable).

This doesn't make sense.  If the function is on the search path, it
doesn't matter what namespace is associated with it:  you'll find it.


Perhaps I need to be more explicit.  The find() function does indeed
find it, and I can edit it in ESS using the normal C-c C-d sequence.
HOWEVER, when I do args() of it, I get the args of the plyr function
-- even when I've not loaded that package.  Trying to use the function
in code ends up calling the plyr function.


If you have a function with the same name in globalenv() then you'll
have problems.  The simple solution is to remove it (e.g. rm(f)); a
better long term solution is to *never* store anything in your workspace
between sessions.  Start with a clean global environment each time.


I thought I'd found a fix when I specifically loaded plyr and then
detached it with the unload = TRUE argument.  sessionInfo() seems to
show that I had gotten rid of the plyr by namespace, but I still get this:

summarize
function(.data, ...) {
  eval(substitute(data.frame(...)), .data, parent.frame())
}


Curiouser and curiouser as Alice would say.



And where is that function?  find("summarize") should tell you.  The 
fact that it has the plyr namespace as its environment doesn't mean it 
is stored there.


Duncan Murdoch

__
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] ensemble for machine learning

2009-12-23 Thread Jack Lewis
Could someone give a better example of how to extend [1] to create an 
ensemble from multiple machine learning classifiers to improve the 
classification performance?


[1] 
http://heuristically.wordpress.com/2009/12/23/compare-performance-machine-learning-classifiers-r/


Berry and Linoff  ("Mastering Data Mining", p217) suggest the approach 
below, but the performance is similar to the individual models.


# create ensemble (per Berry and Linoff)
evidence_a <- attr(x.svm.prob, "probabilities")[,2] * x.ip.prob[,2] * 
x.cf.prob
evidence_b <- ( 1-x.ip.prob[,2]) * (1-attr(x.svm.prob, 
"probabilities")[,2] * (1-x.cf.prob))

x.en.prob <- (evidence_a) / (evidence_a + evidence_b)

# bagging
x.ip.prob.rocr <- prediction(x.ip.prob[,2], BreastCancer[ind == 2,'Class'])
x.ip.perf <- performance(x.ip.prob.rocr, "tpr","fpr")
plot(x.ip.perf, col=2)

# svm
x.svm.prob.rocr <- prediction(attr(x.svm.prob, "probabilities")[,2], 
BreastCancer[ind == 2,'Class'])

x.svm.perf <- performance(x.svm.prob.rocr, "tpr","fpr")
plot(x.svm.perf, col=3, add=TRUE)


# cforest
x.cf.prob.rocr <- prediction(x.cf.prob, BreastCancer[ind == 2,'Class'])
x.cf.perf <- performance(x.cf.prob.rocr, "tpr","fpr")
plot(x.cf.perf, col=4, add=TRUE)

# ensemble
#x.en.rocr <- prediction(rowMeans(cbind(x1=x.cf.prob, 
x2=x.ip.prob[,2])), BreastCancer[ind == 2,'Class'])

x.en.rocr <- prediction(x.en.prob, BreastCancer[ind == 2,'Class'])
x.en.perf <- performance(x.en.rocr, "tpr","fpr")
plot(x.en.perf, col=5, add=TRUE)

# Draw a legend.
legend(0.6, 0.6, c('bagging','svm', 'cforest', 'ensemble'), 2:5)



Jack

__
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] Unwanted association between a function and a namespace

2009-12-23 Thread p_connolly


Quoting Duncan Murdoch :


On 23/12/2009 3:36 PM, p_conno...@slingshot.co.nz wrote:

I can't understand how the plyr package is turning up here:



[...]


I can understand that lattice would be using grid without having that
package loaded, but I can't understand how plyr got there.


One way for this to happen is if you have a copy of a function from plyr
in your global environment.  The functions in plyr reference its
namespace, so you'd get it loaded that way.


I've never loaded the plyr package, except for when I used the reshape
package.  It's possible at that time, I had occasion to use a function
I have of the same name as one in the plyr package, but I would not
have saved a copy of either function in the global environment.





It wouldn't matter if that namespace hadn't become associated somehow
with a function I have somewhere else on the search path (thereby
rendering the function unfindable).


This doesn't make sense.  If the function is on the search path, it
doesn't matter what namespace is associated with it:  you'll find it.


Perhaps I need to be more explicit.  The find() function does indeed
find it, and I can edit it in ESS using the normal C-c C-d sequence.
HOWEVER, when I do args() of it, I get the args of the plyr function
-- even when I've not loaded that package.  Trying to use the function
in code ends up calling the plyr function.


If you have a function with the same name in globalenv() then you'll
have problems.  The simple solution is to remove it (e.g. rm(f)); a
better long term solution is to *never* store anything in your workspace
between sessions.  Start with a clean global environment each time.


I thought I'd found a fix when I specifically loaded plyr and then
detached it with the unload = TRUE argument.  sessionInfo() seems to
show that I had gotten rid of the plyr by namespace, but I still get this:

summarize
function(.data, ...) {
 eval(substitute(data.frame(...)), .data, parent.frame())
}


Curiouser and curiouser as Alice would say.

--
Patrick Connolly
Plant & Food Research
Mt Albert
Auckland
New Zealand
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
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] as.Date question

2009-12-23 Thread Marek Janad
Look at documentation

?as.Date

as.Date first represents time in UTC, what gives:

as.POSIXlt(zzz1, tz="UTC")

HTH

2009/12/20 MAL :
> All!
>
> This piece of code:
>
> zzz1 <- as.POSIXct("1999-03-18", tz="CET")
> zzz2 <- as.POSIXlt("1999-03-18", tz="CET")
> zzz1 == zzz2
> as.Date(zzz1)
> as.Date(zzz2)
>
> yields TRUE for "zzz1==zzz2", but the two dates returned by as.Date are
> different:
>
>> as.Date(zzz1)
>
> [1] "1999-03-17"
>>
>> as.Date(zzz2)
>
> [1] "1999-03-18"
>
> I'm using R 2.10.0.
>
> Would be glad for any clarifications. Thanks!
>
> __
> 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.
>



-- 
Marek

__
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] prcomp : plotting only explanatory axis arrows

2009-12-23 Thread milton ruser
Dear all,

I have a very large dataset (1712351 , 20) and would like
to plot only the arrows that represent the
contribution of each variables.
On the sample below I woild like to plot
only the explanatory variables (Murder, Assault..)
and not the sites.

prcomp(USArrests)  # inappropriate
prcomp(USArrests, scale = TRUE)
prcomp(~ Murder + Assault + Rape, data = USArrests, scale = TRUE)
plot(prcomp(USArrests))
summary(prcomp(USArrests, scale = TRUE))
biplot(prcomp(USArrests, scale = TRUE))
Thanks a lot,

milton

[[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] loading data into ZOO

2009-12-23 Thread Gabor Grothendieck
read.zoo does not allow multiple index fields but you can read it in
using read.table, combine the index fields and use read.zoo to read
the resulting data frame.  Note that read.zoo can read data frames,
not just files. Also note the aggregate= argument on read.zoo allows
direct handling of situations like this where there are multiple time
series each indicated by a field, in this case, SYMBOL.

On Wed, Dec 23, 2009 at 3:21 PM, Stephen J. Barr  wrote:
> Hello,
>
> I have a simple question. I am trying to load data into a zoo object. I have
> the data in CSV format as follows
>
> SYMBOL DATE             TIME              PRICE
> XX            MMDD HH:MM:SS      n.nn
>
> and there are multiple symbols in this one data frame.
>
> My question is, do I need to merge DATE and TIME before loading them or can
> I specify multiple index.column or index.name fields?
>
> Thanks,
> -stephen

__
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] Unwanted association between a function and a namespace

2009-12-23 Thread Duncan Murdoch

On 23/12/2009 3:36 PM, p_conno...@slingshot.co.nz wrote:

I can't understand how the plyr package is turning up here:


sessionInfo()

R version 2.10.1 (2009-12-14)
i686-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] lattice_0.17-26

loaded via a namespace (and not attached):
[1] grid_2.10.1 plyr_0.1.9

I can understand that lattice would be using grid without having that
package loaded, but I can't understand how plyr got there.


One way for this to happen is if you have a copy of a function from plyr 
in your global environment.  The functions in plyr reference its 
namespace, so you'd get it loaded that way.




It wouldn't matter if that namespace hadn't become associated somehow
with a function I have somewhere else on the search path (thereby
rendering the function unfindable).  


This doesn't make sense.  If the function is on the search path, it 
doesn't matter what namespace is associated with it:  you'll find it. 
If you have a function with the same name in globalenv() then you'll 
have problems.  The simple solution is to remove it (e.g. rm(f)); a 
better long term solution is to *never* store anything in your workspace 
between sessions.  Start with a clean global environment each time.


Duncan Murdoch

My guess is that if I knew how that

happened, I'd then know why plyr is loaded by namespace.  However, I'm
lost for ideas on how that could have happened.

Suggestions as to where I should be looking greatly appreciated.  Or, even
if that's unknowable, how to remove the association between the namespace
and the function.

TIA

--
Patrick Connolly
Plant & Food Research
Mt Albert
Auckland
New Zealand
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
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] Resent: colorkey: Placement of labels and ticks in center positions of "color key" of a levelplot ?

2009-12-23 Thread Zia Ahmed
Is it possible to place  labels  and ticks  in center positions of each 
cut of  "color key" of levelplot ? Here is my code that I used to 
produce a map (see attachment). The two  labels and ticks  were  placed  
in  left  sides each segment of the color key. I want to show them 
center of the cuts.

Help will be appreciated.
Thanks

Zia

windows(width=4, height=5)
jpeg( file="/Fig_1.jpg",
units = "px", pointsize = 12, quality = 75, bg = "white",
res = NA, restoreConsole = TRUE)

levelplot(ffreq~x+y, aspect="iso",
   xlab=list("E (m)",cex=.6), ylab="N (m)",
   scales=list(y=list(draw=T,cex=.7,rot=90, tck= 
.35),x=list(draw=T, cex=.7,tck= .35)),
colorkey = list(space="right",tick.number=1,height=1, 
width=1.5,

labels = list(at = seq(1,2,length=2),cex=.7,rot=90,
lab = c("annual", "2-5 years"))),
# I want place above labels center of each cuts of colorkey"
as.data.frame(meuse.grid),
col.regions=gray.colors,cuts=1,
panel = function(...) {
panel.levelplot(...)
panel.grid(h=-1, v=-1, col="darkgrey")
}, )
dev.off()
__
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] 3-D barplot

2009-12-23 Thread Terry Therneau
> I would like to create a 3 dimensional barplot of 16 odds ratios that
> demonstrate an interaction between two variables (CD14 and CD23).

odds<- matrix( c(1, 0.61, 2.1, 6.1,
  1.5 ,1.3, 3.5, 11.9,
  1.8 ,1.5, 4.4, 10.6,
  8.2 ,4.6, 5.5, 16.8), 
  4,4, byrow=T)

matplot(1:4, odds, type='b', log='y', xaxt='n',
xlab='CD23', ylab='Odds Ratio')
axis(1, 1:4, 1:4)

  No, this did not create a 3-d bar plot, it created something far more
useful.  In this plot you can see that most of the data fits an additive
model and how well it does so.  It is much better than what you
requested -- which isn't hard as a 3-d barplot is one of the worst tools
ever made for information conveyance.  

Terry Therneau

__
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] Unwanted association between a function and a namespace

2009-12-23 Thread p_connolly
I can't understand how the plyr package is turning up here:

> sessionInfo()
R version 2.10.1 (2009-12-14)
i686-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] lattice_0.17-26

loaded via a namespace (and not attached):
[1] grid_2.10.1 plyr_0.1.9
>

I can understand that lattice would be using grid without having that
package loaded, but I can't understand how plyr got there.

It wouldn't matter if that namespace hadn't become associated somehow
with a function I have somewhere else on the search path (thereby
rendering the function unfindable).  My guess is that if I knew how that
happened, I'd then know why plyr is loaded by namespace.  However, I'm
lost for ideas on how that could have happened.

Suggestions as to where I should be looking greatly appreciated.  Or, even
if that's unknowable, how to remove the association between the namespace
and the function.

TIA

--
Patrick Connolly
Plant & Food Research
Mt Albert
Auckland
New Zealand
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
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] loading data into ZOO

2009-12-23 Thread Brian G. Peterson

Stephen J. Barr wrote:

I have a simple question. I am trying to load data into a zoo object. I have
the data in CSV format as follows

SYMBOL DATE TIME  PRICE
XXMMDD HH:MM:SS  n.nn

and there are multiple symbols in this one data frame.

My question is, do I need to merge DATE and TIME before loading them or can
I specify multiple index.column or index.name fields?


index.column in read.zoo is a single column only

you can either merge in your CVS format, simplifying things in R, or use 
read.table to get the data into R and then merge your index columns when you 
call as.zoo.


Regards,

- Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

__
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] loading data into ZOO

2009-12-23 Thread Stephen J. Barr
Hello,

I have a simple question. I am trying to load data into a zoo object. I have
the data in CSV format as follows

SYMBOL DATE TIME  PRICE
XXMMDD HH:MM:SS  n.nn

and there are multiple symbols in this one data frame.

My question is, do I need to merge DATE and TIME before loading them or can
I specify multiple index.column or index.name fields?

Thanks,
-stephen

[[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] colorkey: Placement of labels and ticks in center positions of "color key" of a levelplot ?

2009-12-23 Thread Zia Ahmed
Is it possible to place  labels  and ticks  in center positions of each 
cut of  "color key" of levelplot ? Here is my code that I used to 
produce a map (see attachment). The two  labels and ticks  were  placed  
in  left  sides each segment of the color key. I want to show them 
center of the cuts.

Help will be appreciated.
Thanks

Zia

# R code

data(meuse.grid)
coordinates(meuse.grid) = ~x+y
names(meuse.grid)

windows(width=4, height=5)
tiff( 
file="E:/Paper_Zia/Spatial_Variability/Paper_1/Output/Figures/Fig_1.tif",

width=4, height=5,units = "in", pointsize = 12, res=1600,
restoreConsole = T,compression =  "lzw",bg="transparent")

levelplot(ffreq~x+y, aspect="iso",
xlab=list("E (m)",cex=.6), ylab="N (m)",
scales=list(y=list(draw=T,cex=.7,rot=90, tck= 
.35),x=list(draw=T, cex=.7,tck= .35)),
 colorkey = list(space="right",tick.number=1,height=1, 
width=1.5,

 labels = list(at = seq(1,2,length=2),cex=.7,rot=90,
 lab = c("annual", "2-5 years"))),
# I want place above labels center of each cuts of colorkey"
 as.data.frame(meuse.grid),
 col.regions=gray.colors,cuts=1,
 panel = function(...) {
 panel.levelplot(...)
 panel.grid(h=-1, v=-1, col="darkgrey")
 #panel.text(2670600, 563000, cex=.7, " (c)")
 }, )
dev.off()
__
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] Problem with "Cannot compute correct p-values with ties"

2009-12-23 Thread Ted Harding
The issue of ties in the Mann-Whitney test needs some thought.
The distribution function of the Mann-Whitney test is derived
on the assumption that (in effect) the data are continuous
variables so that (theoretically) there should be no ties.
Whn ties occur, then this assumjtion has failed.

1. If the data represent a continuous underlying variable which
has been recorded to a relatively coarse precision ("binned"),
so that some ties are likely, then random "tie-breaking" is
a plausible solution. In effect, a tie-cluster of size k would
then represent k unequal observations which could have been in
any one of k! orders (indistinguishable from the data in hand).

On the assumption that the "bin" width is so small that their
possible distinct unobserved values can not be so different
that any difference would materially effect the probabilities
of different orderings (i.e. they can be considered as if they
were uniformly distributed over the "bin"), then these k! orders
can be considered equally likely. Then the "jittering" (adding
small independent noise values to each of the equal data) will
yield one of these k! orderings with the same probability for
each. Then, when all the tie-clusters have been broken in this
way, the P-value for the Mann-Whitney will be exactly correct
for that particular breaking of the ties.

However, this is just one of the k! possible orderings; similarly
for any other tie-clusters in the data.

A different "jittering" would yield a different ordering, and
a different P-value. So what to choose? Well, you have to recognise
that they are all possible as far as the data tell, and all equally
likely. So an appropriate approach is to simulate a lot of random
tie-breaks, getting a P-value for each, and ending up with an
adequately large sample of random P-values.

What you do with this depends on what you need, and on how they
are distributed. If, for instance, all of 1 P-values were
less than, say, 0.001, and 0.001 was an adequate P-value for
your purposes, then you can be very confident that you have a
"significant result" -- in other words, if you had known the
exact underlying values (with no ties), then it is almost certain
that you would still have got a P < 0.001 test result.

Similarly, maybe 2 out of 1 are greater than 0.01, the rest less.
Then you can be fairly confident that the "true" P-value is less
than 0.01.

Or you could estimate the "true" P-value as the mean of the simulated
ones (preferable with a Standard Error too). Indeed, you could simply
compute a confidence interval for the P-value (but you would have
to choose the confidence level).

If there are only a few ties in the data, then a complete enumeration
of all possible tie-breaks is feasible. You then have everything you
could possibly need to know, given the data, relative to this approach.

2. If the data represent essentially discrete values (e.g. they
are count data, or ordered categorical), where ties are intrinsically
possible, then strictly speaking the Mann-Whitney test is not
appropriate, since its distribution function depends on the assumption
of continuity which is not true here.

However, nothing prevents you adopting the Mann=-Whitney statistic
as your test statistic of choice. The only problem is that you
may not refer its valuer to the Mann-Whitney distribution.

If there are k ordered categories C1 < C2 < ... < Ck, then the
Null Hypothesis is that Prob(X in Cj) is the same for each of
the two groups of data. It is then possible to devise a "permutation
test", whose evaluation for the data in hand could again be achieved
by random simulation. But you're also getting into contingency table
territory here, which is a somwhat different kind of universe!

Hoping this adds something useful!
Ted.

On 23-Dec-09 17:32:50, Greg Snow wrote:
> Adding random noise to data in order to avoid a warning is like
> removing the batteries from a smoke detector to silence it rather than
> investigating the what is causing the alarm to go off.
> 
> If the function is giving a warning it is best to investigate why, it
> is possible that you can ignore the warning (the burnt toast of smoke
> alarm analogies) but it is best to convince yourself that it is ok.  It
> is also possible in this case that another tool may be more
> appropriate, and investigating the warning could help you find that
> tool.
> 
> -- 
> 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 Bernardo Rangel Tura
>> Sent: Tuesday, December 22, 2009 1:16 AM
>> To: ivoryto...@emails.bjut.edu.cn
>> Cc: R-help@r-project.org
>> Subject: Re: [R] Problem with "Cannot compute correct p-values with
>> ties"
>> 
>> On Wed, 2009-12-02 at 16:52 +0800, Zhijiang Wang wrote:
>> > Dear All,
>> >1. why did the problem happen?
>> >2. How to solve it?
>> >
>>

Re: [R] iid.test

2009-12-23 Thread William Dunlap
After the
   install.packages("iid.test")
you will need to call
   library("iid.test")
The former you do once and the latter you
do each time you restart R.  install.packages()
puts the package onto your computer's disk
and library() loads it into an R session.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Brian G. Peterson
> Sent: Wednesday, December 23, 2009 9:52 AM
> To: Gavriel & Esti Zoladz; r-help@r-project.org
> Subject: Re: [R] iid.test
> 
> You're clearly in over your head.
> 
> install.packages("iid.test")
> 
> will install the package.  you may replace this with any "packagename"
> 
> ?functionname
> 
> in R on any 'functionname' will bring up the Fine Manual 
> which you are 
> to then use to
> 
> Read the Fine Manual (RTFM)
> 
> before posting questions to the list.
> 
> Gavriel & Esti Zoladz wrote:
> > I cant find this
> >
> > On 12/23/09, *Brian G. Peterson*  > > wrote:
> >
> > Gavriel & Esti Zoladz wrote:
> >
> > I found there that it is supposed to be in destdir, but I
> > can't find this folder.
> >
> > On 12/23/09, *Brian G. Peterson*  >   > >> wrote:
> >
> >Gavriel & Esti Zoladz wrote:
> >
> >I downloaded the iid.test, but I can't run 
> it. I get the
> >following message:
> >Error: could not find function "iid.test"
> >Where am I supposed to save this package in 
> order that
> > it works?
> >
> >
> >?install.packages
> >
> >
> > RTFM, and keep replies on the list.
> >
> >
> 
> 
> -- 
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
> 
> __
> 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] iid.test

2009-12-23 Thread Brian G. Peterson

You're clearly in over your head.

install.packages("iid.test")

will install the package.  you may replace this with any "packagename"

?functionname

in R on any 'functionname' will bring up the Fine Manual which you are 
to then use to


Read the Fine Manual (RTFM)

before posting questions to the list.

Gavriel & Esti Zoladz wrote:

I cant find this

On 12/23/09, *Brian G. Peterson* > wrote:


Gavriel & Esti Zoladz wrote:

I found there that it is supposed to be in destdir, but I
can't find this folder.

On 12/23/09, *Brian G. Peterson* mailto:br...@braverock.com> >> wrote:

   Gavriel & Esti Zoladz wrote:

   I downloaded the iid.test, but I can't run it. I get the
   following message:
   Error: could not find function "iid.test"
   Where am I supposed to save this package in order that
it works?
   


   ?install.packages


RTFM, and keep replies on the list.





--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

__
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] ?OT: Probabilistic Simulation

2009-12-23 Thread Greg Snow
A simple starting place for your simulation could be something like:

peg <- rnorm(10, 1.8, 0.01)
hole <- rnorm(10, 1.8, 0.02)

fits <- peg < hole

table(fits)
mean(fits)

Then you would need to add in the effects of temperature, drill type, etc. to 
account for the different pieces.  If you want to take into account 
non-circularity, then you will need a more complicated comparison than the 
simple <.

You may want to then wrap all of this in a function so that you can change the 
different settings and see the outcomes.

If things get more complicated, then the sapply and replicate functions may be 
of help.

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 Polwart Calum (County Durham and Darlington
> NHS Foundation Trust)
> Sent: Friday, December 18, 2009 4:17 PM
> To: r-help@r-project.org
> Subject: [R] ?OT: Probabilistic Simulation
> 
> 
> Sorry this may well be defined as Off Topic.  I apologize in advance.
> 
> I am interested in performing what I think would be a probabilistic
> sensitivity simulation.  I've done some crude ones before in excel but
> I'm wondering if R can help me do it more effectively?
> 
> I have a set of theoretical variables for simplicity lets use (what I
> think) is an easier example:  I have a peg and a hole which I want to
> predict how often they would not fit together securely.
> 
> The peg should be 1.8mm in diameter.
> But there are some variables which might affect if it is actually 1.8mm
> but I'd expect it to be normally distributed around 1.8mm with a known
> standard deviation.  There are also variables such as temperature which
> would influence if the peg was the correct size (there would be a known
> relationship to temperature, and a mean temperature with a standard
> deviation would be known)
> 
> The hole should be 1.8mm diameter as well.  Again there are variables
> that affect if it is, drill size, drilling method, substrate being
> drilled, temperature at time of drilling, temperature at time of
> fitting peg (would be same as above).  I'd be looking to model if the
> peg would fit in the hole, AND if it fitted how well it fitted.
> 
> I'd then want to run a simulation of say 500 scenarios, randomly
> picking temperature, hole characteristics etc for each simulation.
> From there I'd get the number of times in 500 samples the peg wouldn't
> fit.  I could then try adjusting a variable - say using a different
> drilling method and see if that 'easier' but less reliable drilling
> method actually would affect the number of times the peg didn't fit the
> hole properly.
> 
> So from what I understand this is a MonteCarlo simulation of
> probability.  And this is where I go off topic!  Am I right?  I know
> its off topic - so what I'd like to know is can someone point me to
> where I can find out?
> 
> Then if it is a monte-carlo can someone point me to a good description
> of how to get R to model this?
> 
> Ta
> 
> Calum
> 
> ***
> *
> 
> This message may contain confidential information. If
> yo...{{dropped:21}}
> 
> __
> 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] Rgraphviz on mac 10.6.2

2009-12-23 Thread Martin Morgan
Please report issues with Bioconductor packages on the Bioconductor
mailing list.

  http://bioconductor.org/docs/mailList.html

The top of the page you mention has

  Users on all platforms must install graphviz; see the README file,
  available in the source distribution of this file, for details.

A 'binary' installation of Rgraphviz requires that the version of
graphviz on the machine on which it is installed matches the version on
the machine on which it was built; from the README file:


OSX installation


Most users would want to use a binary version of Rgraphviz. This means
obtaining the exact same version of Graphviz as is being used on the
build machine. Rgraphviz will inform you of any version
inconsistencies when loaded.

At the moment the Graphviz website only distribute binaries for
Leopard. For Bioconductor 2.5 you will need version 2.22.2 from their
website.



Rgraphviz can also be installed from source, e.g., biocLite('Rgrahpviz',
type='source'). There is then no specific requirement for graphviz
version, but you must have tools for building binary packages available
on your computer. See

  http://r.research.att.com/tools/

Martin

kulwinder banipal wrote:
>  Rgraphviz Install works fine 
> (http://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html) 
> Latest version of graphviz is installed as well
> however I get following error when loading Rgraphviz (on Mac 10.6.2) 
> Error in dyn.load(file, DLLpath = DLLpath, ...) :   unable to load shared 
> library '/Users/jb/Library/R/2.9/library/Rgraphviz/libs/i386/Rgraphviz.so':  
> dlopen(/Users/jb/Library/R/2.9/library/Rgraphviz/libs/i386/Rgraphviz.so, 6): 
> Library not loaded: 
> /Library/Frameworks/R.framework/Versions/2.10/Resources/lib/libR.dylib  
> Referenced from: 
> /Users/jb/Library/R/2.9/library/Rgraphviz/libs/i386/Rgraphviz.so  Reason: 
> image not foundIn addition: Warning message:package 'Rgraphviz' was built 
> under R version 2.10.0 Error: package/namespace load failed for 'Rgraphviz'
> 
>  I will appreciate feedback from someone who has this package working on mac 
> 10.6.2 
> 
>  Thanks 
> _
> Hotmail: Powerful Free email with security by Microsoft.
> 
>   [[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.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
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] Problem with "Cannot compute correct p-values with ties"

2009-12-23 Thread Greg Snow
Adding random noise to data in order to avoid a warning is like removing the 
batteries from a smoke detector to silence it rather than investigating the 
what is causing the alarm to go off.

If the function is giving a warning it is best to investigate why, it is 
possible that you can ignore the warning (the burnt toast of smoke alarm 
analogies) but it is best to convince yourself that it is ok.  It is also 
possible in this case that another tool may be more appropriate, and 
investigating the warning could help you find that tool.

-- 
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 Bernardo Rangel Tura
> Sent: Tuesday, December 22, 2009 1:16 AM
> To: ivoryto...@emails.bjut.edu.cn
> Cc: R-help@r-project.org
> Subject: Re: [R] Problem with "Cannot compute correct p-values with
> ties"
> 
> On Wed, 2009-12-02 at 16:52 +0800, Zhijiang Wang wrote:
> > Dear All,
> >1. why did the problem happen?
> >2. How to solve it?
> >
> >--
> >
> > Best wishes,
> > Zhijiang Wang
> 
> 
> Well... The algorithm for Mann-whitney test have problem with ties
> 
> To solve you can use jitter
> 
> a<-1:10
> b<-1:10
> wilcox.test(a,b)
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  a and b
> W = 50, p-value = 1
> alternative hypothesis: true location shift is not equal to 0
> 
> Warning message:
> In wilcox.test.default(a, b) : cannot compute exact p-value with ties
> 
> wilcox.test(a,jitter(b))
> 
>   Wilcoxon rank sum test
> 
> data:  a and jitter(b)
> W = 49, p-value = 0.9705
> alternative hypothesis: true location shift is not equal to 0
> 
> look ?jitter for more information
> 
> --
> Bernardo Rangel Tura, M.D,MPH,Ph.D
> National Institute of Cardiology
> Brazil
> 
> __
> 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] iid.test

2009-12-23 Thread Brian G. Peterson

Gavriel & Esti Zoladz wrote:

I downloaded the iid.test, but I can't run it. I get the following message:
Error: could not find function "iid.test"
Where am I supposed to save this package in order that it works?
  


?install.packages

__
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] iid.test

2009-12-23 Thread Gavriel & Esti Zoladz
I downloaded the iid.test, but I can't run it. I get the following message:
Error: could not find function "iid.test"
Where am I supposed to save this package in order that it works?

Thanks,
EZ

[[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 with model.tables SE means

2009-12-23 Thread David Winsemius


On Dec 23, 2009, at 11:45 AM, Jon Prince wrote:


David and Peter,

Thanks so much for all of your help, I think I understand R much  
better as a result. Omitting the Error() term in my aov does indeed  
allow me to get SE means, so I guess that was the issue. I suppose I  
can go back and calculate the SE values for each p*t entry (averaged  
across subject) from Matlab.


By the way, the reason I separated the p and t objects derived from  
rate_data in my initial example was for readability.


No need; see below.


If I do it as below then I get the same result.

In any case, again many thanks for your help. Cheers and Happy  
Holidays.


Jon


rate_data=read.table("/Users/jonprince/Desktop/attend_pitch_3p3t.txt")
 rate_data$p=factor(rate_data$V3)
 rate_data$t=factor(rate_data$V2)
 rate_data$subj=factor(rate_data$V1)
 rate_data$rate=rate_data$V4
 fm=aov(rate_data$rate ~ rate_data$p*rate_data$t + Error(rate_data 
$subj/(rate_data$p*rate_data$t)),rate_data)


Try instead:
rm(p); rm(rate); rm(t); rm(subject)
# my memory of what your free-standing variables were named

fm=aov( rate ~ p*t + Error( subj/(p*t) ), data= rate_data)

R regression functions generally let you specify the column names as  
long as you supply the data.frame to a "data=" argument.





Peter Alspach wrote:


Tena korua David and Jon

Without an Error() in the model, you get standard errors for the  
effects

and standard errors of the difference for the means.  With fully
balanced data, as in the example, these are directly comparable  
(compare

model.tables(npk.aov, se=T)*sqrt(2) with model.tables(npk.aov,
type='means', se=T)$se).  For data with uneven replication this  
will not

be the case.

The standard errors of the differences for the means is not yet
implemented for aovlist (which is returned with an Error() in the  
model
as in npk.aovE).  I imagine this is because of the issues that  
arise in

comparing means from different strata.

HTH .

Peter Alspach



-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
Sent: Wednesday, 23 December 2009 4:13 p.m.
To: Jon Prince
Cc: r-help@r-project.org
Subject: Re: [R] trouble with model.tables SE means


On Dec 22, 2009, at 8:52 PM, Jon Prince wrote:



David Winsemius wrote:


On Dec 22, 2009, at 5:19 PM, Jon Prince wrote:


David Winsemius wrote:


On Dec 22, 2009, at 4:22 PM, Jon Prince wrote:



Hi, I'm new to R, with some experience with Matlab and SPSS.
I've figured out how to run my repeated measures anova and am
getting the right numbers for my effects (comparing


with results


from other software), but am having trouble with the


model.tables


function. Specifically, using:

prints the means, but then won't do the SE values,


instead giving:


Warning message:
In model.tables.aovlist(fm, "means", se = TRUE) :
SEs for type 'means' are not yet implemented"

Asking for SEs for "effects" works fine, but that's not what I
want. I searched the help for this issue and one other


person has


had this problem last year



(http://markmail.org/message/k5yxxqcfiihvzvtp?q=list:r-project+mod


el%2Etables ), but the person helping them was unable


to replicate

it, inferring that it was an out-of-date version. My version  
is:


R version 2.10.1 (2009-12-14)

I only downloaded it the other day, and therefore


cannot have an

outdated version. How can I fix this error and get my SE  
values?

Apologies if I have not provided sufficient information, and
thanks in advance for your help.


When I look at the output of the first model.tables call copied
from the help page, I see a list element that holds "se" values.
Try:

model.tables(fm,"means",se=TRUE)$se



Thanks for the rapid reply! Unfortunately adding the $se returns
NULL, and repeats the same warning message ("...not yet
implemented"). If you're not experiencing the issue, is


it possible


for me to replace the relevant code/source file with what


you have


(or would that require recompiling)? Could this be an OS


issue? I'm


running Mac OSX 10.6.2.

By the way, I "replied all" on this message, but let me


know if that


is not the preferred convention. Cheers,


Reply all. That way people can correct my mistakes and general
cluelessness. I'm running MacOSX 10.5.8 so it would seem


less likely


that is the explanation.

1) Did you run the example in the help pages?

2) When I look at :



methods(model.tables)


[1] model.tables.aov* model.tables.aovlist*

... I see both an "aov" method and an "aovlist" method. Is it
possible that there is something about the object that you are
working on that makes it an aovlist at thus invokes a different
function than what the help page invokes?

The code would not require complination... it's available with
getAnywhere() and I do not see any calls to compiled or .Internal
subroutines. Tell me what happens with the above questions first.



Sorry for the delayed response, I've been trying to w

Re: [R] how to create normal qqplot with the 95% confidence interval

2009-12-23 Thread Greg Snow
What type of confidence limits do you want?  And more importantly, why do you 
want them?  

-- 
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 CJ Rubio
> Sent: Wednesday, December 23, 2009 5:13 AM
> To: r-help@r-project.org
> Subject: [R] how to create normal qqplot with the 95% confidence
> interval
> 
> 
> hi everyone!
> 
> season's greetings!
> 
> is there any way that i can create a normal qqplot showing, aside from
> the
> qqline, the 95% confidence limits? thank you very much..
> 
> happy holidays!
> --
> View this message in context: http://n4.nabble.com/how-to-create-
> normal-qqplot-with-the-95-confidence-interval-tp977727p977727.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-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] COnfidence intervals for estimates of linear model

2009-12-23 Thread Greg Snow
Using 1.95996 is appropriate when you know the population standard deviation or 
the sample size is approximately infinity.  Otherwise you should use the 
t-distribution, the qt function is useful for that.

Or if you want intervals for the coefficients look at the confint function, if 
you want intervals for predictions, then look at predict.lm as has been pointed 
out (estimates could be interpreted either way).

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 Daniel Brewer
> Sent: Wednesday, December 23, 2009 3:28 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] COnfidence intervals for estimates of linear model
> 
> Hello,
> 
> I would like to calculate the 95% confidence intervals for the
> estimates
> of a linear model and I just wanted to check that I am doing it
> correct.
>  Is it just:
> 
> Estimate + 1.95996*Std.Error to Estimate - 1.95996*Std.Error
> 
> or is there another approach that doesn't assume a normal distrbution?
> 
> Thanks.  Apologies for my naiivity
> 
> Dan
> 
> --
> **
> Daniel Brewer, Ph.D.
> 
> Institute of Cancer Research
> Molecular Carcinogenesis
> Email: daniel.bre...@icr.ac.uk
> **
> 
> The Institute of Cancer Research: Royal Cancer Hospital, a charitable
> Company Limited by Guarantee, Registered in England under Company No.
> 534147 with its Registered Office at 123 Old Brompton Road, London SW7
> 3RP.
> 
> This e-mail message is confidential and for use by the
> a...{{dropped: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@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 with model.tables SE means

2009-12-23 Thread Jon Prince
David and Peter,

Thanks so much for all of your help, I think I understand R much better 
as a result. Omitting the Error() term in my aov does indeed allow me to 
get SE means, so I guess that was the issue. I suppose I can go back and 
calculate the SE values for each p*t entry (averaged across subject) 
from Matlab.

By the way, the reason I separated the p and t objects derived from 
rate_data in my initial example was for readability. If I do it as below 
then I get the same result.

In any case, again many thanks for your help. Cheers and Happy Holidays.

Jon


rate_data=read.table("/Users/jonprince/Desktop/attend_pitch_3p3t.txt")
 rate_data$p=factor(rate_data$V3)
 rate_data$t=factor(rate_data$V2)
 rate_data$subj=factor(rate_data$V1)
 rate_data$rate=rate_data$V4
 fm=aov(rate_data$rate ~ rate_data$p*rate_data$t + 
Error(rate_data$subj/(rate_data$p*rate_data$t)),rate_data)


Peter Alspach wrote:
> Tena korua David and Jon
>
> Without an Error() in the model, you get standard errors for the effects
> and standard errors of the difference for the means.  With fully
> balanced data, as in the example, these are directly comparable (compare
> model.tables(npk.aov, se=T)*sqrt(2) with model.tables(npk.aov,
> type='means', se=T)$se).  For data with uneven replication this will not
> be the case.
>
> The standard errors of the differences for the means is not yet
> implemented for aovlist (which is returned with an Error() in the model
> as in npk.aovE).  I imagine this is because of the issues that arise in
> comparing means from different strata.
>
> HTH .
>
> Peter Alspach 
>
>   
>> -Original Message-
>> From: r-help-boun...@r-project.org 
>> [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
>> Sent: Wednesday, 23 December 2009 4:13 p.m.
>> To: Jon Prince
>> Cc: r-help@r-project.org
>> Subject: Re: [R] trouble with model.tables SE means
>>
>>
>> On Dec 22, 2009, at 8:52 PM, Jon Prince wrote:
>>
>> 
>>> David Winsemius wrote:
>>>   
 On Dec 22, 2009, at 5:19 PM, Jon Prince wrote:
 
> David Winsemius wrote:
>   
>> On Dec 22, 2009, at 4:22 PM, Jon Prince wrote:
>>
>> 
>>> Hi, I'm new to R, with some experience with Matlab and SPSS.  
>>> I've figured out how to run my repeated measures anova and am 
>>> getting the right numbers for my effects (comparing 
>>>   
>> with results 
>> 
>>> from other software), but am having trouble with the 
>>>   
>> model.tables 
>> 
>>> function. Specifically, using:
>>>
>>> prints the means, but then won't do the SE values, 
>>>   
>> instead giving:
>> 
>>> Warning message:
>>> In model.tables.aovlist(fm, "means", se = TRUE) :
>>> SEs for type 'means' are not yet implemented"
>>>
>>> Asking for SEs for "effects" works fine, but that's not what I 
>>> want. I searched the help for this issue and one other 
>>>   
>> person has 
>> 
>>> had this problem last year 
>>>
>>>   
>> (http://markmail.org/message/k5yxxqcfiihvzvtp?q=list:r-project+mod
>> 
>>> el%2Etables ), but the person helping them was unable 
>>>   
>> to replicate 
>> 
>>> it, inferring that it was an out-of-date version. My version is:
>>>
>>> R version 2.10.1 (2009-12-14)
>>>
>>> I only downloaded it the other day, and therefore 
>>>   
>> cannot have an 
>> 
>>> outdated version. How can I fix this error and get my SE values?
>>> Apologies if I have not provided sufficient information, and 
>>> thanks in advance for your help.
>>>   
>> When I look at the output of the first model.tables call copied 
>> from the help page, I see a list element that holds "se" values.
>> Try:
>>
>> model.tables(fm,"means",se=TRUE)$se
>>
>> 
> Thanks for the rapid reply! Unfortunately adding the $se returns 
> NULL, and repeats the same warning message ("...not yet 
> implemented"). If you're not experiencing the issue, is 
>   
>> it possible 
>> 
> for me to replace the relevant code/source file with what 
>   
>> you have 
>> 
> (or would that require recompiling)? Could this be an OS 
>   
>> issue? I'm 
>> 
> running Mac OSX 10.6.2.
>
> By the way, I "replied all" on this message, but let me 
>   
>> know if that 
>> 
> is not the preferred convention. Cheers,
>   
 Reply all. That way people can correct my mistakes and general 
 cluelessness. I'm running MacOSX 10.5.8 so it would seem 
 
>> less likely 
>> 
 that is the explanation.

 1) Did you run the example in the help pages?

 2) When I look at :

 
> methods(model.tables)
>   
 [1] model.tables.ao

Re: [R] Cohen's kappa, unequal score ranges

2009-12-23 Thread Julia Myatt

Hi, Sorry, it's ok I've figured it out using the as.matrix function! 

Cheers,

Julia. 



From: Scot W. McNary [smcn...@charm.net]
Sent: 23 December 2009 15:41
To: Julia Myatt
Cc: r-help@r-project.org
Subject: Re: [R] Cohen's kappa, unequal score ranges

Julia,

I was able to get your toy data to work, using the n * 2 data frame,
which is what ckappa takes as input.

 > chk <- data.frame(matrix(c(
+3,   4,
+4,   3,
+2,   1,
+2,   1,
+5,   1,
+2,   4), byrow = TRUE, ncol = 2))
 > chk
  X1 X2
1  3  4
2  4  3
3  2  1
4  2  1
5  5  1
6  2  4

 > sk <- ckappa(chk)
 > sk
$table
  1 2 3 4 5
1 0 0 0 0 0
2 2 0 0 1 0
3 0 0 0 1 0
4 0 0 1 0 0
5 1 0 0 0 0

$kappa
[1] -0.0909091

 > str(sk)
List of 2
 $ table: num [1:5, 1:5] 0 2 0 0 1 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:5] "1" "2" "3" "4" ...
  .. ..$ : chr [1:5] "1" "2" "3" "4" ...
 $ kappa: num -0.091

Hope this helps,

Scot

Julia Myatt wrote:
> Hi Jim,
>
> Thanks for your help, I tried that function which did result in an output. 
> The only issue now is my summary looks like this:
>
>   Length Class  Mode
> table 16 -none- numeric
> kappa  1 -none- numeric
>
> Not what I was expecting, this was the case when my data was in the following 
> format:
>
>   ob1 ob2
> 1   3   4
> 2   4   3
> 3   2   1
> 4   2   1
> 5   5   1
> 6   2   4
>
> I then tried entering my data as a matrix like the one below (all this data 
> is made up until I get it to work!):
>
>  p1 p2 p3 p4 p5
> p1  3  1  0  4  2
> p2  3  5  0  7  1
> p3  2  3  4  6  3
> p4  4  1  0  4  0
> p5  8  2  0  2  5
>
> and this resulted in the same type of output:
>
>  Length Class  Mode
> table 36 -none- numeric
> kappa  1 -none- numeric
>
> If that is the kappa output (1) something isn't right as I purposely made the 
> data without good interrater reliability! I was wondering if you have anymore 
> tips as to what I am doing wrong? I'm afraid I'm very new to R so don't even 
> know the basics!!
>
> Thanks for all your help,
>
> Julia.
>
>
> 
> From: Jim Lemon [...@bitwrit.com.au]
> Sent: 23 December 2009 02:15
> To: Julia Myatt
> Cc: r-help@r-project.org
> Subject: Re: [R] Cohen's kappa, unequal score ranges
>
> On 12/23/2009 01:58 AM, Julia Myatt wrote:
>
>> Hi,
>>
>> I am having problems getting cohen's kappa to work. I have been using the 
>> function:
>>
>>
>>
>>> <-ckappa(x,y)
>>>
>>>
>> from the psy package.
>>
>> I am trying to test for inter-observer reliability, I have 2 observers and 
>> 26 categories, however, the two observers might not necessarily have the 
>> same range of categories (I have unequal score ranges). However, I thought R 
>> could cope with this.
>>
>> Each time I try the function above I get the following output:
>>
>>
>>
>>> Error in ckappa(ob1, ob2) : unused argument(s) (ob2)
>>>
>>>
>> I got this even when I altered the data to have equal score ranges, 
>> therefore I am not sure what this means or what I should do!!
>>
>> Any help in this area would be much appreciated, or anything about the best 
>> way to deal with inter-observer reliability (my data is all categorical),
>>
>>
>>
> Hi Julia,
> The ckappa function only takes one argument, a rater by object matrix or
> dataframe of scores. Try:
>
> ckappa(cbind(ob1,ob2))
>
> Jim
>
> __
> 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.
>

--
Scot McNary
smcnary at charm dot net

__
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] Cohen's kappa, unequal score ranges

2009-12-23 Thread Julia Myatt
Hi,

Thank you so much for your help with this, I can get it to work now! 

Just one more question, my actual data will involve hundreds of rows in my two 
columns, is there anyway to import my data frame via read.table, and then 
convert this into the matrix ready for ckappa, rather than typing the data into 
R directly?

Sorry, I really am a beginner!

Thanks again,

Julia. 


From: Scot W. McNary [smcn...@charm.net]
Sent: 23 December 2009 15:41
To: Julia Myatt
Cc: r-help@r-project.org
Subject: Re: [R] Cohen's kappa, unequal score ranges

Julia,

I was able to get your toy data to work, using the n * 2 data frame,
which is what ckappa takes as input.

 > chk <- data.frame(matrix(c(
+3,   4,
+4,   3,
+2,   1,
+2,   1,
+5,   1,
+2,   4), byrow = TRUE, ncol = 2))
 > chk
  X1 X2
1  3  4
2  4  3
3  2  1
4  2  1
5  5  1
6  2  4

 > sk <- ckappa(chk)
 > sk
$table
  1 2 3 4 5
1 0 0 0 0 0
2 2 0 0 1 0
3 0 0 0 1 0
4 0 0 1 0 0
5 1 0 0 0 0

$kappa
[1] -0.0909091

 > str(sk)
List of 2
 $ table: num [1:5, 1:5] 0 2 0 0 1 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:5] "1" "2" "3" "4" ...
  .. ..$ : chr [1:5] "1" "2" "3" "4" ...
 $ kappa: num -0.091

Hope this helps,

Scot

Julia Myatt wrote:
> Hi Jim,
>
> Thanks for your help, I tried that function which did result in an output. 
> The only issue now is my summary looks like this:
>
>   Length Class  Mode
> table 16 -none- numeric
> kappa  1 -none- numeric
>
> Not what I was expecting, this was the case when my data was in the following 
> format:
>
>   ob1 ob2
> 1   3   4
> 2   4   3
> 3   2   1
> 4   2   1
> 5   5   1
> 6   2   4
>
> I then tried entering my data as a matrix like the one below (all this data 
> is made up until I get it to work!):
>
>  p1 p2 p3 p4 p5
> p1  3  1  0  4  2
> p2  3  5  0  7  1
> p3  2  3  4  6  3
> p4  4  1  0  4  0
> p5  8  2  0  2  5
>
> and this resulted in the same type of output:
>
>  Length Class  Mode
> table 36 -none- numeric
> kappa  1 -none- numeric
>
> If that is the kappa output (1) something isn't right as I purposely made the 
> data without good interrater reliability! I was wondering if you have anymore 
> tips as to what I am doing wrong? I'm afraid I'm very new to R so don't even 
> know the basics!!
>
> Thanks for all your help,
>
> Julia.
>
>
> 
> From: Jim Lemon [...@bitwrit.com.au]
> Sent: 23 December 2009 02:15
> To: Julia Myatt
> Cc: r-help@r-project.org
> Subject: Re: [R] Cohen's kappa, unequal score ranges
>
> On 12/23/2009 01:58 AM, Julia Myatt wrote:
>
>> Hi,
>>
>> I am having problems getting cohen's kappa to work. I have been using the 
>> function:
>>
>>
>>
>>> <-ckappa(x,y)
>>>
>>>
>> from the psy package.
>>
>> I am trying to test for inter-observer reliability, I have 2 observers and 
>> 26 categories, however, the two observers might not necessarily have the 
>> same range of categories (I have unequal score ranges). However, I thought R 
>> could cope with this.
>>
>> Each time I try the function above I get the following output:
>>
>>
>>
>>> Error in ckappa(ob1, ob2) : unused argument(s) (ob2)
>>>
>>>
>> I got this even when I altered the data to have equal score ranges, 
>> therefore I am not sure what this means or what I should do!!
>>
>> Any help in this area would be much appreciated, or anything about the best 
>> way to deal with inter-observer reliability (my data is all categorical),
>>
>>
>>
> Hi Julia,
> The ckappa function only takes one argument, a rater by object matrix or
> dataframe of scores. Try:
>
> ckappa(cbind(ob1,ob2))
>
> Jim
>
> __
> 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.
>

--
Scot McNary
smcnary at charm dot net

__
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] animated R plots

2009-12-23 Thread Zd Gibbs
 Hi,
I want to be able to save the following animated plot as a flash.  There are 
ultimately 6 plots, but when I run this and save it as a flash all I get is the 
last (6th) plot, not all six different plots in order by "year".  I’ve 
tested the flash commands and they work; so it has to be my function code. I am 
guessing that the problem has something to do with overlaying the plot points, 
but I don’t know how to rewrite it and keep the animated elements.  
I am running R version 2..9.2 on Windows Vista. 
 
Data looks like this:
 
service usage amount year 
transport 11.33105 15.75016 2004 
transport 11.38398 15.82374 2005 
transport 11.44057 15.90239 2005 
 
Thanks!
 
ZdGibbs (I can provide a subset of the data as .txt if necessary).
 
#order service year in ascending order and set frame options
library(animation)
library(lattice)
service <- service[order(service$year), ]
oopt = ani.options(interval = 1.0)
 
# create the function
 
Service <- function (...) 
             {
 
interval = ani.options("interval")
index <- unique(service$year)
 
plot(amount~usage, data=service, type="n", xlab = " ", ylab = " ", bty="l", 
ylim=c(0,500))
 
legend("topright", legend=c("Transport", "Family", "Housing", "Substance Use", 
"Medical", "Mental Health"), pch=c(19,19,19,19,19,19), col=c("#7FC97F", 
"#BEAED4", "#FDC086", "#99", "#386CB0", "#F0027F"), bty="n", inset=.02)
             
for (i in 1:length(index)) {
rect(11.4, 425, 11.9, 500, col="white", border="red")
 
year.service <- service[which(service$year==index[i]),]
 
graphics <- year.service[year.service$service=="Graphics",]
                         
              trans <- 
year.service[year.service$service=="transport",]
              fam <- year.service[year.service$service=="family",]
              hous <- 
year.service[year.service$service=="housing",]
              subuse <- 
year.service[year.service$service=="subuse",]
              med <- 
year.service[year.service$service=="genhealth",]
              menhlth <- 
year.service[year.service$service=="mental health",]
                                     
text(mean(range(service$usage, na.rm=TRUE)), 455, index[i], col = rgb(0, 0, 0, 
0.5), cex = 4)
points(amount~usage, data=trans, pch=19, col="#7FC97F")
points(amount~usage, data=fam, pch=19, col="#BEAED4")
points(amount~usage, data=hous, pch=19, col="#FDC086")
points(amount~usage, data=subuse, pch=19, col="#99")
points(amount~usage, data=med, pch=19, col="#386CB0")
points(amount~usage, data=menhlth, pch=19, col="#F0027F")
                         
            Sys.sleep(interval)
 
}
             
}
#run animation
Service()
 
#save as flash
oopt = ani.options(nmax = 6, interval = 1.0)
saveSWF(Service(), interval = 2.0, swfname="place.swf", dev = "pdf", 
filename="Pplot", fmt = "%03d", outdir = getwd(), swftools="C:/Program 
Files/SWFTools")
ani.options(oopt)


  
[[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] Fw: R and minitab : Censored Kendall

2009-12-23 Thread Dennis J Low
Dennis J.  Low
Hydrologist
U.S.Geological Survey - WRD
215 Limekiln Road
New Cumberland, Pennsylvania 17070
(717) 730-6959





I have been running censored Kendall on Minitab, 
and more recently on R because of the large data 
size (about 4,000 samples). I have begun to 
compare the two results and am confused about why 
the results do not agree. Listed below are two 
runs for each method on the same dataset where N 
= 1447:

Results from R

slope  [1] 6.527546

intercept  [1] 162.4725

tau  [1] 0.08137884

p  [1] 2.356061e-06

True = censored data
False = non-censored data

Results from Minitab
S   -6875.00
tau -0.00657152
taub-0.0108607
z   -0.457711
pval0.647160

1 = censored data
0 = non-censored data

Why don't they agree on anything?

I was surprised that R does not present a taub 
which I believe takes into account ties.

I thought p and pval were basically the Pearson's 
result which indicated significance.

What else am I missing?


[[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] Rgraphviz on mac 10.6.2

2009-12-23 Thread kulwinder banipal

 Rgraphviz Install works fine 
(http://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html) 
Latest version of graphviz is installed as well
however I get following error when loading Rgraphviz (on Mac 10.6.2) 
Error in dyn.load(file, DLLpath = DLLpath, ...) :   unable to load shared 
library '/Users/jb/Library/R/2.9/library/Rgraphviz/libs/i386/Rgraphviz.so':  
dlopen(/Users/jb/Library/R/2.9/library/Rgraphviz/libs/i386/Rgraphviz.so, 6): 
Library not loaded: 
/Library/Frameworks/R.framework/Versions/2.10/Resources/lib/libR.dylib  
Referenced from: 
/Users/jb/Library/R/2.9/library/Rgraphviz/libs/i386/Rgraphviz.so  Reason: image 
not foundIn addition: Warning message:package 'Rgraphviz' was built under R 
version 2.10.0 Error: package/namespace load failed for 'Rgraphviz'

 I will appreciate feedback from someone who has this package working on mac 
10.6.2 

 Thanks   
_
Hotmail: Powerful Free email with security by Microsoft.

[[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] Cohen's kappa, unequal score ranges

2009-12-23 Thread Scot W. McNary

Julia,

I was able to get your toy data to work, using the n * 2 data frame, 
which is what ckappa takes as input.


> chk <- data.frame(matrix(c(
+3,   4,
+4,   3,
+2,   1,
+2,   1,
+5,   1,
+2,   4), byrow = TRUE, ncol = 2))  
> chk

 X1 X2
1  3  4
2  4  3
3  2  1
4  2  1
5  5  1
6  2  4

> sk <- ckappa(chk)
> sk
$table
 1 2 3 4 5
1 0 0 0 0 0
2 2 0 0 1 0
3 0 0 0 1 0
4 0 0 1 0 0
5 1 0 0 0 0

$kappa
[1] -0.0909091

> str(sk)
List of 2
$ table: num [1:5, 1:5] 0 2 0 0 1 0 0 0 0 0 ...
 ..- attr(*, "dimnames")=List of 2
 .. ..$ : chr [1:5] "1" "2" "3" "4" ...
 .. ..$ : chr [1:5] "1" "2" "3" "4" ...
$ kappa: num -0.091

Hope this helps,

Scot

Julia Myatt wrote:

Hi Jim,

Thanks for your help, I tried that function which did result in an output. The 
only issue now is my summary looks like this:

  Length Class  Mode   
table 16 -none- numeric

kappa  1 -none- numeric

Not what I was expecting, this was the case when my data was in the following 
format:

  ob1 ob2
1   3   4
2   4   3
3   2   1
4   2   1
5   5   1
6   2   4

I then tried entering my data as a matrix like the one below (all this data is 
made up until I get it to work!):

 p1 p2 p3 p4 p5
p1  3  1  0  4  2
p2  3  5  0  7  1
p3  2  3  4  6  3
p4  4  1  0  4  0
p5  8  2  0  2  5

and this resulted in the same type of output:

 Length Class  Mode   
table 36 -none- numeric

kappa  1 -none- numeric

If that is the kappa output (1) something isn't right as I purposely made the 
data without good interrater reliability! I was wondering if you have anymore 
tips as to what I am doing wrong? I'm afraid I'm very new to R so don't even 
know the basics!!

Thanks for all your help,

Julia.



From: Jim Lemon [...@bitwrit.com.au]
Sent: 23 December 2009 02:15
To: Julia Myatt
Cc: r-help@r-project.org
Subject: Re: [R] Cohen's kappa, unequal score ranges

On 12/23/2009 01:58 AM, Julia Myatt wrote:
  

Hi,

I am having problems getting cohen's kappa to work. I have been using the 
function:




<-ckappa(x,y)

  

from the psy package.

I am trying to test for inter-observer reliability, I have 2 observers and 26 
categories, however, the two observers might not necessarily have the same 
range of categories (I have unequal score ranges). However, I thought R could 
cope with this.

Each time I try the function above I get the following output:




Error in ckappa(ob1, ob2) : unused argument(s) (ob2)

  

I got this even when I altered the data to have equal score ranges, therefore I 
am not sure what this means or what I should do!!

Any help in this area would be much appreciated, or anything about the best way 
to deal with inter-observer reliability (my data is all categorical),




Hi Julia,
The ckappa function only takes one argument, a rater by object matrix or
dataframe of scores. Try:

ckappa(cbind(ob1,ob2))

Jim

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


--
Scot McNary
smcnary at charm dot net

__
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] Cohen's kappa, unequal score ranges

2009-12-23 Thread Julia Myatt
Hi Jim,

Thanks for your help, I tried that function which did result in an output. The 
only issue now is my summary looks like this:

  Length Class  Mode   
table 16 -none- numeric
kappa  1 -none- numeric

Not what I was expecting, this was the case when my data was in the following 
format:

  ob1 ob2
1   3   4
2   4   3
3   2   1
4   2   1
5   5   1
6   2   4

I then tried entering my data as a matrix like the one below (all this data is 
made up until I get it to work!):

 p1 p2 p3 p4 p5
p1  3  1  0  4  2
p2  3  5  0  7  1
p3  2  3  4  6  3
p4  4  1  0  4  0
p5  8  2  0  2  5

and this resulted in the same type of output:

 Length Class  Mode   
table 36 -none- numeric
kappa  1 -none- numeric

If that is the kappa output (1) something isn't right as I purposely made the 
data without good interrater reliability! I was wondering if you have anymore 
tips as to what I am doing wrong? I'm afraid I'm very new to R so don't even 
know the basics!!

Thanks for all your help,

Julia.



From: Jim Lemon [...@bitwrit.com.au]
Sent: 23 December 2009 02:15
To: Julia Myatt
Cc: r-help@r-project.org
Subject: Re: [R] Cohen's kappa, unequal score ranges

On 12/23/2009 01:58 AM, Julia Myatt wrote:
> Hi,
>
> I am having problems getting cohen's kappa to work. I have been using the 
> function:
>
>
>> <-ckappa(x,y)
>>
> from the psy package.
>
> I am trying to test for inter-observer reliability, I have 2 observers and 26 
> categories, however, the two observers might not necessarily have the same 
> range of categories (I have unequal score ranges). However, I thought R could 
> cope with this.
>
> Each time I try the function above I get the following output:
>
>
>> Error in ckappa(ob1, ob2) : unused argument(s) (ob2)
>>
> I got this even when I altered the data to have equal score ranges, therefore 
> I am not sure what this means or what I should do!!
>
> Any help in this area would be much appreciated, or anything about the best 
> way to deal with inter-observer reliability (my data is all categorical),
>
>
Hi Julia,
The ckappa function only takes one argument, a rater by object matrix or
dataframe of scores. Try:

ckappa(cbind(ob1,ob2))

Jim

__
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] [R-SIG-Finance] Fitting ACD model

2009-12-23 Thread Brian G. Peterson

R_help Help wrote:

Hi - I'm wondering if there is any existing package in R that
facilitates ACD (Autoregressive Conditional Duration) model. I
googled. Apparently there were packages dynamo and fACD. However, they
do not seem to be on any CRAN. I am wondering if anyone could point me
to an existing package (if any). Thank you.
  
You were close.  Try a little harder and perhaps use your real name next 
time...


dynamo looks to me like it's on CRAN:

http://cran.r-project.org/web/packages/dynamo/index.html

and fACD is on R-Forge

http://r-forge.r-project.org/R/?group_id=156

instructions for installnig R-Forge packages are on the page above.

Regards,

- Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

__
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] panel data quantile regression?

2009-12-23 Thread Junyu

Hi All,

About the quantile regression of panel data, what are the difference about
Koenker’ s method of “Quantile Regression for Longitudinal Data” and added a
dummy variable to represent individual effect? For example, if I have a five
year and three country panel data set , I added following dummy variable to
solve the fixed effect problem:

1 0 0
1 0 0
1 0 0
1 0 0
1 0 0
0 1 0
0 1 0
0 1 0
0 1 0
0 1 0
0 0 1
0 0 1
0 0 1
0 0 1
0 0 1

do some one know the difference?thank you!

bests

Jun-yu

-- 
View this message in context: 
http://n4.nabble.com/panel-data-quantile-regression-tp977744p977744.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] Problem with expand.grid

2009-12-23 Thread Martin Maechler
> "KJ" == Keith Jewell 
> on Tue, 22 Dec 2009 16:02:49 - writes:

KJ> Hi All,
KJ> This example code
KJ> 
KJ> dDF <- structure(list(y = c(4.75587, 4.8451, 5.04139, 4.85733, 5.20412,
KJ> 5.92428, 5.69897, 4.78958, 4, 4), t = c(0, 48, 144, 192, 240,
KJ> 312, 360, 0, 48, 144), Batch = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1
KJ> ), T = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2), pH = c(4.6, 4.6, 4.6,
KJ> 4.6, 4.6, 4.6, 4.6, 4.6, 4.6, 4.6), S = c(0, 0, 0, 0, 0, 0, 0,
KJ> 0, 0, 0), N = c(0, 0, 0, 0, 0, 0, 0, 80, 80, 80)), .Names = c("y",
KJ> "t", "Batch", "T", "pH", "S", "N"), row.names = c(NA, 10L), class = 
KJ> "data.frame")
KJ> str(dDF)
KJ> expand.grid(dDF)
KJ> 
KJ> 'hangs' for a while and then gives an error

KJ> Error in `[[<-.data.frame`(`*tmp*`, i, value = c(4.75587, 4.8451, 
5.04139, 
KJ> :
KJ> replacement has 1000 rows, data has 10

KJ> In NEWS.R-2.11.0dev I read:
KJ> o   The new (in 2.9.0) 'stringsAsFactors' argument to expand.grid()
KJ> was not working: it now does work but has default TRUE for
KJ> backwards compatibility.

KJ> but I don't think that's relevant, I have no factors.

KJ> I'm probably being silly.

yes, probably ;-)

At least you are using  expand.grid() in an unusual way.
[What are you trying to use expand.grid() for ?]
E.g., (dataframe) variable 'S' has only values '0'.

One thing which works and may be close to what you want is the
following:

dU <- lapply(dDF, unique)
r <- expand.grid(dU)


Here's the illustration about it :

> str(dDF)
'data.frame':   10 obs. of  7 variables:
 $ y: num  4.76 4.85 5.04 4.86 5.2 ...
 $ t: num  0 48 144 192 240 312 360 0 48 144
 $ Batch: num  1 1 1 1 1 1 1 1 1 1
 $ T: num  2 2 2 2 2 2 2 2 2 2
 $ pH   : num  4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6
 $ S: num  0 0 0 0 0 0 0 0 0 0
 $ N: num  0 0 0 0 0 0 0 80 80 80
> 
> str(dU <- lapply(dDF, unique))
List of 7
 $ y: num [1:9] 4.76 4.85 5.04 4.86 5.2 ...
 $ t: num [1:7] 0 48 144 192 240 312 360
 $ Batch: num 1
 $ T: num 2
 $ pH   : num 4.6
 $ S: num 0
 $ N: num [1:2] 0 80
> r <- expand.grid(dU)
> str(r)
'data.frame':   126 obs. of  7 variables:
 $ y: num  4.76 4.85 5.04 4.86 5.2 ...
 $ t: num  0 0 0 0 0 0 0 0 0 48 ...
 $ Batch: num  1 1 1 1 1 1 1 1 1 1 ...
 $ T: num  2 2 2 2 2 2 2 2 2 2 ...
 $ pH   : num  4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 ...
 $ S: num  0 0 0 0 0 0 0 0 0 0 ...
 $ N: num  0 0 0 0 0 0 0 0 0 0 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim : Named int  9 7 1 1 1 1 2
  .. ..- attr(*, "names")= chr  "y" "t" "Batch" "T" ...
  ..$ dimnames:List of 7
  .. ..$ y: chr  "y=4.75587" "y=4.84510" "y=5.04139" "y=4.85733" ...
  .. ..$ t: chr  "t=  0" "t= 48" "t=144" "t=192" ...
  .. ..$ Batch: chr "Batch=1"
  .. ..$ T: chr "T=2"
  .. ..$ pH   : chr "pH=4.6"
  .. ..$ S: chr "S=0"
  .. ..$ N: chr  "N= 0" "N=80"
> 

---

may be that helps?

Regards,
Martin Maechler, ETH Zurich

__
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] by function ??

2009-12-23 Thread Matthew Dowle
You asked how to 'create confidence intervals around the median'. Since 
intervals was plural and you asked within the context of 'by' LEAID then 
that made sense and I guessed you meant 'confidence interval around the 
median ratio of each group'. I already assumed you had posted a small subset 
of data, which is why I wrote 'with enough data' to explain the warning 
message.

Maybe someone else on the list understands you better and can help, but if 
not then please be much more specific. If you can't 'get it to run', then 
what exactly is 'it' and whats the error message? If there is no error then 
what is the result returned and what do you want instead?  Please follow the 
posting guidelines as you did at the start of this thread (including the R 
version details).

"L.A."  wrote in message 
news:1261529371221-977494.p...@n4.nabble.com...
>
> Thanks, but that produces what I think is an estimated interval.
>   I really want to use the above formula. I just can't figure out how to
> get it to run by the LEAID.
> It does require 9 observations to produce an interval, but I was showing a
> sample.
> Thanks again.
> L.A.
>
>
> Matthew Dowle-3 wrote:
>>
>> Maybe this (with enough data for a CI) ? :
>>
>>> Dataset = data.table(Dataset)
>>> Dataset[,as.list(wilcox.test(ratio,conf.int=TRUE)$conf.int),by="LEAID"]
>>  LEAID  V1  V2
>> [1,]  6307   0.720   0.92
>> [2,]  8300   0.5678462   0.83
>> Warning messages:
>> 1: In switch(alternative, two.sided = { :
>>   Requested conf.level not achievable
>>
>>
>> "L.A."  wrote in message
>> news:1261418507079-976414.p...@n4.nabble.com...
>>>
>>>
>>> Well, I'm back again.
>>>   Thanks for all the help. Besides working, it's helping me begin to
>>> understand how these functions work.
>>> I still have trouble reading or following the process of a function,
>>> which
>>> brings my next question:
>>>
>>> Dataset:
>>>
>>> LEAID ratio
>>> 3 6307 0.720
>>> 1 6307 0.7623810
>>> 2 6307 0.860
>>> 4 6307 0.920
>>> 5 8300 0.5678462
>>> 7 8300 0.770
>>> 6 8300 0.830
>>>
>>> Here I want to create confidence intervals around the median. My hang-up
>>> now
>>> is how to do pbinom() by LEAID.
>>>
>>> Here's my script.
>>>
>>> Dataset$obs <- with(Dataset, ave(ratio, LEAID, 
>>> FUN=function(x)length(x)))
>>> obs <-by(Dataset[ , "ratio"], LEAID, length)
>>> obsn <-by(Dataset[ , "obs"], LEAID, FUN=function(x)1:max(x))
>>>
>>> q <- obsn
>>> n <- obs
>>> pbinom <-pbinom(q, n, .5)
>>> pbinom <- with(Dataset, by(obs, LEAID, FUN=function(x)pbinom(q, n, .5)))
>>> x <- pbinom
>>> x.nolag=x[2:n]
>>> x.lag1=x[1:(obs-1)]
>>> my.new=cbind(x.nolag,x.lag1)
>>> x.fill= cbind(0,0)
>>> my.dat.fr=rbind(x.fill, my.new)
>>> my.dat.fr
>>> pr=1 - (2 * my.dat.fr)
>>> cil=ifelse(pr >= .95, Dataset[,"ratio"], 0)
>>> cil
>>> max=sort(cil)
>>> LowerCI=round(max(max),digits=2)
>>> LowerCI
>>> cn=ifelse(pr >= .95, Dataset[,"ObsNumber"], 0)
>>> cmax=sort(cn)
>>> c=max(cmax)
>>> prb=ifelse(pr >= .95, pr, 999)
>>> con=sort(prb)
>>> Confidence=min(con)
>>> o= n -( c - 1)
>>> ch=ifelse (q <= o , Dataset[,"Ratio"], 0)
>>> UpperCI=round(max(ch),digits=2)
>>> UpperCI
>>>
>>>
>>> I hope your not growing tired of my questions, I try reading all I can
>>> find,
>>> but I often can't seem understand it until I can actually see it in
>>> process.
>>> Thanks,
>>> L.A.
>>> -- 
>>> View this message in context:
>>> http://n4.nabble.com/by-function-tp955789p976414.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.
>>
>>
>
> -- 
> View this message in context: 
> http://n4.nabble.com/by-function-tp955789p977494.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 create normal qqplot with the 95% confidence interval

2009-12-23 Thread brestat

Rubio,


Look at library(fBasics) the function qqnormPlot(). Below an example:

qqnormPlot(rnorm(100))

Best's

Walmes Zeviani, Brasil.





CJ Rubio wrote:
> 
> hi everyone!
> 
> season's greetings!
> 
> is there any way that i can create a normal qqplot showing, aside from the
> qqline, the 95% confidence limits? thank you very much..
> 
> happy holidays!
> 

-- 
View this message in context: 
http://n4.nabble.com/how-to-create-normal-qqplot-with-the-95-confidence-interval-tp977727p977751.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] String question

2009-12-23 Thread Gustaf Rydevik
On Wed, Dec 23, 2009 at 11:21 AM, Knut Krueger  wrote:
> Hi to all
>
> I need a string like
> temp <- paste("m1","m2","m3",sep=",")
> But i must know how many items are in the string,afterwards
> the other option would be to use a vector
> temp <- c("m1","m2","m3")
> No problem to get the count of items but I must get afterwards the string
>  "m1,m2,m3"
> No problem to build the string with a loop, but it should be more easy but
> it seems that I am looking to the wrong functions.
>
> Kind regards Knut
>

Just thought I'd show you a solution from the other direction, in
addition to those that all other have posted:


temp <- paste("m1","m2","m3",sep=",")##Generate string
nchar(gsub("([^,])","",temp))+1## Count commas in the string and add 1.


Regards,
Gustaf

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
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] Mean, median and other moments

2009-12-23 Thread John Sorkin
An answer to your second question:
Random number generated by your computer are not truly random, they are pseduo 
random meaning that if your computer is it the exact same state at two 
movements, it will produce the same string of "random" numbers. Set.seed 
effectively puts your machine in a given state - it primes the pseudo random 
number generator. If you set the seed before requesting a set of random 
numbers, you will always get the same set of numbers. If you don't use 
set.seed, the machine primes the generator using some other source, which may 
be the system clock. Thus, if you don't use set.seed, it would be very, very, 
unlikely that you would get the same string of random numbers.
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> Amelia 
Livington  12/23/2009 6:24 AM >>>
Hi!

Suppose I have a dataset as follows

pd = c(10,7,10,11,7,11,7,6,8,3,12,7,7,10,10)

I wish to calculate the mean, standard deviation, median, skewness and kurtosis 
i.e. regular standard statistical measures.

average = mean(pd)
stdev= sd(pd)
median = median(pd)
skew= skewness(pd)
kurt =  kurtosis(pd)

Q. No (1)

How do I get these at a stretch using some R package? I came across moments and 
e1071 package, but I am not sure which one to use and how?

Q. No. (2)
Many times I came across the command

set.seed(1234)

What is the significance of this command. I understand this is related to 
random number generation. But what does it do?

Thanking in advance

Amelia



  
[[alternative HTML version deleted]]


Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped: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] Playing with rgl: a Youtube video

2009-12-23 Thread Duncan Murdoch

On 23/12/2009 7:13 AM, Rainer M Krug wrote:



On Tue, Dec 22, 2009 at 8:10 PM, Duncan Murdoch > wrote:


On 22/12/2009 12:49 PM, Mark Knecht wrote:

On Mon, Dec 21, 2009 at 4:42 AM, Duncan Murdoch
mailto:murd...@stats.uwo.ca>> wrote:
 > I've just posted a demo made with the rgl package to Youtube,
visible here:
 >  http://www.youtube.com/watch?v=prdZWQD7L5c
 >
 > For future reference, here are the steps I used:
 >
 > 1.  Design a shape to be displayed, and then play with the
animation
 > functions to make it change over time.  Use play3d to do it
live in R,
 > movie3d to write the individual frames of the movie to .png
files.
 >
 > 2.  Use the ffmpeg package (not an R package, a separate
project at
 > http://ffmpeg.org) to convert the .png files to an .mp4 file.
 The
 > individual frames totalled about 1 GB; the compressed movie
is about 45 MB.


Could you please post the command line options you used for ffmpeg? I 
remember I wanted to do an animation, also from .png, and I struggled a lot.


Sure.  The png files were 1024 by 768, designed to be displayed at 
24fps.  The command line was


ffmpeg  -b 240 -r 24 -i movie%03d.png -s xga movie.mp4

The -b option controls the target bit rate.  The -r option says how many 
frames per second, -i includes all the files (named things like 
movie001.png, etc.), -s sets the output size, with xga being a quick way 
to say 1024x768, and movie.mp4 is the output file.  There are tons of 
options to change codec, etc., but I found the -b option was the only 
one I needed to play with.


Duncan Murdoch



Rainer
 


 > 3.  Upload to Youtube.  I'm not a musician, so I had to use
one of their
 > licensed background tracks, I couldn't write my own.  I spent
a lot of time
 > picking one and then adjusting the timing of the video to
compensate.  Each
 > render/upload cycle at full resolution took about an hour and
a half.  It's
 > a lot faster to render in a smaller window with fewer frames
per second, but
 > it's still tedious.   It's easier to synchronize if you
actually have a copy
 > of the music locally, but Youtube doesn't let you download
their music.  So
 > the timing isn't perfect, but it's good enough for me!
 >
 > Duncan Murdoch
 >

Cool enough video. Thanks for sharing.

I'm curious - did you do the equations for the knot in R? If so what
did they look like, assuming there's no reason you cannot share it.
 



The knot has equation

cbind(sin(theta)+2*sin(2*theta), 2*sin(3*theta),
cos(theta)-2*cos(2*theta))

The threads in the braid have equation

cbind(sin(theta) + sin(2*theta)/2, sin(theta-pi) + sin(2*theta)/2,
theta)

in the local coordinates of the knot.

Overall it's about 100 lines of R code, too ugly to post.

Duncan Murdoch


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




--
NEW GERMAN FAX NUMBER!!!

Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation 
Biology, UCT), Dipl. Phys. (Germany)


Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:   +27 - (0)83 9479 042
Fax:+27 - (0)86 516 2782
Fax:+49 - (0)321 2125 2244
email:  rai...@krugs.de 

Skype:  RMkrug
Google: r.m.k...@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] Playing with rgl: a Youtube video

2009-12-23 Thread Rainer M Krug
On Tue, Dec 22, 2009 at 8:10 PM, Duncan Murdoch wrote:

> On 22/12/2009 12:49 PM, Mark Knecht wrote:
>
>> On Mon, Dec 21, 2009 at 4:42 AM, Duncan Murdoch 
>> wrote:
>> > I've just posted a demo made with the rgl package to Youtube, visible
>> here:
>> >  http://www.youtube.com/watch?v=prdZWQD7L5c
>> >
>> > For future reference, here are the steps I used:
>> >
>> > 1.  Design a shape to be displayed, and then play with the animation
>> > functions to make it change over time.  Use play3d to do it live in R,
>> > movie3d to write the individual frames of the movie to .png files.
>> >
>> > 2.  Use the ffmpeg package (not an R package, a separate project at
>> > http://ffmpeg.org) to convert the .png files to an .mp4 file.  The
>> > individual frames totalled about 1 GB; the compressed movie is about 45
>> MB.
>>
>
Could you please post the command line options you used for ffmpeg? I
remember I wanted to do an animation, also from .png, and I struggled a lot.

Rainer


> > 3.  Upload to Youtube.  I'm not a musician, so I had to use one of their
>> > licensed background tracks, I couldn't write my own.  I spent a lot of
>> time
>> > picking one and then adjusting the timing of the video to compensate.
>>  Each
>> > render/upload cycle at full resolution took about an hour and a half.
>>  It's
>> > a lot faster to render in a smaller window with fewer frames per second,
>> but
>> > it's still tedious.   It's easier to synchronize if you actually have a
>> copy
>> > of the music locally, but Youtube doesn't let you download their music.
>>  So
>> > the timing isn't perfect, but it's good enough for me!
>> >
>> > Duncan Murdoch
>> >
>>
>> Cool enough video. Thanks for sharing.
>>
>> I'm curious - did you do the equations for the knot in R? If so what
>> did they look like, assuming there's no reason you cannot share it.
>>
>>
>
> The knot has equation
>
> cbind(sin(theta)+2*sin(2*theta), 2*sin(3*theta), cos(theta)-2*cos(2*theta))
>
> The threads in the braid have equation
>
> cbind(sin(theta) + sin(2*theta)/2, sin(theta-pi) + sin(2*theta)/2, theta)
>
> in the local coordinates of the knot.
>
> Overall it's about 100 lines of R code, too ugly to post.
>
> Duncan Murdoch
>
>
> __
> 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.
>



-- 
NEW GERMAN FAX NUMBER!!!

Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:   +27 - (0)83 9479 042
Fax:+27 - (0)86 516 2782
Fax:+49 - (0)321 2125 2244
email:  rai...@krugs.de

Skype:  RMkrug
Google: r.m.k...@gmail.com

[[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] how to create normal qqplot with the 95% confidence interval

2009-12-23 Thread CJ Rubio

hi everyone!

season's greetings!

is there any way that i can create a normal qqplot showing, aside from the
qqline, the 95% confidence limits? thank you very much..

happy holidays!
-- 
View this message in context: 
http://n4.nabble.com/how-to-create-normal-qqplot-with-the-95-confidence-interval-tp977727p977727.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] String question

2009-12-23 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 23.12.2009 12:08:02:

> Jim Lemon schrieb:
> >
> > Not as easy as I thought it would be, but:
> >
> > mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
> > do.call("paste",c(mlist,sep=","))
> >
> 
> Hi Jim,
> yes it works  :-)
> 
> temp <- c("November", "December","Monday","Tuesday")
> length(temp) #getting the length of the vector
> string1=do.call("paste",c(as.list(temp),sep=",")) #converting to a 
string

Isn't it same like

> paste(temp, collapse=",")
[1] "November,December,Monday,Tuesday"

I also thought you actually wanted

> paste(paste(temp, seq_along(temp), sep="."), collapse=",")
[1] "November.1,December.2,Monday.3,Tuesday.4"

Regards
Petr


> 
> but I have no idea where I could find that documentation ;-)
> 
> Thanks a lot
> Knut
> 
> __
> 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] String question

2009-12-23 Thread Knut Krueger

Hi Baptiste,

Isn't paste doing exactly this?
  

yes indeed - surprising

temp <- c("November", "December","Monday","Tuesday")
paste(temp, collapse=",")
  


paste(temp, sep=",") I tried to use sep  :-(


 Arguments

|...|   one or more *R* objects, to be converted to character vectors.
|sep| 	a character string to separate the terms. Not |NA_character_ 
|.
|collapse| 	an optional character string to separate the results. Not 
|NA_character_ |.


and I did not realize that I separated the wrong part ...

Kind regards Knut

__
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] String question

2009-12-23 Thread Ted Harding
On 23-Dec-09 11:40:12, baptiste auguie wrote:
> Isn't paste doing exactly this?
> 
> temp <- c("November", "December","Monday","Tuesday")
> paste(temp, collapse=",")
># "November,December,Monday,Tuesday"
> 
> HTH,
> baptiste

Yes, spot-on! I got involved in the confusion resulting from
the use of "sep" in previous postings.

I think that solves it for Knut!
Ted.

> 2009/12/23 Ted Harding :
>> On 23-Dec-09 11:08:02, Knut Krueger wrote:
>>> Jim Lemon schrieb:
 Not as easy as I thought it would be, but:

 mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
 do.call("paste",c(mlist,sep=","))
>>>
>>> Hi Jim,
>>> yes it works _:-)
>>>
>>> temp <- c("November", "December","Monday","Tuesday")
>>> length(temp) #getting the length of the vector
>>> string1=do.call("paste",c(as.list(temp),sep=",")) #converting to a
>>> string
>>>
>>> but I have no idea where I could find that documentation ;-)
>>>
>>> Thanks a lot
>>> Knut
>>
>> Interestingly, cat() does the pasting job in the simplest
>> possible way:
>>
>>> temp <- c("November", "December","Monday","Tuesday")
>>> cat(temp,sep=",")
>> November,December,Monday,Tuesday>
>>
>> [copied from the R console; note the trialing ">" which is
>> _the command prompt for the next input -- not part of the
>> _output of cat() ]
>>
>> with output to screen (or to nominated file). But there
>> seems to be no way to persuade cat to *return* this result
>> as a value, which could be assigned to a variable.
>>
>> If there were such a way, that would be a very smooth solution!
>>
>> Ted.
>>
>> 
>> E-Mail: (Ted Harding) 
>> Fax-to-email: +44 (0)870 094 0861
>> Date: 23-Dec-09 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Time: 11:28:47
>> -- XFMail --
>>
>> __
>> 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.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 23-Dec-09   Time: 11:57:19
-- XFMail --

__
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] Mean, median and other moments

2009-12-23 Thread Jim Lemon

On 12/23/2009 10:24 PM, Amelia Livington wrote:

Hi!

Suppose I have a dataset as follows

pd = c(10,7,10,11,7,11,7,6,8,3,12,7,7,10,10)

I wish to calculate the mean, standard deviation, median, skewness and kurtosis 
i.e. regular standard statistical measures.

average = mean(pd)
stdev= sd(pd)
median = median(pd)
skew= skewness(pd)
kurt =  kurtosis(pd)

Q. No (1)

How do I get these at a stretch using some R package? I came across moments and 
e1071 package, but I am not sure which one to use and how?

Q. No. (2)
Many times I came across the command

set.seed(1234)

What is the significance of this command. I understand this is related to 
random number generation. But what does it do?

   

Hi Amelia,
For 1)

library(prettyR)
library(timeDate)
describe(pd,
 num.desc=c("mean","sd","median","kurtosis","skewness"))

although there are many other ways to do this.

for 2)

set.seed() starts the random number generator at a particular place, 
allowing you to generate the same set of "random" numbers repeatedly. 
This can be useful for things like examples for which the particular set 
of numbers should be repeated when anyone runs the example.


Jim

__
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] String question

2009-12-23 Thread baptiste auguie
Isn't paste doing exactly this?

temp <- c("November", "December","Monday","Tuesday")
paste(temp, collapse=",")
# "November,December,Monday,Tuesday"

HTH,

baptiste


2009/12/23 Ted Harding :
> On 23-Dec-09 11:08:02, Knut Krueger wrote:
>> Jim Lemon schrieb:
>>> Not as easy as I thought it would be, but:
>>>
>>> mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
>>> do.call("paste",c(mlist,sep=","))
>>
>> Hi Jim,
>> yes it works  :-)
>>
>> temp <- c("November", "December","Monday","Tuesday")
>> length(temp) #getting the length of the vector
>> string1=do.call("paste",c(as.list(temp),sep=",")) #converting to a
>> string
>>
>> but I have no idea where I could find that documentation ;-)
>>
>> Thanks a lot
>> Knut
>
> Interestingly, cat() does the pasting job in the simplest
> possible way:
>
>> temp <- c("November", "December","Monday","Tuesday")
>> cat(temp,sep=",")
> November,December,Monday,Tuesday>
>
> [copied from the R console; note the trialing ">" which is
>  the command prompt for the next input -- not part of the
>  output of cat() ]
>
> with output to screen (or to nominated file). But there
> seems to be no way to persuade cat to *return* this result
> as a value, which could be assigned to a variable.
>
> If there were such a way, that would be a very smooth solution!
>
> Ted.
>
> 
> E-Mail: (Ted Harding) 
> Fax-to-email: +44 (0)870 094 0861
> Date: 23-Dec-09                                       Time: 11:28:47
> -- XFMail --
>
> __
> 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] String question

2009-12-23 Thread Ted Harding
On 23-Dec-09 11:08:02, Knut Krueger wrote:
> Jim Lemon schrieb:
>> Not as easy as I thought it would be, but:
>>
>> mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
>> do.call("paste",c(mlist,sep=","))
> 
> Hi Jim,
> yes it works  :-)
> 
> temp <- c("November", "December","Monday","Tuesday")
> length(temp) #getting the length of the vector
> string1=do.call("paste",c(as.list(temp),sep=",")) #converting to a
> string
> 
> but I have no idea where I could find that documentation ;-)
> 
> Thanks a lot
> Knut

Interestingly, cat() does the pasting job in the simplest
possible way:

> temp <- c("November", "December","Monday","Tuesday")
> cat(temp,sep=",")
November,December,Monday,Tuesday> 

[copied from the R console; note the trialing ">" which is
 the command prompt for the next input -- not part of the
 output of cat() ]

with output to screen (or to nominated file). But there
seems to be no way to persuade cat to *return* this result
as a value, which could be assigned to a variable.

If there were such a way, that would be a very smooth solution!

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 23-Dec-09   Time: 11:28:47
-- XFMail --

__
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] Mean, median and other moments

2009-12-23 Thread Amelia Livington
Hi!

Suppose I have a dataset as follows

pd = c(10,7,10,11,7,11,7,6,8,3,12,7,7,10,10)

I wish to calculate the mean, standard deviation, median, skewness and kurtosis 
i.e. regular standard statistical measures.

average = mean(pd)
stdev    = sd(pd)
median = median(pd)
skew    = skewness(pd)
kurt =  kurtosis(pd)

Q. No (1)

How do I get these at a stretch using some R package? I came across moments and 
e1071 package, but I am not sure which one to use and how?

Q. No. (2)
Many times I came across the command

set.seed(1234)

What is the significance of this command. I understand this is related to 
random number generation. But what does it do?

Thanking in advance

Amelia



  
[[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] String question

2009-12-23 Thread Knut Krueger

Jim Lemon schrieb:


Not as easy as I thought it would be, but:

mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
do.call("paste",c(mlist,sep=","))



Hi Jim,
yes it works  :-)

temp <- c("November", "December","Monday","Tuesday")
length(temp) #getting the length of the vector
string1=do.call("paste",c(as.list(temp),sep=",")) #converting to a string

but I have no idea where I could find that documentation ;-)

Thanks a lot
Knut

__
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] COnfidence intervals for estimates of linear model

2009-12-23 Thread ONKELINX, Thierry
Dear Daniel,

Have a look at ?predict.lm The interval argument gives you the
information that you need.

HTH,

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Daniel Brewer
Verzonden: woensdag 23 december 2009 11:28
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] COnfidence intervals for estimates of linear model

Hello,

I would like to calculate the 95% confidence intervals for the estimates
of a linear model and I just wanted to check that I am doing it correct.
 Is it just:

Estimate + 1.95996*Std.Error to Estimate - 1.95996*Std.Error

or is there another approach that doesn't assume a normal distrbution?

Thanks.  Apologies for my naiivity

Dan

--
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

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

This e-mail message is confidential and for use by the a...{{dropped: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.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
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] String question

2009-12-23 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 23.12.2009 11:46:31:

> 
> > Will this do?
> >
> > temp <- paste("m", 1:3, sep="",collapse=",")
> >
> > 
> Unfortunately not, because I explained the example not detailed enough.
> The string could have different Items, like November, December, Monday, 
> Tuesday, Daylight and so on
> Therefore I must count the Items of the string separated by "," or 
> change the vector to a string

like that?
x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech")
paste(x, seq_along(x), sep=".")

Regards
Petr


> 
> Thanks for your reply
> Knut
> 
> __
> 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] String question

2009-12-23 Thread Jim Lemon

On 12/23/2009 09:21 PM, Knut Krueger wrote:

Hi to all

I need a string like
temp <- paste("m1","m2","m3",sep=",")
But i must know how many items are in the string,afterwards
the other option would be to use a vector
temp <- c("m1","m2","m3")
No problem to get the count of items but I must get afterwards the 
string  "m1,m2,m3"
No problem to build the string with a loop, but it should be more easy 
but it seems that I am looking to the wrong functions.



Hi Knut,
Not as easy as I thought it would be, but:

mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
do.call("paste",c(mlist,sep=","))

Jim

__
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] String question

2009-12-23 Thread Knut Krueger



Will this do?

temp <- paste("m", 1:3, sep="",collapse=",")

  

Unfortunately not, because I explained the example not detailed enough.
The string could have different Items, like November, December, Monday, 
Tuesday, Daylight and so on
Therefore I must count the Items of the string separated by "," or 
change the vector to a string


Thanks for your reply
Knut

__
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] String question

2009-12-23 Thread baptiste auguie
Will this do?

temp <- paste("m", 1:3, sep="",collapse=",")

HTH,

baptiste

2009/12/23 Knut Krueger :
> Hi to all
>
> I need a string like
> temp <- paste("m1","m2","m3",sep=",")
> But i must know how many items are in the string,afterwards
> the other option would be to use a vector
> temp <- c("m1","m2","m3")
> No problem to get the count of items but I must get afterwards the string
>  "m1,m2,m3"
> No problem to build the string with a loop, but it should be more easy but
> it seems that I am looking to the wrong functions.
>
> Kind regards Knut
>
> __
> 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] COnfidence intervals for estimates of linear model

2009-12-23 Thread Daniel Brewer
Hello,

I would like to calculate the 95% confidence intervals for the estimates
of a linear model and I just wanted to check that I am doing it correct.
 Is it just:

Estimate + 1.95996*Std.Error to Estimate - 1.95996*Std.Error

or is there another approach that doesn't assume a normal distrbution?

Thanks.  Apologies for my naiivity

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: daniel.bre...@icr.ac.uk
**

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

This e-mail message is confidential and for use by the a...{{dropped: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] String question

2009-12-23 Thread Knut Krueger

Hi to all

I need a string like
temp <- paste("m1","m2","m3",sep=",")
But i must know how many items are in the string,afterwards
the other option would be to use a vector
temp <- c("m1","m2","m3")
No problem to get the count of items but I must get afterwards the 
string  "m1,m2,m3"
No problem to build the string with a loop, but it should be more easy 
but it seems that I am looking to the wrong functions.


Kind regards Knut

__
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 makeClusters for Snow

2009-12-23 Thread Prof Brian Ripley
See http://cran.r-project.org/bin/windows/contrib/2.10/@ReadMe for 
what packages are not made available as binary packages for Windows. 
You can install packages Rmpi and rpvm from the sources (but not 
easily) if you have the requisite software installed.  See e.g.


http://www.stats.uwo.ca/faculty/yu/Rmpi/windows.htm
http://tolstoy.newcastle.edu.au/R/e2/help/06/11/5171.html

'NWS' is not a uniquely defined TLA. Perhaps CRAN package 'nws' is 
meant, which does have a Windows binary, but note the description


Description:   Provides coordination and parallel execution facilities,
   as well as limited cross-language data exchange, using
   the netWorkSpaces server developed by REvolution
   Computing

which suggests you need a commercial product to use it (despite the 
lack of a SystemRequirements field).



On Wed, 23 Dec 2009, Patrick Connolly wrote:


On Tue, 22-Dec-2009 at 09:38PM -0800, SVM wrote:

|>
[]

|>
|> On top of that, I couldn't find the MPI/NWS/PVM libraries for windows. I've
|> looked for them all over the internet but I can't seem to find any resources
|> for it. I even tried installing them directly from R, (i.e.
|> install.packages(rmpi) or install.packages(mpi)), they don't seem to exist
|> in the repository any longer.

Did they ever exist?  According to the listing of Rmpi on CRAN would
indicate that there is none, only the tar.gz file.  This is very OS
specific sort of stuff.

best

Patrick



|>
|> Can anyone please help me with this. Also, where can I find them and how do
|> I install the PVM, MPI, and NWS packages?
|>
|> Any help would be greatly appreciated .


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

__
R-help@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] use of lm() and poly()

2009-12-23 Thread Benoit Boulinguiez


I guess, I would somehow feel interested that someone out of my field is
trying to use the tool I daily manipulate to widen his knowledge or dig
further in his own field, though I might at some point recommend him to get
back to the basis for some concrete concepts that he wouldn't understand
sharply enough. I hope reading "Practical Regression and Anova using R" by
J.J. Faraway will help sharpening out a bit my knowledge's.
For sure though, I'd sound less scornful than you.

BTW, thank you Daniel for pointing out that I was using orthogonal
polynomials instead of regular ones.


Regards/Cordialement


Benoit Boulinguiez 


-Message d'origine-
De : Bert Gunter [mailto:gunter.ber...@gene.com] 
Envoyé : mardi 22 décembre 2009 18:26
À : 'Benoit Boulinguiez'; r-help@r-project.org
Objet : RE: [R] use of lm() and poly()

Get some statistical consulting help or read up on these topics -- any good
textbook on regression should contain the necessary material. This has
nothing to do with nonlinear regression, so you are confused about the basic
ideas. It has nothing to do with R.

If you don't understand how the statistical tools work, you shouldn't be
using them (without help, anyway). Would you feel comfortable about me
playing in your chemistry lab based on my year of college chemistry ~45
years ago?

Bert Gunter
Genentech Nonclinical Biostatistics
 
 -Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Benoit Boulinguiez
Sent: Tuesday, December 22, 2009 9:10 AM
To: r-help@r-project.org
Subject: [R] use of lm() and poly()

Hi all,
 
I want to fit data called "metal" with a polynominal function as dP ~ a.0 +
a.1 * U0 + a.2 * U0^2 + a.3 * U0^3 + a.4 * U0^4 The data set includes, the
independant variable U0 and the dependant variable dP.
 
I've seen that the combination of lm() and poly() can do that instead of
using the nls() function.
But I don't get how to interpret the results from the linear regression, as
the coefficients do not match the ones from the nonlinear regression
 
 
#data
metal
 U0  dP
1  0.00   0
2  0.76  10
3  1.43  20
4  2.56  40
5  3.05  50
6  3.52  60
7  3.76  70
8  4.05  80
9  4.24  90
10 4.47 100
 
#linear
 d <- seq(0, 4, length.out = 200)
 for(degree in 1:4) {
   fm <- lm(dP ~ poly(U0, degree), data = metal)
   assign(paste("metal", degree, sep="."), fm)
   lines(d, predict(fm, data.frame(U0=d)), col = degree)
 }
metal.4
Call:
lm(formula = dP ~ poly(U0, degree), data = metal)
 
Coefficients:
  (Intercept)  poly(U0, degree)1  poly(U0, degree)2  poly(U0, degree)3
poly(U0, degree)4  
   52.000100.612 19.340  7.101
2.628 
 
 
#nonlinear
fm<-nls (dP~ a.0 + a.1*U0 + a.2*U0^2 + a.3*U0^3 + a.4*U0^4, data=metal) 

Nonlinear regression model
  model:  dP ~ a.0 + a.1 * U0 + a.2 * U0^2 + a.3 * U0^3 + a.4 * U0^4 
   data:  metal 
 a.0  a.1  a.2  a.3  a.4 
 0.02408  9.81452  5.54269 -2.24657  0.36737  residual sum-of-squares: 5.843
 
Number of iterations to convergence: 2
Achieved convergence tolerance: 1.378e-06 

 
 
 
 

Regards/Cordialement

-
Benoit Boulinguiez
Ph.D student
Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226
"Sciences Chimiques de Rennes"
Avenue du Giniral Leclerc
CS 50837
35708 Rennes CEDEX 7
Tel 33 (0)2 23 23 80 83
Fax 33 (0)2 23 23 81 20
  http://www.ensc-rennes.fr/ 

 

[[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] Help with makeClusters for Snow

2009-12-23 Thread Patrick Connolly
On Tue, 22-Dec-2009 at 09:38PM -0800, SVM wrote:

|> 
[]

|> 
|> On top of that, I couldn't find the MPI/NWS/PVM libraries for windows. I've
|> looked for them all over the internet but I can't seem to find any resources
|> for it. I even tried installing them directly from R, (i.e.
|> install.packages(rmpi) or install.packages(mpi)), they don't seem to exist
|> in the repository any longer.

Did they ever exist?  According to the listing of Rmpi on CRAN would
indicate that there is none, only the tar.gz file.  This is very OS
specific sort of stuff.

best

Patrick



|> 
|> Can anyone please help me with this. Also, where can I find them and how do
|> I install the PVM, MPI, and NWS packages?
|> 
|> Any help would be greatly appreciated .




|> 
|> Steve
|> -- 
|> View this message in context: 
http://n4.nabble.com/Help-with-makeClusters-for-Snow-tp977592p977592.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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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