Re: [R] Dataframe of factors transform speed?

2007-07-20 Thread Latchezar Dimitrov
Hi,

Thanks for the help. My 1st question still unanswered though :-) Please
see bellow 

> -Original Message-
> From: Benilton Carvalho [mailto:[EMAIL PROTECTED] 
> Sent: Friday, July 20, 2007 3:30 AM
> To: Latchezar Dimitrov
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] Dataframe of factors transform speed?
> 
> set.seed(123)
> genoT = lapply(1:24, function(i) factor(sample(c("AA", 
> "AB", "BB"), 1000, prob=sample(c(1, 1000, 1000), 3), rep=T)))
> names(genoT) = paste("snp", 1:24, sep="") genoT = 
> as.data.frame(genoT)

Now this _is the problem. Everything before converting to data.frame
worked almost instantaneously however as.data.frame runs forever.
Obviously there is some scalability memory management issue. When I
tried my own method but creating a new result (instead of modifying the
old) dataframe it worked like a charm for the 1st 100 cols ~ .3s. I
figured 300,000 cols should be ~1000s. Nope! It ran for about 50,000(!)s
to finish about 42,000 cols only. 

BTW, what ver. of R is yours?

Now here's what I "discovered" further.

#-- create a 1-col frame:
geno   <-
data.frame(c(geno.GASP[[1]],geno.JAG[[1]]),row.names=c(rownames(geno.GAS
P),rownames(geno.JAG)))

#-- main code I repeated it w/ j in 1:1000, 2001:3000, and 3001:4000,
i.e., adding a 1000 of cols to geno each time

system.time(
#   for(j in 1:(ncol(geno.GASP  ))){
for(j in 3001:(4000  )){
  gt.GASP<-geno.GASP[[j]]
   for(l in 1:length([EMAIL PROTECTED])){
 levels(gt.GASP)[l] <-
switch([EMAIL PROTECTED],AA="0",AB="1",BB="2")
   }
   gt.JAG <-geno.JAG [[j]]
#  for(l in 1:length(gt.JAG @levels)){
#levels(gt.JAG )[l] <- switch(gt.JAG
@levels[l],AA="0",AB="1",BB="2")
#  }
   geno[[j]]<-factor(c(as.numeric(factor(gt.GASP,levels=0:2))-1
###   factor(c(as.numeric(factor(gt.GASP,levels=0:2))-1
  ,as.numeric(factor(gt.JAG, levels=0:2))-1
  )
,levels=0:2
)
}
)

Times (each one is for a 1000 cols!):
[1] 26.673  0.032 26.705  0.000  0.000
[1] 77.186  0.037 77.225  0.000  0.000
[1] 128.165   0.042 128.209   0.000   0.000
[1] 180.940   0.047 180.989   0.000   0.000

See the big diff and the scaling I mentioned above?

Further more I removed geno[[j]] assignment leaving the operation
though, i.e., replaced it with ### line above. Times:

[1] 0.857 0.008 0.865 0.000 0.000

Huh!? What the heck! That's my second question :-) Any ideas?

I still believe my method is near optimal. Of course I have to somehow
get rid of the assignment bottleneck.

For now the lesson is: "God bless lists"

Here is my final solution:

> system.time({
+ geno.GASP.L<-lapply(geno.GASP
+,function(x){
+   for(l in 1:length([EMAIL PROTECTED])){levels(x)[l] 
<-
switch([EMAIL PROTECTED],AA="0",AB="1",BB="2")}
+   factor(x,levels=0:2)
+ }
+  )
+ geno.JAG.L <-lapply(geno.JAG
+,function(x){
+ # for(l in 1:length([EMAIL PROTECTED])){levels(x)[l] 
<-
switch([EMAIL PROTECTED],AA="0",AB="1",BB="2")}
+   factor(x,levels=0:2)
+ }
+  )
+ })
[1] 192.800   1.566 194.413   0.000   0.000   ! :-)
> system.time({
+ class(geno.GASP.L)<-"data.frame"
+ row.names(geno.GASP.L)<-row.names(geno.GASP)
+ class(geno.JAG.L )<-"data.frame"
+ row.names(geno.JAG.L )<-row.names(geno.JAG )
+ })
[1] 12.156  0.001 12.155  0.000  0.000
> system.time({
+ geno<-rbind(geno.GASP.L,geno.JAG.L)
+ })
[1] 1542.3409.072 2066.3100.0000.000

I logged my notes here as I was trying various things. Partly the reason
is my two questions:

"What was wrong with me?" and
"What the heck?!" remember above? :-)))

which  still remain unanswered :-(

I would have had a lot of fun if I had not to have this done by ...
Yesterday :-))

Thanks a lot for the help

Latchezar  

> dim(genoT)
> class(genoT)
> system.time(out <- lapply(genoT, function(x) match(x, c("AA", "AB",
> "BB"))-1))
> ##
> ##
> user  system elapsed
> 119.288   0.004 119.339
> 
> (for all 240K)
> 
> best,
> b
> 
> ps: note that "out" is a list.
> 
> On Jul 20, 2007, at 2:01 AM, Latchezar Dimitrov wrote:
> 
> > Hi,
> >
> >> -Original Message-
> >> From: Benilton Carvalho [mailto:[EMAIL PROTECTED]
> >> Sent: Friday, July 20, 2007 12:25 AM
> >> To: Latchezar Dimitrov
> >> Cc: r-help@stat.math.ethz.ch
> >> Subject: Re: [R] Dataframe of factors transform speed?
> >>
> >> it looks like that whatever method you used to genotype the
> >> 1002 samples on the STY array gave you a transposed matrix of 
> >> genotype calls. :-)
> >
> > It only looks like :-)
> >
> > Otherwise it is correctly created dataframe of 1002 samples X (big
> > number) of columns (SNP genotypes). It worked perfectly until I 
> > 

[R] Robust PLS

2007-07-20 Thread Pedro Mardones
Dear all;
Does anyone have written or know where to get a function for fitting
robust partial least squares in R?
Thanks for any ideas
PM

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


Re: [R] avoiding timconsuming for loop renaming identifiers

2007-07-20 Thread François Pinard
[EMAIL PROTECTED]

>I was wondering if I can avoid a time-consuming for loop on my 60 
>obs dataset.

>school_id   y
>8   9.87
>8   8.89
>8   7.89
>8   8.88
>20  6.78
>20  9.99
>20  8.79
>31  10.1
>31  11

>There are, say, 143 different schools in this 60 obs dataset.
>I need to thave sequential identifiers, 1,2,3,4,5,...,143.

Hello, Toby.  Maybe:

   dta$id <- cumsum(c(1, diff(dta$school_id) != 0))

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


Re: [R] avoiding timconsuming for loop renaming identifiers

2007-07-20 Thread Benilton Carvalho
as.integer(factor(dta[["school_id"]]))

b

On Jul 20, 2007, at 9:26 PM, [EMAIL PROTECTED] wrote:

> Hi All
>
> I was wondering if I can avoid a time-consuming for loop on my  
> 60 obs dataset.
>
> school_id   y
> 8   9.87
> 8   8.89
> 8   7.89
> 8   8.88
> 20  6.78
> 20  9.99
> 20  8.79
> 31  10.1
> 31  11
>
> There are, say, 143 different schools in this 60 obs dataset.
>
> I need to thave sequential identifiers, 1,2,3,4,5,...,143.
>
> I was using an awkward for look that took 30 minutes to run.
> sid = 1
> dta$sid[1] = 1
> for (i in 2:nrow(dta)) {
> if (dta$school_id[i] != dta$school_[i-1]) sid = sid+1
> dta$sid[i] = sid
> }
>
> Any hints appreciated.
>
> Thanks Toby
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] set class attribute method question

2007-07-20 Thread chenxh007
setReplaceMethod("set.version", c("dat", "character"),
function(object, value) {
[EMAIL PROTECTED] <- value
object })

Xiaohui

Tae-Hoon Chung wrote:
> Hi, All;
> 
> Suppose I have a class 'dat' such that setClass('dat', representation 
> (.version='character', x='numeric', y='numeric')).
> If I want to make a method that changes the .version slot of 'dat'  
> class in a way like set.version(d) <- '0.2' when d is an object of  
> 'dat' class, how can I do this? Thanks in advance.
> 
> Tae-Hoon Chung
> 
> Post-Doctoral Researcher
> Computational Biology Division, TGEN
> 445 N 5th St. Phoenix, AZ 85004 USA
> O: 1-602-343-8724
> F: 1-602-343-8840
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] avoiding timconsuming for loop renaming identifiers

2007-07-20 Thread toby909
Hi All

I was wondering if I can avoid a time-consuming for loop on my 60 obs 
dataset.

school_id   y
8   9.87
8   8.89
8   7.89
8   8.88
20  6.78
20  9.99
20  8.79
31  10.1
31  11

There are, say, 143 different schools in this 60 obs dataset.

I need to thave sequential identifiers, 1,2,3,4,5,...,143.

I was using an awkward for look that took 30 minutes to run.
sid = 1
dta$sid[1] = 1
for (i in 2:nrow(dta)) {
if (dta$school_id[i] != dta$school_[i-1]) sid = sid+1
dta$sid[i] = sid
}

Any hints appreciated.

Thanks Toby

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


[R] R2WinBUGS awkward to use

2007-07-20 Thread toby909
Hi All

Does anyone know if I can avoid to use the write.model() function below? I dont 
want to do this. Can't bugs() do that automatically for me just by specifying 
the 4th argument 'model'? Just I like I am also using the 'inits' object!

If I use 'model' in the same way as I use 'inits' I am getting the error:

 > sim <- bugs(data, inits, parameters, model, n.chains=1, n.iter=5000, 
bugs.directory="c:/Program Files/WinBUGS14", working.directory=NULL, 
clearWD=TRUE, DIC=0)
Error in file.exists(c(...)) : invalid 'file' argument


Thanks Toby







data <- list(.)



model <- function() {

[omitted]

}

write.model(model, "cwk.txt")

inits <- function() {.}

parameters <- c("b", "nu", "S1", "S2")

sim <- bugs(data, inits, parameters, "cwk.txt", n.chains=1, n.iter=5000, 
bugs.directory="c:/Program Files/WinBUGS14", working.directory=NULL, 
clearWD=TRUE, DIC=0)

print(sim)
plot(sim)

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


[R] set class attribute method question

2007-07-20 Thread Tae-Hoon Chung
Hi, All;

Suppose I have a class 'dat' such that setClass('dat', representation 
(.version='character', x='numeric', y='numeric')).
If I want to make a method that changes the .version slot of 'dat'  
class in a way like set.version(d) <- '0.2' when d is an object of  
'dat' class, how can I do this? Thanks in advance.

Tae-Hoon Chung

Post-Doctoral Researcher
Computational Biology Division, TGEN
445 N 5th St. Phoenix, AZ 85004 USA
O: 1-602-343-8724
F: 1-602-343-8840



[[alternative HTML version deleted]]

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


Re: [R] RDCOM and R versions

2007-07-20 Thread Gabor Grothendieck
On 7/20/07, Paul <[EMAIL PROTECTED]> wrote:
> Dear R-helpers,
>
>  I have several versions of R installed on my computer, and I cannot do 
> without any of these.
>  However RCDOM seems to authorize only one version installed. Do you know any 
> means to overcome this problem ?
>  Thank you very much for your response.
>
> Paul Poncet

Don't know for sure how RDCOM selects the version but if its via the R
registry keys then, for example, running

   cd \Program Files\R\R-2.5.1\bin
   RSetReg.exe

will set R 2.5.1 to be the current version.

If that works then the batchfiles distribution at:

   http://code.google.com/p/batchfiles/

has two programs:

   Rversions.bat
   Rversions.hta

either of which provides an easier way to select among which version
of R you wish to make current based on the registry.  The .bat one is
a command line tool and the .hta one is a gui tool.

See the README file for more info.

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


Re: [R] binned column in a data.frame

2007-07-20 Thread David Katz

Would "cut" meet your needs?


João Fadista wrote:
> 
> Dear all,
>  
> I would like to know how can I create a binned column in a data.frame. The
> output that I would like is something like this: 
>  
> Start  Binned_Start
> 10-5
> 20-5
> 65-10
> 85-10
> 13  10-15
> ...
>  
>  
>  
> 
> Best regards
> 
> João Fadista
> Ph.d. student
> 
> 
>   
>UNIVERSITY OF AARHUS   
> Faculty of Agricultural Sciences  
> Dept. of Genetics and Biotechnology   
> Blichers Allé 20, P.O. BOX 50 
> DK-8830 Tjele 
>   
> Phone: +45 8999 1900  
> Direct:+45 8999 1900  
> E-mail:[EMAIL PROTECTED]    
> Web:   www.agrsci.org 
> 
> 
> News and news media  .
> 
> This email may contain information that is confidential. Any use or
> publication of this email without written permission from Faculty of
> Agricultural Sciences is not allowed. If you are not the intended
> recipient, please notify Faculty of Agricultural Sciences immediately and
> delete this email.
> 
> 
>   [[alternative HTML version deleted]]
> 
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/binned-column-in-a-data.frame-tf4115787.html#a11717127
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Column-mean-values for targeted rows

2007-07-20 Thread Benilton Carvalho
set.seed(123)
N = 3
K = 400
theData = matrix(rnorm(N*K), ncol=K)
theData = as.data.frame(theData)
theData = cbind(indicator = sample(0:1, N, rep=T), theData)

 > system.time(results <- colMeans(subset(theData, indicator == 1)))
user  system elapsed
   2.309   1.319   3.853


b


On Jul 20, 2007, at 6:17 PM, Diogo Alagador wrote:

> Hi all,
>
> I'm handling massive data.frames and matrices in R (3 x 400).
> In the 1st column, say, I have 0s and 1s indicating rows that  
> matter; other columns have probability values.
> One simple task I would like to do would be to get the column mean  
> values for signaled rows (the ones with 1)
> As a very fresh "programmer" I have build a simple function in R  
> which should not be very efficient indeed! It works well for  
> current-dimension matrices, but it just not goes so well in huge ones.
>
> meanprob<-function(Robj){
> NLINE<-dim(Robj)[1];
> NCOLUMN<-dim(Robj)[2];
> mprob<-c(rep(0,(NCOLUMN-1)));
> for (i in 2:NCOLUMN){
> sumprob<-0;
> pa<-0;
> for (j in 1:NLINE){
> if(Robj[j,1]!=0){
> pa<-pa+1;
> sumprob<-Robj[j,i]+sumprob;
> }
> }
> mprob[i-1]<-sumprob/pa;
> }
> return(mprob);
> }
>
>
> So I "only" see 3 ways to get through the problem:
>
> - to reformulate the function to gain efficiency;
> - to establish a C-routine (for example), where loops are more  
> "speedy", and then interfacing with R;
> - to find some function/ package that already do that.
>
> Can anybody illuminate my way here,
>
> Mush thanks,
>
> Diogo Andre' Alagador
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Column-mean-values for targeted rows

2007-07-20 Thread Diogo Alagador
Hi all,
 
I'm handling massive data.frames and matrices in R (3 x 400).
In the 1st column, say, I have 0s and 1s indicating rows that matter; other 
columns have probability values.
One simple task I would like to do would be to get the column mean values for 
signaled rows (the ones with 1)
As a very fresh "programmer" I have build a simple function in R which should 
not be very efficient indeed! It works well for current-dimension matrices, but 
it just not goes so well in huge ones.
 
meanprob<-function(Robj){ 
NLINE<-dim(Robj)[1];
NCOLUMN<-dim(Robj)[2];
mprob<-c(rep(0,(NCOLUMN-1)));  
for (i in 2:NCOLUMN){   
sumprob<-0;
pa<-0; 
for (j in 1:NLINE){ 
if(Robj[j,1]!=0){   
pa<-pa+1;
sumprob<-Robj[j,i]+sumprob; 
}
}
mprob[i-1]<-sumprob/pa;  
}
return(mprob);
}
 
 
So I "only" see 3 ways to get through the problem:
 
- to reformulate the function to gain efficiency;
- to establish a C-routine (for example), where loops are more "speedy", and 
then interfacing with R;
- to find some function/ package that already do that.
 
Can anybody illuminate my way here,
 
Mush thanks,
 
Diogo Andre' Alagador

[[alternative HTML version deleted]]

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


Re: [R] ?R: Removing white space betwen multiple plots, traditional graphics

2007-07-20 Thread Achim Zeileis
On Fri, 20 Jul 2007, Mr Natural wrote:

>
> I would appreciate suggestions for removing the white spaces the graphs in a
> stack:
>
> par(mar=c(2,2,1,1), mfrow = c(6,1))
> mydates<-dates(1:20,origin=c(month = 1, day = 1, year = 1986))
> plot(rnorm(20,0.1,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
> plot(rnorm(20,0.2,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
> plot(rnorm(20,0.3,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
> plot(rnorm(20,0.5,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
> plot(rnorm(20,0.7,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
> plot(rnorm(20,0.8,0.1)~mydates, type="b",xlab="",ylim=c(0,1) )

Really, there is no need to do this all by hand. Please have a look at the
"zoo" package (as recommended earlier this week).

Then you can do
   x <- cbind(rnorm(20,0.1,0.1),
  rnorm(20,0.2,0.1),
  rnorm(20,0.3,0.1),
  rnorm(20,0.5,0.1),
  rnorm(20,0.7,0.1),
  rnorm(20,0.8,0.1))
   z <- zoo(x, mydates)
   plot(z)
   plot(z, nc = 1, type = "b")
and much more.

Please consult
  vignette("zoo-quickref", package = "zoo")
  vignette("zoo", package = "zoo")
as well as the "Date and Time Classes" article by Gabor Grothendieck and
Thomas Petzoldt in R News 4(1), 29-32. (available from your favourite CRAN
mirror).
Z

> Thanx, Don
> --
> View this message in context: 
> http://www.nabble.com/-R%3A--Removing-white-space-betwen-multiple-plots%2C-traditional-graphics-tf4119626.html#a11716176
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

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


[R] ?R: Removing white space betwen multiple plots, traditional graphics

2007-07-20 Thread Mr Natural

I would appreciate suggestions for removing the white spaces the graphs in a
stack:

par(mar=c(2,2,1,1), mfrow = c(6,1))
mydates<-dates(1:20,origin=c(month = 1, day = 1, year = 1986))
plot(rnorm(20,0.1,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
plot(rnorm(20,0.2,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
plot(rnorm(20,0.3,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
plot(rnorm(20,0.5,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
plot(rnorm(20,0.7,0.1)~mydates, type="b",xlab="",ylim=c(0,1),xaxt = "n")
plot(rnorm(20,0.8,0.1)~mydates, type="b",xlab="",ylim=c(0,1) )

Thanx, Don
-- 
View this message in context: 
http://www.nabble.com/-R%3A--Removing-white-space-betwen-multiple-plots%2C-traditional-graphics-tf4119626.html#a11716176
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] BOA (Bayesian Output Analysis)

2007-07-20 Thread Lucke, Joseph F
>From the website:

"BOA is an R/S-PLUS program for carrying out convergence diagnostics and 
statistical and graphical analysis of Monte Carlo sampling output. It can be 
used as an output processor for the BUGS software or for any other program 
which produces sampling output."

See http://www.public-health.uiowa.edu/boa/



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marcus Vinicius
Sent: Thursday, July 19, 2007 7:11 PM
To: r-help@stat.math.ethz.ch
Subject: [R] BOA (Bayesian Output Analysis)

Dear all,
May anyone help me to use this package for the R software?
My procedure have been:


> dir()
[1] "line1.ind" "line1.out" "line1.txt" "line2.ind" "
line2.out" "line2.txt" "regressao.odc"


> boa.menu()

Bayesian Output Analysis Program (BOA)
Version 1.1.6 for i386, mingw32
Copyright (c) 2007 Brian J. Smith <[EMAIL PROTECTED]>

This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software 
Foundation; either version 2 of the License or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

For a copy of the GNU General Public License write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA, or 
visit their web site at http://www.gnu.org/copyleft/gpl.html

NOTE: if the event of a menu system crash, type "boa.menu(recover = TRUE)" to 
restart and recover your work.

BOA MAIN MENU
*

1: File >>
2: Data >>
3: Analysis >>
4: Plot >>
5: Options  >>
6: Window   >>

Seleção: 1

FILE MENU
=

1: Back
2: ---+
3: Import Data >> |
4: Save Session   |
5: Load Session   |
6: Exit BOA   |
7: ---+

Seleção: 3

IMPORT DATA MENU


1: Back
2: ---+
3: CODA Output Files  |
4: Flat ASCII Files   |
5: Data Matrix Objects|
6: View Format Specifications |
7: Options... |
8: ---+

Seleção: 3

Enter index filename prefix without the .ind extension [Working Directory:
""]
1: line1
Read 1 item

Enter output filename prefix without the .out extension [Default: "line1"]
1: line1
Read 1 item
*Warning: import failed
 Could not find '/line1.ind' or '/line1.out'.*

**

*What is happening??*

*Thanks a lot.*

*Marcus Vinicius*

[[alternative HTML version deleted]]

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


[R] set attribute method question

2007-07-20 Thread Tae-Hoon Chung
Hi, All;

Suppose I have a class 'dat' such that setClass('dat', representation 
(.version='character', x='numeric', y='numeric')).
If I want to make a method that changes the .version slot of 'dat'  
class in a way like set.version(d) <- '0.2' when d is an object of  
'dat' class, how can I do this? Thanks in advance.

Tae-Hoon Chung

Post-Doctoral Researcher
Computational Biology Division, TGEN
445 N 5th St. Phoenix, AZ 85004 USA
O: 1-602-343-8724
F: 1-602-343-8840



[[alternative HTML version deleted]]

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


Re: [R] main title on splited windows.

2007-07-20 Thread Gavin Simpson
On Fri, 2007-07-20 at 12:16 -0700, Milton Cezar Ribeiro wrote:
> Dear all,
> 
> How can I put a main title on the top of a windows?
> I would like put a title like "This is my for graphics" :-)

Create an outer margin to the plot and pop the title in there, e.g.:

## your data
v1<-sort(runif(50))
v2<-sin(v1*3.14)

## set up plotting region
## set oma to have a 2 line + a bit margin at the top, 
## 0 lines on other 3 sides
opar <- par(mfrow=c(2,2), oma = c(0, 0, 2.1, 0))
plot(v1,main="Sort V1")
plot(v2,main="Sin(V1)")
hist(v1,main="Histogram of V1")
boxplot(v1,v2, main="Box plot - v1 & v2")
## now add the title - use outer = TRUE to get it in correct place
## we use cex.main to increase the size a bit
title(main = "This is my for graphics", outer = TRUE, cex.main = 1.5)
## reset the plotting parameters
par(opar)

Is this what you wanted?

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


[R] main title on splited windows.

2007-07-20 Thread Milton Cezar Ribeiro
Dear all,

How can I put a main title on the top of a windows?
I would like put a title like "This is my for graphics" :-)

v1<-sort(runif(50))
v2<-sin(v1*3.14)

par(mfrow=c(2,2))
plot(v1,main="Sort V1")
plot(v2,main="Sin(V1)")
hist(v1,main="Histogram of V1")
boxplot(v1,v2, main="Box plot - v1 & v2")

Thanks in advance

Miltinho
Brazil


  Flickr agora em português. Você cria, todo mundo vê.
http://www.flickr.com.br/
[[alternative HTML version deleted]]

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


[R] tagging results of "apply"

2007-07-20 Thread Bernzweig, Bruce \(Consultant\)
In trying to get a better understanding of vectorization I wrote the
following code:

My objective is to take two sets of time series and calculate the
correlations for each combination of time series.

mat1 <- matrix(sample(1:500, 25), ncol = 5)
mat2 <- matrix(sample(501:1000, 25), ncol = 5)

Scenario 1:
apply(mat1, 1, function(x) cor(mat1, mat2[1,]))

Scenario 2:
apply(mat1, 1, function(x) cor(mat1, mat2))

Using scenario 1, (output below) I can see that correlations are
calculated for just the first row of mat2 against each individual row of
mat1.

Using scenario 2, (output below) I can see that correlations are
calculated for each row of mat2 against each individual row of mat1.  

Q1: The output of scenario2 consists of 25 rows of data.  Are the first
five rows mat1 against mat2[1,], the next five rows mat1 against
mat2[2,], ... last five rows mat1 against mat2[5,]?

Q2: I assign the output of scenario 2 to a new matrix

matC <- apply(mat1, 1, function(x) cor(mat1, mat2))

However, I need a way to identify each row in matC as a pairing of
rows from mat1 and mat2.  Is there a parameter I can add to apply to do
this?

Scenario 1:
> apply(mat1, 1, function(x) cor(mat1, mat2[1,]))
   [,1]   [,2]   [,3]   [,4]   [,5]
[1,] -0.4626122 -0.4626122 -0.4626122 -0.4626122 -0.4626122
[2,] -0.9031543 -0.9031543 -0.9031543 -0.9031543 -0.9031543
[3,]  0.0735273  0.0735273  0.0735273  0.0735273  0.0735273
[4,]  0.7401259  0.7401259  0.7401259  0.7401259  0.7401259
[5,] -0.4548582 -0.4548582 -0.4548582 -0.4548582 -0.4548582

Scenario 2:
> apply(mat1, 1, function(x) cor(mat1, mat2))
 [,1][,2][,3][,4][,5]
 [1,]  0.19394126  0.19394126  0.19394126  0.19394126  0.19394126
 [2,]  0.26402400  0.26402400  0.26402400  0.26402400  0.26402400
 [3,]  0.12923842  0.12923842  0.12923842  0.12923842  0.12923842
 [4,] -0.74549676 -0.74549676 -0.74549676 -0.74549676 -0.74549676
 [5,]  0.64074122  0.64074122  0.64074122  0.64074122  0.64074122
 [6,]  0.26931986  0.26931986  0.26931986  0.26931986  0.26931986
 [7,]  0.08527921  0.08527921  0.08527921  0.08527921  0.08527921
 [8,] -0.28034079 -0.28034079 -0.28034079 -0.28034079 -0.28034079
 [9,] -0.15251915 -0.15251915 -0.15251915 -0.15251915 -0.15251915
[10,]  0.19542415  0.19542415  0.19542415  0.19542415  0.19542415
[11,]  0.75107032  0.75107032  0.75107032  0.75107032  0.75107032
[12,]  0.53042767  0.53042767  0.53042767  0.53042767  0.53042767
[13,] -0.51163612 -0.51163612 -0.51163612 -0.51163612 -0.51163612
[14,] -0.44396048 -0.44396048 -0.44396048 -0.44396048 -0.44396048
[15,]  0.57018745  0.57018745  0.57018745  0.57018745  0.57018745
[16,]  0.70480284  0.70480284  0.70480284  0.70480284  0.70480284
[17,] -0.36674283 -0.36674283 -0.36674283 -0.36674283 -0.36674283
[18,] -0.81826607 -0.81826607 -0.81826607 -0.81826607 -0.81826607
[19,]  0.53145184  0.53145184  0.53145184  0.53145184  0.53145184
[20,]  0.24568385  0.24568385  0.24568385  0.24568385  0.24568385
[21,] -0.10610402 -0.10610402 -0.10610402 -0.10610402 -0.10610402
[22,] -0.78650748 -0.78650748 -0.78650748 -0.78650748 -0.78650748
[23,]  0.04269423  0.04269423  0.04269423  0.04269423  0.04269423
[24,]  0.14704698  0.14704698  0.14704698  0.14704698  0.14704698
[25,]  0.28340166  0.28340166  0.28340166  0.28340166  0.28340166



**
Please be aware that, notwithstanding the fact that the pers...{{dropped}}

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


[R] Simultaneous logit/probit models

2007-07-20 Thread Min Zou
Dear R Users,
 
I'm currently working on simultaneous multinomial models and wonder whether R 
has any package that can estimate such models. 
 
I've got a survey dataset that contains 2,000 individuals and one of the survey 
questions asked the respondents to chose two main reasons to work out of eight 
options (e.g., pay, pepople, to use abilities, etc.) . Now I'd like to model 
the responses using simultaneous logit/probit models. To my knowledge, LIMDEP 
(authored by Greene) can handle these models. As I know little about LIMDEP, I 
wonder if R has any package designed for these models. 
 
I have searched the R archive but haven't got any clue. Any suggestions?
 
Thanks,
 
Min
 
-
Sociology Dept.
Oxford University

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


[R] Unrecognising SEXP [C file compilation using .Call]

2007-07-20 Thread Diogo Alagador
Following an exercise suggestion I went to compile a C file, now with the .Call 
interface to R. The C file is:

 

#include 

#include 

SEXP getInt(SEXP myint, SEXP myintVar) {

 

  int Imyint, n; // declare an integer variable

  int *Pmyint;   // pointer to an integer vector

  PROTECT(myint = AS_INTEGER(myint));

   Imyint = INTEGER_POINTER(myint)[0];

   Pmyint = INTEGER_POINTER(myint);

   n = INTEGER_VALUE(myintVar);

   printf(" Printed from C: \n");

   printf(" Imyint: %d \n", Imyint);

   printf(" n: %d \n", n);

   printf(" Pmyint[0], Pmyint[1]: %d %d \n", 

 Pmyint[0], Pmyint[1]);

   UNPROTECT(1);

   return(R_NilValue);

}

 

Compiling with R CMD SHLIB or with any specific compiler to C/C++ gave an 
unrecognition of SEXP. 

What actually is SEXP? What is for? Why wasn't recognized?

 

Thanks again,

Diogo Andre' Alagador

[[alternative HTML version deleted]]

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


Re: [R] R CMD SHLIB problem [make: *** No rule to make target ]

2007-07-20 Thread Diogo Alagador
Prof. Ripley,
 
I will follow your suggestion about file spaces. However, as you said the path 
declared in the #include row is redundant, so I think the problem did not come 
through that. 
Meanwhile, after some tries I could compile the file. I just got more attention 
to case sensitiveness.
Sorry for the mess.
 
Cheers,
 
Diogo Andre' Alagador
 
 
Please do *not* use paths in your C code, especially those with spaces in. 

(The rw-FAQ did advise you not to install into a path with spaces in if 

you wanted to do development work.) The path is not needed for system 

include files (you used <>) and is likely the problem.

And please do not post multiple times.

On Fri, 20 Jul 2007, Diogo Alagador wrote:

> Hy all,

>

> I apologize for my ingenuity in regard to interfaces in R, but I do 

> need it for my work. In that respect I took a simple and small example 

> from the net (the "hello world", one) to interface R with C. I have a 

> Windows XP OS using R.2.5.0 and in that regard I have installed the 

> Perl and RTools files to my PC. I also wrote a proper path file, as 

> suggested.

>

> The C program is:

>

> #include 

> void hello(int *n){

> int i;

> for(i=0;i<*n;i++){

> Rprintf("Hello, world!\n");

> }

> }

You don't need R.h, but you do need to declare Rprintf, which is in 
. So a more legible version of a correct program would be

% cat holla.c

#include 

void hello(int *n)

{

int i;

for(i = 0; i < *n; i++)

Rprintf("Hello, world!\n");

}

which you could call by

> dyn.load("holla.dll")

> .C("hello", 10L)

(note the L).

 

> However when trying to compile the a C file in the command window:

>

> R CMD SHLIB holla.c

>

> I get the following message:

>

> make: *** No rule to make target `holla.d', needed by `makeMakedeps'. 

> Stop.

>

> Can somebody give me a hand on this,

> Thanks in advance

>

>

> Diogo André Alagador

>

> [[alternative HTML version deleted]]

>

>

-- 

Brian D. Ripley, [EMAIL PROTECTED]

Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ 
 

University of Oxford, Tel: +44 1865 272861 (self)

1 South Parks Road, +44 1865 272866 (PA)

Oxford OX1 3TG, UK Fax: +44 1865 272595


[[alternative HTML version deleted]]

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


[R] Free Online: Data Mining Intro for Beginners, Vendor-Neutral

2007-07-20 Thread Lisa Solomon
Intro to Data Mining for Absolute Beginners (no charge)

This one-hour webinar is a perfect place to start if you are new to data mining 
and have little-to-no background in statistics or machine learning.

-Dates: July 24, August 9, September 7

-Registration: http://salford.webex.com

-Future Webinars:  Multiple timezones and topics are planned.  Let us know if 
you would like to be notified as we schedule new webinar dates and topics. 

-Abstract:
In the one hour "Intro to Data Mining" webinar, we will discuss:
**Data basics: what kind of data is required for data mining and predictive 
analytics; In what format must the data be; what steps are necessary to prepare 
data appropriately
**What kinds of questions can we answer with data mining
**How data mining models work: the inputs, the outputs, and the nature of the 
predictive mechanism
**Evaluation criteria: how predictive models can be assessed and their value 
measured
**Specific background knowledge to prepare you to begin a data mining project.

Please circulate to colleagues who might benefit and do not hesitate to contact 
me if you have any questions.

Sincerely,
Lisa Solomon
[EMAIL PROTECTED]
Salford Systems, 4740 Murphy Canyon Rd. Ste 200, San Diego, Calif. 92123

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


Re: [R] SOS

2007-07-20 Thread John Kane
?round
x <- 1.2223
round(x,2)
[1] 1.22
--- Fabrice McShort <[EMAIL PROTECTED]>
wrote:

> Hi Julian,
>  
> Thank you very much. Please let me know how to get 2
> numbers after the decim.
>  
> Best regards,
>  
> Fabrice
> 
> 
> 
> > Date: Fri, 20 Jul 2007 08:15:42 -0700> From:
> [EMAIL PROTECTED]> To:
> [EMAIL PROTECTED]> CC:
> r-help@stat.math.ethz.ch> Subject: Re: [R] SOS> >
> Multiply by 100? Add> > R=R*100> > Fabrice McShort
> wrote:> > Dear all, I am a new user of R. I would
> like to know how to get fund's returns in percentage
> (%). For example, I use: R <-
> ts(read.xls("FundData"), frequency = 12, start =
> c(1996, 1)) Whith this program, the returns are like
> 0.0152699. But, I would like to have 1.52%. Please
> advise me about the function. Thanks! Fabrice> >
>
_>
> >> > [[trailing spam removed]]> >> > [[alternative
> HTML version deleted]]> >> >
> __> >
> R-help@stat.math.ethz.ch mailing list> >
> https://stat.ethz.ch/mailman/listinfo/r-help> >
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html> > and
> provide commented, minimal, self-contained,
> reproducible code.> >> > > > !
>  -- > Julian M. Burgos> > Fisheries Acoustics
> Research Lab> School of Aquatic and Fishery Science>
> University of Washington> > 1122 NE Boat Street>
> Seattle, WA 98105 > > Phone: 206-221-6864> > 
>
_
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

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


Re: [R] SOS

2007-07-20 Thread jim holtman
You can use sprintf:

> x <- runif(5)
> x
[1] 0.89838968 0.94467527 0.66079779 0.62911404 0.06178627
> cat(sprintf("%.2f%% ", x * 100))
89.84%  94.47%  66.08%  62.91%  6.18% >


On 7/20/07, Fabrice McShort <[EMAIL PROTECTED]> wrote:
> Hi Julian,
>
> Thank you very much. Please let me know how to get 2 numbers after the decim.
>
> Best regards,
>
> Fabrice
>
>
>
> > Date: Fri, 20 Jul 2007 08:15:42 -0700> From: [EMAIL PROTECTED]> To: [EMAIL 
> > PROTECTED]> CC: r-help@stat.math.ethz.ch> Subject: Re: [R] SOS> > Multiply 
> > by 100? Add> > R=R*100> > Fabrice McShort wrote:> > Dear all, I am a new 
> > user of R. I would like to know how to get fund's returns in percentage 
> > (%). For example, I use: R <- ts(read.xls("FundData"), frequency = 12, 
> > start = c(1996, 1)) Whith this program, the returns are like 0.0152699. 
> > But, I would like to have 1.52%. Please advise me about the function. 
> > Thanks! Fabrice> > 
> > _> >> > 
> > [[trailing spam removed]]> >> > [[alternative HTML version deleted]]> >> > 
> > __> > R-help@stat.math.ethz.ch 
> > mailing list> > https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do 
> > read the posting guide http://www.R-project.org/posting-guide.html> > and 
> > provide commented, minimal, self-contained, reproducible code.> >> > > !
 > !
>  -- > Julian M. Burgos> > Fisheries Acoustics Research Lab> School of Aquatic 
> and Fishery Science> University of Washington> > 1122 NE Boat Street> 
> Seattle, WA 98105 > > Phone: 206-221-6864> >
> _
>
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

What is the problem you are trying to solve?

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


Re: [R] can I paste 'newline'?

2007-07-20 Thread runner

Thanks for replied from you all. I 've got better understanding of what
cat/paste does. what I am trying is to make FASTA format data. i.e. for each
line starting with '>', add '\n' at both ends while get rid of all '\n's for
the rest. 

e.g. this is original messy data, I need to remove newlines within the text
bodies:

>no1
this is the first entry ('\n')
but here is extra newline('\n')
and also here that we need to remove.
>no2
this is the second entry, which is fine in format.
>no3


Of course, perl would be good at this, but I want to try with R for the
other reason.
thanks.



Duncan Murdoch-2 wrote:
> 
> On 19/07/2007 7:41 PM, runner wrote:
>> It is ok to bury a reg expression '\n' when using 'cat', but not 'paste'. 
>> e.g.
>> 
>> cat ('I need to move on to a new line', '\n', 'at here') # change line!
>> paste ('I need to move on to a new line', '\n', 'at here') # '\n' is just
>> a
>> character as it is.
>> 
>> Is there a way around pasting '\n' ? Thanks a lot.
> 
> What do you want to get?  Do you want a two element vector?  Then use 
> c().  Do you want a one element vector that prints on two lines?  Use 
> either form, they both work (but you need to use cat() to do the display).
> 
>  > x <- paste ('I need to move on to a new line', '\n', 'at here')
>  > cat(x)
> I need to move on to a new line
>   at here>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/can-I-paste-%27newline%27--tf4114350.html#a11712720
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] automatically jpeg output

2007-07-20 Thread Ding, Rebecca

Hi R users,

Thanks for the jpeg() function. I do find it. However when I used
par(mfrow=c(6,7)), which can put all my histograms in one page, R gave
me the error message:
Error in plot.new() : figure margins too large. The mfrow=c(6,7)statment
was fine in postscript("AYA_ELA.ps"). 

Is there a way to solve that problem?

Thanks.

-Original Message-
From: Benilton Carvalho [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 20, 2007 11:45 AM
To: Ding, Rebecca
Cc: R-help@stat.math.ethz.ch
Subject: Re: [R] automatically jpeg output

jpeg(...) ##if you have X11
bitmap(..., type="jpeg") ##otherwise

b

On Jul 20, 2007, at 11:34 AM, Ding, Rebecca wrote:

> Dear R users,
>
> I used R to draw many histograms and I would like to automatically 
> save them into a jpeg file. I tried the following code since I know 
> .ps file could be saved like this way:
>
> postscript("AYA_ELA.jpeg",horizontal=F,onefile=T)
> ..#some funtions inside here
> dev.off()
>
> There was a jpeg file, however, there were no pictures inside. Any 
> suggestion?
>
> Thanks.
>
> Rebecca

--
This e-mail and any files transmitted with it may contain privileged or 
confidential information.
It is solely for use by the individual for whom it is intended, even if 
addressed incorrectly.
If you received this e-mail in error, please notify the sender; do not 
disclose, copy, distribute,
or take any action in reliance on the contents of this information; and delete 
it from
your system. Any other use of this e-mail is prohibited.

Thank you for your compliance.

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


Re: [R] exclude1 in summary.formula from Hmisc

2007-07-20 Thread david dav
Here is a peace of the data and code :

sex <-c(2,2,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,1,2,2)
AGN <-
c("C","C","C","C","C","A","A","C","B","B","C","C","C","C","C","C","B","B","C","C","C")
X <- c(2,2,2,2,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,2,2)

varqual <- data.frame(sex,AGN,X)

desqual <- summary.formula(varqual$X ~.,  data = subset( varqual, select =
-X), method = "reverse",  overall = T, test = T, long = T, exclude1 = F)

desqual doesn't show the results for sex ==1 as it is redundant.
I also tried long =T wich didn't change anything here.

Bonus question if I may :
This function is a little bit complex for me and  I couldn't figure out how
to get either Yates' continuity correction or Fisher Test instead of
Chisquare. Does it ask a lot of program coding ?

Regards.

David

[[alternative HTML version deleted]]

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


Re: [R] exclude1 in summary.formula from Hmisc

2007-07-20 Thread Frank E Harrell Jr
david dav wrote:
> Here is a peace of the data and code :
> 
> sex <-c(2,2,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,1,2,2)
> AGN <- 
> c("C","C","C","C","C","A","A","C","B","B","C","C","C","C","C","C","B","B","C","C","C")
>  
> 
> X <- c(2,2,2,2,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,2,2)
> 
> varqual <- data.frame(sex,AGN,X)
> 
> desqual <- summary.formula(varqual$X ~.,  data = subset( varqual, select 
> = -X), method = "reverse",  overall = T, test = T, long = T, exclude1 = F)
> 
> desqual doesn't show the results for sex ==1 as it is redundant.
> I also tried long =T wich didn't change anything here.

Oh yes.  exclude1 is not an argument to summary.formula but is an 
argument to the print, plot, and latex methods.  So do print(desqual, 
exclude1=FALSE, long=TRUE).  Thanks for the reproducible example.

Note that you say summary( ) and don't need to type out summary.formula

> 
> Bonus question if I may :
> This function is a little bit complex for me and  I couldn't figure out 
> how to get either Yates' continuity correction or Fisher Test instead of 
> Chisquare. Does it ask a lot of program coding ?

Neither of those is recommended so they are not automatically supported. 
  But users can add their own test functions - see the help file for the 
catTest argument to summary.formula.  Fisher's test is conservative. 
The Yates' continuity correction tries to mimic the conservatism of 
Fisher's test.  I don't like to get larger P-values when I can avoid it. 
  And the recommendations about worrying about the chi-square 
approximation when some cell sizes are small are a bit overdone.  Better 
might be to use the likelihood ratio tests, and many other tests are 
available.

Frank

> 
> Regards.
> 
> David


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

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


Re: [R] Graphical Parameters

2007-07-20 Thread Julian Burgos
Hi Amna,

To have more control on the grid of your plot use the grid function.  
Remove the tck argument from your plot call and add, as following:

plot(Year,Dir,ylab="Annual Maximum Daily Rainfall 
(mm)",cex.lab=1.3,type="o",lab=c(20,20,25),mgp=c(2.5,1,0),asp=1)
grid()

See ?grid to see how to customize the grid lines.

Julian


amna khan wrote:
> Hi Sir
>
> There is a difficulty in creating a comprehensive graph.
> Suppose I have a time series from 1967 to 2006. I have used the 
> following R
> code for creating a graph.
>
>> plot(Year,Dir,ylab="Annual Maximum Daily Rainfall (mm)",cex.lab=1.3
> ,type="o",lab=c(20,20,25),mgp=c(2.5,1,0),tck=1)
> The graph is attached with this email.
> Sir I want the grid lines as dashed lines. Second thing to be asked is 
> that
> the grid lines should make squared blocks not rectangles. Moreover the
> boundries are not in good format.
>
> Sir I request you to please guide in this regards.
>
> Thank You.
>
>
>
>
> 
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   

-- 
Julian M. Burgos

Fisheries Acoustics Research Lab
School of Aquatic and Fishery Science
University of Washington

1122 NE Boat Street
Seattle, WA  98105 

Phone: 206-221-6864

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


Re: [R] mtext formatting

2007-07-20 Thread Prof Brian Ripley
On Fri, 20 Jul 2007, Todd Remund wrote:

> I am trying to create a formatted title using mtext.  Using the format
> function I define the spacing for a specific part of the text then paste
> these together, when I put this in mtext it does not keep the spacing I
> defined. Here is an example.
>
> x <- format(paste("X=", a), width=8)
> y <- format("F=G(x)", width=8)
>
> mtext(text=paste(x, y, sep=""), col="red", font=1)
>
> Does anyone have any suggestions to get the mtext to follow the formatting
> as it does with cat()?

It does for me: you are outputting in a proportionally spaced font which 
may be what is confusing you.  Try family = "mono" to check.

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

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


Re: [R] Dataframe of factors transform speed?

2007-07-20 Thread Charles C. Berry
On Thu, 19 Jul 2007, Latchezar Dimitrov wrote:

> Hello,
>
> This is a speed question. I have a dataframe genoT:
>
>> dim(genoT)
> [1]   1002 238304

It looks like these are all numeric originally. Handling these as a
vector or matrix will speed things up a bit. You can then stitch
together a data.frame:

# simulate: 
#   genoT.names <- scan('data.file, what='a', nlines=1,  ) 
#   genoT <- scan('data.file',skip=1)
#
>
> genoT <- sample(0:2, 24*1002, repl=T)
> t1 <- proc.time()
> genoT <- factor(genoT,0:2,c("AA","AB","BB"))
> dim(genoT) <- c(1002,24)
> genoT.list <- lapply(1:24, function(x) genoT[,x])
> # simulate: names(genoT.list) <- genoT.names :
> names(genoT.list) <- make.names(1:24)
> class(genoT.list) <- "data.frame"
> row.names(genoT.list) <- 1:1002
> proc.time()-t1
user  system elapsed
  20.978   2.036  49.714
>

Most of the _elapsed_ time is due to lags in copy-and-paste-ing in the 
commands.

HTH,

Chuck
>
>> str(genoT)
> 'data.frame':   1002 obs. of  238304 variables:
> $ SNP_A.4261647: Factor w/ 3 levels "0","1","2": 3 3 3 3 3 3 3 3 3 3
> ...
> $ SNP_A.4261610: Factor w/ 3 levels "0","1","2": 1 1 3 3 1 1 1 2 2 2
> ...
> $ SNP_A.4261601: Factor w/ 3 levels "0","1","2": 1 1 1 1 1 1 1 1 1 1
> ...
> $ SNP_A.4261704: Factor w/ 3 levels "0","1","2": 3 3 3 3 3 3 3 3 3 3
> ...
> $ SNP_A.4261563: Factor w/ 3 levels "0","1","2": 3 1 2 1 2 3 2 3 3 1
> ...
> $ SNP_A.4261554: Factor w/ 3 levels "0","1","2": 1 1 NA 1 NA 2 1 1 2 1
> ...
> $ SNP_A.4261666: Factor w/ 3 levels "0","1","2": 1 1 2 1 1 1 1 1 1 2
> ...
> $ SNP_A.4261634: Factor w/ 3 levels "0","1","2": 3 3 2 3 3 3 3 3 3 2
> ...
> $ SNP_A.4261656: Factor w/ 3 levels "0","1","2": 1 1 2 1 1 1 1 1 1 2
> ...
> $ SNP_A.4261637: Factor w/ 3 levels "0","1","2": 1 3 2 3 2 1 2 1 1 3
> ...
> $ SNP_A.4261597: Factor w/ 3 levels "AA","AB","BB": 2 2 3 3 3 2 1 2 2 3
> ...
> $ SNP_A.4261659: Factor w/ 3 levels "AA","AB","BB": 3 3 3 3 3 3 3 3 3 3
> ...
> $ SNP_A.4261594: Factor w/ 3 levels "AA","AB","BB": 2 2 2 1 1 1 2 2 2 2
> ...
> $ SNP_A.4261698: Factor w/ 2 levels "AA","AB": 1 1 1 1 1 1 1 1 1 1 ...
> $ SNP_A.4261538: Factor w/ 3 levels "AA","AB","BB": 2 3 2 2 3 2 2 1 1 2
> ...
> $ SNP_A.4261621: Factor w/ 3 levels "AA","AB","BB": 1 1 1 1 1 1 1 1 1 1
> ...
> $ SNP_A.4261553: Factor w/ 3 levels "AA","AB","BB": 1 1 2 1 1 1 1 1 1 1
> ...
> $ SNP_A.4261528: Factor w/ 2 levels "AA","AB": 1 1 1 1 1 1 1 1 1 1 ...
> $ SNP_A.4261579: Factor w/ 3 levels "AA","AB","BB": 1 1 1 1 1 2 1 1 1 2
> ...
> $ SNP_A.4261513: Factor w/ 3 levels "AA","AB","BB": 2 1 2 2 2 NA 1 NA 2
> 1 ...
> $ SNP_A.4261532: Factor w/ 3 levels "AA","AB","BB": 1 2 2 1 1 1 3 1 1 1
> ...
> $ SNP_A.4261600: Factor w/ 2 levels "AB","BB": 2 2 2 2 2 2 2 2 2 2 ...
> $ SNP_A.4261706: Factor w/ 2 levels "AA","BB": 1 1 1 1 1 1 1 1 1 1 ...
> $ SNP_A.4261575: Factor w/ 3 levels "AA","AB","BB": 1 1 1 1 1 1 1 2 2 1
> ...
>
> Its columns are factors with different number of levels (from 1 to 3 -
> that's what I got from read.table, i.e., it dropped missing levels). I
> want to convert it to uniform factors with 3 levels. The 1st 10 rows
> above show already converted columns and the rest are not yet converted.
> Here's my attempt wich is a complete failure as speed:
>
>> system.time(
> + for(j in 1:(10 )){ #-- this is to try 1st 10 cols and
> measure the time, it otherwise is ncol(genoT) instead of 10
>
> +gt<-genoT[[j]]  #-- this is to avoid 2D indices
> +for(l in 1:length([EMAIL PROTECTED])){
> +  levels(gt)[l] <- switch([EMAIL PROTECTED],AA="0",AB="1",BB="2")
> #-- convert levels to "0","1", or "2"
> +  genoT[[j]]<-factor(gt,levels=0:2)   #-- make a 3-level factor
> and put it back
> +}
> + }
> + )
> [1] 785.085   4.358 789.454   0.000   0.000
>
> 789s for 10 columns only!
>
> To me it seems like replacing 10 x 3 levels and then making a factor of
> 1002 element vector x 10 is a "negligible" amount of operations needed.
>
> So, what's wrong with me? Any idea how to accelerate significantly the
> transformation or (to go to the very beginning) to make read.table use a
> fixed set of levels ("AA","AB", and "BB") and not to drop any (missing)
> level?
>
> R-devel_2006-08-26, Sun Solaris 10 OS - x86 64-bit
>
> The machine is with 32G RAM and AMD Opteron 285 (2.? GHz) so it's not
> it.
>
> Thank you very much for the help,
>
> Latchezar Dimitrov,
> Analyst/Programmer IV,
> Wake Forest University School of Medicine,
> Winston-Salem, North Carolina, USA
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http

Re: [R] R CMD SHLIB problem [make: *** No rule to make target ]

2007-07-20 Thread Prof Brian Ripley
Please do *not* use paths in your C code, especially those with spaces in. 
(The rw-FAQ did advise you not to install into a path with spaces in if 
you wanted to do development work.)  The path is not needed for system 
include files (you used <>) and is likely the problem.


And please do not post multiple times.

On Fri, 20 Jul 2007, Diogo Alagador wrote:


Hy all,

I apologize for my ingenuity in regard to interfaces in R, but I do need it for my work. 
In that respect I took a simple and small example from the net (the "hello 
world", one) to interface R with C.
I have a Windows XP OS using R.2.5.0 and in that regard I have installed the 
Perl and RTools files to my PC. I also wrote a proper path file, as suggested.

The C program is:

#include 
void hello(int *n){
int i;
for(i=0;i<*n;i++){
Rprintf("Hello, world!\n");
}
}


You don't need R.h, but you do need to declare Rprintf, which is in
.  So a more legible version of a correct program would be

% cat holla.c

#include 

void hello(int *n)
{
int i;
for(i = 0; i < *n; i++)
 Rprintf("Hello, world!\n");
}

which you could call by


dyn.load("holla.dll")
.C("hello", 10L)


(note the L).



However when trying to compile the a C file in the command window:

R CMD SHLIB holla.c

I get the following message:

make: *** No rule to make target `holla.d', needed by `makeMakedeps'.  Stop.

Can somebody give me a hand on this,
Thanks in advance


Diogo André Alagador

[[alternative HTML version deleted]]




--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] GEE code

2007-07-20 Thread Thomas Lumley
On Fri, 20 Jul 2007, Dimitris Rizopoulos wrote:

> from your description I think you need a random-effects model.

Since he specifically said "fixed effects" I would have assumed from the 
description that he wanted a fixed-effects model.

>Since
> you assume normality the parameter estimates from a random-effects
> model (in your case `GDP.log2') have a marginal interpretation (in
> fact they have both conditional and marginal interpretation).

But they still aren't the fixed effects estimates, and they behave 
quite differently under model misspecification (and under confounding).

A fixed effects linear model with GEE just needs the formula
   ineq~GDP.log2+country.
to specify an indicator variable for each country.

If he had a logistic regression model things would be more complicated, 
but for a linear or log-linear model it is just a matter of adding 
predictors.

Now, I might well use a linear mixed model in this context, but he did 
fairly clearly indicate that wasn't he was looking for.

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

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


Re: [R] automatically jpeg output

2007-07-20 Thread Ted Harding
On 20-Jul-07 15:34:00, Ding, Rebecca wrote:
> Dear R users,
> 
> I used R to draw many histograms and I would like to automatically save
> them into a jpeg file. I tried the following code since I know .ps file
> could be saved like this way:
> 
> postscript("AYA_ELA.jpeg",horizontal=F,onefile=T)
> ..#some funtions inside here
> dev.off()
> 
> There was a jpeg file, however, there is no pictures inside. Any
> suggestion? 
> 
> Thanks.
> 
> Rebecca

If your "some functions inside here" do draw histograms, then
there will indeed be pictures inside, but they will be in PostScript,
since that is what is created when you use the postscript() device.
The fact that you used ".jpeg" in the fileneam has nothing to
do with it -- it will simply store the output, as PostScript,
in the file whose name you give to it. It trusts you.

You would have seen the PostScript pictures if you had used a
PostScript viewer which reacts to the content of the files,
whereas presumably your system expects a file whose name ends
in ".jpeg" or ".jpg" to be a JPEG file; and therefore will
use the wrong interpreter and fail to recognise the picture
(as you have just proved).

If you want to create JPEG files in a similar way, use the
jpeg() function -- read ?jpeg for details.

Best wishes,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Jul-07   Time: 17:07:20
-- XFMail --

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


[R] mtext formatting

2007-07-20 Thread Todd Remund
I am trying to create a formatted title using mtext.  Using the format 
function I define the spacing for a specific part of the text then paste 
these together, when I put this in mtext it does not keep the spacing I 
defined. Here is an example.

x <- format(paste("X=", a), width=8)
y <- format("F=G(x)", width=8)

mtext(text=paste(x, y, sep=""), col="red", font=1)

Does anyone have any suggestions to get the mtext to follow the formatting 
as it does with cat()?

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


Re: [R] automatically jpeg output

2007-07-20 Thread Benilton Carvalho
jpeg(...) ##if you have X11
bitmap(..., type="jpeg") ##otherwise

b

On Jul 20, 2007, at 11:34 AM, Ding, Rebecca wrote:

> Dear R users,
>
> I used R to draw many histograms and I would like to automatically  
> save
> them into a jpeg file. I tried the following code since I know .ps  
> file
> could be saved like this way:
>
> postscript("AYA_ELA.jpeg",horizontal=F,onefile=T)
> ..#some funtions inside here
> dev.off()
>
> There was a jpeg file, however, there is no pictures inside. Any
> suggestion?
>
> Thanks.
>
> Rebecca

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


[R] SOS

2007-07-20 Thread Fabrice McShort
Hi Julian,
 
Thank you very much. Please let me know how to get 2 numbers after the decim.
 
Best regards,
 
Fabrice



> Date: Fri, 20 Jul 2007 08:15:42 -0700> From: [EMAIL PROTECTED]> To: [EMAIL 
> PROTECTED]> CC: r-help@stat.math.ethz.ch> Subject: Re: [R] SOS> > Multiply by 
> 100? Add> > R=R*100> > Fabrice McShort wrote:> > Dear all, I am a new user of 
> R. I would like to know how to get fund's returns in percentage (%). For 
> example, I use: R <- ts(read.xls("FundData"), frequency = 12, start = c(1996, 
> 1)) Whith this program, the returns are like 0.0152699. But, I would like to 
> have 1.52%. Please advise me about the function. Thanks! Fabrice> > 
> _> >> > 
> [[trailing spam removed]]> >> > [[alternative HTML version deleted]]> >> > 
> __> > R-help@stat.math.ethz.ch 
> mailing list> > https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do 
> read the posting guide http://www.R-project.org/posting-guide.html> > and 
> provide commented, minimal, self-contained, reproducible code.> >> > > > !
 -- > Julian M. Burgos> > Fisheries Acoustics Research Lab> School of Aquatic 
and Fishery Science> University of Washington> > 1122 NE Boat Street> Seattle, 
WA 98105 > > Phone: 206-221-6864> > 
_



[[alternative HTML version deleted]]

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


[R] automatically jpeg output

2007-07-20 Thread Ding, Rebecca
Dear R users,

I used R to draw many histograms and I would like to automatically save
them into a jpeg file. I tried the following code since I know .ps file
could be saved like this way:

postscript("AYA_ELA.jpeg",horizontal=F,onefile=T)
..#some funtions inside here
dev.off()

There was a jpeg file, however, there is no pictures inside. Any
suggestion? 

Thanks.

Rebecca 


--
This e-mail and any files transmitted with it may contain privileged or 
confidential information.
It is solely for use by the individual for whom it is intended, even if 
addressed incorrectly.
If you received this e-mail in error, please notify the sender; do not 
disclose, copy, distribute,
or take any action in reliance on the contents of this information; and delete 
it from
your system. Any other use of this e-mail is prohibited.

Thank you for your compliance.
--

[[alternative HTML version deleted]]

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


Re: [R] SOS

2007-07-20 Thread Julian Burgos
Multiply by 100?   Add

R=R*100

Fabrice McShort wrote:
> Dear all, I am a new user of R. I would like to know how to get fund's 
> returns in percentage (%). For example, I use: R <- ts(read.xls("FundData"), 
> frequency = 12, start = c(1996, 1)) Whith this program, the returns are like 
> 0.0152699. But, I would like to have 1.52%. Please advise me about the 
> function. Thanks! Fabrice
> _
>
> [[trailing spam removed]]
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>   

-- 
Julian M. Burgos

Fisheries Acoustics Research Lab
School of Aquatic and Fishery Science
University of Washington

1122 NE Boat Street
Seattle, WA  98105 

Phone: 206-221-6864

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


Re: [R] presence/absence matrix

2007-07-20 Thread Ted Harding
On 20-Jul-07 14:16:39, [EMAIL PROTECTED] wrote:
> I have a table such that:
> 
> sample #   species
> 1a
> 1b
> 2a   
> 2c
> 3b 
> 
> and i would like to build a matrix with species names (i.e. a b and c) 
> as field names and samples (i.e. 1,2 and 3) as row names
> and 1/0 as inner values
> such as:
> a   b   c
> 1   1   1   0
> 2   1   0   1
> 3   0   1   0
> 
> I am currently using Rcmdr package for managing datasets but need a 
> function about I tried to use stack function but only with worst
> results

The following generates the sort of thing you show above:

## Identities of possible species and samples
  Species<-c("a","b","c","d")
  Samples<-c(1,2,3,4,5,6)

## Generate a set of samples and corresponding species:
  species<-sample(Species,20,replace=TRUE)
  samples=sample(Samples,20,replace=TRUE)
## Have a look:
 cbind(samples,species)
  samples species
 [1,] "5" "c"
 [2,] "2" "c"
 [3,] "4" "a"
 [4,] "5" "b"
 [5,] "5" "d"
 [6,] "1" "d"
 [7,] "2" "b"
 [8,] "2" "b"
 [9,] "3" "b"
[10,] "2" "d"
[11,] "4" "d"
[12,] "1" "b"
[13,] "3" "b"
[14,] "2" "c"
[15,] "2" "d"
[16,] "6" "b"
[17,] "5" "a"
[18,] "4" "a"
[19,] "2" "b"
[20,] "5" "a"

## Now generate a table:
  T<-table(samples,species)
  T
  species
  samples a b c d
1 0 1 0 1
2 0 3 2 2
3 0 2 0 0
4 2 0 0 1
5 2 1 1 1
6 0 1 0 0

Now this is a "table" structure, and also gives counts of
occurrences and not merely presence/absence. So we need to
get these out as a matrix.

  U<-as.matrix(T)
  U
  species
  samples a b c d
1 0 1 0 1
2 0 3 2 2
3 0 2 0 0
4 2 0 0 1
5 2 1 1 1
6 0 1 0 0

  U<-1*(U>0)
  U
  species
  samples a b c d
1 0 1 0 1
2 0 1 1 1
3 0 1 0 0
4 1 0 0 1
5 1 1 1 1
6 0 1 0 0

Is that what you want?
Best wishes,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Jul-07   Time: 16:14:14
-- XFMail --

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


Re: [R] cv.glm error function

2007-07-20 Thread Prof Brian Ripley
On Fri, 20 Jul 2007, Rachel Davidson wrote:

> I have a couple quick questions about the use of cv.glm for
> cross-validation.
>
> 1. If we have a Poisson GLM with counts Y~Poisson(mu) and
> ln(mu)=beta0+beta1*x1+..., is the prediction error (delta) that is output
> from cv.glm provided in terms of the counts (y) or the (mu)?

It is of prediction error as measured by the cost function.  Since y and 
mu are on the same scale I wonder if you meant was it on log scale?  If 
so, it is on the response scale.

The default cost function is probably not appropriate for a log-linear 
model.

> 2. Can cv.glm be used for negative binomial models fit using glm.nb? It
> appears to work, but since NB models aren't strictly GLM's I wanted to
> check.

NB models are strictly glms, but glm.nb estimates parameters that glm does 
not, so no.

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

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

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


[R] SOS

2007-07-20 Thread Fabrice McShort
Dear all, I am a new user of R. I would like to know how to get fund's returns 
in percentage (%). For example, I use: R <- ts(read.xls("FundData"), frequency 
= 12, start = c(1996, 1)) Whith this program, the returns are like 0.0152699. 
But, I would like to have 1.52%. Please advise me about the function. Thanks! 
Fabrice
_

[[trailing spam removed]]

[[alternative HTML version deleted]]

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


Re: [R] presence/absence matrix

2007-07-20 Thread Stefano Calza
What about

table(sample,species)

Stefano


On Fri, Jul 20, 2007 at 04:16:39PM +0200, [EMAIL PROTECTED] wrote:
I have a table such that:

sample #   species
1a
1b
2a   
2c
3b 

and i would like to build a matrix with species names (i.e. a b and 
c) 
as field names and samples (i.e. 1,2 and 3) as row names
and 1/0 as inner values
such as:
a   b   c
1   1   1   0
2   1   0   1
3   0   1   0

I am currently using Rcmdr package for managing datasets but need a 
function about I tried to use stack function but only with worst 
results

Thanks
Duccio

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

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


Re: [R] presence/absence matrix

2007-07-20 Thread Francisco J. Zagmutt
See ?table  i.e.

 > x
   sample # species
11   a
21   b
32   a
42   c
53   b

 > table(x)
 species
sample # a b c
1 1 1 0
2 1 0 1
3 0 1 0

Regards,

Francisco

Francisco J. Zagmutt


[EMAIL PROTECTED] wrote:
> I have a table such that:
> 
> sample #   species
> 1a
> 1b
> 2a   
> 2c
> 3b 
> 
> and i would like to build a matrix with species names (i.e. a b and c) 
> as field names and samples (i.e. 1,2 and 3) as row names
> and 1/0 as inner values
> such as:
> a   b   c
> 1   1   1   0
> 2   1   0   1
> 3   0   1   0
> 
> I am currently using Rcmdr package for managing datasets but need a 
> function about I tried to use stack function but only with worst results
> 
> Thanks
> Duccio
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] R CMD SHLIB problem [make: *** No rule to make target ]

2007-07-20 Thread Diogo Alagador
Hy all,
 
I apologize for my ingenuity in regard to interfaces in R, but I do need it for 
my work. In that respect I took a simple and small example from the net (the 
"hello world", one) to interface R with C.
I have a Windows XP OS using R.2.5.0 and in that regard I have installed the 
Perl and RTools files to my PC. I also wrote a proper path file, as suggested. 
 
The C program is:
 
#include 
void hello(int *n){
int i;
for(i=0;i<*n;i++){
 Rprintf("Hello, world!\n");
}
}
 
However when trying to compile the a C file in the command window:
 
R CMD SHLIB holla.c
 
I get the following message:

make: *** No rule to make target `holla.d', needed by `makeMakedeps'.  Stop.
 
Can somebody give me a hand on this,
Thanks in advance
 
 
Diogo André Alagador

[[alternative HTML version deleted]]

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


[R] presence/absence matrix

2007-07-20 Thread [EMAIL PROTECTED]
I have a table such that:

sample #   species
1a
1b
2a   
2c
3b 

and i would like to build a matrix with species names (i.e. a b and c) 
as field names and samples (i.e. 1,2 and 3) as row names
and 1/0 as inner values
such as:
a   b   c
1   1   1   0
2   1   0   1
3   0   1   0

I am currently using Rcmdr package for managing datasets but need a 
function about I tried to use stack function but only with worst results

Thanks
Duccio

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


[R] Graphical Parameters

2007-07-20 Thread amna khan

Hi Sir

There is a difficulty in creating a comprehensive graph.
Suppose I have a time series from 1967 to 2006. I have used the following R
code for creating a graph.


plot(Year,Dir,ylab="Annual Maximum Daily Rainfall (mm)",cex.lab=1.3

,type="o",lab=c(20,20,25),mgp=c(2.5,1,0),tck=1)
The graph is attached with this email.
Sir I want the grid lines as dashed lines. Second thing to be asked is that
the grid lines should make squared blocks not rectangles. Moreover the
boundries are not in good format.

Sir I request you to please guide in this regards.

Thank You.




--
AMINA SHAHZADI
Department of Statistics
GC University Lahore, Pakistan.
Email:
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R CMD SHLIB problem [make: *** No rule to make target ]

2007-07-20 Thread Diogo Alagador
Hy all,
 
I apologize for my ingenuity in regard to interfaces in R, but I do need it for 
my work. In that respect I took a simple and small example from the net (the 
"hello world", one) to interface R with C.
I have a Windows XP OS using R.2.5.0 and in that regard I have installed the 
Perl and RTools files to my PC. I also wrote a proper path file, as suggested. 
 
The C program is:
 
#include 
void hello(int *n){
int i;
for(i=0;i<*n;i++){
 Rprintf("Hello, world!\n");
}
}
 
However when trying to compile the a C file in the command window:
 
R CMD SHLIB holla.c
 
I get the following message:

make: *** No rule to make target `holla.d', needed by `makeMakedeps'.  Stop.
 
Can somebody give me a hand on this,
Thanks in advance
 
 
Diogo André Alagador

[[alternative HTML version deleted]]

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


[R] Huh?

2007-07-20 Thread Susan Parham

   Vipxiltxyagdohhrfhxrhra $1.79 Cnkwqaffsuaialepqyemfris = $3.93

and many other items for 10% of the price.
[1]Click to visit the shop 
 _

References

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


Re: [R] (R) Using arguments for the empirical cumulative distribution function

2007-07-20 Thread AA
Hi Tobias,
Maybe I do not understand the issue here but the following line adds main 
and xlab
plot(F10,verticals = TRUE, do.p = TRUE, lwd = 3, main = "myTitle", xlab = 
"myXlab")
You could find all this in the introduction manual. see r-project.org in the 
documentation section.
Good luck
AA.
- Original Message - 
From: "squall44" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, July 19, 2007 10:13 AM
Subject: [R] (R) Using arguments for the empirical cumulative distribution 
function


>
> Hi,
>
> I have just started using R. Now I have the following problem:
>
> I want to create an Empirical Cumulative Distribution Function and I only
> came so far:
>
> F10 <- ecdf(x)
> plot(F10, verticals= TRUE, do.p = TRUE, lwd=3)
> x=c(1.6,1.8,2.4,2.7,2.9,3.3,3.4,3.4,4,5.2)
>
> Now I'd like to use arguments such as xlabs and main but I don't know how 
> to
> integrate them.
>
> I hope someone can help me, I am really stuck!
>
> -- 
> View this message in context: 
> http://www.nabble.com/%28R%29-Using-arguments-for-the-empirical-cumulative-distribution-function-tf4111355.html#a11690150
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] how do I draw such a barplot?

2007-07-20 Thread Donatas G.
I did not have much success with ggplot2 and reshape libraries, so finally I 
managed to work out the graph in a rather complicated way. The only thing I 
cannot figure out is, how do I place the legend outside the barplot column 
area?

attach(tolerancija.data)
ateist = table(G09_01)
dvasin = table(G09_02)
gamtos = table(G09_03)
kr_klm = table(G09_04)
musulm = table(G09_05)
na_kri = table(G09_06)
pagoni = table(G09_07)
satani = table(G09_08)
rytų_k = table(G09_08)
satani = table(G09_09)
tradic = table(G09_10)
eilutes=cbind(ateist,dvasin,gamtos,krikšč,musulm,kr_klm,na_kri,pagoni,rytų_k,satani,tradic)
barplot(prop.table(eilutes,2),col=c("red3","red2","cyan","green2","green3"),legend.text=c("visiškai
 
sutinku","nesutinku","abejoju","sutinku","visiškai sutinku"),main="My title")
dettach(tolerancija.data)

However, this is a lot of writing. How do I make into a function to be 
reusable? 


Donatas

On Jul 16, 2007, at 9:06 , Donatas G. wrote:

> Hi,
>
> I cannot figure out how to draw a certain plot: could someone help  
> me out?
>
> I have this data.frame from a survey
> my.data
>
> that looks like something like this:
>
>    col1  col2  col3  col4
> 1     5     5     4     5
> 2     3     5     3     1
> 3     2     3     4     5
> 4     3     1     1     2
> 5     5     5     4     5
> 6     4     2     5     5
> 
>
>
> Each row represents a single questionnaire with someone giving his
> agreement/disagreement with a statement (each column is a  
> statement) that is
> coded from 1 to 5.
>
> I need to draw a barplot giving a visual representation showing  
> differences
> between the five columns: Each bar should represent a single  
> column, and
> should be divided into 5 sections, the thickness of each depending  
> on the
> number of respondents who choose that particular answer.
>
> How do I do that? All I have managed to do so far is to produce a  
> barplot of a
> single column, and that - only with bars side by side...


-- 
Donatas Glodenis
http://dg.lapas.info

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


Re: [R] binned column in a data.frame

2007-07-20 Thread jim holtman
You can also use 'cut' to break the bins:

> x <- c(1,2,6,8,13,0,5,10, runif(10) * 100)
> x.bins <- seq(0, max(x)+5, 5)
> x.cut <- cut(x, breaks=x.bins, include.lowest=TRUE)
> x.names <- paste(head(x.bins, -1), tail(x.bins, -1), sep='-')
> data.frame(x, bins=x.names[x.cut])
  x  bins
1   1.0   0-5
2   2.0   0-5
3   6.0  5-10
4   8.0  5-10
5  13.0 10-15
6   0.0   0-5
7   5.0   0-5
8  10.0  5-10
9  75.85256 75-80
10 38.20424 35-40
11 77.30647 75-80
12 62.02278 60-65
13 73.42095 70-75
14 78.69244 75-80
15 66.52972 65-70
16 61.64897 60-65
17 23.99252 20-25
18 42.08632 40-45


On 7/20/07, João Fadista <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I would like to know how can I create a binned column in a data.frame. The 
> output that I would like is something like this:
>
> Start  Binned_Start
> 10-5
> 20-5
> 65-10
> 85-10
> 13  10-15
> ...
>
>
>
>
> Best regards
>
> João Fadista
> Ph.d. student
>
>
>
> UNIVERSITY OF AARHUS
> Faculty of Agricultural Sciences
> Dept. of Genetics and Biotechnology
> Blichers Allé 20, P.O. BOX 50
> DK-8830 Tjele
>
> Phone:   +45 8999 1900
> Direct:  +45 8999 1900
> E-mail:  [EMAIL PROTECTED] 
> Web: www.agrsci.org 
> 
>
> News and news media  .
>
> This email may contain information that is confidential. Any use or 
> publication of this email without written permission from Faculty of 
> Agricultural Sciences is not allowed. If you are not the intended recipient, 
> please notify Faculty of Agricultural Sciences immediately and delete this 
> email.
>
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


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

What is the problem you are trying to solve?

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


[R] cv.glm error function

2007-07-20 Thread Rachel Davidson
I have a couple quick questions about the use of cv.glm for
cross-validation.

1. If we have a Poisson GLM with counts Y~Poisson(mu) and
ln(mu)=beta0+beta1*x1+..., is the prediction error (delta) that is output
from cv.glm provided in terms of the counts (y) or the (mu)?

2. Can cv.glm be used for negative binomial models fit using glm.nb? It
appears to work, but since NB models aren't strictly GLM's I wanted to
check.

Thanks!

[[alternative HTML version deleted]]

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


Re: [R] RDCOM and R versions

2007-07-20 Thread Prof Brian Ripley
There is a separate list for support of RDCOM at

http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l

The answer to your question depends a bit how you are making use of RDCOM: 
the R interface is via rproxy.dll, and that recognizes R_HOME.  This is 
also mentioned in the installation instructions for the server.  So I 
would expect setting R_HOME in the appropriate environment to allow you to 
choose which R to use: it used to work some years ago.

On Fri, 20 Jul 2007, Paul wrote:

> Dear R-helpers,
>
>  I have several versions of R installed on my computer, and I cannot do 
> without any of these.
>  However RCDOM seems to authorize only one version installed. Do you know any 
> means to overcome this problem ?
>  Thank you very much for your response.
>
> Paul Poncet
>
>
>
> -
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

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


Re: [R] exclude1 in summary.formula from Hmisc

2007-07-20 Thread Frank E Harrell Jr
david dav wrote:
> Dear Users,
> Still having troubles with sharing my results, I'm trying to display a
> contingency table using summary.formula.
> Computing works well but I'd like to display information on redundant
> entries say, males AND females.

Please tell us what output you got.  And it is sometimes helpful to get 
a trivial example of the failure with simulated data.

Also see a related parameter "long".

Frank

> I wonder if this code is correct :
> 
> desqualjum <- summary.formula(varqual1$X ~.,  data = subset( varqual1,
> select = -X), method = "reverse",  overall = T, test = T, exclude1 = FALSE)
> where varqual1 is the data frame containing the variable "sex".
> 
> I'm using R 2.5.1 and Hmisc 3.4-2 on a Mac (OSX.4, intel)  but I had the
> same trouble with  former versions of R and the package.
> 
> Thank you for your help.
> David
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


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

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


[R] RDCOM and R versions

2007-07-20 Thread Paul
Dear R-helpers,

  I have several versions of R installed on my computer, and I cannot do 
without any of these.
  However RCDOM seems to authorize only one version installed. Do you know any 
means to overcome this problem ?
  Thank you very much for your response.

Paul Poncet



-

[[alternative HTML version deleted]]

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


Re: [R] plot3d labels

2007-07-20 Thread Birgit Lemcke
Thanks a lot for this  really time saving method compared to mine.

Greetings

Birgit

Am 20.07.2007 um 11:53 schrieb Duncan Murdoch:

> On 20/07/2007 5:23 AM, Birgit Lemcke wrote:
>> Hello Jim,
>> thanks for your answer but  I still have problems with the  
>> labels.  Perhaps you can help me a second time.
>> I have the output of cmdscale and it looks like this:
>>[,1]  [,2]  [,3]
>> Anth_cap  -0.011833788 -0.1091355289 -0.0222467839
>> Anth_crin -0.008178993 -0.0219545815 -0.0076695878
>> Anth_eck   0.026900827 -0.0422055677 -0.1340542844
>> Anth_gram -0.010860990  0.0080112322  0.0201743866.
>> In the next step I created 3 vectors out of the three columns
>> PCoA1<-PCoA[,1]
>> PCoA2<-PCoA[,2]
>> PCoA3<-PCoA[,3]
>> After that I plotted the 3 vectors
>> plot3d(PCoA1,PCoA2,PCoA3, type="p", col=rainbow(1000),size=5)
>
> There's no need to extract the 3 columns:  you could just use
>
> plot3d(PCoA, type="p", col=rainbow(1000),size=5)
>
> with the data above.
>> and now I try to handle this text3d function and label the points  
>> in  the graphic with the names in the first column. But I am a  
>> beginner  and don´t know the syntax for this in the text3d.
>> I tried to make vectors out of every row like this:
>> Anth_cap<- PCoA[1,]
>>  > Anth_crin<- PCoA[2,]
>>  > Anth_eck<- PCoA[3,]
>>  > Anth_gram<- PCoA[4,]
>>  > Anth_insi<- PCoA[5,]
>>  > Anth_laxi<- PCoA[6,].
>> and than tried to implement this in the text3d:
>> text3d( c(Anth_cap,
>> Anth_crin,
>
> I think all you need is
>
> text3d(PCoA, text=Nam)
>
> but you might want to set the adj argument if you want the labels  
> offset from the points, and you might want type="n" in the original  
> plot3d call if you don't want the points to interfere with the labels.
>
> Duncan Murdoch

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]

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


Re: [R] Can I test if there are statistical significance between different rows in R*C table?

2007-07-20 Thread Uwe Ligges


zhijie zhang wrote:
> Dear  friends,
>   My R*C table is as follow:
> 
> 
> 
> better
> 
> good
> 
> bad
> 
> Goup1
> 
> 16
> 
> 71
> 
> 37
> 
> Group2
> 
> 0
> 
> 4
> 
> 61
> 
> Group3
> 
> 1
> 
> 6
> 
> 57
> 
>Can I test if there are statistical significant between Group1 and
> Group2, Group2 and Group3, Group1 and Group2, taking into the multiple
> comparisons?


So what is you hypothesis? Statistical significance of what it to be tested?

Uwe Ligges



> The table can be set up using the following program:
> 
> a<-matrix(data=c(16,71,37,0,4,61,1,6,57),nrow=3,byrow=TRUE)
> Thanks very much.
> 
>

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


Re: [R] plot centered line on barplot

2007-07-20 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:
> Dear R user,
> 
> I need plot an histogram for the occurrence of a dataset, and then add a line 
> corresponding to the freuqnecy of another similar dataset. in order to do 
> this i used the function 
>> hist_data1=hist(data1, breaks= seq(0,50,5), plot=FALSE)
>> hist_data2=hist(data2, breaks= seq(0,50,5), plot=FALSE)
> 
> then I plotted the frequency
> 
>> barplot(hist_data1$density)
>> lines(hist_data1$density)


barplot() returns the positions on x-axis (these may be non-integers) 
where it draws the plots, hence you can say:

  bp <- barplot(hist_data1$density)
  lines(bp, hist_data1$density)


> but the line is shifted in respect to the center of the bars. how can I 
> properly plot the line? another question. this is easy, how can I smooth the 
> curve (not fit with loess of spline)?

If you do not tell us which kind of smoother you prefer 

Uwe Ligges



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

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


Re: [R] how to determine/assign a numeric vector to "Y" in the cor.test function for spearman's correlations?

2007-07-20 Thread Uwe Ligges


G. wrote:
> Hello to all of you, R-expeRts!
> I am trying to compute the cor.test for a matrix that i labelled mydata
> according to mydata=read.csv...
> then I converted my csv file into a matrix with the 
> mydata=as.matrix(mydata)
> NOW, I need to get the p-values from the correlations...
> I can successfully get the spearman's correlation matrix with:
> cor(mydata, method="s", use="pairwise,complete,obs")
> but then if I try the 
> cor.test(mydata, method="s", use="pairwise.complete.obs")
> i always get an error message as follows:
> the "y" argument is missing and does not have any default value assigned... 
> (excuse my translation)
> WHAT SHOULD I DO???
> HOW CAN I DEFINE "Y" AS A NUMERIC VECTOR???
> thanx guys, i just can't express myself as a computer would...
> G :)


You have to specify two vectors for the test, e.g.:

   cor.test(mydata[,1], mydata[,2], method = "s",
 use = "pairwise.complete.obs")

See the help page ?cor.test

Best,
Uwe

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


Re: [R] (R) Using arguments for the empirical cumulative distribution function

2007-07-20 Thread Mike Lawrence
?plot.ecdf()

On 20-Jul-07, at 6:57 AM, squall44 wrote:

>
> Is there no one who can help me? :,(
> --  
> View this message in context: http://www.nabble.com/%28R%29-Using- 
> arguments-for-the-empirical-cumulative-distribution-function- 
> tf4111355.html#a11705448
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University

Website: http://memetic.ca

Public calendar: http://icalx.com/public/informavore/Public

"The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less."
- Piet Hein

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


Re: [R] custom point shapes

2007-07-20 Thread Dieter Menne
baptiste Auguié  exeter.ac.uk> writes:

> I'm new to R, but a search through the list didn't quite solve this  
> problem: I want to draw a few ellipses (or any custom shape for that  
> matter) at given locations in a graph. I know how to plot points from  
> my data, set the point type "pch" to any built in value, but I do not  
> know how to specify a custom shape.
> A search for drawing ellipses gave me functions to plot one at a  
> given location, possibly using some dataset but only to display a  
> confidence interval or other convex hull. Nothing to use as pch.
> 
> Say I have this data:
> 
> x<-c(1:10)
> y<-x^2
> 
> I would like to plot (x,y) with some ellipses of custom aspect ratio  
> for every point.

If you want to use pch, you are stuck with the existing symbols, and don't have
much freedom in manipulating these. Looks like you are best off with ellipse in
package car that you probably found already.

Dieter

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


Re: [R] (R) Using arguments for the empirical cumulative distribution function

2007-07-20 Thread squall44

Is there no one who can help me? :,(
-- 
View this message in context: 
http://www.nabble.com/%28R%29-Using-arguments-for-the-empirical-cumulative-distribution-function-tf4111355.html#a11705448
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] plot3d labels

2007-07-20 Thread Duncan Murdoch
On 20/07/2007 5:23 AM, Birgit Lemcke wrote:
> Hello Jim,
> 
> thanks for your answer but  I still have problems with the labels.  
> Perhaps you can help me a second time.
> 
> I have the output of cmdscale and it looks like this:
> 
>[,1]  [,2]  [,3]
> Anth_cap  -0.011833788 -0.1091355289 -0.0222467839
> Anth_crin -0.008178993 -0.0219545815 -0.0076695878
> Anth_eck   0.026900827 -0.0422055677 -0.1340542844
> Anth_gram -0.010860990  0.0080112322  0.0201743866.
> 
> In the next step I created 3 vectors out of the three columns
> 
> PCoA1<-PCoA[,1]
> PCoA2<-PCoA[,2]
> PCoA3<-PCoA[,3]
> 
> After that I plotted the 3 vectors
> 
> plot3d(PCoA1,PCoA2,PCoA3, type="p", col=rainbow(1000),size=5)

There's no need to extract the 3 columns:  you could just use

plot3d(PCoA, type="p", col=rainbow(1000),size=5)

with the data above.
> 
> and now I try to handle this text3d function and label the points in  
> the graphic with the names in the first column. But I am a beginner  
> and don´t know the syntax for this in the text3d.
> 
> I tried to make vectors out of every row like this:
> 
> Anth_cap<- PCoA[1,]
>  > Anth_crin<- PCoA[2,]
>  > Anth_eck<- PCoA[3,]
>  > Anth_gram<- PCoA[4,]
>  > Anth_insi<- PCoA[5,]
>  > Anth_laxi<- PCoA[6,].
> 
> and than tried to implement this in the text3d:
> 
> text3d( c(Anth_cap,
> Anth_crin,

I think all you need is

text3d(PCoA, text=Nam)

but you might want to set the adj argument if you want the labels offset 
from the points, and you might want type="n" in the original plot3d call 
if you don't want the points to interfere with the labels.

Duncan Murdoch

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


Re: [R] binned column in a data.frame

2007-07-20 Thread Mike Meredith


Try something like this:

x <- c(1,2,6,8,13,0,5,10, runif(10) * 100)
tmp <- x %/% 5 + 1
bin.names <- paste((0:19) * 5, (1:20) * 5, sep="-")
data.frame(Start = x, Binned_Start = bin.names[tmp])

This assumes you want (eg.) 5 in the 5-10 bin, not the 0-5 bin. You may also
want to make Binned_Start into a factor rather than a character vector.

HTH, Mike.



João Fadista wrote:
> 
> Dear all,
>  
> I would like to know how can I create a binned column in a data.frame. The
> output that I would like is something like this: 
>  
> Start  Binned_Start
> 10-5
> 20-5
> 65-10
> 85-10
> 13  10-15
> ...
>  
>  
>  
> 
> Best regards
> 
> João Fadista
> Ph.d. student
> 
> 
>   
>UNIVERSITY OF AARHUS   
> Faculty of Agricultural Sciences  
> Dept. of Genetics and Biotechnology   
> Blichers Allé 20, P.O. BOX 50 
> DK-8830 Tjele 
>   
> Phone: +45 8999 1900  
> Direct:+45 8999 1900  
> E-mail:[EMAIL PROTECTED]    
> Web:   www.agrsci.org 
> 
> 
> News and news media  .
> 
> This email may contain information that is confidential. Any use or
> publication of this email without written permission from Faculty of
> Agricultural Sciences is not allowed. If you are not the intended
> recipient, please notify Faculty of Agricultural Sciences immediately and
> delete this email.
> 
> 
>   [[alternative HTML version deleted]]
> 
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/binned-column-in-a-data.frame-tf4115787.html#a11705240
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] plot3d labels

2007-07-20 Thread Birgit Lemcke
Hello Jim,

thanks for your answer but  I still have problems with the labels.  
Perhaps you can help me a second time.

I have the output of cmdscale and it looks like this:

   [,1]  [,2]  [,3]
Anth_cap  -0.011833788 -0.1091355289 -0.0222467839
Anth_crin -0.008178993 -0.0219545815 -0.0076695878
Anth_eck   0.026900827 -0.0422055677 -0.1340542844
Anth_gram -0.010860990  0.0080112322  0.0201743866.

In the next step I created 3 vectors out of the three columns

PCoA1<-PCoA[,1]
PCoA2<-PCoA[,2]
PCoA3<-PCoA[,3]

After that I plotted the 3 vectors

plot3d(PCoA1,PCoA2,PCoA3, type="p", col=rainbow(1000),size=5)

and now I try to handle this text3d function and label the points in  
the graphic with the names in the first column. But I am a beginner  
and don´t know the syntax for this in the text3d.

I tried to make vectors out of every row like this:

Anth_cap<- PCoA[1,]
 > Anth_crin<- PCoA[2,]
 > Anth_eck<- PCoA[3,]
 > Anth_gram<- PCoA[4,]
 > Anth_insi<- PCoA[5,]
 > Anth_laxi<- PCoA[6,].

and than tried to implement this in the text3d:

text3d( c(Anth_cap,
Anth_crin,
Anth_eck,
Anth_gram,
Anth_insi,
Anth_laxi,
Anth_sing,
Aski_albo_ari,
Aski_alt,
Aski_and,
Aski_capi,
Aski_chart,
Aski_deli,
Aski_ester,
Aski_ins,
Aski_long,
Aski_nit,
Aski_pani,
Aski_rug,
Calo_ad,
Calo_as,
Calo_and,
Calo_bur,
Calo_clan,
Calo_dura,
Calo_ester,
Calo__fili,
Calo_fruti,
Calo_gra,
Calo_hya,
Calo_im,
Calo_lev,
Calo_mar,
Calo_mem,
Calo_mon,
Calo_mui,
Calo_nud,
Calo_pani,
Calo_pul,
Calo_rig,
Calo_rigo,
Calo_spa,
Calo_vim,
Can_anf,
Can_are,
Can_ari,
Can_con,
Can_gran,
Can_nit,
Can_prim,
Can_parv,
Can_sau,
Can_scir,
Can_schl,
Can_spi,
Can_vir,
Cera_arg,
Cera_cae,
Cera_deci,
Cera_fim,
Cera_pers,
Cera_fis,
Cera_pul,
Cera_xer,
E_aco,
E_aggre,
E_alt,
E_amo,
E_asper,
E_atrat,
E_cae,
E_cap,
E_col,
E_cus,
E_deci,
E_deu,
E_ebra,
E_eleph,
E_equi,
E_ester,
E_ext,
E_fast,
E_fenest,
E_fil,
E_fis,
E_fuc,
E_galp,
E_glome,
E_gran,
E_grandisp,
E_hook,
E_hutch,
E_inter,
E_juncea,
E_macro,
E_mar,
E_micro,
E_mucron,
E_mui,
E_neesii,
E_nuda,
E_pers,
E_prom,
E_racem,
E_recta,
E_rig,
E_spath,
E_squam,
E_stip,
E_stok,
E_tectorum,
E_thyrsi,
E_thyrso,
E_vaginul,
E_verr,
Hydr_ratt,
Hypo_albo,
Hypo_alt,
Hypo_arg,
Hypo_arist,
Hypo_laev,
Hypo_mon,
Hypo_neesii,
Hypo_proc,
Hypo_rigi,
Hypo_rug,
Hypo_squam,
Hypo_stri,
Hypo_sul,
Hypo_syn,
Hypo_will,
Isch_aff,
Isch_ari,
Isch_cae,
Isch_cap,
Isch_cinc,
Isch_coa,
Isch_cons,
Isch_curvib,
Isch_curvir,
Isch_dist,
Isch_dut,
Isch_eleo,
Isch_els,
Isch_ester,
Isch_frat,
Isch_fusc,
Isch_gaudi_l,
Isch_gaudi_g,
Isch_goss,
Isch_hele,
Isch_hys,
Isch_kar,
Isch_lani,
Isch_lept,
Isch_longex,
Isch_macer,
Isch_mar,
Isch_mon,
Isch_nana,
Isch_nub,
Isch_ocre,
Isch_palud,
Isch_papill,
Isch_prat
Isch_pyg,
Isch_riv,
Isch_rott,
Isch_sabul,
Isch_sax,
Isch_schoe,
Isch_seti,
Isch_sie,
Isch_spor,
Isch_sub,
Isch_tenuis,
Isch_tenuissi,
Isch_tr,
Isch_uni,
Isch_ven,
Isch_vilis,
Isch_virgea,
Isch_wall,
Isch_witt,
Mast_digit,
Mast_pur,
Mast_spa,
Nev_obt,
Nev_sing,
Nev_vlokii,
Plat_ac,
Plat_an,
Plat_call,
Plat_cascad,
Plat_com,
Plat_depa,
Plat_major,
Plat_sub,
Res_aco,
Res_alti,
Res_amb,
Res_arcu,
Res_aur,
Res_bifa,
Res_bifi,
Res_bifu,
Res_bolus,
Res_brachi,
Res_brun,
Res_bur,
Res_capi,
Res_colli,
Res_com,
Res_conf,
Res_corn,
Res_cym,
Res_debilis,
Res_deci,
Res_deg,
Res_disp,
Res_disti,
Res_dista,
Res_dodii_d,
Res_dodii_p,
Res_echin,
Res_egregius,
Res_ejunci,
Res_festuci,
Res_fili,
Res_fragilis,
Res_fusi,
Res_galp,
Res_har,
Res_impli,
Res_inconuus,
Res_ing,
Res_insi,
Res_inveter,
Res_lepto,
Res_mahonii_m,
Res_mahonii,
Res_micans,
Res_miser,
Res_mlanji,
Res_mon,
Res_nod,
Res_multi,
Res_nuw,
Res_obs,
Res_occ,
Res_pachy,
Res_paludi,
Res_papy,
Res_pat,
Res_pec,
Res_pedicell,
Res_perp,
Res_perse,
Res_pillansii,
Res_pondo,
Res_praeac,
Res_pulvin,
Res_pumi,
Res_purp,
Res_quadr,
Res_quar,
Res_quin,
Res_rarus,
Res_rupi,
Res_sar,
Res_scaber,
Res_scaberu,
Res_secun,
Res_sejun,
Res_similis,
Res_sing,
Res_stere,
Res_stok,
Res_stri,
Res_strob,
Res_subtilis,
Res_tetra,
Res_trit,
Res_tube,
Res_verruc,
Res_vers,
Res_zulu,
Res_zwar,
Rho_alpina,
Rho_ar,
Rho_cap,
Rho_foli,
Rho_fruti,
Rho_gig,
Rho_gra,
Rho_vlei,
Sta_aem,
Sta_banksii,
Sta_cernua,
Sta_dis,
Sta_multi,
Sta_orn,
Sta_stok,
Sta_remota,
Sta_vagin,
Thamn_ac,
Thamn_amo,
Thamn_ar,
Thamn_bach,
Thamn_cine,
Thamn_dum,
Thamn_ellip,
Thamn_ere,
Thamn_frat,
Thamn_frutic,
Thamn_glaber,
Thamn_gra,
Thamn_guthr,
Thamn_insi,
Thamn_kar,
Thamn_lev,
Thamn_luc,
Thamn_mui,
Thamn_nu,
Thamn_obt,
Thamn_panicul,
Thamn_papy,
Thamn_pelluci,
Thamn_plat,
Thamn_plur,
Thamn_pulcher,
Thamn_punct,
Thamn_rigi,
Thamn_schl,
Thamn_spici,
Thamn_spor,
Thamn_stok,
Will_aff,
Will_aresc,
Will_boii,
Will_glome,
Will_humilis,
Will_incurv,
Will_pur,
Will_rug,
Will_stok,
Will_sulc,
Will_teres), y=NULL,  z=NULL, text=(Nam)) #Nam is a vector with the  
labelnames.

But it is still not working and it semms to that this way is really  
complicated.

Would be nice if somebody could help me.

Thanks in advanc

Re: [R] Trend lines on a scatterplot matrix

2007-07-20 Thread Mark Difford

Hi Alan, 

There is a good, ready made, way of doing this, with additional options, in
Professor Fox's car package.  See:---

require(car)
?scatterplot.matrix

Cheers,
Mark.


Alan S Barnett-2 wrote:
> 
> I'm using pairs() to generate a scatterplot matrix;
> 
> pairs(~
> Fuzzy.gray.white.ratio+Fuzzy.gw.t.score+AgeWhenTested+signal_mean.noise,
>   data=datam,subset=status=="control",main="Controls",
> labels=c("G/W","Peak Separation","Age","S/N"))
> 
> 
> How can I add regression lines to the plots?
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Trend-lines-on-a-scatterplot-matrix-tf4113952.html#a11704499
Sent from the R help mailing list archive at Nabble.com.

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


[R] binned column in a data.frame

2007-07-20 Thread João Fadista
Dear all,
 
I would like to know how can I create a binned column in a data.frame. The 
output that I would like is something like this: 
 
Start  Binned_Start
10-5
20-5
65-10
85-10
13  10-15
...
 
 
 

Best regards

João Fadista
Ph.d. student



 UNIVERSITY OF AARHUS   
Faculty of Agricultural Sciences
Dept. of Genetics and Biotechnology 
Blichers Allé 20, P.O. BOX 50   
DK-8830 Tjele   

Phone:   +45 8999 1900  
Direct:  +45 8999 1900  
E-mail:  [EMAIL PROTECTED]    
Web: www.agrsci.org 


News and news media  .

This email may contain information that is confidential. Any use or publication 
of this email without written permission from Faculty of Agricultural Sciences 
is not allowed. If you are not the intended recipient, please notify Faculty of 
Agricultural Sciences immediately and delete this email.


[[alternative HTML version deleted]]

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


Re: [R] GEE code

2007-07-20 Thread Dimitris Rizopoulos
from your description I think you need a random-effects model. Since 
you assume normality the parameter estimates from a random-effects 
model (in your case `GDP.log2') have a marginal interpretation (in 
fact they have both conditional and marginal interpretation). Thus, 
you could also use lmer() from package `lme4' to fit such a model, 
e.g.,

fit1 <- lmer(ineq ~ GDP.log2 + (1 | country), data = data3)
summary(fit1)
# intercept + Emprirical Bayes estimates of
# the random-effect per country
fixef(fit1)[1] + unlist(ranef(fit1))

If you have repeated measurement in time, you could include 
random-slopes (e.g., in lmer()) or an AR1 structure, as you did below. 
For the latter case, you probably want to use functions lme() and 
gls() from package `nlme'.


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: "Chris Linton" <[EMAIL PROTECTED]>
To: 
Sent: Friday, July 20, 2007 9:34 AM
Subject: [R] GEE code


> I'm writing a paper aimed at motivating the use of GEE within the 
> field of
> economics.  However, after computing using the geeglm function, I 
> noticed
> there's one intercept in the summary output.  I assume this means 
> the
> function is pooling the data.  That means my code is not what I 
> want.  I
> want a "fixed effects" model, meaning I want the intercept to vary 
> by
> cluster.  Here's my current code.
>
> gfit4<-geeglm(ineq~GDP.log2,family=gaussian(link="identity"),data=data3,id=country,corstr="ar1")
> summary(gfit4)
>
>
> What do I need to include to get the function to compute a model 
> where the
> intercept varies by the country?
>
>
>
> Thanks
>
> -chris linton
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


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

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


Re: [R] Help with Dates

2007-07-20 Thread Achim Zeileis
Alex:

> I am taking an excel dataset and reading it into R using read.table.

This sets up a "data.frame" object. The data you have are probably more
conveniently represented as a time series, storing the date in an
appropriate format, e.g., in class "Date".

> (actually I am dumping the data into a .txt file first and then reading data
> in to R).

Then you can do both steps (calling read.table() and transformation to a
time series) in one go using the function read.zoo() from package "zoo".

If your text file looks like

 Date  Price Open.Int. Comm.Long Comm.Short net.comm
15-Jan-86 673.25175645 65910  2842537485
31-Jan-86 677.00167350 54060  2712026940
14-Feb-86 680.25157985 37955  2542512530
28-Feb-86 691.75162775 49760  1603033730
14-Mar-86 706.50163495 54120  2799526125
31-Mar-86 709.75164120 54715  3039024325

then you can read it in via
  z <- read.zoo("mydata.txt", format = "%d-%b-%y", header = TRUE)

Then you can do all sorts of standard things for time series, such as
  plot(z)
or...

> The dataset runs from 1986 to 2007.
>
> I want to be able to take subsets of my data based on date e.g. data between
> 2000 - 2005.

...subsetting

  z2 <- window(z, start = as.Date("2000-01-01"), end = as.Date("2005-12-31"))

etc. Look at the "zoo" package vignettes for more information
  vignette("zoo-quickref", package = "zoo")
  vignette("zoo", package = "zoo")

hth,
Z

> As it stands, I can't work with the dates as they are not in correct format.
>
> I tried successfully converting the dates to just the year using:
>
> transform(data, Yr = format(as.Date(as.character(Date),format = '%d-%b-%y'),
> "%y")))
>
> This gives the following format:
>
>Date  Price Open.Int. Comm.Long Comm.Short net.comm Yr
> 1 15-Jan-86 673.25175645 65910  2842537485 86
> 2 31-Jan-86 677.00167350 54060  2712026940 86
> 3 14-Feb-86 680.25157985 37955  2542512530 86
> 4 28-Feb-86 691.75162775 49760  1603033730 86
> 5 14-Mar-86 706.50163495 54120  2799526125 86
> 6 31-Mar-86 709.75164120 54715  3039024325 86
>
> I can subset for a single year e.g:
>
> head(subset(df, Yr =="00")
>
> But how can I subset for multiple periods e.g 00- 05? The following won't
> work:
>
> head(subset(df, Yr =="00" & Yr=="01")
>
> or
>
> head(subset(df, Yr = c("00","01","02","03")
>
> I can't help but feeling that I am missing something and there is a simpler
> route.
>
> I leafed through R newletter 4.1 which deals with dates and times but it
> seemed that strptime and POSIXct / POSIXlt are not what I need either.
>
> Can anybody help me?
>
> Regards
>
>
> Alex
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

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


[R] custom point shapes

2007-07-20 Thread baptiste Auguié
Hi,

I'm new to R, but a search through the list didn't quite solve this  
problem: I want to draw a few ellipses (or any custom shape for that  
matter) at given locations in a graph. I know how to plot points from  
my data, set the point type "pch" to any built in value, but I do not  
know how to specify a custom shape.
A search for drawing ellipses gave me functions to plot one at a  
given location, possibly using some dataset but only to display a  
confidence interval or other convex hull. Nothing to use as pch.

Say I have this data:

x<-c(1:10)
y<-x^2

I would like to plot (x,y) with some ellipses of custom aspect ratio  
for every point.

Thanks,

Best regards,

baptiste

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


[R] GEE code

2007-07-20 Thread Chris Linton
I'm writing a paper aimed at motivating the use of GEE within the field of
economics.  However, after computing using the geeglm function, I noticed
there's one intercept in the summary output.  I assume this means the
function is pooling the data.  That means my code is not what I want.  I
want a "fixed effects" model, meaning I want the intercept to vary by
cluster.  Here's my current code.

gfit4<-geeglm(ineq~GDP.log2,family=gaussian(link="identity"),data=data3,id=country,corstr="ar1")
summary(gfit4)


What do I need to include to get the function to compute a model where the
intercept varies by the country?



Thanks

-chris linton

[[alternative HTML version deleted]]

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


Re: [R] Dataframe of factors transform speed?

2007-07-20 Thread Benilton Carvalho
set.seed(123)
genoT = lapply(1:24, function(i) factor(sample(c("AA", "AB",  
"BB"), 1000, prob=sample(c(1, 1000, 1000), 3), rep=T)))
names(genoT) = paste("snp", 1:24, sep="")
genoT = as.data.frame(genoT)
dim(genoT)
class(genoT)
system.time(out <- lapply(genoT, function(x) match(x, c("AA", "AB",  
"BB"))-1))
##
##
user  system elapsed
119.288   0.004 119.339

(for all 240K)

best,
b

ps: note that "out" is a list.

On Jul 20, 2007, at 2:01 AM, Latchezar Dimitrov wrote:

> Hi,
>
>> -Original Message-
>> From: Benilton Carvalho [mailto:[EMAIL PROTECTED]
>> Sent: Friday, July 20, 2007 12:25 AM
>> To: Latchezar Dimitrov
>> Cc: r-help@stat.math.ethz.ch
>> Subject: Re: [R] Dataframe of factors transform speed?
>>
>> it looks like that whatever method you used to genotype the
>> 1002 samples on the STY array gave you a transposed matrix of
>> genotype calls. :-)
>
> It only looks like :-)
>
> Otherwise it is correctly created dataframe of 1002 samples X (big
> number) of columns (SNP genotypes). It worked perfectly until I  
> decided
> to put together to cohorts independently processed in R already. I got
> stuck with my lack of foreseeing. Otherwise I would have put 3 dummy
> lines w/ AA,AB, and AB on each one to make sure all 3 genotypes are
> present and that's it! Lesson for the future :-)
>
> Maybe I am not using columns and rows appropriately here but the
> dataframe is correct (I have not used FORTRAN since FORTRAN IV ;-)  
> - as
> str says 1002 observ. of (big number) vars.
>
>>
>> i'd use:
>>
>> genoT = read.table(yourFile, stringsAsFactors = FALSE)
>>
>> as a starting point... but I don't think that would be
>> efficient (as you'd need to fix one column at a time - lapply).
>
> No it was not efficient at all. 'matter of fact nothing is more
> efficient then loading already read data, alas :-(
>
>>
>> i'd preprocess yourFile before trying to load it:
>>
>> cat yourFile | sed -e 's/AA/1/g' | sed -e 's/AB/2/g' | sed -e
>> 's/BB/3/ g' > outFile
>>
>> and, now, in R:
>>
>> genoT = read.table(outFile, header=TRUE)
>
> ... Too late ;-) As it must be clear now I have two dataframes I  
> want to
> put together with rbind(geno1,geno2). The issue again is
> "uniformization" of factor variables w/ missing factors - they  
> ended up
> like levels AA,BB on one of the and levels AB,BB on the other which
> means as.numeric of AA is 1 on the 1st and as.numeric of AB is 1 on  
> the
> second - complete mess. That's why I tried to make both uniform, i.e.
> levels "AA","AB", and "BB" for every SNP and then rbind works.
>
> In any case my 1st questions remains: "What's wrong with me?" :-)
>
> Thanks,
> Latchezar
>
>>
>> b
>>
>> On Jul 19, 2007, at 11:51 PM, Latchezar Dimitrov wrote:
>>
>>> Hello,
>>>
>>> This is a speed question. I have a dataframe genoT:
>>>
 dim(genoT)
>>> [1]   1002 238304
>>>
 str(genoT)
>>> 'data.frame':   1002 obs. of  238304 variables:
>>>  $ SNP_A.4261647: Factor w/ 3 levels "0","1","2": 3 3 3 3 3
>> 3 3 3 3 3
>>> ...
>>>  $ SNP_A.4261610: Factor w/ 3 levels "0","1","2": 1 1 3 3 1
>> 1 1 2 2 2
>>> ...
>>>  $ SNP_A.4261601: Factor w/ 3 levels "0","1","2": 1 1 1 1 1
>> 1 1 1 1 1
>>> ...
>>>  $ SNP_A.4261704: Factor w/ 3 levels "0","1","2": 3 3 3 3 3
>> 3 3 3 3 3
>>> ...
>>>  $ SNP_A.4261563: Factor w/ 3 levels "0","1","2": 3 1 2 1 2
>> 3 2 3 3 1
>>> ...
>>>  $ SNP_A.4261554: Factor w/ 3 levels "0","1","2": 1 1 NA 1 NA 2 1 1
>>> 2 1
>>> ...
>>>  $ SNP_A.4261666: Factor w/ 3 levels "0","1","2": 1 1 2 1 1
>> 1 1 1 1 2
>>> ...
>>>  $ SNP_A.4261634: Factor w/ 3 levels "0","1","2": 3 3 2 3 3
>> 3 3 3 3 2
>>> ...
>>>  $ SNP_A.4261656: Factor w/ 3 levels "0","1","2": 1 1 2 1 1
>> 1 1 1 1 2
>>> ...
>>>  $ SNP_A.4261637: Factor w/ 3 levels "0","1","2": 1 3 2 3 2
>> 1 2 1 1 3
>>> ...
>>>  $ SNP_A.4261597: Factor w/ 3 levels "AA","AB","BB": 2 2 3 3 3 2 1
>>> 2 2 3
>>> ...
>>>  $ SNP_A.4261659: Factor w/ 3 levels "AA","AB","BB": 3 3 3 3 3 3 3
>>> 3 3 3
>>> ...
>>>  $ SNP_A.4261594: Factor w/ 3 levels "AA","AB","BB": 2 2 2 1 1 1 2
>>> 2 2 2
>>> ...
>>>  $ SNP_A.4261698: Factor w/ 2 levels "AA","AB": 1 1 1 1 1 1 1 1 1
>>> 1 ...
>>>  $ SNP_A.4261538: Factor w/ 3 levels "AA","AB","BB": 2 3 2 2 3 2 2
>>> 1 1 2
>>> ...
>>>  $ SNP_A.4261621: Factor w/ 3 levels "AA","AB","BB": 1 1 1 1 1 1 1
>>> 1 1 1
>>> ...
>>>  $ SNP_A.4261553: Factor w/ 3 levels "AA","AB","BB": 1 1 2 1 1 1 1
>>> 1 1 1
>>> ...
>>>  $ SNP_A.4261528: Factor w/ 2 levels "AA","AB": 1 1 1 1 1 1 1 1 1
>>> 1 ...
>>>  $ SNP_A.4261579: Factor w/ 3 levels "AA","AB","BB": 1 1 1 1 1 2 1
>>> 1 1 2
>>> ...
>>>  $ SNP_A.4261513: Factor w/ 3 levels "AA","AB","BB": 2 1 2
>> 2 2 NA 1 NA
>>> 2
>>> 1 ...
>>>  $ SNP_A.4261532: Factor w/ 3 levels "AA","AB","BB": 1 2 2 1 1 1 3
>>> 1 1 1
>>> ...
>>>  $ SNP_A.4261600: Factor w/ 2 levels "AB","BB": 2 2 2 2 2 2 2 2 2
>>> 2 ...
>>>  $ SNP_A.4261706: Factor w/ 2 levels "AA","BB": 1 1 1 1 1 1 1 1 1
>>> 1 ...
>>>  $ SNP_A.4261575: Factor w/ 3 levels "AA","AB","BB": 1 1 1 1 1 1 1
>>> 2 2 1
>>> ...
>>>
>>