Re: [R] read multiple large files into one dataframe

2010-01-25 Thread Brad Patrick Schneid

Thats it Hadley!!!
Thank you.
-- 
View this message in context: 
http://n4.nabble.com/read-multiple-large-files-into-one-dataframe-tp891835p1290089.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Matching a character in a string

2010-01-25 Thread Fabrice DELENTE
> grep("o", "hello")

Thanks, I hadn't noticed R has grep included!

-- 
Fabrice DELENTE

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


Re: [R] Hypothsis simulation

2010-01-25 Thread Jim Silverton
I wish to simulate:

Ho: Odds Ratio =1
H1 Odds Ratio <> 1

Can any of the R users show me how to generate this data for say 20% from Ho
and 80% from H1?

Thanks,

Jim

[[alternative HTML version deleted]]

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


[R] Problem with "nls" function

2010-01-25 Thread hammadi jbeli
Dear R users,
I have a response variable in a csv file called "y" and a matrix of
predictor variables in a csv file called "mat". I have used the function
"nls" I have specified the nonlinear relation between these variable.The
code I have witten is called Rprog which begins with the phrase:
L.minor.m1<-nls(Y~a etc..
The program when I execute the program, I obtain the following message:
L.minor.m1 file not found.
You find attached Rprog, y.csv and mat.csv.
Can you please help me, it is very important for my phd thesis.
Thanks in advance.
Hammadi.
mat<- read.csv(file="mat.csv",head=FALSE,sep=";")
y<-read.csv(file="y.csv",head=FALSE,sep=";")
Y=y[,1]
D_1=mat[,1]
D_2=mat[,2]
D_3=mat[,3]
D_4=mat[,4]
Y_1=mat[,5]
Y_2=mat[,6]
Y_3=mat[,7]
Y_4=mat[,8]
s_F=mat[,9]
s_G=mat[,10]
L.minor=data.frame(Y=Y,D_1=D_1,D_2=D_2,D_3=D_3,D_4=D_4,Y_1=Y_1,Y_2=Y_2,Y_3=Y_3,Y_4=Y_4,s_F=s_F,s_G=s_G)
stdS=1/(sd(s_F))
stdG=1/(sd(s_G))
L.minor.m1<-nls(Y~a_1_1*D_1+a_2_1*D_2+a_3_1*D_3+a_4_1*D_4+a_1_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_1+a_2_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_2+a_3_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_3+a_4_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_4+p_1_1*Y_1+p_2_1*Y_2+p_3_1*Y_3+p_4_1*Y_4+p_1_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_1+p_2_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_2+p_3_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_3

+p_4_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_4,start=list(a_1_1=0.0593,a_2_1=-0.0822,a_3_1=
0.0300
,a_4_1=-0.1259,a_1_2=-0.0477,gamma_1_F=0.5,c_1_F=-0.1555,gamma_2_F=0.5,c_2_F=-0.0292,a_2_2=
  0.0873,a_3_2= -0.0567,a_4_2= 0.1443,p_1_1=-0.0297,p_2_1= 0.1865,p_3_1= 
-0.0776,p_4_1=0.5260,p_1_2=0.0075,gamma_1_G=0.1,c_1_G=-0.1555,gamma_2_G=0.3,c_2_G=-0.0545,p_2_2=
 -0.1911,p_3_2=0.0696,p_4_2= -0.4640), trace=TRUE)
summary(L.minor.m1)


















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


[R] a question about the variance of growth model

2010-01-25 Thread 孟欣
Hi all:
In the growth model (Ref.Multilevel Modeling in R (2.3)),I have a question 
about the variance:
 
On p.73, it says:"To model decreasing variance one can use the varExp option. 
In cases where variance increases can use the varFixed option (see Pinheiro & 
Bates, 2000 for details)."
 
My question is: if variance's change is not in a unique trend(for instance: 
varance increase at first, and then decrease...) How to do with this situation?
 
Thanks a lot!
 
My best 
[[alternative HTML version deleted]]

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


Re: [R] More than on loop??

2010-01-25 Thread jim holtman
It sounds like you want to use 'barplot' like below given that it
appears that the value in x.c would be the matrix you want to graph:

x.c <- cleaved(x)
barplot(x.c, col=c("#FF", "#CC", "#99", "#66", "#33",
   "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33",
   "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933",
   "#FF9900", "#FF33FF", "#FF33CC"))

THis seems to produce something like you want.

On Mon, Jan 25, 2010 at 10:42 PM, che  wrote:
>
> 70% yes, the problem is i am trying to produce a graph similar to the one in
> attachments in this message, which represents the frequency of each letter
> "aminoacid" in the cleaved function and the noncleaved function. some thing
> else i added to the attachments is the pattern which seemingly working
> correctly, i am trying now to create a R code to loop and simulate this
> pattern in order to draw all rectangles for the eight columns. But i don't
> know exactly how to deal with this variable which i highlighted with yellow
> in the image, it is cumulative in a challenging way.
> http://n4.nabble.com/file/n1290048/cleaved.jpg cleaved.jpg
> http://n4.nabble.com/file/n1290048/pattern.jpg pattern.jpg
> --
> View this message in context: 
> http://n4.nabble.com/More-than-on-loop-tp1015851p1290048.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] R2WinBUGS/ trap

2010-01-25 Thread Ben Bolker
julien martin  gmail.com> writes:

> 
> I am generating 1000 replicate data sets in R, each data set is then
> analyzed with WinBUGS in batch mode using R2WinBUGS. Unfortunately,
> occasionally some data sets lead WinBUGS to open a "trap" window; and the
> simulations are interrupted as result of the message. Is there any ways to
> set R2WinBUGS so that it would ignore the trap message and  proceed with the
> simulations?
  
  I'm not sure -- I don't think so -- I don't remember if R hangs
or returns an error on a trap -- but you could try (1) try() 
and (2) JAGS/R2jags

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


Re: [R] More than on loop??

2010-01-25 Thread che

70% yes, the problem is i am trying to produce a graph similar to the one in
attachments in this message, which represents the frequency of each letter
"aminoacid" in the cleaved function and the noncleaved function. some thing
else i added to the attachments is the pattern which seemingly working
correctly, i am trying now to create a R code to loop and simulate this
pattern in order to draw all rectangles for the eight columns. But i don't
know exactly how to deal with this variable which i highlighted with yellow
in the image, it is cumulative in a challenging way.   
http://n4.nabble.com/file/n1290048/cleaved.jpg cleaved.jpg 
http://n4.nabble.com/file/n1290048/pattern.jpg pattern.jpg 
-- 
View this message in context: 
http://n4.nabble.com/More-than-on-loop-tp1015851p1290048.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] ff package: ff objects don't reload completely on NFS drives from a different machine

2010-01-25 Thread Hao Cen
Hi Jens,

Thanks for the suggestions. I tried closing the ff file on one nfs client
and open that file from another client. It doesn't work.

Jeff
-Original Message-
From: Jens Oehlschlägel [mailto:oehl_l...@gmx.de] 
Sent: Monday, January 25, 2010 5:07 PM
To: h...@andrew.cmu.edu
Cc: R-help@r-project.org
Subject: Re: [R] ff package: ff objects don't reload completely on NFS
drives from a different machine

Try to close the file on the first nfs client before reopening it on the
second nfs client. NFS has something called "close-to-open cache
consistency".
This means that two clients which have the same nfs file open, cannot rely
on seeing the updates from the respective other client. If one clients
closes, and the other client opens thereafter, it should see the changes. If
you want multiple clients to write at the same time, you should make sure
they only write non-overlapping sections (and then all need to close for
synching). Let me know if this worked for you. 
J.

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


Re: [R] problem with "nls" function

2010-01-25 Thread Walmes Zeviani

I supose you are following the SAS formulation style. R has a different
formulation style, such as:

da <- expand.grid(A=factor(1:3), x=1:10)
da$y <- as.numeric(da$A)*da$x/(1.2+da$x)+rnorm(da$x, 0, 0.1)

m0 <- nls(y~Asym[A]*x/(Time[A]+x), data=da, start=list(Asym=c(1,2,3),
Time=c(1,1,1)))
summary(m0)

At your disposal.
Walmes.

-
..oooO
..
..()... 0ooo...  Walmes Zeviani
...\..(.(.)... Master in Statistics and Agricultural
Experimentation
\_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil

(_/
-- 
View this message in context: 
http://n4.nabble.com/problem-with-nls-function-tp1290020p1290034.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] More than on loop??

2010-01-25 Thread jim holtman
Does this do what you want?  You were not initializing the plot before
calling 'rect'.  also it appears that you only have to call cleaved(x)
once to get the matrix and then use it in the loop -- more efficient
that way.

x<-read.table("C:/hiv.txt", header=TRUE)
num<-nrow(x)
AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y')
nc<-x$Label[61:308]
c<-x$Label[nc]
noncleaved<-function(x)
{
y<-matrix(0,20,8)
colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4")
for(i in 1:num){
if (x$Label[i] %in% nc)
{
for(j in 1:8){
res<-which(AA==substr(x$Peptide[i],j,j))
y[res, j]=y[res, j]+1
}
}
}
return (y/274*100)
}

cleaved<-function(x)
{
y<-matrix(0,20,8)
colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4")
for(i in 1:num){
if (x$Label[i] %in% nc)
{
for(j in 1:8){
res<-which(AA==substr(x$Peptide[i],j,j))
y[res, j]=y[res, j]+1
}
}
}
return (y/113*100)
}


hi<-function(x)
{
height<-rep(0,8)
for (j in 1:8){
height[j]<-sum(round(cleaved(x)[,j]))
max.height<-max(height)
}
plot(c(0,10*8),c(0,max.height+20),col="white")
}
recta<-function(x)
{
plot(0, type='n', xlim=c(0,100), ylim=c(0,60))
colmap<-c("#FF", "#CC", "#99", "#66", "#33",
"#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33",
"#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933",
"#FF9900", "#FF33FF", "#FF33CC")
x.c <- cleaved(x)
for (j in 1:8){

xx<-j*10
for(k in 1:20){

yy<-round(x.c[k,j])

rect(xx,yy,xx+10,yy+round(x.c[k,j]),col=colmap[k])
 }
 }
 }

recta(x)


On Mon, Jan 25, 2010 at 9:51 PM, che  wrote:
>
> hopefully it is here, two files, one of them is .dat and the others is .txt,
> just in case.
> http://n4.nabble.com/file/n1290026/hiv.dat hiv.dat
> http://n4.nabble.com/file/n1290026/hiv.txt hiv.txt
> --
> View this message in context: 
> http://n4.nabble.com/More-than-on-loop-tp1015851p1290026.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] More than on loop??

2010-01-25 Thread che

hopefully it is here, two files, one of them is .dat and the others is .txt,
just in case.
http://n4.nabble.com/file/n1290026/hiv.dat hiv.dat 
http://n4.nabble.com/file/n1290026/hiv.txt hiv.txt 
-- 
View this message in context: 
http://n4.nabble.com/More-than-on-loop-tp1015851p1290026.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] problem with "nls" function

2010-01-25 Thread hammadi jbeli
Dear R users,
I have a response variable in a csv file called "y" and a matrix of
predictor variables in a csv file called "mat". I have used the function
"nls" I have specified the nonlinear relation between these variable.The
code I have witten is called Rprog which begins with the phrase:
L.minor.m1<-nls(Y~a etc..
The program when I execute the program, I obtain the following message:
L.minor.m1 file not found.
You find attached Rprog, y.csv and mat.csv.
Can you please help me, it is very important for my phd thesis.
Thanks in advance.
Hammadi.
mat<- read.csv(file="mat.csv",head=FALSE,sep=";")
y<-read.csv(file="y.csv",head=FALSE,sep=";")
Y=y[,1]
D_1=mat[,1]
D_2=mat[,2]
D_3=mat[,3]
D_4=mat[,4]
Y_1=mat[,5]
Y_2=mat[,6]
Y_3=mat[,7]
Y_4=mat[,8]
s_F=mat[,9]
s_G=mat[,10]
L.minor=data.frame(Y=Y,D_1=D_1,D_2=D_2,D_3=D_3,D_4=D_4,Y_1=Y_1,Y_2=Y_2,Y_3=Y_3,Y_4=Y_4,s_F=s_F,s_G=s_G)
stdS=1/(sd(s_F))
stdG=1/(sd(s_G))
L.minor.m1<-nls(Y~a_1_1*D_1+a_2_1*D_2+a_3_1*D_3+a_4_1*D_4+a_1_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_1+a_2_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_2+a_3_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_3+a_4_2*(exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))/(1+exp(-gamma_1_F*stdS*(s_F-c_1_F))+exp(gamma_2_F*stdS*(s_F-c_2_F)))*D_4+p_1_1*Y_1+p_2_1*Y_2+p_3_1*Y_3+p_4_1*Y_4+p_1_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_1+p_2_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_2+p_3_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_3

+p_4_2*(exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))/(1+exp(-gamma_1_G*stdG*(s_G-c_1_G))+exp(gamma_2_G*stdG*(s_G-c_2_G)))*Y_4,start=list(a_1_1=0.0593,a_2_1=-0.0822,a_3_1=
0.0300
,a_4_1=-0.1259,a_1_2=-0.0477,gamma_1_F=0.5,c_1_F=-0.1555,gamma_2_F=0.5,c_2_F=-0.0292,a_2_2=
  0.0873,a_3_2= -0.0567,a_4_2= 0.1443,p_1_1=-0.0297,p_2_1= 0.1865,p_3_1= 
-0.0776,p_4_1=0.5260,p_1_2=0.0075,gamma_1_G=0.1,c_1_G=-0.1555,gamma_2_G=0.3,c_2_G=-0.0545,p_2_2=
 -0.1911,p_3_2=0.0696,p_4_2= -0.4640), trace=TRUE)
summary(L.minor.m1)


















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


Re: [R] More than on loop??

2010-01-25 Thread che

here you are the whole code, and the data is attached:
> x<-read.table("C:/Uni/502/CA2/hiv.dat", header=TRUE)
> num<-nrow(x)
> AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y')
> nc<-x$Label[61:308]
> c<-x$Label[nc]
> noncleaved<-function(x)
+ {
+ y<-matrix(0,20,8)
+ colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4")
+ for(i in 1:num){
+ if (x$Label[i] %in% nc)
+ {
+ for(j in 1:8){
+ res<-which(AA==substr(x$Peptide[i],j,j))
+ y[res, j]=y[res, j]+1
+ }
+ }
+ }
+ return (y/274*100)
+ }
> 
> cleaved<-function(x)
+ {
+ y<-matrix(0,20,8)
+ colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4")
+ for(i in 1:num){
+ if (x$Label[i] %in% nc)
+ {
+ for(j in 1:8){
+ res<-which(AA==substr(x$Peptide[i],j,j))
+ y[res, j]=y[res, j]+1
+ }
+ }
+ }
+ return (y/113*100)
+ }
> 
> hi<-function(x)
+ {
+ height<-rep(0,8)
+ for (j in 1:8){
+ height[j]<-sum(round(cleaved(x)[,j]))
+ max.height<-max(height)
+ }
+ plot(c(0,10*8),c(0,max.height+20),col="white")
+ }
> recta<-function(x)
+ {
+ colmap<-c("#FF", "#CC", "#99", "#66", "#33",
+ "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33",
+ "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933",
+ "#FF9900", "#FF33FF", "#FF33CC")
+ for (j in 1:8){
+ xx<-j*10
+ for(k in 1:20){
+ yy<-round(cleaved(x)[k,j])
+ rect(xx,yy,xx+10,yy+round(cleaved(x)[k,j]),col=colmap[k])
+  }
+  }
+  }
-- 
View this message in context: 
http://n4.nabble.com/More-than-on-loop-tp1015851p1290019.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Matching a character in a string

2010-01-25 Thread GlenB

See also ?unlist  (you can unlist(strsplit(...)) for the same effect
-- 
View this message in context: 
http://n4.nabble.com/Matching-a-character-in-a-string-tp1289795p1290011.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] newton method for single nonlinear equation

2010-01-25 Thread Roslina Zakaria

Hi r-users,
 
I would like to solve for z values using newton iteration method.  I 'm not 
sure which part of the code is wrong since I'm not very good at programming but 
would like to learn.  There seem to be some output but what I expected is a 
vector of z values.  Thank you so much for any help given.
 
newton.inputsingle <- function(pars,n)
{  runi    <- runif(974, min=0, max=1)
   lendt   <- length(runi)
   ## Parameter to estimate
   z <- vector(length=lendt, mode= "numeric")
   z  <- pars[1]
   
   ## Constant value  
   
   alp  <- 2.0165 ; rho <- 0.868; 
   c    <- sqrt(pi)/(gamma(alp)*(1-rho)^alp)
   
   for (i in 1:n)
   {  t1   <- exp(-pars[1]/(1-rho))   
  t2   <- (pars[1]*(1-rho)/(2*sqrt(rho)))^(alp-0.5)   
  bes1 <- besselI(pars[1]*sqrt(rho)/(1-rho),alp-0.5)  
  bes2 <- besselI(pars[1]*sqrt(rho)/(1-rho),alp-1.5)
  bes3 <- besselI(pars[1]*sqrt(rho)/(1-rho),alp+0.5)
 
   ## Equation
  f   <- c*t1*t2*bes1 - runi
   
   ## derivative
  fprime   <- c*t1*t2*( -bes1/(1-rho) + (alp-0.5)*bes1/pars[1] + 
sqrt(rho)*(bes2-bes3)/(2*(1-rho)))
  z[i+1] <- z[i] - f/fprime 
  }
  z
}
 
pars <- 0.5  
newton.inputsingle(pars,5)
 
The output :
 
> pars <- 0.5  
> newton.inputsingle(pars,5)
[1]  0.500 -0.4826946 -1.4653892 -2.4480838 -3.4307784 -4.4134730
Warning messages:
1: In z[i + 1] <- z[i] - f/fprime :
  number of items to replace is not a multiple of replacement length
2: In z[i + 1] <- z[i] - f/fprime :
  number of items to replace is not a multiple of replacement length
3: In z[i + 1] <- z[i] - f/fprime :
  number of items to replace is not a multiple of replacement length
4: In z[i + 1] <- z[i] - f/fprime :
  number of items to replace is not a multiple of replacement length
5: In z[i + 1] <- z[i] - f/fprime :
  number of items to replace is not a multiple of replacement length



  
[[alternative HTML version deleted]]

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


Re: [R] Matching a character in a string

2010-01-25 Thread GlenB

The output from strsplit("hello","") is not suitable as input for the second
argument for charmatch.

compare with:

 charmatch("o",strsplit("hello","")[[1]])

-- 
View this message in context: 
http://n4.nabble.com/Matching-a-character-in-a-string-tp1289795p1289976.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Summer internships

2010-01-25 Thread Nicholas Lewin-Koh



Hi 
I am forwarding this announcement the list, as one of our projects is
focused on statistical computing and graphics. Among our other projects we
have a project which involves linking dynamic graphics to genomic
information. Graduate students with a strong interest in computing are urged
to apply.

Thanks
Nicholas Lewin-Koh 

Organization Name: Genentech, Inc.
Location:  South San Francisco, California
Number of Positions:  4
Type of Student (e.g. graduate, Ph.D.):  Graduate, pursuing PhD in
Statistics, Biostatistics, or related field   
Deadline for applying for this position:  January 31, 2010 but offers may be
made earlier

 Brief Description of work
Genentech is a leading biotechnology company that discovers, develops,
manufactures and commercializes biotherapeutics for patients with
significant unmet medical needs.  For more information on Genentech, see
www.gene.com.  Our biostatistics summer interns work for 10-12 weeks under
the supervision of experienced biostatisticians on theoretical or applied
problems with direct relevance to on-going clinical or non-clinical
drug-development research in the diverse therapeutic areas including
oncology, immunology, ophthalmology, and virology.  The specific topics
range from   problems in genomics and, more generally, translational
research to late stage clinical trials and post-marketing evaluations. At
the end of his/her internship, each student gives a department-wide
presentation on their research topic.  It is not uncommon for an intern to
summarize their work in a peer-reviewed publication.  

Name and Address of Person to Contact
E-Mail: Please send CV, personal statement of interest and a letter of
recommendation to gne20...@gene.com 
 
Other Relevant Information
Applicants must be at least 18 years old and must be current graduate
students pursuing a PhD degree in statistics, biostatistics or related field
who have completed at least one year of graduate work by May 2010 and who
will be returning to school in the fall of 2010.  The applicant must be
legally authorized to work in the US.  In addition, applicants should have a
good working knowledge of R, S-Plus or SAS and have good communication
skills.

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


Re: [R] Microsoft SQL Server and R

2010-01-25 Thread Seeliger . Curt
r-help-boun...@r-project.org wrote on 01/25/2010 03:32:41 PM:
Jim writes to David:
> These days I tend to use RJDBC http://www.rforge.net/RJDBC/ which is a
> bit less of a hassle.
> 
> Hint use the jtds driver http://jtds.sourceforge.net/
> ...
> >
> > I have a client running Microsoft SQL Server. I am interested in 
> ways of  accessing data from this server using R.

We use RODBC here, with some snags:
a) The column types in the dataframes returned by sqlFetch() are 
independent of the table definitions; instead they seem to be based on the 
values in each column.
b) sqlQuery() will report an error if the query returns no rows, which is 
perfectly legal and even expected when performing an update to a table.
c) Probably others too, but my memory is short today.

Good question, I'm hoping for some tips on this myself.

cur
-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638

[[alternative HTML version deleted]]

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


Re: [R] Min hash

2010-01-25 Thread Bert Gunter
Did you perchance try

RSiteSearch("hash",restr="func")

or check the "hash" package on CRAN (or BioConductor or ...) ??

No clue whether any of this is relevant, but  it seems like a sensible first
place to look. 

Bert Gunter
Genentech Nonclinical Biostatistics
 
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Nathan Stephens
Sent: Monday, January 25, 2010 3:32 PM
To: r-help
Subject: [R] Min hash

Anyone know of a min hash algorithm written in R?

--Nathan

[[alternative HTML version deleted]]

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

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


Re: [R] Microsoft SQL Server and R

2010-01-25 Thread Jim Porzak
David,

You can certainly use RODBC to get to MS SQL, once you configure the
ODBC connection in windows.

These days I tend to use RJDBC http://www.rforge.net/RJDBC/ which is a
bit less of a hassle.

Hint use the jtds driver http://jtds.sourceforge.net/

HTH,
Jim Porzak
Ancestry.com
San Francisco, CA
www.linkedin.com/in/jimporzak
use R! Group SF: www.meetup.com/R-Users/


On Mon, Jan 25, 2010 at 2:55 PM, David Scott  wrote:
>
> I have a client running Microsoft SQL Server. I am interested in ways of  
> accessing data from this server using R.
>
> I would welcome any information about how this can be done. I have a 
> reasonable grasp of SQL and have experience with MySQL and RODBC but don't 
> know anything much about Microsoft SQL Server.
>
> David Scott
> --
> _
> David Scott     Department of Statistics
>                The University of Auckland, PB 92019
>                Auckland 1142,    NEW ZEALAND
> Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
> Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018
>
> Director of Consulting, Department of Statistics
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Min hash

2010-01-25 Thread Nathan Stephens
Anyone know of a min hash algorithm written in R?

--Nathan

[[alternative HTML version deleted]]

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


Re: [R] Data transformation

2010-01-25 Thread Gabor Grothendieck
Try this:

> t(apply(x, 1, function(r) table(factor(r, levels = seq_len(max(x))
 1 2 3 4 5 6 7 8 9 10
[1,] 1 0 1 0 0 0 0 0 0  0
[2,] 0 2 0 0 0 0 0 0 0  0
[3,] 0 0 0 1 0 0 1 0 0  0
[4,] 0 0 0 0 0 1 0 1 0  0
[5,] 0 0 0 0 1 0 0 0 0  1

If you use aaply in the plyr package instead of apply then you can
omit the transpose.


On Mon, Jan 25, 2010 at 5:39 PM, Lisa  wrote:
>
> Dear all,
>
> I  have a dataset that looks like this:
>
> x <- read.table(textConnection("col1 col2
> 3 1
> 2 2
> 4 7
> 8 6
> 5 10"), header=TRUE)
>
> I want to rewrite it as below:
>
> var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
>    1     0     1      0     0     0     0     0      0      0
>    0     2     0      0     0     0     0     0      0      0
>    0     0     0      1     0     0     1     0      0      0
>    0     0     0      0     0     1     0     1      0      0
>    0     0     0      0     1     0     0     0      0      1
>
> Can anybody please help how to get this done? Your help would be greatly
> appreciated.
>
> Lisa
>
> --
> View this message in context: 
> http://n4.nabble.com/Data-transformation-tp1289899p1289899.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Data transformation

2010-01-25 Thread Seeliger . Curt
r-help-boun...@r-project.org wrote on 01/25/2010 02:39:32 PM:
> x <- read.table(textConnection("col1 col2 
> 3 1 
> 2 2 
> 4 7 
> 8 6 
> 5 10"), header=TRUE) 
> 
> I want to rewrite it as below:
> 
> var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
> 1 0 1  0 0 0 0 0  0  0
> 0 2 0  0 0 0 0 0  0  0
> 0 0 0  1 0 0 1 0  0  0
> 0 0 0  0 0 1 0 1  0  0
> 0 0 0  0 1 0 0 0  0  1
> 
> Can anybody please help how to get this done? Your help would be greatly
> appreciated. 

Thanks, I've not seen textConnection() before.  The table() function will 
get you close:

table(c(rownames(x),rownames(x)), c(x$col1,x$col2))

cur
-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638



[[alternative HTML version deleted]]

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


Re: [R] Data transformation

2010-01-25 Thread Lisa

Thank you so much.

Lisa
-- 
View this message in context: 
http://n4.nabble.com/Data-transformation-tp1289899p1289915.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Microsoft SQL Server and R

2010-01-25 Thread David Scott


I have a client running Microsoft SQL Server. I am interested in ways of 
 accessing data from this server using R.


I would welcome any information about how this can be done. I have a 
reasonable grasp of SQL and have experience with MySQL and RODBC but 
don't know anything much about Microsoft SQL Server.


David Scott
--
_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

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


Re: [R] Data transformation

2010-01-25 Thread Steve Lianoglou
Hi,

On Mon, Jan 25, 2010 at 5:39 PM, Lisa  wrote:
>
> Dear all,
>
> I  have a dataset that looks like this:
>
> x <- read.table(textConnection("col1 col2
> 3 1
> 2 2
> 4 7
> 8 6
> 5 10"), header=TRUE)
>
> I want to rewrite it as below:
>
> var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
>    1     0     1      0     0     0     0     0      0      0
>    0     2     0      0     0     0     0     0      0      0
>    0     0     0      1     0     0     1     0      0      0
>    0     0     0      0     0     1     0     1      0      0
>    0     0     0      0     1     0     0     0      0      1
>
> Can anybody please help how to get this done? Your help would be greatly
> appreciated.

I was trying to do it w/o for loops, but I can't figure out a way to do so:

R> bounds <- range(x)
R> m <- matrix(0, nrow=nrow(x), ncol=bounds[2])
R> colnames(m) <- paste('var', seq(bounds[2]), sep="")
## Ugly nested for-loop one-liner below
R> for (i in 1:nrow(x))for (j in 1:ncol(x)) m[i,x[i,j]] <- m[i,x[i,j]] + 1
R> m

 var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
[1,]101000000 0
[2,]020000000 0
[3,]000100100 0
[4,]000001010 0
[5,]000010000 1

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] Data transformation

2010-01-25 Thread Sarah Goslee
Well, I have no idea how to get from one to the other. There's
col1 and col2 but no var1 var2 var3, etc. I thought perhaps col1
was the row index and col2 was the column index, but that doesn't
match up either, and not all the cell values are 1.

So you will need to explain more clearly what you intend.

Meanwhile, you might try reshape, or perhaps crosstab from the
ecodist package.

Sarah

On Mon, Jan 25, 2010 at 5:39 PM, Lisa  wrote:
>
> Dear all,
>
> I  have a dataset that looks like this:
>
> x <- read.table(textConnection("col1 col2
> 3 1
> 2 2
> 4 7
> 8 6
> 5 10"), header=TRUE)
>
> I want to rewrite it as below:
>
> var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
>    1     0     1      0     0     0     0     0      0      0
>    0     2     0      0     0     0     0     0      0      0
>    0     0     0      1     0     0     1     0      0      0
>    0     0     0      0     0     1     0     1      0      0
>    0     0     0      0     1     0     0     0      0      1
>
> Can anybody please help how to get this done? Your help would be greatly
> appreciated.
>
> Lisa
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] Data transformation

2010-01-25 Thread Lisa

Dear all,

I  have a dataset that looks like this:

x <- read.table(textConnection("col1 col2 
3 1 
2 2 
4 7 
8 6 
5 10"), header=TRUE) 

I want to rewrite it as below:

var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
1 0 1  0 0 0 0 0  0  0
0 2 0  0 0 0 0 0  0  0
0 0 0  1 0 0 1 0  0  0
0 0 0  0 0 1 0 1  0  0
0 0 0  0 1 0 0 0  0  1

Can anybody please help how to get this done? Your help would be greatly
appreciated. 

Lisa 

-- 
View this message in context: 
http://n4.nabble.com/Data-transformation-tp1289899p1289899.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] ff package: ff objects don't reload compl etely on NFS drives from a different machine

2010-01-25 Thread Jens Oehlschlägel
Try to close the file on the first nfs client before reopening it on the second 
nfs client. NFS has something called "close-to-open cache consistency".
This means that two clients which have the same nfs file open, cannot rely on 
seeing the updates from the respective other client. If one clients closes, and 
the other client opens thereafter, it should see the changes. If you want 
multiple clients to write at the same time, you should make sure they only 
write non-overlapping sections (and then all need to close for synching). Let 
me know if this worked for you. 
J.

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


[R] Postscript graphs

2010-01-25 Thread Lu Wang
Hi,

I tried to use the following commands to create a postscript pie chart using R:

postscript(file="H:/piechart.eps")
# then I wrote my commands to generate the pie chart
pie(filename,labels=,col=,radius=0.6)
dev.off()

After I ran those commands, instead of giving the pie chart, it showed 
> dev.off()
postscript 
 2 
> 
In my H drive, there is a file called piechart.eps, but I want to look at it. 
Is there any way I can see the figure and import it to word or pdf file? I am 
writing a paper that needs this graph. It would be more helpful If I can see it.

Thanks,
John



  
[[alternative HTML version deleted]]

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


Re: [R] PCA: Showing file datalabels on biplot

2010-01-25 Thread colin1

Many thanks Kevin,

As a result of your advice, and that of other helpful experts, I ended up with 
the following script, which worked brilliantly:


cat <-read.table("R855868825matrix.csv", sep=",", header=T)

 head (cat, n=24)

catopsis = cat[,-1]
row.names(catopsis) = cat$sample

pca <- prcomp (t(catopsis))

plot(pca, catopsis [])

summary(prcomp(catopsis))

biplot(prcomp(catopsis, scale = TRUE))

  - Original Message - 
  From: Kevin Wright-5 [via R] 
  To: colin1 
  Sent: Monday, January 25, 2010 5:04 PM
  Subject: Re: [R] PCA: Showing file datalabels on biplot


  str(catopsis) shows no labels, so how can biplot know what to use? 

  Try this before call prcomp: 

  colnames(catopsis) <- c('a','b','c','d') 
  rownames(catopsis) <- cat$sample 

  Also, see the 'reshape' package for easier data manipulation. 

  Kevin 


  On Mon, Jan 25, 2010 at 10:39 AM, colin1 <[hidden email]>wrote: 


  > 
  > The script below successfully produces a biplot of the data but the 'site 
  > names' (rows) and the names of the 'response variables' (columns) are shown 
  > as simple numerals (rather than the column and row names). How might I 
  > 'enforce' the use of the row/column names used in the datafile (section of 
  > datafile shown below)? 
  > Can anyone help, please? 
  > 
  > Section of datafile 
  > 
  > sample  a   b   c   d ---n42 
  > HBR-6   1   1   1   1 
  > HBR-7   1   1   1   2 
  > HBR-8   1   1   1   1 
  > HBR-9   1   1   1   2 
  > HBR-10  1   1   1   1 
  > HBR-11  1   1   1   1 
  > HBR-12  1   1   1   1 
  > HBR-13  1   1   1   1 
  > HBR-14  2   1   2   2 
  > HBR-15  2   1   2   1 
  > HBR-16  1   1   2   1 
  > HBR-17  1   1   2   1 
  > HBR-18  1   1   2   1 
  > HBR-19  1   1   2   1 
  > HBR-20  1   1   2   1 
  > HBR-21  1   2   1   1 
  > HBR-30  1   1   2   2 
  > HBR-31  1   2   1   2 
  > HBR-32  2   2   1   2 
  > HBR-33  1   2   1   2 
  > HBR-34  1   2   2   2 
  > HBR-35  1   2   2   1 
  > HBR-36  1   2   1   2 
  > HBR-37  1   2   1   2 
  > 
  > 
  > cat <-read.table("R855868825matrix.csv", sep=",", header=T) 
  >  head (cat, n=24) 
  > catopsis <- (cbind(cat$a, cat$b, cat$c, cat$d, cat$e, cat$f, cat$g, cat$h, 
  > cat$i, cat$j, cat$k, cat$l, cat$m, cat$n, cat$o, cat$p, cat$q, cat$r, 
  > cat$s, 
  > cat$t, cat$u, cat$v, cat$w, cat$x, cat$y, cat$z, cat$aa, cat$ab, cat$ac, 
  > cat$ad, cat$ae, cat$af, cat$ag, cat$ah, cat$ai, cat$aj, cat$ak, cat$al, 
  > cat$am, cat$an, cat$ao, cat$ap)) 
  > pca <- prcomp (t(catopsis)) 
  > plot(pca, catopsis []) 
  > summary(prcomp(catopsis)) 
  > biplot(prcomp(catopsis, scale = TRUE)) 
  > 
  > -- 
  > View this message in context: 
  > 
http://n4.nabble.com/PCA-Showing-file-datalabels-on-biplot-tp1289524p1289524.html
  > Sent from the R help mailing list archive at Nabble.com. 
  > 
  > __ 
  > [hidden email] mailing list 
  > https://stat.ethz.ch/mailman/listinfo/r-help
  > PLEASE do read the posting guide 
  > http://www.R-project.org/posting-guide.html
  > and provide commented, minimal, self-contained, reproducible code. 
  > 



  -- 
  Kevin Wright 

  [[alternative HTML version deleted]] 

  __ 
  [hidden email] mailing list 
  https://stat.ethz.ch/mailman/listinfo/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 message @ 
http://n4.nabble.com/PCA-Showing-file-datalabels-on-biplot-tp1289524p1289545.html
 
  To unsubscribe from PCA: Showing file datalabels on biplot, click here. 


-- 
View this message in context: 
http://n4.nabble.com/PCA-Showing-file-datalabels-on-biplot-tp1289524p1289869.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] question on sqldf syntax

2010-01-25 Thread Gabor Grothendieck
On Mon, Jan 25, 2010 at 2:17 PM, GL  wrote:
>
> trying to structure sql to merge two datasets. structure follows:
>
> dbs.possible.combos (all possible combinations of dates and places)
> Date Place
> 1/1/10 N-01
> 1/1/10 S-02
> 1/2/10 N-01
> 1/2/10 S-02
> etc...
>
> dbs.aggregate (the raw data aggregated by date and location)
> Date Place Days
> 1/1/10 N-01 6
> 1/1/10 S-02 10
> 1/2/10 S-02 5
>
>
> Trying to merge so I look-up the values for each possible combo
> dbs.final <- sqldf("select dbs.possible.combos$Date,
> dbs.possible.combos$Place, dbs.possible.combos$Days FROM dbs.possible.combos
> LEFT JOIN dbs.aggregate ON (dbs.possible.combos$Place = dbs.aggregate$Place)
> AND (dbs.possible.combos$Date = dbs.aggregate$Date)")
>
> Resulting in:
> Error in sqliteExecStatement(con, statement, bind.data) :
>  RS-DBI driver: (error in statement: near ".": syntax error)
>
> What am I getting wrong in the syntax?

You have to pass it a valid SQL statement but $ is not an SQL
operator.  Also dot (.) is an SQL operator so you have quote
identifiers that contain a dot so that it will not regard those dots
as operators.

Try this:

library(sqldf)

lines1 <- "Date Place
1/1/10 N-01
1/1/10 S-02
1/2/10 N-01
1/2/10 S-02"
dbs.possible.combos <-
   read.table(textConnection(lines1), header = TRUE, as.is = TRUE)

lines2 <- "Date Place Days
1/1/10 N-01 6
1/1/10 S-02 10
1/2/10 S-02 5"
dbs.aggregate <- read.table(textConnection(lines2), header = TRUE, as.is = TRUE)

dbs.final <- sqldf('select Date, Place, Days
FROM "dbs.possible.combos"
LEFT JOIN "dbs.aggregate" using (Place, Date)')

Giving:

> dbs.final
Date Place Days
1 1/1/10  N-016
2 1/1/10  S-02   10
3 1/2/10  N-01   NA
4 1/2/10  S-025

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


Re: [R] question on sqldf syntax

2010-01-25 Thread lith
On 25 Jan., 20:26, GL  wrote:
> Actually, better sql would likely be:
>
> dbs.final <- sqldf("select * from dbs.possible.combos left join
> dbs.aggregate using (Date,Place)")
>
> but this still doesn't work

I'd suspect name mangling to cause the problem:
http://code.google.com/p/sqldf/#2._Why_does_sqldf_seem_to_mangle_certain_variable_names?

Try to quote the table names with backticks (`).

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


Re: [R] R Output and ArcGIS

2010-01-25 Thread Paul Hiemstra

Steve Murray wrote:

Dear all,

I've been using R on a Mac to process some data for export to ArcMap GIS (which only runs on 
Windows). ArcMap seems to require tab-delimited data (my data are in 3 columns), so I've been using 
the sep="\t" argument. However, this resulted in strange end-of-line characters when 
displayed on a PC. I looked in the write.table help file to find that eol="\r\n" can be 
used to get around this problem, and it does indeed prevent these unwanted characters from 
appearing.

However, the data still aren't properly recognised by ArcMap when created on a 
Mac (the exact same code works fine from a PC). In ArcMap, when I select 
'Display XY Data', the X (Longitude) and Y (Latitude) columns aren't available 
to select. It's as if Arc isn't correctly interpreting the output from R - this 
is despite me using col.names=TRUE in the write.table command.

Any light shed on this will be very gratefully received.

Many thanks for your help,

Steve

 		 	   		  
_

We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

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

Hi,

In addition to the other people. If you convert your data in R to one of 
the spatial classes (see the sp-pacakge) you can use the rgdal-package 
to dump these objects to e.g. a shapefile. This can be read by ArcGIS.


As a note, there is a special mailing list for geographic data and R, 
r-sig-geo, which might be a better place to ask these kind of specific 
questions.


good luck!

Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] Two == expressions in bquote

2010-01-25 Thread Bert Gunter
Peter's way is better than mine.

Bert Gunter
Genentech Nonclinical Biostatistics
 
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Peter Dalgaard
Sent: Monday, January 25, 2010 12:57 PM
To: Larry Hotchkiss
Cc: r-help@r-project.org
Subject: Re: [R] Two == expressions in bquote

Larry Hotchkiss wrote:
> Hi,
> 
> I want to put text on a plot containing something like: a = b^2 =  using bquote.
> 
> Example:
> 
>   mu = 5
>   plot(1:10,1:10)
>   text(2,8, bquote(delta == mu^2))# This works
>   text(2.5,8, bquote(phantom(0) == .(mu^2)))  # but is unpredictable
> 
>   text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work
> 
> The last text function returns the error:
> 
>  Error: unexpected '==' in "  text(2,8, bquote(delta == mu^2 =="

The comparison operators are not associative (they once were, but people 
were getting surprises from 3 > 2 > 1 evaluating to TRUE > 1 evaluating 
to FALSE). A set of suitably placed braces should clear things up:

text(2,8,bquote(delta == {mu^2 == .(mu^2)}))


> The first two text functions work in this example, using a default
graphics window on a 64-bit Windows machine, and either R 2.11.0 development
edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)). 
> 
> I don't mind the two statements except that when trying to automate this
by using the base x coordinate + epsilon*max(x), for example --
> 
>   x <- 1:10
>   epsilon=0.05
>   text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2)))
> 
> for the x position on the 2nd text function, the position of the
additional text is not predictable.
> 
> Thanks,
> 
> Larry Hotchkiss
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


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

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

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


Re: [R] Two == expressions in bquote

2010-01-25 Thread Bert Gunter
I think that careful examination will show that Henrique's solution is not
quite right: the text '=' character is slightly different than the symbol
font character. This is admittedly nitpicking, but ...

try instead:

text(2,8,bquote(paste(delta==mu^2,phantom()==.(mu^2

Cheers,

Bert Gunter
Genentech Nonclinical Biostatistics
 
 
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Henrique Dallazuanna
Sent: Monday, January 25, 2010 12:10 PM
To: Larry Hotchkiss
Cc: r-help@r-project.org
Subject: Re: [R] Two == expressions in bquote

Try this:

text(2,8, bquote(delta~'='~mu^2 == .(mu^2)))

On Mon, Jan 25, 2010 at 6:00 PM, Larry Hotchkiss  wrote:
> Hi,
>
> I want to put text on a plot containing something like: a = b^2 =  using bquote.
>
> Example:
>
>  mu = 5
>  plot(1:10,1:10)
>  text(2,8, bquote(delta == mu^2))            # This works
>  text(2.5,8, bquote(phantom(0) == .(mu^2)))  # but is unpredictable
>
>  text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work
>
> The last text function returns the error:
>
>     Error: unexpected '==' in "  text(2,8, bquote(delta == mu^2 =="
>
> The first two text functions work in this example, using a default
graphics window on a 64-bit Windows machine, and either R 2.11.0 development
edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)).
>
> I don't mind the two statements except that when trying to automate this
by using the base x coordinate + epsilon*max(x), for example --
>
>  x <- 1:10
>  epsilon=0.05
>  text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2)))
>
> for the x position on the 2nd text function, the position of the
additional text is not predictable.
>
> Thanks,
>
> Larry Hotchkiss
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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

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


Re: [R] Matching a character in a string

2010-01-25 Thread Paul Hiemstra

Fabrice DELENTE wrote:

Hello.

Sorry for this very basic question but I didn't find (of didn't understand)
the answer either in the help or in the online guide.

I have a string, let's say "hello". I want to know if there is some
character in it, let's say an 'o'.

I tried

  

charmatch("o", strstplit("hello",""))



but it gives NA (why??)

Thinking it may be a type problem, I tried

  

charmatch("o",as.character(strsplit("hello","")))



but it gives NA too (why???)

So how can I know if a given string contains a given char?

Thanks!

  

try:

grep("o", "hello")

if the output is 1, there is a match. Note that the command is 
vectorized so:


grep("o", c("hello","pizza", "spam", "ogle"))

also works, picking out items 1 and 4 as containing an "o". The first 
argument to grep is a regular expression, and this can be very powerful. 
For example, which words start with a "p":


grep("^p", c("hello","pizza", "spam", "ogle"))

Check out more stuff on regular expressions on the internet. They are 
very powerful, but take some time to learn.


cheers,
Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] Two == expressions in bquote

2010-01-25 Thread Peter Dalgaard

Larry Hotchkiss wrote:

Hi,

I want to put text on a plot containing something like: a = b^2 =  using bquote.

Example:

  mu = 5
  plot(1:10,1:10)
  text(2,8, bquote(delta == mu^2))# This works
  text(2.5,8, bquote(phantom(0) == .(mu^2)))  # but is unpredictable

  text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work

The last text function returns the error:

 Error: unexpected '==' in "  text(2,8, bquote(delta == mu^2 =="


The comparison operators are not associative (they once were, but people 
were getting surprises from 3 > 2 > 1 evaluating to TRUE > 1 evaluating 
to FALSE). A set of suitably placed braces should clear things up:


text(2,8,bquote(delta == {mu^2 == .(mu^2)}))


The first two text functions work in this example, using a default graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)). 


I don't mind the two statements except that when trying to automate this by 
using the base x coordinate + epsilon*max(x), for example --

  x <- 1:10
  epsilon=0.05
  text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2)))

for the x position on the 2nd text function, the position of the additional 
text is not predictable.

Thanks,

Larry Hotchkiss

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



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

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


[R] Matching a character in a string

2010-01-25 Thread Fabrice DELENTE
Hello.

Sorry for this very basic question but I didn't find (of didn't understand)
the answer either in the help or in the online guide.

I have a string, let's say "hello". I want to know if there is some
character in it, let's say an 'o'.

I tried

> charmatch("o", strstplit("hello",""))

but it gives NA (why??)

Thinking it may be a type problem, I tried

> charmatch("o",as.character(strsplit("hello","")))

but it gives NA too (why???)

So how can I know if a given string contains a given char?

Thanks!

-- 
Fabrice DELENTE

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


Re: [R] Issue using tapply

2010-01-25 Thread LCOG1

Ista you have suggested the correct solution, i didnt htink it would matter
not having that value but it did. Things work as they should now, thankyou
-- 
View this message in context: 
http://n4.nabble.com/Issue-using-tapply-tp1289681p1289764.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Two == expressions in bquote

2010-01-25 Thread Henrique Dallazuanna
Try this:

text(2,8, bquote(delta~'='~mu^2 == .(mu^2)))

On Mon, Jan 25, 2010 at 6:00 PM, Larry Hotchkiss  wrote:
> Hi,
>
> I want to put text on a plot containing something like: a = b^2 =  numeric value of b> using bquote.
>
> Example:
>
>  mu = 5
>  plot(1:10,1:10)
>  text(2,8, bquote(delta == mu^2))            # This works
>  text(2.5,8, bquote(phantom(0) == .(mu^2)))  # but is unpredictable
>
>  text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work
>
> The last text function returns the error:
>
>     Error: unexpected '==' in "  text(2,8, bquote(delta == mu^2 =="
>
> The first two text functions work in this example, using a default graphics 
> window on a 64-bit Windows machine, and either R 2.11.0 development edition 
> for 64-bit Windows or R 9.2.2 on the same machine ((x 86)).
>
> I don't mind the two statements except that when trying to automate this by 
> using the base x coordinate + epsilon*max(x), for example --
>
>  x <- 1:10
>  epsilon=0.05
>  text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2)))
>
> for the x position on the 2nd text function, the position of the additional 
> text is not predictable.
>
> Thanks,
>
> Larry Hotchkiss
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] Error in plot.new()

2010-01-25 Thread jean luc picard

My distribution is Ubuntu.

xwininfo: Window id: 0x441 "R Graphics: Device 2 (ACTIVE)"

  Absolute upper-left X:  558
  Absolute upper-left Y:  27
  Relative upper-left X:  558
  Relative upper-left Y:  27
  Width: 787
  Height: 744
  Depth: 24
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: Always
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +558+27  --67+27  --67-27  +558-27
  -geometry 787x744--67+27

> plot(1:5,1:5)
> capabilities()
jpeg  png tifftcltk  X11 aqua http/ftp  sockets 
TRUE TRUE TRUE TRUE TRUEFALSE TRUE TRUE 
  libxml fifo   clediticonv  NLS  profmemcairo 
TRUE TRUE TRUE TRUE TRUE TRUE TRUE 
Warning message:
Display list redraw incomplete 


Restarting with R --vanilla:
> X11(type="Xlib")
> plot(1:5,1:5)
> plot(1:5,1:5)
> X11(type="cairo")
> X11(type="cairo")
> plot(1:5,1:5)
> plot(1:5,1:5)
> plot(1:5,1:5)
> q()

Windows are opened but no plot is displayed.
Any further ideas?

Many thanks.

Peter
-- 
View this message in context: 
http://n4.nabble.com/Error-in-plot-new-tp1288878p1289769.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Two == expressions in bquote

2010-01-25 Thread Larry Hotchkiss
Hi,

I want to put text on a plot containing something like: a = b^2 =  using bquote.

Example:

  mu = 5
  plot(1:10,1:10)
  text(2,8, bquote(delta == mu^2))# This works
  text(2.5,8, bquote(phantom(0) == .(mu^2)))  # but is unpredictable

  text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work

The last text function returns the error:

 Error: unexpected '==' in "  text(2,8, bquote(delta == mu^2 =="

The first two text functions work in this example, using a default graphics 
window on a 64-bit Windows machine, and either R 2.11.0 development edition for 
64-bit Windows or R 9.2.2 on the same machine ((x 86)). 

I don't mind the two statements except that when trying to automate this by 
using the base x coordinate + epsilon*max(x), for example --

  x <- 1:10
  epsilon=0.05
  text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2)))

for the x position on the 2nd text function, the position of the additional 
text is not predictable.

Thanks,

Larry Hotchkiss

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


Re: [R] Issue using tapply

2010-01-25 Thread Henrique Dallazuanna
Try this:

tapply(Emp.Et.Em[EtToEm..$Et], EtToEm..$Em, sum, na.rm = TRUE)


On Mon, Jan 25, 2010 at 4:57 PM, LCOG1  wrote:
>
> Hello all,
>   I am trying to use the tapply function to sum some values and change the
> column names of the resulting vector.
>
> I input
>     Emp  Et
> 1  10565 ACC
> 2   7515 ADM
> 3    625 AGF
> 4   6243 CNS
> 5  12721 EDU
> 6   3924 FIN
> 7  18140 HLH
> 8   3686 INF
> 9  15841 MFG
> 10   243 MIN
> 11  1864 MNG
> 12  4664 OSV
> 13  5496 PRF
> 14  4988 PUB
> 15  2166 REC
> 16  2153 REL
> 17 16082 RTL
> 18  3582 TRN
> 19   757 UTL
> 20  5818 WHL
>
> and i want to aggregate certain types based on the following matches
>
>    Et     Em
> 1  AGF AFREMP
> 2  MIN MINEMP
> 3  UTL TCPEMP
> 4  CNS CONEMP
> 5  MFG MFGEMP
> 6  WHL WSTEMP
> 7  RTL RETEMP
> 8  TRN TCPEMP
> 9  INF SVCEMP
> 10 FIN FINEMP
> 11 REL FINEMP
> 12 PRF SVCEMP
> 13 MNG FINEMP
> 14 ADM SVCEMP
> 15 EDU SVCEMP
> 16 HLH SVCEMP
> 17 REC SVCEMP
> 18 ACC SVCEMP
> 19 RST SVCEMP
> 20 OSV SVCEMP
> 21 PUB GVTEMP
>
> but the last value in my result is NA when it should be 5818. so my actual
> result is
> AFREMP CONEMP FINEMP GVTEMP MFGEMP MINEMP RETEMP SVCEMP TCPEMP WSTEMP
>   625       6243     7941      4988    15841     243    3582     81035
> 6575     NA
>
> I have rechecks to make sure there isnt a simple labeling error but i havent
> found anything.  Below is test code.
>
> Et<-c("AGF","MIN","UTL","CNS","MFG","WHL","RTL","TRN","INF","FIN","REL",
> "PRF","MNG","ADM","EDU","HLH","REC","ACC","RST","OSV","PUB")
>
> Em<-c("AFREMP","MINEMP","TCPEMP","CONEMP","MFGEMP","WSTEMP","RETEMP","TCPEMP",
> "SVCEMP","FINEMP","FINEMP","SVCEMP","FINEMP","SVCEMP","SVCEMP","SVCEMP","SVCEMP",
> "SVCEMP","SVCEMP","SVCEMP","GVTEMP")
>
> EtToEm..<-data.frame(Et,Em)
>
> Emp<-c(10565,7515,625,6243,12721,3924,18140,3686,15841,243,1864,4664,5496,4988
> ,2166,2153,16082,3582,757,5818)
>
> Et.t<-c("ACC","ADM","AGF","CNS","EDU","FIN","HLH","INF","MFG","MIN"
> ,"MNG","OSV"
> ,"PRF","PUB","REC","REL","RTL","TRN","UTL","WHL")
>
> Emp.Et<-data.frame(Emp,Et.t)
> names(Emp.Et)[2]<-"Et"
>
> Emp.Et.Em<-as.vector(Emp.Et$Em)
> names(Emp.Et.Em) <- Emp.Et$Et
>
> EmpEt.Em <- tapply(Emp.Et.Em[EtToEm..$Et], EtToEm..$Em, sum)
>
> --
> View this message in context: 
> http://n4.nabble.com/Issue-using-tapply-tp1289681p1289681.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] Issue using tapply

2010-01-25 Thread Ista Zahn
I think the problem is that there is no value for RST in Emp.Et.Em.

-Ista

On Mon, Jan 25, 2010 at 6:57 PM, LCOG1  wrote:
>
> Hello all,
>   I am trying to use the tapply function to sum some values and change the
> column names of the resulting vector.
>
> I input
>     Emp  Et
> 1  10565 ACC
> 2   7515 ADM
> 3    625 AGF
> 4   6243 CNS
> 5  12721 EDU
> 6   3924 FIN
> 7  18140 HLH
> 8   3686 INF
> 9  15841 MFG
> 10   243 MIN
> 11  1864 MNG
> 12  4664 OSV
> 13  5496 PRF
> 14  4988 PUB
> 15  2166 REC
> 16  2153 REL
> 17 16082 RTL
> 18  3582 TRN
> 19   757 UTL
> 20  5818 WHL
>
> and i want to aggregate certain types based on the following matches
>
>    Et     Em
> 1  AGF AFREMP
> 2  MIN MINEMP
> 3  UTL TCPEMP
> 4  CNS CONEMP
> 5  MFG MFGEMP
> 6  WHL WSTEMP
> 7  RTL RETEMP
> 8  TRN TCPEMP
> 9  INF SVCEMP
> 10 FIN FINEMP
> 11 REL FINEMP
> 12 PRF SVCEMP
> 13 MNG FINEMP
> 14 ADM SVCEMP
> 15 EDU SVCEMP
> 16 HLH SVCEMP
> 17 REC SVCEMP
> 18 ACC SVCEMP
> 19 RST SVCEMP
> 20 OSV SVCEMP
> 21 PUB GVTEMP
>
> but the last value in my result is NA when it should be 5818. so my actual
> result is
> AFREMP CONEMP FINEMP GVTEMP MFGEMP MINEMP RETEMP SVCEMP TCPEMP WSTEMP
>   625       6243     7941      4988    15841     243    3582     81035
> 6575     NA
>
> I have rechecks to make sure there isnt a simple labeling error but i havent
> found anything.  Below is test code.
>
> Et<-c("AGF","MIN","UTL","CNS","MFG","WHL","RTL","TRN","INF","FIN","REL",
> "PRF","MNG","ADM","EDU","HLH","REC","ACC","RST","OSV","PUB")
>
> Em<-c("AFREMP","MINEMP","TCPEMP","CONEMP","MFGEMP","WSTEMP","RETEMP","TCPEMP",
> "SVCEMP","FINEMP","FINEMP","SVCEMP","FINEMP","SVCEMP","SVCEMP","SVCEMP","SVCEMP",
> "SVCEMP","SVCEMP","SVCEMP","GVTEMP")
>
> EtToEm..<-data.frame(Et,Em)
>
> Emp<-c(10565,7515,625,6243,12721,3924,18140,3686,15841,243,1864,4664,5496,4988
> ,2166,2153,16082,3582,757,5818)
>
> Et.t<-c("ACC","ADM","AGF","CNS","EDU","FIN","HLH","INF","MFG","MIN"
> ,"MNG","OSV"
> ,"PRF","PUB","REC","REL","RTL","TRN","UTL","WHL")
>
> Emp.Et<-data.frame(Emp,Et.t)
> names(Emp.Et)[2]<-"Et"
>
> Emp.Et.Em<-as.vector(Emp.Et$Em)
> names(Emp.Et.Em) <- Emp.Et$Et
>
> EmpEt.Em <- tapply(Emp.Et.Em[EtToEm..$Et], EtToEm..$Em, sum)
>
> --
> View this message in context: 
> http://n4.nabble.com/Issue-using-tapply-tp1289681p1289681.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] Delete components of a list

2010-01-25 Thread Lisa

It works well. Thank you very much.

Lisa
-- 
View this message in context: 
http://n4.nabble.com/Delete-components-of-a-list-tp1289732p1289745.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R2WinBUGS trap

2010-01-25 Thread julien martin
I am generating 1000 replicate data sets in R, each data set is then
analyzed with WinBUGS in batch mode using R2WinBUGS. Unfortunately,
occasionally some data sets lead WinBUGS to open a "trap" window; and
the simulations are interrupted as result of the message. Is there any
ways to set R2WinBUGS so that it would ignore the trap message and
proceed with the simulations?
Cheers

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


Re: [R] Delete components of a list

2010-01-25 Thread Henrique Dallazuanna
Try this:

# Exclude the first column:
lapply(l, '[', -1)

# Remove the second row:
lapply(l, '[', , i = -2)



On Mon, Jan 25, 2010 at 5:37 PM, Lisa  wrote:
>
> Dear all,
>
> I have a question about deleting components of a list. For example, I have a
> list that looks like this:
>
> [[1]]
> var1 var2 var3
>   1    3    4
>   2    2    1
>
> [[2]]
> var1 var2 var3
>   2    5    1
>   2    1    7
>
> [[3]]
> var1 var2 var3
>   1    6    7
>   3    8    4
>
> How to delete, say, the first columns of the list or the second rows? Thank
> in advance.
>
> Lisa
>
> --
> View this message in context: 
> http://n4.nabble.com/Delete-components-of-a-list-tp1289732p1289732.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


[R] R2WinBUGS/ trap

2010-01-25 Thread julien martin
I am generating 1000 replicate data sets in R, each data set is then
analyzed with WinBUGS in batch mode using R2WinBUGS. Unfortunately,
occasionally some data sets lead WinBUGS to open a "trap" window; and the
simulations are interrupted as result of the message. Is there any ways to
set R2WinBUGS so that it would ignore the trap message and  proceed with the
simulations?
Cheers

[[alternative HTML version deleted]]

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


[R] Delete components of a list

2010-01-25 Thread Lisa

Dear all,

I have a question about deleting components of a list. For example, I have a
list that looks like this:

[[1]]
var1 var2 var3
   134 
   221   

[[2]]
var1 var2 var3
   251 
   217   

[[3]]
var1 var2 var3
   167 
   384   

How to delete, say, the first columns of the list or the second rows? Thank
in advance.

Lisa

-- 
View this message in context: 
http://n4.nabble.com/Delete-components-of-a-list-tp1289732p1289732.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] question on sqldf syntax

2010-01-25 Thread GL

Actually, better sql would likely be: 

dbs.final <- sqldf("select * from dbs.possible.combos left join
dbs.aggregate using (Date,Place)")

but this still doesn't work
-- 
View this message in context: 
http://n4.nabble.com/question-on-sqldf-syntax-tp1289707p1289718.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] problem with the precision of numbers

2010-01-25 Thread Hans W Borchers
kayj  yahoo.com> writes:
> 
> 
> Hi All,
> 
> thank you all for your help. I have tried Bill's script and it works! so I
> am trying to think what was the problem and it looks like it i sthe
> precision. so you defined a function of the precision and evaluates at
> precision=500. Bill, I was wondering how did you choose 500? is it
> arbitrary?
> 

Your question was "I was wondering if it is possible to increase the precision
using R", but you never told which accuracy you really need, As a rule of thumb,
the number of correct decimal digits is about 0.3 * precision, so for 50 digits
you could set the precision to 256 to Be on the safe side.

And if you are wondering how to compute the binomial coefficients with 'Rmpfr',
here's one possibility to do that:

require(Rmpfr)

mpfrChoose <- function(a, b, prec=128) {
m1 <- mpfr(1, prec=prec)
# r <- gamma(m1+a) / (gamma(m1+b) * gamma(m1+a-b))
# if (is.whole(r)) return(r) else return(round(r))
gamma(m1+a) / (gamma(m1+b) * gamma(m1+a-b))
}

An advantage of using 'Rmpfr' is that the power of R can be applied, for
example vectorization, so avoid 'for' loops if possible:

pr  <- 256
m_1 <- mpfr(-1, pr)
m1  <- mpfr(1, pr)

i <- mpfr(0:80, pr)
s <- sum((m_1^i) * mpfrChoose(80, i, prec=pr) * (m1-(i+1)*1/200)^200)

print(s, digits=50)
# 1 'mpfr' number of precision  256   bits
# [1] 6.6568524789662037699673275771182135789699510194000e-20

Hans Werner

> 
> thanks again for your help
>

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


[R] question on sqldf syntax

2010-01-25 Thread GL

trying to structure sql to merge two datasets. structure follows:

dbs.possible.combos (all possible combinations of dates and places)
Date Place
1/1/10 N-01
1/1/10 S-02
1/2/10 N-01
1/2/10 S-02
etc...

dbs.aggregate (the raw data aggregated by date and location)
Date Place Days
1/1/10 N-01 6
1/1/10 S-02 10
1/2/10 S-02 5


Trying to merge so I look-up the values for each possible combo 
dbs.final <- sqldf("select dbs.possible.combos$Date,
dbs.possible.combos$Place, dbs.possible.combos$Days FROM dbs.possible.combos
LEFT JOIN dbs.aggregate ON (dbs.possible.combos$Place = dbs.aggregate$Place)
AND (dbs.possible.combos$Date = dbs.aggregate$Date)")

Resulting in: 
Error in sqliteExecStatement(con, statement, bind.data) : 
  RS-DBI driver: (error in statement: near ".": syntax error)

What am I getting wrong in the syntax?
  



-- 
View this message in context: 
http://n4.nabble.com/question-on-sqldf-syntax-tp1289707p1289707.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] z value from wilcox.exact

2010-01-25 Thread Peter Ehlers

netrunner wrote:
Hi, 
does anibody know if is possible  to have as ouptut from the  wilcox.exact

function also a z value to  "link" the U value at the normal distribution?


I don't think that wilcox.exact() provides this directly.
I would use wilcox_test() in pkg 'coin'.
If you do want to restrict yourself to exactRankTests::wilcox.exact,
then you could use the call with 'exact=FALSE' and invert the P-value:

pv <- wilcox.exact(y ~ x, exact = FALSE)$p.value
Z <- qnorm(pv/2) # for the default 2-sided test

You will have to provide the appropriate sign for Z.

 -Peter Ehlers



thank you!

netrunner


--
Peter Ehlers
University of Calgary

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


[R] Issue using tapply

2010-01-25 Thread LCOG1

Hello all, 
   I am trying to use the tapply function to sum some values and change the
column names of the resulting vector.  

I input 
 Emp  Et
1  10565 ACC
2   7515 ADM
3625 AGF
4   6243 CNS
5  12721 EDU
6   3924 FIN
7  18140 HLH
8   3686 INF
9  15841 MFG
10   243 MIN
11  1864 MNG
12  4664 OSV
13  5496 PRF
14  4988 PUB
15  2166 REC
16  2153 REL
17 16082 RTL
18  3582 TRN
19   757 UTL
20  5818 WHL

and i want to aggregate certain types based on the following matches

Et Em
1  AGF AFREMP
2  MIN MINEMP
3  UTL TCPEMP
4  CNS CONEMP
5  MFG MFGEMP
6  WHL WSTEMP
7  RTL RETEMP
8  TRN TCPEMP
9  INF SVCEMP
10 FIN FINEMP
11 REL FINEMP
12 PRF SVCEMP
13 MNG FINEMP
14 ADM SVCEMP
15 EDU SVCEMP
16 HLH SVCEMP
17 REC SVCEMP
18 ACC SVCEMP
19 RST SVCEMP
20 OSV SVCEMP
21 PUB GVTEMP

but the last value in my result is NA when it should be 5818. so my actual
result is 
AFREMP CONEMP FINEMP GVTEMP MFGEMP MINEMP RETEMP SVCEMP TCPEMP WSTEMP 
   625   6243 7941  498815841 2433582 81035 
6575 NA 

I have rechecks to make sure there isnt a simple labeling error but i havent
found anything.  Below is test code.

Et<-c("AGF","MIN","UTL","CNS","MFG","WHL","RTL","TRN","INF","FIN","REL",
"PRF","MNG","ADM","EDU","HLH","REC","ACC","RST","OSV","PUB")

Em<-c("AFREMP","MINEMP","TCPEMP","CONEMP","MFGEMP","WSTEMP","RETEMP","TCPEMP",
"SVCEMP","FINEMP","FINEMP","SVCEMP","FINEMP","SVCEMP","SVCEMP","SVCEMP","SVCEMP",
"SVCEMP","SVCEMP","SVCEMP","GVTEMP")

EtToEm..<-data.frame(Et,Em)

Emp<-c(10565,7515,625,6243,12721,3924,18140,3686,15841,243,1864,4664,5496,4988
,2166,2153,16082,3582,757,5818)

Et.t<-c("ACC","ADM","AGF","CNS","EDU","FIN","HLH","INF","MFG","MIN"
,"MNG","OSV"
,"PRF","PUB","REC","REL","RTL","TRN","UTL","WHL")

Emp.Et<-data.frame(Emp,Et.t)
names(Emp.Et)[2]<-"Et"

Emp.Et.Em<-as.vector(Emp.Et$Em)
names(Emp.Et.Em) <- Emp.Et$Et

EmpEt.Em <- tapply(Emp.Et.Em[EtToEm..$Et], EtToEm..$Em, sum)

-- 
View this message in context: 
http://n4.nabble.com/Issue-using-tapply-tp1289681p1289681.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R Output and ArcGIS

2010-01-25 Thread Michael Denslow
Hi Steve,

On Mon, Jan 25, 2010 at 12:54 PM, Steve Murray  wrote:
>
> Dear all,
>
> I've been using R on a Mac to process some data for export to ArcMap GIS 
> (which only runs on Windows). ArcMap seems to require tab-delimited data (my 
> data are in 3 columns), so I've been using the sep="\t" argument. However, 
> this resulted in strange end-of-line characters when displayed on a PC. I 
> looked in the write.table help file to find that eol="\r\n" can be used to 
> get around this problem, and it does indeed prevent these unwanted characters 
> from appearing.

How did you look at the output? in Excel?

> However, the data still aren't properly recognised by ArcMap when created on 
> a Mac (the exact same code works fine from a PC). In ArcMap, when I select 
> 'Display XY Data', the X (Longitude) and Y (Latitude) columns aren't 
> available to select. It's as if Arc isn't correctly interpreting the output 
> from R - this is despite me using col.names=TRUE in the write.table command.

I usually use col.names=NA, when I am writing a file to be read by a
spreadsheet. This is also documented in ?write.table.

As Milton pointed out you should also make sure that you are careful
with your column names since R and ArcMap have different rules.

Posting the results of str(YourData) might shed some light as well.

Hope this helps,
Michael


>
> Any light shed on this will be very gratefully received.
>
> Many thanks for your help,
>
> Steve
>
>
> _
> We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
> now
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Michael Denslow

I.W. Carpenter Jr. Herbarium [BOON]
Department of Biology
Appalachian State University
Boone, North Carolina U.S.A.
-- AND --
Communications Manager
Southeast Regional Network of Expertise and Collections
sernec.org

36.214177, -81.681480 +/- 3103 meters

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


[R] (no subject)

2010-01-25 Thread Chuck White
Hello -- I would like to know of a more efficient way of writing the following 
piece of code. Thanks.

options(stringsAsFactors=FALSE)
orig <- 
c(rep('',10),rep('',20),rep('',30),rep('',40))
orig.unique <- unique(orig)
system.time(df <- as.data.frame(sapply(orig.unique, function(x) ifelse(orig==x, 
1, 0

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


Re: [R] Quartiles and Inter-Quartile Range

2010-01-25 Thread David Freedman

please do some reading - I *think* the main difference is that the x and y
axes are reversed, but I really don't know what SAS prints out

there are a many 'defaults' that are rather arbitrary - sometimes SAS uses
1, while R uses another

??qqnorm brings up a list of functions, including stats::qqnorm
?stats::qqnorm brings up the help page for the function

On Mon, Jan 25, 2010 at 12:41 PM, eeramalho [via R] <
ml-node+1289588-934349...@n4.nabble.com
> wrote:

> Thank you David. I got it now.
>
> Maybe you can help again.
>
> I am typing the following code to draw a QQ plot but the line does not look
> right?
>
> ***
> qqnorm(cbiomass)
>
> qqline(cbiomass)
> ***
> the graph looks very different from the graph generated by SAS.
>
> Thank you again.
>
> Emiliano.
>
> --
> Date: Fri, 22 Jan 2010 21:32:26 -0800
> From: [hidden 
> email]
> To: [hidden 
> email]
> Subject: Re: Quartiles and Inter-Quartile Range
>
> It's looks like you think that type=2 are the 'true' quantiles, but the
> default method in R is type=7
>
> You might want to look at ?stats::quantile
>
> hth
> david freedman
>
> --
>  View message @
> http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1213199.html
> To unsubscribe from Quartiles and Inter-Quartile Range, click here.
>
>
> --
> Quer fazer um álbum íncrivel? Conheça o Windows Live Fotos clicando 
> aqui.
>
> --
>  View message @
> http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1289588.html
> To unsubscribe from Re: Quartiles and Inter-Quartile Range, click here< (link 
> removed) =>.
>
>
>


-- 
Natalia and/or David

-- 
View this message in context: 
http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1289653.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] Rearranging long dataframe for printing in Sweave (andrecoding a factor)

2010-01-25 Thread Jean-Louis Abitbol
Ista,

Thanks, you got the question perfectly well.

And the proposed solution gets me on my way.

I just corrected the typo n.cbroup to n.cgroup.

Thanks again,

Best wishes, JL

On Mon, 25 Jan 2010 17:42 +, "Ista Zahn"  wrote:
> If I understand the OP's issue correctly, this is how I would do it:
> 
> library(Hmisc)
> 
> test <- data.frame(conc=trunc(runif(1000,
> 1,1000)),nam=rep(c("A","B"),500))
> 
> final <- cbind(test[1:200,], test[201:400,], test[401:600,],
> test[601:800,], test[801:1000,])
> 
> latex(final, cgroup=c(paste("Obs. ",seq(1, 801, by=200), "-", seq(200,
> 1000, by=200), sep="")), n.cbroup=rep(2, 5), rowname=NULL)
> 
> Jean-Louis, is that what you were after, or did I misunderstand your
> question?
> 
> -Ista
> 
> On Mon, Jan 25, 2010 at 2:44 PM, Steve Sidney 
> wrote:
> > JL
> >
> > The solution which was proposed by Joseph Wright on the Latex Community
> > Forum was as follows
> >
> > 1) Use R to create the table and then save it in csv format
> >
> > 2) Use LaTex to print the table.
> >
> > 3) LaTex on it's own is not able to do this and you must install the
> > 'datatool' package.
> >
> > 4) What 'datatool' allows you to do is to read the csv into an internal
> > database and from that various very nice table printing styles can be
> > provided.
> >
> > 5) If you click on the link below provided by Liviu, you can follow the
> > postings between Joesph and myself and there are various code files as well
> > as pdf's which show how a single table with more rows than one page, can be
> > divided in two and placed one one page. If that's what you are looking for
> > then this might be a solution. The only problem is that if like me you don't
> > have strong LaTex skills, then you will have to do some experimenting and
> > learning, in order to achieve this result.
> >
> > HTH - Good luck
> > Steve
> >
> >
> > - Original Message - From: "Jean-Louis Abitbol" 
> > To: "Steve Sidney" ; "Liviu Andronic"
> > 
> > Cc: "R Help" 
> > Sent: Monday, January 25, 2010 9:18 AM
> > Subject: Re: [R] Rearranging long dataframe for printing in Sweave
> > (andrecoding a factor)
> >
> >
> > Hi Steve and Liviu,
> >
> > Thanks for the pointer to your posts.
> >
> > Steve can you share your elegant solution ?
> >
> > Up to now I have not had any answer from R-Help ...
> >
> > Best, JL
> >
> > On Sun, 24 Jan 2010 18:24 +0200, "Steve Sidney" 
> > wrote:
> >>
> >> Dear Liviu / Jean-Louis
> >>
> >> As the original poster I did find what I think is an elegant solution.
> >>
> >> The only remaining problem is that I have not been able to get it to work
> >> in
> >> Lyx, but it does work using a LaTeX editor (in this case WinEdt) and
> >> MikTex.
> >>
> >> I would still like to resolve why I can't read the csv table in Lyx.
> >>
> >> Regards
> >> Steve
> >>
> >> - Original Message - From: "Liviu Andronic"
> >> 
> >> To: "Jean-Louis Abitbol" 
> >> Cc: "R Help" 
> >> Sent: Sunday, January 24, 2010 5:56 PM
> >> Subject: Re: [R] Rearranging long dataframe for printing in Sweave
> >> (andrecoding a factor)
> >>
> >>
> >> > Hello
> >> >
> >> > On 1/24/10, Jean-Louis Abitbol  wrote:
> >> >>  I have to print a dataframe with >1000 rows and 2 columns for a report
> >> >>  done with Sweave.
> >> >>
> >> >>  I could use Hmisc latex function with longtable option.
> >> >>  However it is a waiste of space and paper given that I have only 2 (or
> >> >>  sometime 3) columns in the dataframe.
> >> >>
> >> >>  So it came to my mind that I could maybe  rearrange the dataframe and
> >> >>  create several new variables from the original 2 in a tabular way for
> >> >>  printing in less space.
> >> >>
> >> > There was a recent discussion on lyx-users [1] on a similar issue. I
> >> > am not sure whether the original poster found a solution, though.
> >> >
> >> > Liviu
> >> >
> >> > [1] http://www.mail-archive.com/lyx-us...@lists.lyx.org/msg78933.html
> >> >
> >> > __
> >> > R-help@r-project.org mailing list
> >> > https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guide
> >> > http://www.R-project.org/posting-guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >> >
> >>
> > --
> >  Jean-Louis Abitbol
> >  abit...@sent.com
> >  Tel 33 (0)6 24 47 59 34
> >  1 ter Rue Céline, 92160
> >  Antony, France
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> -- 
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
-- 
  Jean-Louis Abitbol
  abit...@sent.com
  Tel 33 (0)6 24 47 59 34
  1 ter Rue Céline, 92160 
  Antony, France 

__
R-help@r-project.org mai

Re: [R] Quartiles and Inter-Quartile Range

2010-01-25 Thread Peter Ehlers


eeramalho wrote:


Thank you David. I got it now.

Maybe you can help again.

I am typing the following code to draw a QQ plot but the line does not look 
right?

***
qqnorm(cbiomass)

qqline(cbiomass)
***
the graph looks very different from the graph generated by SAS.


There are two possibilities:
1. you need to use the argument 'datax = TRUE'
2. SAS is wrong

You might also have a look at the qq.plot() function
in package 'car'.

 -Peter Ehlers



Thank you again.

Emiliano.

Date: Fri, 22 Jan 2010 21:32:26 -0800
From: ml-node+1213199-1966337...@n4.nabble.com
To: eerama...@hotmail.com
Subject: Re: Quartiles and Inter-Quartile Range



It's looks like you think that type=2 are the 'true' quantiles, but the default 
method in R is type=7


You might want to look at ?stats::quantile


hth

david freedman





View message @ 
http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1213199.html


To unsubscribe from Quartiles and Inter-Quartile Range, click here.


 		 	   		  
_

Sabia que você tem 25Gb de armazenamento grátis na web? Conheça o Skydrive 
agora.

Live:produtoSkyDrive:Tagline:WLCRM:On:WL:pt-BR:SkyDrive




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


--
Peter Ehlers
University of Calgary

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


Re: [R] problem with the precision of numbers

2010-01-25 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of kayj
> Sent: Monday, January 25, 2010 8:04 AM
> To: r-help@r-project.org
> Subject: Re: [R] problem with the precision of numbers
> 
> 
> Hi All,
> 
> thank you all for your help. I have tried Bill's script and 
> it works! so I
> am trying to think what was the problem and it looks like it i sthe
> precision. so you defined a function of the precision and evaluates at
> precision=500. Bill, I was wondering how did you choose 500? is it
> arbitrary?

The problem was that you were computing several quantities
in the machine's native double precision format, not using
the mpfr format.   I chose to parameterize the function
with precision so you could see how the precision affected
the result.  I showed precision=500 mainly because that is
what you used for the variables that you did use in mpfr
format.  I did not do any analysis to see what precision
would be needed to get a given final precision, but that
would be possible.  Here is how precision affects the results:

> f <- function (precision){
require(Rmpfr)
s <- mpfr(0, precision)
j <- mpfr(-1, precision)
c <- mpfr(1, precision)
for (i in 0:80) {
i <- mpfr(i, precision)
s <- s + ((j^i) * c * (1 - (i + 1) * 1/200)^200)
c <- (c * (80 - i))/(i + 1)
}
s
}
> p<-2^(1:10) # choose 10 values for precision
> z<-lapply(p, f) # evaluate f at those 10 values
> invisible(lapply(z,print,digits=20)) # print(z, digits=20) doesn't
work.
1 'mpfr' number of precision  2   bits 
[1] 7.2535549176877750482e24
1 'mpfr' number of precision  4   bits 
[1] 1099511627776
1 'mpfr' number of precision  8   bits 
[1] -99090432
1 'mpfr' number of precision  16   bits 
[1] 1815744
1 'mpfr' number of precision  32   bits 
[1] 40.655612170696258545
1 'mpfr' number of precision  64   bits 
[1] 3.3910635476710543806e-9
1 'mpfr' number of precision  128   bits 
[1] 6.6568524698115877284e-20
1 'mpfr' number of precision  256   bits 
[1] 6.6568524789662037700e-20
1 'mpfr' number of precision  512   bits 
[1] 6.6568524789662037700e-20
1 'mpfr' number of precision  1024   bits 
[1] 6.6568524789662037700e-20 

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> I have looked at the Rmpfr documentation and they defined the 
> mfr object to
> be
>  Usage
> mpfr(x, precBits, base = 10)
> Const(name = c("pi", "gamma", "catalan"), prec = 120L)
> 
> so is the precision defined in Bill's script the same as precBits?
> 
> my bc package works , I have used bc ( from run "raw" and not 
> from R) so is
> it possible to use it from R?
> 
> thanks again for your help
> 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/problem-with-the-precision-of-numbers-tp1
288905p1289483.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


Re: [R] More than on loop??

2010-01-25 Thread che

can i ask your help again, please excuse my questions:
It is working perfectly now, i still have the last part which i tried a lot
with but still i can’t translate it properly for the computer through R. I
need to draw rectangular based on the frequency of each residue, actually i
found the pattern, but i am not able to translate it into an automatic R
function.
First, i drew an empty plot where the rectangles should be placed, then with
rect function i drew the rectangles in the preferable  pattern but in a
manual way, i used this command for this purpose: 
rect(x*10,y,x+10,y+round(cleaved(x)[k,j]),col=colmap[k])
 now i want to translate this pattern to an R function to go through the all
data set, specially the y which i suffered with should be cumulative.
hear is what i wrote, at the end i put the code which i used, but it is not
working properly to translate the pattern that  i made manually :
hi<-function(x)
{
height<-rep(0,8)
for (j in 1:8){
height[j]<-sum(round(cleaved(x)[,j]))
max.height<-max(height)
}
plot(c(0,10*8),c(0,max.height+20),col="white")
}
recta<-function(x)
{
colmap<-c("#FF", "#CC", "#99", "#66", "#33",
"#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33",
"#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933",
"#FF9900", "#FF33FF", "#FF33CC")

rect(1*10,20,10+10,20+round(cleaved(x)[1,1]),col=colmap[1])
rect(1*10,40,10+10,40+round(cleaved(x)[2,1]),col=colmap[2])
rect(1*10,53,10+10,53+round(cleaved(x)[3,1]),col=colmap[3])
rect(1*10,63,10+10,63+round(cleaved(x)[4,1]),col=colmap[4])
rect(1*10,69,10+10,69+round(cleaved(x)[5,1]),col=colmap[5])
rect(1*10,73,10+10,73+round(cleaved(x)[6,1]),col=colmap[6])
rect(1*10,85,10+10,85+round(cleaved(x)[7,1]),col=colmap[7])
rect(1*10,89,10+10,89+round(cleaved(x)[8,1]),col=colmap[8])
rect(1*10,96,10+10,96+round(cleaved(x)[9,1]),col=colmap[9])
rect(1*10,110,10+10,110+round(cleaved(x)[10,1]),col=colmap[10])
rect(1*10,118,10+10,118+round(cleaved(x)[11,1]),col=colmap[11])
rect(1*10,123,10+10,123+round(cleaved(x)[12,1]),col=colmap[12])
rect(1*10,144,10+10,144+round(cleaved(x)[13,1]),col=colmap[13])
rect(1*10,149,10+10,149+round(cleaved(x)[14,1]),col=colmap[14])
rect(1*10,158,10+10,158+round(cleaved(x)[15,1]),col=colmap[15])
rect(1*10,170,10+10,170+round(cleaved(x)[16,1]),col=colmap[16])
rect(1*10,198,10+10,198+round(cleaved(x)[17,1]),col=colmap[17])
rect(1*10,213,10+10,213+round(cleaved(x)[18,1]),col=colmap[18])
rect(1*10,225,10+10,225+round(cleaved(x)[19,1]),col=colmap[19])
rect(1*10,229,10+10,225+round(cleaved(x)[20,1]),col=colmap[20])

}
recta<-function(x)
{
colmap<-c("#FF", "#CC", "#99", "#66", "#33",
"#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33",
"#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933",
"#FF9900", "#FF33FF", "#FF33CC")
for (j in 1:8){
xx<-j*10
for(k in 1:20){
yy<-cumsum(round(cleaved(x)[k,j]))
rect(xx,yy,xx+10,yy+round(cleaved(x)[k,j]),col=colmap[k])
}
}
}
 
-- 
View this message in context: 
http://n4.nabble.com/More-than-on-loop-tp1015851p1289636.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Quartiles and Inter-Quartile Range

2010-01-25 Thread eeramalho


Thank you David. I got it now.

Maybe you can help again.

I am typing the following code to draw a QQ plot but the line does not look 
right?

***
qqnorm(cbiomass)

qqline(cbiomass)
***
the graph looks very different from the graph generated by SAS.

Thank you again.

Emiliano.

Date: Fri, 22 Jan 2010 21:32:26 -0800
From: ml-node+1213199-1966337...@n4.nabble.com
To: eerama...@hotmail.com
Subject: Re: Quartiles and Inter-Quartile Range



It's looks like you think that type=2 are the 'true' quantiles, but the default 
method in R is type=7


You might want to look at ?stats::quantile


hth

david freedman





View message @ 
http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1213199.html


To unsubscribe from Quartiles and Inter-Quartile Range, click here.


  
_
Sabia que você tem 25Gb de armazenamento grátis na web? Conheça o Skydrive 
agora.

Live:produtoSkyDrive:Tagline:WLCRM:On:WL:pt-BR:SkyDrive
-- 
View this message in context: 
http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1289588.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] binary

2010-01-25 Thread Peter Ehlers

Val wrote:

Hi all

Assume I have a data set xx;

Group: 1=group1  , 2=group2

IQ:  1= High, 0 =low

fit <- glm(IQ ~group, data = xx, family = binomial())

summary(fit)

Results

   Estimate Std. Error z value Pr(>|z|)

(Intercept) -2.554560.210 -12.273  < 5e-16 ***

 group  0.36180  0.076   3.952 5.24e-05 ***

the odd ratio = exp(0.36180 )= 1.435912

My question is that the log-odd  estimate 0.3618  is it for group1 or group2?

What does the odd ratio 1.43359 is interpreted?


Val,
  Before using R's model fitting functions, it helps
  to understand your model. See any introductory text
  on logistic regression.

  Despite what you claim, it appears that your data 'set'
  may be a data.frame with variables 'IQ' and 'group',
  something like this:

set.seed(34)
xx <- data.frame(IQ = sample(0:1, 10, TRUE), group = gl(2, 5))
xx

  The summary you show was not produced by R, at least
  not as you show it. Here's the result for the above
  data:

fit <- glm(IQ ~ group, data=xx, family=binomial())
summary(fit)

## snipped R output
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept)  -0.4055 0.9129  -0.4440.657
group20.8109 1.2910   0.6280.530

## end R output

  Note the '2' in 'group2'. R is smart. It let's you
  know which level of factor 'group' should get the
  added 0.8109 in its log-odds estimate. From your
  reported output it would be impossible to tell that.
  You might have set 'group' to have level '2' as the
  reference level, in which case R would show a
  'group1' row.

  For more on logistic regression, you could consult
  Wikipedia, but here's a brief explanation of your
  simple case:
  Consider two models, one for each group:

  log(Pr(IQ=1)/Pr(IQ=0)) = const_1  (group 1)
  log(Pr(IQ=1)/Pr(IQ=0)) = const_2  (group 2)

  Combine these into a single model, using an
  indicator variable to signal the group:

  log(Pr(IQ=1)/Pr(IQ=0)) = beta_0 + beta_1 * Indic(group 2)

  where Indic(group 2) = 1 for group 2 and 0 otherwise and
  beta_0 = const_1,
  beta_0 + beta_1 = const_2.

This should help you answer your questions yourself.

 - Peter Ehlers




Thanks in advance

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




--
Peter Ehlers
University of Calgary

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


Re: [R] R Output and ArcGIS

2010-01-25 Thread milton ruser
Hi Steve,

As I have no problem with this because I run windows, I prefere to use .txt
files.
But may be on your case you install xlsReadWrite (or WriteRead), because
.xls file works fine for ArcGis.

Remember not use complex (like having dots) or large names because some
times you get error on ArcGis.

Good luck,

milton

On Mon, Jan 25, 2010 at 12:54 PM, Steve Murray wrote:

>
> Dear all,
>
> I've been using R on a Mac to process some data for export to ArcMap GIS
> (which only runs on Windows). ArcMap seems to require tab-delimited data (my
> data are in 3 columns), so I've been using the sep="\t" argument. However,
> this resulted in strange end-of-line characters when displayed on a PC. I
> looked in the write.table help file to find that eol="\r\n" can be used to
> get around this problem, and it does indeed prevent these unwanted
> characters from appearing.
>
> However, the data still aren't properly recognised by ArcMap when created
> on a Mac (the exact same code works fine from a PC). In ArcMap, when I
> select 'Display XY Data', the X (Longitude) and Y (Latitude) columns aren't
> available to select. It's as if Arc isn't correctly interpreting the output
> from R - this is despite me using col.names=TRUE in the write.table command.
>
> Any light shed on this will be very gratefully received.
>
> Many thanks for your help,
>
> Steve
>
>
> _
> We want to hear all your funny, exciting and crazy Hotmail stories. Tell us
> now
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] R Output and ArcGIS

2010-01-25 Thread Steve Murray

Dear all,

I've been using R on a Mac to process some data for export to ArcMap GIS (which 
only runs on Windows). ArcMap seems to require tab-delimited data (my data are 
in 3 columns), so I've been using the sep="\t" argument. However, this resulted 
in strange end-of-line characters when displayed on a PC. I looked in the 
write.table help file to find that eol="\r\n" can be used to get around this 
problem, and it does indeed prevent these unwanted characters from appearing.

However, the data still aren't properly recognised by ArcMap when created on a 
Mac (the exact same code works fine from a PC). In ArcMap, when I select 
'Display XY Data', the X (Longitude) and Y (Latitude) columns aren't available 
to select. It's as if Arc isn't correctly interpreting the output from R - this 
is despite me using col.names=TRUE in the write.table command.

Any light shed on this will be very gratefully received.

Many thanks for your help,

Steve

  
_
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

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


Re: [R] locfit questions/problems

2010-01-25 Thread Liaw, Andy
Just replacing preplot() with predict() should be fine.

BTW, it's always a good idea to specify the version of the package
you're using as well.

Best,
Andy 

From: mh...@berkeley.edu
> 
> Hi,
> 
> I'm trying to work through the examples and code in Loader's
> LOCAL REGRESSION AND LIKELIHOOD, and have run into a problem
> with the code for one sided smoothing and change point analysis
> (p. 110-112).
> 
> The code, after loading locfit:
> 
> midp<-(1945:1988)+0.5
> fitl<-locfit(thickness~left(year), data=penny, alpha=c(0,10), 
> deg=1, ev=midp)
> fitr<-locfit(thickness~right(year),data=penny, alpha=c(0,10), 
> deg=1, ev=midp)
> plot((preplot(fitr)-preplot(fitl))^2, type="b")
> 
> the error message crops up after the plot command and is:
> 
> Error in preplot(fitr) - preplot(fitl) :
>   non-numeric argument to binary operator
> 
> looking at preplot(fitr0 and preplot(fitl) shows a list with 
> numeric values.
> 
> Any suggestions on how to resolve this problem?  I'm using R 
> 2.7.1 on a
> Windows XP machine with Service pack 2.
> 
> best and thanks, Mark Hall
> 
> PS--a similar error case occurs using R 2.3.1 and 2.5.1
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:10}}

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


Re: [R] Rearranging long dataframe for printing in Sweave (andrecoding a factor)

2010-01-25 Thread Ista Zahn
If I understand the OP's issue correctly, this is how I would do it:

library(Hmisc)

test <- data.frame(conc=trunc(runif(1000, 1,1000)),nam=rep(c("A","B"),500))

final <- cbind(test[1:200,], test[201:400,], test[401:600,],
test[601:800,], test[801:1000,])

latex(final, cgroup=c(paste("Obs. ",seq(1, 801, by=200), "-", seq(200,
1000, by=200), sep="")), n.cbroup=rep(2, 5), rowname=NULL)

Jean-Louis, is that what you were after, or did I misunderstand your question?

-Ista

On Mon, Jan 25, 2010 at 2:44 PM, Steve Sidney  wrote:
> JL
>
> The solution which was proposed by Joseph Wright on the Latex Community
> Forum was as follows
>
> 1) Use R to create the table and then save it in csv format
>
> 2) Use LaTex to print the table.
>
> 3) LaTex on it's own is not able to do this and you must install the
> 'datatool' package.
>
> 4) What 'datatool' allows you to do is to read the csv into an internal
> database and from that various very nice table printing styles can be
> provided.
>
> 5) If you click on the link below provided by Liviu, you can follow the
> postings between Joesph and myself and there are various code files as well
> as pdf's which show how a single table with more rows than one page, can be
> divided in two and placed one one page. If that's what you are looking for
> then this might be a solution. The only problem is that if like me you don't
> have strong LaTex skills, then you will have to do some experimenting and
> learning, in order to achieve this result.
>
> HTH - Good luck
> Steve
>
>
> - Original Message - From: "Jean-Louis Abitbol" 
> To: "Steve Sidney" ; "Liviu Andronic"
> 
> Cc: "R Help" 
> Sent: Monday, January 25, 2010 9:18 AM
> Subject: Re: [R] Rearranging long dataframe for printing in Sweave
> (andrecoding a factor)
>
>
> Hi Steve and Liviu,
>
> Thanks for the pointer to your posts.
>
> Steve can you share your elegant solution ?
>
> Up to now I have not had any answer from R-Help ...
>
> Best, JL
>
> On Sun, 24 Jan 2010 18:24 +0200, "Steve Sidney" 
> wrote:
>>
>> Dear Liviu / Jean-Louis
>>
>> As the original poster I did find what I think is an elegant solution.
>>
>> The only remaining problem is that I have not been able to get it to work
>> in
>> Lyx, but it does work using a LaTeX editor (in this case WinEdt) and
>> MikTex.
>>
>> I would still like to resolve why I can't read the csv table in Lyx.
>>
>> Regards
>> Steve
>>
>> - Original Message - From: "Liviu Andronic"
>> 
>> To: "Jean-Louis Abitbol" 
>> Cc: "R Help" 
>> Sent: Sunday, January 24, 2010 5:56 PM
>> Subject: Re: [R] Rearranging long dataframe for printing in Sweave
>> (andrecoding a factor)
>>
>>
>> > Hello
>> >
>> > On 1/24/10, Jean-Louis Abitbol  wrote:
>> >>  I have to print a dataframe with >1000 rows and 2 columns for a report
>> >>  done with Sweave.
>> >>
>> >>  I could use Hmisc latex function with longtable option.
>> >>  However it is a waiste of space and paper given that I have only 2 (or
>> >>  sometime 3) columns in the dataframe.
>> >>
>> >>  So it came to my mind that I could maybe  rearrange the dataframe and
>> >>  create several new variables from the original 2 in a tabular way for
>> >>  printing in less space.
>> >>
>> > There was a recent discussion on lyx-users [1] on a similar issue. I
>> > am not sure whether the original poster found a solution, though.
>> >
>> > Liviu
>> >
>> > [1] http://www.mail-archive.com/lyx-us...@lists.lyx.org/msg78933.html
>> >
>> > __
>> > R-help@r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
> --
>  Jean-Louis Abitbol
>  abit...@sent.com
>  Tel 33 (0)6 24 47 59 34
>  1 ter Rue Céline, 92160
>  Antony, France
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] Fwd: how to write a long string to many lines in a fasta text file

2010-01-25 Thread jim holtman
?strwrap

On Mon, Jan 25, 2010 at 11:02 AM, mary guo  wrote:
> Hi,
> I want to write a long string to many lines in R, but I do not know how to
> do it.
> Hope to get your help.
>
> Thanks.
>
> Mary
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] problem with the precision of numbers

2010-01-25 Thread kayj

Hi All,

thank you all for your help. I have tried Bill's script and it works! so I
am trying to think what was the problem and it looks like it i sthe
precision. so you defined a function of the precision and evaluates at
precision=500. Bill, I was wondering how did you choose 500? is it
arbitrary?

I have looked at the Rmpfr documentation and they defined the mfr object to
be
 Usage
mpfr(x, precBits, base = 10)
Const(name = c("pi", "gamma", "catalan"), prec = 120L)

so is the precision defined in Bill's script the same as precBits?

my bc package works , I have used bc ( from run "raw" and not from R) so is
it possible to use it from R?

thanks again for your help


-- 
View this message in context: 
http://n4.nabble.com/problem-with-the-precision-of-numbers-tp1288905p1289483.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] reshape package cast() function

2010-01-25 Thread Ista Zahn
OK, I think I figured it out (each level of id corresponds to only one
level of variable in m.test).

Thanks,
Ista
On Mon, Jan 25, 2010 at 4:59 PM, Ista Zahn  wrote:
> Hi all,
> I think I'm cracking up. Please help me understand why I'm getting
> different results with m.test and m.test2 in the example below.
>
>> library(reshape)
> Loading required package: plyr
>>
>> m.test <- data.frame(id = factor(rep(1:10, 2)), 
>> variable=rep(c("var1","var2"),10), value=rnorm(20))
>> cast(m.test, ...~variable, value="value") ## cast is aggregating even though 
>> I have ... in the formula.
> Aggregation requires fun.aggregate: length used as default
>   id var1 var2
> 1   1    2    0
> 2   2    0    2
> 3   3    2    0
> 4   4    0    2
> 5   5    2    0
> 6   6    0    2
> 7   7    2    0
> 8   8    0    2
> 9   9    2    0
> 10 10    0    2
>>
>> test2 <- data.frame(id=factor(1:10), var1=rnorm(10), var2=rnorm(1))
>> m.test2 <- melt(test2, id="id")
>> cast(m.test2, ...~variable, value="value") ## this is the result I want. I 
>> don't understand why I'm not getting the same thing for m.test.
>   id        var1      var2
> 1   1  0.19829479 -0.642097
> 2   2  0.37971900 -0.642097
> 3   3 -0.23557248 -0.642097
> 4   4  0.12969246 -0.642097
> 5   5 -0.12019995 -0.642097
> 6   6  0.09744247 -0.642097
> 7   7 -1.24467558 -0.642097
> 8   8  1.69505449 -0.642097
> 9   9  1.60714925 -0.642097
> 10 10  0.11961170 -0.642097
>
> Thanks,
> --
> Ista Zahn
> Graduate student
> University of Rochester
> Department of Clinical and Social Psychology
> http://yourpsyche.org
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


[R] Fwd: how to write a long string to many lines in a fasta text file

2010-01-25 Thread mary guo
Hi,
I want to write a long string to many lines in R, but I do not know how to
do it.
Hope to get your help.

Thanks.

Mary

[[alternative HTML version deleted]]

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


Re: [R] summing a large, partitioned data frame

2010-01-25 Thread Benilton Carvalho
check aggregate()   (the examples are quite helpful)

b


On Mon, Jan 25, 2010 at 4:07 PM,   wrote:
> Dear R community,
> I'm trying to develop a fast way of summing specific rows of a large data 
> frame.
> Here is an example of the kind of data frames I'm dealing with:
>
>> refls
>  H K L M/ISYM BATCH  I SIGI
> 43247 1 0 5 2179   61.44117  2.20553
> 1040  1 0 5257 6   15.16316  0.54431
> 2324  1 0 5257 5   46.76152  1.67858
> 31515 1 0 525960   57.97305  2.08104
> 35158 1 0 5259613.15614  0.11329
> 51575 1 0 625988  380.04477  8.08878
> 51846 1 0 625989  624.90802 13.30038
> 28946 1 1 4  142 2517.79492 55.37144
> 23199 1 1 4  531 2525.67407 55.54472
> 23198 1 1 4 2139 2519.44653 55.40777
> 
> 
>
> I need to add up all I's with same H, K, L and M/ISYM.
> The new data frame coming out of this partial summing should look, in this 
> case, like:
>
>  H K L M/ISYM BATCH  I SIGI
> 43247 1 0 5 2179   61.44117  2.20553
> 1040  1 0 5257 6   61.92468  0.54431
> 31515 1 0 525960   61.12919  2.08104
> 51575 1 0 625988 1004.95279  8.08878
> 28946 1 1 4  142 2517.79492 55.37144
> 23199 1 1 4  531 2525.67407 55.54472
> 23198 1 1 4 2139 2519.44653 55.40777
> 
> 
>
>
> Essentially I only add those I's with same H, K, L, M/ISYM and replace the sum
> in a unique row in the new data frame. In other words there's first a 
> partition and then
> a sum.
>
> I have tried with a for loop, but it really takes too long.
>
> I was wondering whether anyone knows of a better and faster way of doing this 
> operation.
>
>
> J
>
>
>
> Dr James Foadi PhD
> Membrane Protein Laboratory (MPL)
> Diamond Light Source Ltd
> Diamond House
> Harewell Science and Innovation Campus
> Chilton, Didcot
> Oxfordshire OX11 0DE
>
> Email:  james.fo...@diamond.ac.uk
> Alt Email:  j.fo...@imperial.ac.uk
>
> --
> This e-mail and any attachments may contain confidential...{{dropped:8}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] PCA: Showing file datalabels on biplot

2010-01-25 Thread Kevin Wright
str(catopsis) shows no labels, so how can biplot know what to use?

Try this before call prcomp:

colnames(catopsis) <- c('a','b','c','d')
rownames(catopsis) <- cat$sample

Also, see the 'reshape' package for easier data manipulation.

Kevin


On Mon, Jan 25, 2010 at 10:39 AM, colin1 wrote:

>
> The script below successfully produces a biplot of the data but the 'site
> names' (rows) and the names of the 'response variables' (columns) are shown
> as simple numerals (rather than the column and row names). How might I
> 'enforce' the use of the row/column names used in the datafile (section of
> datafile shown below)?
> Can anyone help, please?
>
> Section of datafile
>
> sample  a   b   c   d ---n42
> HBR-6   1   1   1   1
> HBR-7   1   1   1   2
> HBR-8   1   1   1   1
> HBR-9   1   1   1   2
> HBR-10  1   1   1   1
> HBR-11  1   1   1   1
> HBR-12  1   1   1   1
> HBR-13  1   1   1   1
> HBR-14  2   1   2   2
> HBR-15  2   1   2   1
> HBR-16  1   1   2   1
> HBR-17  1   1   2   1
> HBR-18  1   1   2   1
> HBR-19  1   1   2   1
> HBR-20  1   1   2   1
> HBR-21  1   2   1   1
> HBR-30  1   1   2   2
> HBR-31  1   2   1   2
> HBR-32  2   2   1   2
> HBR-33  1   2   1   2
> HBR-34  1   2   2   2
> HBR-35  1   2   2   1
> HBR-36  1   2   1   2
> HBR-37  1   2   1   2
>
>
> cat <-read.table("R855868825matrix.csv", sep=",", header=T)
>  head (cat, n=24)
> catopsis <- (cbind(cat$a, cat$b, cat$c, cat$d, cat$e, cat$f, cat$g, cat$h,
> cat$i, cat$j, cat$k, cat$l, cat$m, cat$n, cat$o, cat$p, cat$q, cat$r,
> cat$s,
> cat$t, cat$u, cat$v, cat$w, cat$x, cat$y, cat$z, cat$aa, cat$ab, cat$ac,
> cat$ad, cat$ae, cat$af, cat$ag, cat$ah, cat$ai, cat$aj, cat$ak, cat$al,
> cat$am, cat$an, cat$ao, cat$ap))
> pca <- prcomp (t(catopsis))
> plot(pca, catopsis [])
> summary(prcomp(catopsis))
> biplot(prcomp(catopsis, scale = TRUE))
>
> --
> View this message in context:
> http://n4.nabble.com/PCA-Showing-file-datalabels-on-biplot-tp1289524p1289524.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Kevin Wright

[[alternative HTML version deleted]]

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


[R] reshape package cast() function

2010-01-25 Thread Ista Zahn
Hi all,
I think I'm cracking up. Please help me understand why I'm getting
different results with m.test and m.test2 in the example below.

> library(reshape)
Loading required package: plyr
>
> m.test <- data.frame(id = factor(rep(1:10, 2)), 
> variable=rep(c("var1","var2"),10), value=rnorm(20))
> cast(m.test, ...~variable, value="value") ## cast is aggregating even though 
> I have ... in the formula.
Aggregation requires fun.aggregate: length used as default
   id var1 var2
1   120
2   202
3   320
4   402
5   520
6   602
7   720
8   802
9   920
10 1002
>
> test2 <- data.frame(id=factor(1:10), var1=rnorm(10), var2=rnorm(1))
> m.test2 <- melt(test2, id="id")
> cast(m.test2, ...~variable, value="value") ## this is the result I want. I 
> don't understand why I'm not getting the same thing for m.test.
   idvar1  var2
1   1  0.19829479 -0.642097
2   2  0.37971900 -0.642097
3   3 -0.23557248 -0.642097
4   4  0.12969246 -0.642097
5   5 -0.12019995 -0.642097
6   6  0.09744247 -0.642097
7   7 -1.24467558 -0.642097
8   8  1.69505449 -0.642097
9   9  1.60714925 -0.642097
10 10  0.11961170 -0.642097

Thanks,
-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


[R] PCA: Showing file datalabels on biplot

2010-01-25 Thread colin1

The script below successfully produces a biplot of the data but the 'site
names' (rows) and the names of the 'response variables' (columns) are shown
as simple numerals (rather than the column and row names). How might I
'enforce' the use of the row/column names used in the datafile (section of
datafile shown below)?
Can anyone help, please?

Section of datafile

sample  a   b   c   d ---n42
HBR-6   1   1   1   1
HBR-7   1   1   1   2
HBR-8   1   1   1   1
HBR-9   1   1   1   2
HBR-10  1   1   1   1
HBR-11  1   1   1   1
HBR-12  1   1   1   1
HBR-13  1   1   1   1
HBR-14  2   1   2   2
HBR-15  2   1   2   1
HBR-16  1   1   2   1
HBR-17  1   1   2   1
HBR-18  1   1   2   1
HBR-19  1   1   2   1
HBR-20  1   1   2   1
HBR-21  1   2   1   1
HBR-30  1   1   2   2
HBR-31  1   2   1   2
HBR-32  2   2   1   2
HBR-33  1   2   1   2
HBR-34  1   2   2   2
HBR-35  1   2   2   1
HBR-36  1   2   1   2
HBR-37  1   2   1   2


cat <-read.table("R855868825matrix.csv", sep=",", header=T)
 head (cat, n=24)
catopsis <- (cbind(cat$a, cat$b, cat$c, cat$d, cat$e, cat$f, cat$g, cat$h,
cat$i, cat$j, cat$k, cat$l, cat$m, cat$n, cat$o, cat$p, cat$q, cat$r, cat$s,
cat$t, cat$u, cat$v, cat$w, cat$x, cat$y, cat$z, cat$aa, cat$ab, cat$ac,
cat$ad, cat$ae, cat$af, cat$ag, cat$ah, cat$ai, cat$aj, cat$ak, cat$al,
cat$am, cat$an, cat$ao, cat$ap))
pca <- prcomp (t(catopsis))
plot(pca, catopsis [])
summary(prcomp(catopsis))
biplot(prcomp(catopsis, scale = TRUE))

-- 
View this message in context: 
http://n4.nabble.com/PCA-Showing-file-datalabels-on-biplot-tp1289524p1289524.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] binary

2010-01-25 Thread Val
Thanks for your response.

Do you mean that both the log-odds and odd ratio have the same meaning?





My question is that the log-odd  estimate 0.3618  is it for group1 or group2?


normally 1vs2, glm takes 2 as reference, in the group1 the IQ increase
by 0.3618compared to group 2


What does the odd ratio 1.43359 is interpreted?


in the group1 the IQ score  increase by 1.43359  compared to group 2

On Mon, Jan 25, 2010 at 10:05 AM, Mohamed Lajnef
 wrote:
> Hi val,
>
>
> Val a écrit :
>>
>> Hi all
>>
>> Assume I have a data set xx;
>>
>> Group: 1=group1  , 2=group2
>>
>> IQ:  1= High, 0 =low
>>
>> fit <- glm(IQ ~group, data = xx, family = binomial())
>>
>> summary(fit)
>>
>> Results
>>
>>                   Estimate Std. Error z value Pr(>|z|)
>>
>> (Intercept) -2.55456    0.210 -12.273  < 5e-16 ***
>>
>>  group          0.36180      0.076   3.952     5.24e-05 ***
>>
>> the odd ratio = exp(0.36180 )= 1.435912
>>
>> My question is that the log-odd  estimate 0.3618  is it for group1 or
>> group2?
>>
>
> normally 1vs2, glm takes 2 as reference, in the group1 the IQ increase by
> 0.3618compared to group 2
>
>> What does the odd ratio 1.43359 is interpreted?
>>
>
> in the group1 the IQ score  increase by 1.43359  compared to group 2
>
>> Thanks in advance
>>
>
> Regards
> ML
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
> --
> Mohamed Lajnef
> INSERM Unité 955. 40 rue de Mesly. 94000 Créteil.
> Courriel : mohamed.laj...@inserm.fr tel.: 01 49 81 31 31 (poste 18470)
> Sec : 01 49 81 32 90
> fax : 01 49 81 30 99 Portable:06 15 60 01 62
>
>

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


[R] z value from wilcox.exact

2010-01-25 Thread netrunner

Hi, 
does anibody know if is possible  to have as ouptut from the  wilcox.exact
function also a z value to  "link" the U value at the normal distribution?

thank you!

netrunner
-- 
View this message in context: 
http://n4.nabble.com/z-value-from-wilcox-exact-tp1289481p1289481.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Help with subset

2010-01-25 Thread Jerry Floren

Hi Peter,

Thanks again for showing me how to do this. This will save me hours of
tedious work, and I can't believe how quickly R reads in and processes my
data. It was taking about 40 minutes when I used Word's mail merge for this.
When I first switched from Excel to R, R was so much faster than Excel that
I could live with the 40 minute processing time. 

This is another major improvement. What will really save me the most time is
the" if (nrow(rsubset) > 8)"  statement. 

Thanks,

Jerry Floren
Minnesota Department of Agriculture
-- 
View this message in context: 
http://n4.nabble.com/Help-with-subset-tp1049883p1289485.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] summing a large, partitioned data frame

2010-01-25 Thread james.foadi
Dear R community,
I'm trying to develop a fast way of summing specific rows of a large data frame.
Here is an example of the kind of data frames I'm dealing with:

> refls
  H K L M/ISYM BATCH  I SIGI
43247 1 0 5 2179   61.44117  2.20553
1040  1 0 5257 6   15.16316  0.54431
2324  1 0 5257 5   46.76152  1.67858
31515 1 0 525960   57.97305  2.08104
35158 1 0 5259613.15614  0.11329
51575 1 0 625988  380.04477  8.08878
51846 1 0 625989  624.90802 13.30038
28946 1 1 4  142 2517.79492 55.37144
23199 1 1 4  531 2525.67407 55.54472
23198 1 1 4 2139 2519.44653 55.40777



I need to add up all I's with same H, K, L and M/ISYM.
The new data frame coming out of this partial summing should look, in this 
case, like:

  H K L M/ISYM BATCH  I SIGI
43247 1 0 5 2179   61.44117  2.20553
1040  1 0 5257 6   61.92468  0.54431
31515 1 0 525960   61.12919  2.08104
51575 1 0 625988 1004.95279  8.08878
28946 1 1 4  142 2517.79492 55.37144
23199 1 1 4  531 2525.67407 55.54472
23198 1 1 4 2139 2519.44653 55.40777




Essentially I only add those I's with same H, K, L, M/ISYM and replace the sum
in a unique row in the new data frame. In other words there's first a partition 
and then
a sum.

I have tried with a for loop, but it really takes too long.

I was wondering whether anyone knows of a better and faster way of doing this 
operation.


J



Dr James Foadi PhD
Membrane Protein Laboratory (MPL)
Diamond Light Source Ltd
Diamond House
Harewell Science and Innovation Campus
Chilton, Didcot
Oxfordshire OX11 0DE

Email:  james.fo...@diamond.ac.uk
Alt Email:  j.fo...@imperial.ac.uk

-- 
This e-mail and any attachments may contain confidential...{{dropped:8}}

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


Re: [R] binary

2010-01-25 Thread Mohamed Lajnef

Hi val,


Val a écrit :

Hi all

Assume I have a data set xx;

Group: 1=group1  , 2=group2

IQ:  1= High, 0 =low

fit <- glm(IQ ~group, data = xx, family = binomial())

summary(fit)

Results

   Estimate Std. Error z value Pr(>|z|)

(Intercept) -2.554560.210 -12.273  < 5e-16 ***

 group  0.36180  0.076   3.952 5.24e-05 ***

the odd ratio = exp(0.36180 )= 1.435912

My question is that the log-odd  estimate 0.3618  is it for group1 or group2?
  
normally 1vs2, glm takes 2 as reference, in the group1 the IQ increase 
by 0.3618compared to group 2



What does the odd ratio 1.43359 is interpreted?
  

in the group1 the IQ score  increase by 1.43359  compared to group 2


Thanks in advance
  


Regards
ML

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

  



--
Mohamed Lajnef
INSERM Unité 955. 
40 rue de Mesly. 94000 Créteil.
Courriel : mohamed.laj...@inserm.fr 
tel.: 01 49 81 31 31 (poste 18470)

Sec : 01 49 81 32 90
fax : 01 49 81 30 99 
Portable:06 15 60 01 62


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


[R] Rscript is not loading some of one of the standard R packages

2010-01-25 Thread petertait

Hi,


I have a script I can run step by step through the R interpreter and it works 
fine. I then run as a shell script with Rscript and it fails.


The error message comes when I am creating a model matrix with 
model.matrix.default().


Error in `contrasts<-`(`*tmp*`, value = "contr.Treatment") : 
  could not find function "is"
Calls: model.matrix.default -> contrasts<-


I included the following command at the beginning of my Rscript : 


cat("Looking for environment(is): ", environment(is), "\n")


and I received the same error message:


Error in environment(is) : object 'is' not found
Calls: cat -> environment




At the command line (through the R interpreter) the same command returns:
> environment(is)



Rscript is not loading the methods package and I don't know how to fix this.


Why would this be happening and how can I prevent it in the future?




I am running the following R session at the command line:
> sessionInfo()
R version 2.10.1 (2009-12-14) 
x86_64-pc-linux-gnu 

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

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

Here is what I get when I run sessionInfo() from Rscript

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

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

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



The version of Rscript I am running is:
$ Rscript --version
R scripting front-end version 49838





Thank you for your help
Peter


  
[[alternative HTML version deleted]]

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


[R] glmnet in caret packge

2010-01-25 Thread Alex Roy
Dear all,
  I want to train my model with LASSO using caret package
(glmnet). So, in glmnet, there are two parameters, alpha and lambda. How can
I fix my alpha=1 to get a lasso model?



con<-trainControl(method="cv",number=10)

model <- train(X, y, "glmnet", metric="RMSE",tuneLength = 10, trControl =
con)



Thanks

Alex Roy

[[alternative HTML version deleted]]

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


Re: [R] How to define degree=1 in mgcv

2010-01-25 Thread Simon Wood
On Monday 25 January 2010 02:40, hellen lee wrote:
> Hi, all
>
> I have a question on mgcv and ns. Now I want to compare the results from
> glm, gam and ns. Take a simple model y~x for example.
>
> glm1 = glm(y~x, data=data1)
> gam1 = gam(y~s(x), data=data1)
> ns1 = glm(y~ns(x),data=data1)
>
> In order to confirm the result from glm1 is consistent to those from gam1
> and ns1, I want to define degree=1 in mgcv and ns. I am wondering if there
> is somebody can give me some suggestions? I appreciate.
gam(y~x,data=data1) 

or

gam(y~s(x,sp=1e6),data=data1)

you might need to increase the value supplied in `sp' in order to get the EDF 
for the smooth term close enough to 1 for your liking.

best,
Simon

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283

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


Re: [R] sequence of equal-length numbers (for filenames)

2010-01-25 Thread Don MacQueen

One can also use
  formatC()
with the flag option.

-Don

At 10:47 AM -0200 1/25/10, Henrique Dallazuanna wrote:

Try sprintf:

sprintf("%03d", Sequence)
sprintf("file%03d.dat", Sequence)




On Mon, Jan 25, 2010 at 10:39 AM, Îroutík  wrote:

 Dear R-users,

 I'd like to create filenames in a mask "file000.dat" numbered from 1 to e.g.
 123. The last problem I'm dealing with is creating the sequence of numbers
 with equal length, i.e. 001, 002, 023, 024, 122, 123.

 The closest I got is by a repetition:

 Sequence <- c(1:123)
 for(i in c(1:length(Sequence))) {
 print(
paste(rep("0",
 max(nchar(as.character(Sequence)))-nchar(as.character(Sequence[i]))),
as.character(Sequence[i]),
sep=""))
 }

 where pasting "0"-replication the missing-times I 'm possibly creating the
 desired output. It's just that rep()'s output is not a vector and not
 subsequent atoms. and gives "02" and "02" instead of "002".

 Any idea hot to correct the function above or suggestions on
 file000.dat-mask filename, please?

 Thank you for your time.
 M

[[alternative HTML version deleted]]

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

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





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

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



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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


Re: [R] Display of results

2010-01-25 Thread Robert Baer
I don't know this test, but as written, LM <- Lo.Mac(y,kvec), will just make 
an assignment.  To display the result you could write:

(LM <- Lo.Mac(y,kvec))



- Original Message - 
From: "Hichem Ben Khedhiri" 

To: 
Sent: Sunday, January 24, 2010 9:47 AM
Subject: [R] Display of results


Dear R-helpers,

I have been trying to carry out some variance ratio tests such as
Lo-MacKinlay test and Chow-Denning test. However, When I write the
function LM <- Lo.Mac(y,kvec)
or any other functions I don't get the results displayed. The only
sign I get is <

I don't understand what's wrong (is it the package, misspecification
of the function, Vista). I am really stuck in and I would be grateful
for any hints that
may help me get the results displayed.


Many thanks in advance,

Ben.

[[alternative HTML version deleted]]








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

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



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


[R] Same y-axis on multiple plots?

2010-01-25 Thread Andreas Bergstrøm
Greetings,

I am attempting to use R throug PL/R in PostgreSQL to make several graphs (they 
show usage over time for radiochannels).

However, as some never go above 100 in a 24 hour period, and others go well 
over 500, they get different y-axis values (which normally would be a good 
thing). However, as I want to overlay the graphs to add/remove channels in CSS 
on a webpage, I need a set y-axis.

I have looked through the documentation, google and the mailinglist as ylim, 
setting xpd=F and modifying clip, plot.window, but I can't seem to find what I 
am looking for. I am certain that it is something simple, and would be 
gratefull if someone could point me in the right direction.


R code run through PL/R in Postgres is as follows:

mymain <- "Graph 3";
myxlab <- "Time: 24/Hours";
myylab <- "Number of Hits";

png(''/tmp/graph3.png'');
plot(str,type="b",main=mymain,xlab=myxlab,ylab=myylab,lwd=2, axes=F, 
ylim.max=0);
clip(0, 25, 0, 600);
axis(1, at = c(0, 3, 6, 9, 12, 15, 18, 21, 24));
axis(2, at = c(0, 100, 200, 300, 400, 500, 600));
abline(h = c(100, 200, 300, 400, 500, 600), lty=2);
mtext("Usage over a  24 hour period",side=3);
dev.off();



Contents of str structure:
str <-
structure(list(timeofday = 1:23, connections = c(116L, 87L, 51L, 
44L, 75L, 147L, 264L, 275L, 233L, 294L, 132L, 140L, 198L, 171L, 
248L, 226L, 257L, 246L, 210L, 189L, 180L, 238L, 303L)), .Names = c("timeofday", 
"connections"), row.names = c("1", "2", "3", "4", "5", "6", "7", 
"8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", 
"19", "20", "21", "22", "23"), class = "data.frame")

Regards,

--
Andreas Bergstrøm
Østfold University College
Dept. of Computer Sciences
Tel: +47 69 21 53 71
http://media.hiof.no/

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


[R] binary

2010-01-25 Thread Val
Hi all

Assume I have a data set xx;

Group: 1=group1  , 2=group2

IQ:  1= High, 0 =low

fit <- glm(IQ ~group, data = xx, family = binomial())

summary(fit)

Results

   Estimate Std. Error z value Pr(>|z|)

(Intercept) -2.55456    0.210 -12.273  < 5e-16 ***

 group  0.36180  0.076   3.952 5.24e-05 ***

the odd ratio = exp(0.36180 )= 1.435912

My question is that the log-odd  estimate 0.3618  is it for group1 or group2?

What does the odd ratio 1.43359 is interpreted?

Thanks in advance

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


Re: [R] Rearranging long dataframe for printing in Sweave (andrecoding a factor)

2010-01-25 Thread Steve Sidney

JL

The solution which was proposed by Joseph Wright on the Latex Community 
Forum was as follows


1) Use R to create the table and then save it in csv format

2) Use LaTex to print the table.

3) LaTex on it's own is not able to do this and you must install the 
'datatool' package.


4) What 'datatool' allows you to do is to read the csv into an internal 
database and from that various very nice table printing styles can be 
provided.


5) If you click on the link below provided by Liviu, you can follow the 
postings between Joesph and myself and there are various code files as well 
as pdf's which show how a single table with more rows than one page, can be 
divided in two and placed one one page. If that's what you are looking for 
then this might be a solution. The only problem is that if like me you don't 
have strong LaTex skills, then you will have to do some experimenting and 
learning, in order to achieve this result.


HTH - Good luck
Steve


- Original Message - 
From: "Jean-Louis Abitbol" 
To: "Steve Sidney" ; "Liviu Andronic" 


Cc: "R Help" 
Sent: Monday, January 25, 2010 9:18 AM
Subject: Re: [R] Rearranging long dataframe for printing in Sweave 
(andrecoding a factor)



Hi Steve and Liviu,

Thanks for the pointer to your posts.

Steve can you share your elegant solution ?

Up to now I have not had any answer from R-Help ...

Best, JL

On Sun, 24 Jan 2010 18:24 +0200, "Steve Sidney" 
wrote:

Dear Liviu / Jean-Louis

As the original poster I did find what I think is an elegant solution.

The only remaining problem is that I have not been able to get it to work
in
Lyx, but it does work using a LaTeX editor (in this case WinEdt) and
MikTex.

I would still like to resolve why I can't read the csv table in Lyx.

Regards
Steve

- Original Message - 
From: "Liviu Andronic" 

To: "Jean-Louis Abitbol" 
Cc: "R Help" 
Sent: Sunday, January 24, 2010 5:56 PM
Subject: Re: [R] Rearranging long dataframe for printing in Sweave
(andrecoding a factor)


> Hello
>
> On 1/24/10, Jean-Louis Abitbol  wrote:
>>  I have to print a dataframe with >1000 rows and 2 columns for a report
>>  done with Sweave.
>>
>>  I could use Hmisc latex function with longtable option.
>>  However it is a waiste of space and paper given that I have only 2 (or
>>  sometime 3) columns in the dataframe.
>>
>>  So it came to my mind that I could maybe  rearrange the dataframe and
>>  create several new variables from the original 2 in a tabular way for
>>  printing in less space.
>>
> There was a recent discussion on lyx-users [1] on a similar issue. I
> am not sure whether the original poster found a solution, though.
>
> Liviu
>
> [1] http://www.mail-archive.com/lyx-us...@lists.lyx.org/msg78933.html
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


--
 Jean-Louis Abitbol
 abit...@sent.com
 Tel 33 (0)6 24 47 59 34
 1 ter Rue Céline, 92160
 Antony, France

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


Re: [R] R Memory Problem

2010-01-25 Thread Johann Hibschman
prem_R  writes:

> I'm running predictive analytics using R and to calibrate my model i
> used to adjust the variables used in the model and the problem happens
> here.R just runs out of memory .I tried garbage cleaning also.

I'm analyzing a 8 GB data set using R, so it can certainly handle large
data sets.  It tends to copy data very often, however, so you have to be
very careful with it.

For example, if you modify a single column in a data frame, R will copy
the entire data frame, rather than just replace the modified column.  If
you are running a regression that saves the input data in the model
result object, and you are modifying the data frame between runs, then
it would be very easy to have many copies of your data in memory at
once.

One solution would be not to keep the model result objects around.
Another would be to manually modify them to strip out the data object.
This can be tricky, however, since copies of the data may live on in the
environments of saved functions; I had this problem with 'mgcv::gam'
fits.

I hope that helps.

Regards,
Johann

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


Re: [R] Where can I get training for R-PLUS

2010-01-25 Thread Romain Francois

On 01/25/2010 03:02 PM, jamy wrote:

Hi friends,
Does any one know ,where can I get free training for R-PLUS.If any one know
please let me know.

Thanks,
James.


http://lmgtfy.com/?q=R-plus+training

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009

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


[R] frequency table help

2010-01-25 Thread Paola Pesci
Hi,

I have a dataset like this:

Specieslength (cm)

A 12.4

B 45

A 34.6

C 73

C 24.5

D 4.5

..

I'm trying to obtain a barplot with the class length in x (fixed classes, 5
cm) and the number of species in y, but using just a barplot is not the case
(I think).

So, maybe the best way is to first obtain a frequency table and then to plot
the graph, but I managed only to obtain a frequency table with 5 cm of class
length but the frequency are the numbers of individuals by class and this is
not what I need. Do you know how I can do? 

Thank you in advance.

Paola

 


[[alternative HTML version deleted]]

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


[R] Where can I get training for R-PLUS

2010-01-25 Thread jamy

Hi friends,
Does any one know ,where can I get free training for R-PLUS.If any one know
please let me know.

Thanks,
James.
-- 
View this message in context: 
http://n4.nabble.com/Where-can-I-get-training-for-R-PLUS-tp1289371p1289371.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] read multiple large files into one dataframe

2010-01-25 Thread hadley wickham
On Mon, Jan 25, 2010 at 4:43 AM, Paul Hiemstra  wrote:
> Brad Patrick Schneid wrote:
>>
>> ###  The following is very helpful # listOfFiles <-
>> list.files(pattern= ".txt") d <- do.call(rbind, lapply(listOfFiles,
>> read.table)) ###
>>
>> but what if each file contains information corresponding to a different
>> subject and I need to be able to tell where each row came from?  i.e.: I
>> need a new row
>
> a new column I presume, not a row
>>
>> that repeats the original filename for each observation of
>> the former respective files.
>>
>> Any ideas?
>>
>>
>
> listOfFiles <- list.files(pattern= ".txt")
> d <- do.call(rbind, lapply(listOfFiles, read.table))

Or use the plyr package:

listOfFiles <- list.files(pattern= ".txt")
names(listOfFiles) <- basename(listOfFiles)

d <- ldply(listOfFiles, read.table)

See http://had.co.nz/plyr for more info.

Hadley

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

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


Re: [R] Quantile loess smother?

2010-01-25 Thread Dieter Menne


Tal Galili wrote:
> 
> Something that will be a combination of what rq (package quantreg} does,
> with loess.
> 

qss in quantreg comes close.

Dieter

-- 
View this message in context: 
http://n4.nabble.com/Quantile-loess-smother-tp1289277p1289349.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R Memory Problem

2010-01-25 Thread jim holtman
How big is your data set (use object.size on the object and 'str').
Exactly what statements are you executing?  Exactly what error message
are you getting?

On Mon, Jan 25, 2010 at 5:44 AM, prem_R  wrote:
>
> Is anyone could help me to resolve this problem?I'm presently an SAS user for
> my application and was exploring R to use it for my application.I have
> already posted this question on using my 32 bit machine with 2GB RAM and
> from what i understood was to use a 64Bit machine .I tried using 64bit
> machine using 4GB RAM .I'm running predictive analytics using R and to
> calibrate my model i used to adjust the variables used in the model and the
> problem happens here.R just runs out of memory .I tried garbage cleaning
> also.
> data
> APN    condition    quality    site_zip   sale_date    sale_price
> estimate
> 1.1-1   good         good       10201    1/1/07         $234,000
> $254,000
> 1.5-1   average     good       10201    1/1/08         $254,000
> $276,000
> 1.6-1    poor          poor       10202    1/1/06         $192,000
> $199,000
> 1.7-1    good         good        10202    1/1/07        $300,000
> $305,000
>
> Regression equation
>
> Sale_price=condition quality site_zip
>
> after running the above equation i will be getting the estimates and
> then i will calibrate the model using the dependent variables.
>
> For that purpose seperate dataset are created and run for 50 Iterations
> .Problem occurs here after running few iterations it shows out of space.
>
> I'm using R 2.10.0
>
> If you need any other clarifications i shall provide the needed .Help me to
> solve this
> --
> View this message in context: 
> http://n4.nabble.com/R-Memory-Problem-tp1289221p1289221.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] sequence of equal-length numbers (for filenames)

2010-01-25 Thread Henrique Dallazuanna
Try sprintf:

sprintf("%03d", Sequence)
sprintf("file%03d.dat", Sequence)




On Mon, Jan 25, 2010 at 10:39 AM, Žroutík  wrote:
> Dear R-users,
>
> I'd like to create filenames in a mask "file000.dat" numbered from 1 to e.g.
> 123. The last problem I'm dealing with is creating the sequence of numbers
> with equal length, i.e. 001, 002, 023, 024, 122, 123.
>
> The closest I got is by a repetition:
>
> Sequence <- c(1:123)
> for(i in c(1:length(Sequence))) {
> print(
>    paste(rep("0",
> max(nchar(as.character(Sequence)))-nchar(as.character(Sequence[i]))),
>    as.character(Sequence[i]),
>    sep=""))
> }
>
> where pasting "0"-replication the missing-times I 'm possibly creating the
> desired output. It's just that rep()'s output is not a vector and not
> subsequent atoms. and gives "02" and "02" instead of "002".
>
> Any idea hot to correct the function above or suggestions on
> file000.dat-mask filename, please?
>
> Thank you for your time.
> M
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


[R] sequence of equal-length numbers (for filenames)

2010-01-25 Thread Žroutík
Dear R-users,

I'd like to create filenames in a mask "file000.dat" numbered from 1 to e.g.
123. The last problem I'm dealing with is creating the sequence of numbers
with equal length, i.e. 001, 002, 023, 024, 122, 123.

The closest I got is by a repetition:

Sequence <- c(1:123)
for(i in c(1:length(Sequence))) {
print(
paste(rep("0",
max(nchar(as.character(Sequence)))-nchar(as.character(Sequence[i]))),
as.character(Sequence[i]),
sep=""))
}

where pasting "0"-replication the missing-times I 'm possibly creating the
desired output. It's just that rep()'s output is not a vector and not
subsequent atoms. and gives "02" and "02" instead of "002".

Any idea hot to correct the function above or suggestions on
file000.dat-mask filename, please?

Thank you for your time.
M

[[alternative HTML version deleted]]

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


Re: [R] Quantile loess smother?

2010-01-25 Thread Gavin Simpson
On Mon, 2010-01-25 at 14:08 +0200, Tal Galili wrote:
> Hello all,
> 
> I wish to fit a loess smother to a plot of Y`X, but in predicting the 95%
> quantile.
> Something that will be a combination of what rq (package quantreg} does,
> with loess.
> 
> Is there a function/method for doing this?

?rqss in package quantreg provides smoothers for quantile regression.
This doesn't appear to be a LOESS smoother however, but might be useful
nonetheless.

G

> 
> Thanks,
> Tal
> 
> 
> 
> 
> 
> 
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com/ (English)
> --
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


  1   2   >