Re: [R] Finding different hues for a mosaic plot compatible with grayscale printing

2010-05-13 Thread Simon Kiss

Dear Colleagues,
Thanks for that JIm, but It strikes me that printing the residual  
values in the cells might be a simpler way of communicating the  
direction of each cell.
I can get the residuals printed via the labeling_values commands in  
mosaic, but I cannot seem to *combine* this with labeling_borders  
commands that I'd like to use to modify the rotation, font size and  
contents of variable names and labels.

The following mosaic command draws the plot with the labeling I'd like.

mosaic(~social_class+ctax_agg_scaled, pop=FALSE, shade=TRUE,  
main=The Liberals Carbon Tax Or Green Shift Would Hurt The Canadian  
Economy By EGP Class Category, main_gp=gpar(fontsize=16),  
gp=shading_hcl(CST21$observed, CST21$expected, ASR21, df=12,  
h=c(260,0), c=c(100,0), l=c(90,50), interpolate=c(1,2,3,4)),  
labeling_args=list(labels=TRUE, rot_labels=c(25,0,0,25),  
gp_labels=gpar(fontsize=7), just_labels=center,  
offset_labels=c(1,0,0,4), offset_varnames=c(2,0,0,4),  
set_varnames=c(ctax_agg_scaled=The Liberal Green Shift Or Carbon Tax  
Would Hurt The Canadian Economy, social_class=EGP Class Category)))


And when I take out the labeling_borders commands and insert the  
following,

labeling=labeling_values(value_type=c(residuals), suppress=0)

then I do get the residuals printed, but the labels are unattractive.

How do I combine labeling_borders and labeling_values commands in one  
command.


Yours, Simon Kiss   
On 12-May-10, at 2:42 PM, Jim Lemon wrote:


On 05/12/2010 07:34 PM, Simon Kiss wrote:

I'm working with the following code below to generate a
how do I set the h,c, and l values such that the significant,  
positive

residuals appear different on a grayscale printer from significant
grayscale residuals. The challenge as I see it is that one can only
distinguish the positive and negative residuals with the hue/.  
Varying
the chroma and the luminance only affect the distinctions between  
large

and small and significant and non significant. But my positive and
negative residuals are both large (absolutely) and significant,  
meaning
that they will have the same chroma and luminosity, but different  
hues.

I guess the key here is to find two separate hue values that appear
substantially different *on a grayscale printer* at the same chroma  
and

luminance. I have read through Zeileis et al. (2007, 2008) but can't
quite find the answer there.
I have also tried the Friendly shading to vary the line type, but I
can't find line types that are different enough to communicate the
difference between positive and negative residuals clearly.

Your assistance is appreciated.

mosaic(~educ+trade_off_scaled, shade=TRUE, main=Support For
Environmental Protection At The Expense of Creating Jobs By  
Education,
gp=shading_hcl(CST17$observed, CST17$expected, ASR17, df=6,  
h=c(260,0),

c=c(100,0), l=c(90,0)), labeling_args=list(rot_labels=c(25,90,0,0),
offset_labels=c(1,0,0,2), offset_varnames=c(2,0,0,4),
set_varnames=c(trade_off_scaled=Protecting The Environment Is More
Important Than Creating Jobs, educ=Level of Education)))


Hi Simon,
I thought that the symbolbox function might do something useful, but  
it required a bit of modification. The attached mod allows the user  
to fill a rectangle with symbols, which includes things like + and  
-.


Jim

symbolbox.R


*
Simon J. Kiss, PhD
SSHRC and DAAD Post-Doctoral Fellow
John F. Kennedy Institute of North America Studies
Free University of Berlin
Lansstraße 7-9
14195 Berlin, Germany
Cell: +49 (0)1525-300-2812,
Web: http://www.jfki.fu-berlin.de/index.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.


[R] access objects in my environment

2010-05-13 Thread arnaud Gaboury
Dear group,

Here are my objects in my environment:

 ls()
[1] Pos100415 Pos100416 posA  pose15pose16pose16t
position  trade x  

I need to pass the object Pos100415 to a function. This element is a
data.frame, obtained through a function: Pos(x)-myfun(x) with x-100415 in
this example.

If I do this :

posA-paste(c(Pos,100415),collapse=) #I can't use directly Pos100415.I
need to access it via paste(c(Pos,x),collapse=) in general.

Here is what I got :

 posA
[1] Pos100415

It is certainly not what I want, as I need to have posA as the same
data.frame than Pos100415.

Any help?

TY

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] access objects in my environment

2010-05-13 Thread Patrizio Frederic
Hi,
have a look at function 'get'  (and function 'assign' too)
In your example:

x - 1000
assign(paste('Pos',x,sep=''),rnorm(100))
Pos1000
posa - get(paste(c(Pos,x),collapse=))
posa

hope it's help

PF

On Thu, May 13, 2010 at 10:37 AM, arnaud Gaboury
arnaud.gabo...@gmail.com wrote:
 Dear group,

 Here are my objects in my environment:

 ls()
 [1] Pos100415 Pos100416 posA      pose15    pose16    pose16t
 position  trade     x

 I need to pass the object Pos100415 to a function. This element is a
 data.frame, obtained through a function: Pos(x)-myfun(x) with x-100415 in
 this example.

 If I do this :

posA-paste(c(Pos,100415),collapse=) #I can't use directly Pos100415.I
 need to access it via paste(c(Pos,x),collapse=) in general.

 Here is what I got :

 posA
 [1] Pos100415

 It is certainly not what I want, as I need to have posA as the same
 data.frame than Pos100415.

 Any help?

 TY

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




-- 
+-
| Patrizio Frederic, PhD
| Assistant Professor,
| Department of Economics,
| University of Modena and Reggio Emilia,
| Via Berengario 51,
| 41100 Modena, Italy
|
| tel:  +39 059 205 6727
| fax:  +39 059 205 6947
| mail: patrizio.frede...@unimore.it
+-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Vectorized expression to extrapolate matrix columns with columns of another matrix

2010-05-13 Thread Abiel X Reinhart
Thanks Gabor, this looks like it serves my needs. I've extended the code to 
work with an example where we have two multicolumn zoo objects, one with the 
original data and another that has the growth rates.

# mat1 = zoo object to extend
# mat2 = zoo object whose growth rate is used to extend mat1
mergeGrowth - function(mat1, mat2)
{
ix - is.na(mat1)
mat1.locf - na.locf(mat1, na.rm=F)
mat2.locf - mat2
mat2.locf[ix] - NA
mat2.locf - na.locf(mat2.locf, na.rm=F)
coredata(mat1)[ix] - coredata(mat1.locf * mat2 / mat2.locf)[ix]
mat1
}


Abiel Reinhart

-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: Wednesday, May 12, 2010 12:00 PM
To: Abiel X Reinhart
Cc: r-help@r-project.org
Subject: Re: [R] Vectorized expression to extrapolate matrix columns with 
columns of another matrix

Yes, that is what it does.  Note that na.approx interpolates and does
not work precisely as you discussed but its easy, does use m[,2] and
may be good enough.   If you really do want something precisely as you
discussed try this.  It NAs out the rows of m for which column 1 is NA
and then uses na.locf to move the prior non-NA into it.  Then we apply
the formula:

 library(zoo)
 m - zoo(cbind(c(1, 2, NA, NA, 5, NA, NA), seq(7)^2), as.Date(1:7))

 # mm will hold result; m.locf
 m.locf - mm - m
 ix - is.na(mm[,1])
 m.locf[ix,] - NA
 m.locf - na.locf(m.locf)
 mm[ix, 1] - m.locf[ix, 1] * mm[ix,2] / m.locf[ix,2]
 mm

1970-01-02 1.0  1
1970-01-03 2.0  4
1970-01-04 4.5  9
1970-01-05 8.0 16
1970-01-06 5.0 25
1970-01-07 7.2 36
1970-01-08 9.8 49

1970-01-02 1.0  1
1970-01-03 2.0  4
1970-01-04 4.5  9
1970-01-05 8.0 16
1970-01-06 5.0 25
1970-01-07 7.2 36
1970-01-08 9.8 49





Yes, that is what it does. Please read the help file for na.approx and
approx.  If you want something different you will have to special case
the end values.

On Wed, May 12, 2010 at 11:11 AM, Abiel X Reinhart
abiel.x.reinh...@jpmchase.com wrote:
 Gabor,

 Maybe I am doing this wrong, but rule=2 does not look like it is growing the 
 series out, but rather just carrying the last value forward. It looks like 
 na.approx() followed by na.locf(). For instance:

 m - zoo(cbind(c(1, 2, NA, NA, 5, NA, NA), seq(7)^2), as.Date(1:7))
 na.approx(m[, 1], x = m[, 2], rule=2)

 1970-01-02 1970-01-03 1970-01-04 1970-01-05 1970-01-06 1970-01-07 1970-01-08
       1.0        2.0        2.7        3.7        5.0        5.0        5.0

 Abiel Reinhart

 -Original Message-
 From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
 Sent: Wednesday, May 12, 2010 10:40 AM
 To: Abiel X Reinhart
 Cc: r-help@r-project.org
 Subject: Re: [R] Vectorized expression to extrapolate matrix columns with 
 columns of another matrix

 Use rule = 2 as in the extrapolation examples in the na.approx help file.

 On Wed, May 12, 2010 at 10:10 AM, Abiel X Reinhart
 abiel.x.reinh...@jpmchase.com wrote:
 Gabor,

 This comes close to solving my problem, but I am still left with the problem 
 of how I can extrapolate, not just interpolate. In our example, if I define 
 m as,

 m - zoo(cbind(c(1, 2, NA, NA, 5, NA, NA), seq(7)^2), as.Date(1:7))

 instead of

 m - zoo(cbind(c(1, 2, NA, NA, 5, NA, 7), seq(7)^2), as.Date(1:7))

 then I will only get five values back, when I really want m[,1] to be fully 
 extrapolated so that there are seven values. Is there a workaround?

 Abiel Reinhart

 -Original Message-
 From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
 Sent: Wednesday, May 12, 2010 8:37 AM
 To: Abiel X Reinhart
 Cc: r-help@r-project.org
 Subject: Re: [R] Vectorized expression to extrapolate matrix columns with 
 columns of another matrix

 Try this using the zoo package.  See ?na.approx for more and note that
 this functionality requires zoo 1.6-3 or later.

 . m - zoo(cbind(c(1, 2, NA, NA, 5, NA, 7), seq(7)^2), as.Date(1:7))
 na.approx(m[, 1], x = m[, 2])
 1970-01-02 1970-01-03 1970-01-04 1970-01-05 1970-01-06 1970-01-07 1970-01-08
  1.00   2.00   2.714286   3.714286   5.00   5.916667   7.00
 na.approx(m[, 1])
 1970-01-02 1970-01-03 1970-01-04 1970-01-05 1970-01-06 1970-01-07 1970-01-08
         1          2          3          4          5          6          7


 On Tue, May 11, 2010 at 4:48 PM, Abiel X Reinhart
 abiel.x.reinh...@jpmchase.com wrote:
 I have two identically sized matrices of data that represent time series (I 
 am storing the data in zoo objects, but the idea should apply to any matrix 
 of data). The time series in the second matrix extend further than in the 
 first matrix, and I would like to use the data in matrix 2 to extrapolate 
 the data in matrix 1. In other words, if mat1[i,j] == NA, then mat1[i,j] - 
 mat1[i-1, j]*mat2[i,j]/mat2[i-1,j]. Of course, before we can calculate 
 mat1[i,j] we may need to calculate mat1[i-1,j], and that in turn may 
 require the computation of mat1[i-2,j], etc. This could all clearly be done 
 with loops, but I am wondering 

Re: [R] Robust SE Heteroskedasticity-consistent estimation

2010-05-13 Thread RATIARISON Eric
Hi, here my new version:
I submit you my case:
( Pseudo likehood for exponential family with offset )

loglik - function(param)  {
   b-param
   m=as.vector(of+z%*%b)
   ll - sum(v*m-exp(m))   }

gradlik - function(param) {
 b-param
 m=as.vector(of+z%*%b)
 gg-(v-exp(m))*z  }

hesslik - function(param) {
 b-param
 m=as.vector(of+z%*%b)
 hh - -t(exp(m)*z)%*%z }

resMaxlik - 
maxLik(loglik,grad=gradlik,hess=hesslik,start=sc,method=nr,tol=1e-4);

resMaxlik$offset-of
resMaxlik$x-z
resMaxlik$y-v



estfun - function(obj,...)
{
m=as.vector(obj$offset+obj$x%*%obj$estimate)
(obj$y-exp(m))*obj$x
}

M - function(obj, adjust = FALSE, ...)
{
psi - estfun(obj)
k - NCOL(psi)
n - NROW(psi)
rval - crossprod(as.matrix(psi))/n
if(adjust) rval - n/(n - k) * rval
rval
}


B - function(obj, ...)
{ as.matrix(ginv(obj$hessian))
}
 

So S -B(resMaxlik)*M(resMaxlik)*B(resMaxlik) directly. It's ok.

But I call sandwich function like this : sandwich(resMaxlik,meat.=M,bread.=B)
It returns a error message : Erreur dans UseMethod(estfun) : 
  pas de méthode pour 'estfun' applicable pour un objet de classe c('maxLik', 
'maxim', 'list')





-Message d'origine-
De : Arne Henningsen [mailto:arne.henning...@googlemail.com] 
Envoyé : mardi 11 mai 2010 08:25
À : Achim Zeileis; RATIARISON Eric; r-help@r-project.org; Ott-Siim Toomet
Objet : Re: [R] Robust SE  Heteroskedasticity-consistent estimation

On 11 May 2010 00:52, Achim Zeileis achim.zeil...@uibk.ac.at wrote:
 On Mon, 10 May 2010, RATIARISON Eric wrote:
 I'm using maxlik with functions specified (L, his gradient  hessian).

 Now I would like determine some robust standard errors of my estimators.

 So I 'm try to use vcovHC, or hccm or robcov for example

 but in use one of them with my result of maxlik, I've a the following
 error message :

 Erreur dans terms.default(object) : no terms component

 Is there some attributes to give to maxlik objet for fitting the call
 of vcovHC?

 This is discussed in
  vignette(sandwich-OOP, package = sandwich)
 one of the vignettes accompanying the sandwich package that provides the
 vcovHC() function. At the very least, you need an estfun() method which
 extracts the gradient contributions per observation. Then you need a bread()
 function, typically based on the observed Hessian. Then you can compute the
 basic sandwich() estimators.

Is it possible to implement the estfun() method and the bread()
function in the maxLik package so that vcovHC() can be easily used by
all users of the maxLik package? If yes: should we (Eric, Achim, Ott,
Arne) implement this feature together?

/Arne

-- 
Arne Henningsen
http://www.arne-henningsen.name

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] merge for data.frame and matrix

2010-05-13 Thread Yuan Jian
Hello,

how to merge a data.frame and a matrix by one column in the data.frame and 
rownames of the matrix?
df - data.frame(col1=c(kk,yy,kk),col2=c(6,4,3))
 df
  col1 col2
1   kk    6
2   yy    4
3   kk    3
m-matrix(c(3,8,56,9), nrow=2, dimnames = list(c(aa,kk),c(col1,col2)))
 m
   col1 col2
aa    3   56
kk    8    9

the result is expected as
col1.x col2.x col1.y col2.y
kk   6    8    9
kk   3    8    9

Yuan Jian




  
[[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] sem error no variance or error-variance parameter

2010-05-13 Thread Jan Schubert

Hi,
I am using the R version 2.11.0 and the version of sem package: sem_0.9-20
under Windows XP.
I read the questions:
http://r.789695.n4.nabble.com/computationally-singular-and-lack-of-variance-parameters-in-SEM-td891081.html#a891082

and 

http://r.789695.n4.nabble.com/computationally-singular-and-lack-of-variance-parameters-in-SEM-td891081.html#a891081

but it does not seem to be my problem. I try to replicate the sem model (see
the attacheted image) but i got stuck with the problem while computing the
estimates of the model:
The error message:

Error in nlm(if (analytic.gradient) objective.2 else objective.1, start,  : 
  probable coding error in analytic gradient
In addition: Warning message:
In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names =
vars,  :
  The following variables have no variance or error-variance parameter
(double-headed arrow):
 Fugural1 
The model is almost surely misspecified; check also for missing covariances.

Here is my script:

cov.matrix -
matrix(c(56.21,0,0,0,0,0,0,0,0,31.55,75.55,0,0,0,0,0,0,0,23.27,28.30,44.45,0,0,0,0,0,0,24.48,32.24,22.56,84.64,0,0,0,0,0,22.51,29.54,20.61,57.61,78.93,0,0,0,0,22.65,27.56,15.33,53.57,49.27,73.76,0,0,0,33.24,46.49,31.44,67.81,54.76,54.58,141.77,0,0,32.56,40.37,25.58,55.82,55.33,47.74,98.62,117.33,0,30.32,40.44,27.69,54.78,53.44,59.52,96.95,84.87,106.35),nrow=9,ncol=9,byrow=FALSE)
rownames(cov.matrix) - colnames(cov.matrix) -
c(IND1,IND2,IND3,FR11,FR12,FR13,FR21,FR22,FR23)

# options(nlm=(check.analyticals = TRUE)); I tried to set the nlm on
different option, but did not work either

m1 - specify.model()
Induction - IND1, NA, 1
Induction - IND2, y2, NA
Induction - IND3, y3, NA
Fugural1 - FR11, NA, 1
Figural1 - FR12, y5, NA
Figural1 - FR13, y6, NA
Figural2 - FR21, NA, 1
Figural2 - FR22, y8, NA
Figural2 - FR23, y9, NA
Induction - Figural1, x1, NA
Figural1 - Figural2,x2, NA
Induction - Figural2, x3, NA
IND1 - IND1, e1, NA
IND2 - IND2, e2, NA
IND3 - IND3, e3, NA
FR11 - FR11, e4, NA
FR12 - FR12, e5, NA   
FR13 - FR13, e6, NA
FR21 - FR21,e7, NA
FR22 - FR22, e8, NA
FR23 - FR23, e9, NA
Figural1 - Figural1, e10, NA
Figural2 - Figural2, e11, NA
Induction - Induction, NA, 1

sem1 - sem(m1,cov.matrix,N=220,debug=T)

# I added the Induction - Induction, NA, 1 fixed parametr after reading
the help from John Fox, that every variable should have an error variance 


Can anybody please advise me what I am doing wrong? 
Many thanks!

Jan Schubert
Institute of Social Science
Charles University, Prague 
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/sem-error-no-variance-or-error-variance-parameter-tp2196743p2196743.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] Robust SE Heteroskedasticity-consistent estimation

2010-05-13 Thread Ott-Siim Toomet
Hi,

the error message tells you that there is no method estfun for maxLik
objects.  Which is (unfortunately) true.  I try to look at this stuff
during the weekend (given my son sleeps well ;-).

Actually, maxLik can only implement estfun  friends given the user
supplies them.  AFAIK, you need to supply your likelihood function in
BHHH form, i.e. without 'sum' in the last row in your example below, and
the gradient in the same way.  If your function only returns a single
likelihood value, there is now way maxLik can distribute it to
individual observations.

Best,
Ott



 Hi, here my new version:
 I submit you my case:
 ( Pseudo likehood for exponential family with offset )

 loglik - function(param)  {
b-param
m=as.vector(of+z%*%b)
ll - sum(v*m-exp(m))   }

 gradlik - function(param) {
  b-param
  m=as.vector(of+z%*%b)
  gg-(v-exp(m))*z  }

 hesslik - function(param) {
  b-param
  m=as.vector(of+z%*%b)
  hh - -t(exp(m)*z)%*%z }

 resMaxlik -
 maxLik(loglik,grad=gradlik,hess=hesslik,start=sc,method=nr,tol=1e-4);

 resMaxlik$offset-of
 resMaxlik$x-z
 resMaxlik$y-v



 estfun - function(obj,...)
 {
 m=as.vector(obj$offset+obj$x%*%obj$estimate)
 (obj$y-exp(m))*obj$x
 }

 M - function(obj, adjust = FALSE, ...)
 {
 psi - estfun(obj)
 k - NCOL(psi)
 n - NROW(psi)
 rval - crossprod(as.matrix(psi))/n
 if(adjust) rval - n/(n - k) * rval
 rval
 }


 B - function(obj, ...)
 { as.matrix(ginv(obj$hessian))
 }


 So S -B(resMaxlik)*M(resMaxlik)*B(resMaxlik) directly. It's ok.

 But I call sandwich function like this :
 sandwich(resMaxlik,meat.=M,bread.=B)
 It returns a error message : Erreur dans UseMethod(estfun) :
   pas de méthode pour 'estfun' applicable pour un objet de classe
 c('maxLik', 'maxim', 'list')





 -Message d'origine-
 De : Arne Henningsen [mailto:arne.henning...@googlemail.com]
 Envoyé : mardi 11 mai 2010 08:25
 À : Achim Zeileis; RATIARISON Eric; r-help@r-project.org; Ott-Siim Toomet
 Objet : Re: [R] Robust SE  Heteroskedasticity-consistent estimation

 On 11 May 2010 00:52, Achim Zeileis achim.zeil...@uibk.ac.at wrote:
 On Mon, 10 May 2010, RATIARISON Eric wrote:
 I'm using maxlik with functions specified (L, his gradient  hessian).

 Now I would like determine some robust standard errors of my
 estimators.

 So I 'm try to use vcovHC, or hccm or robcov for example

 but in use one of them with my result of maxlik, I've a the following
 error message :

 Erreur dans terms.default(object) : no terms component

 Is there some attributes to give to maxlik objet for fitting the call
 of vcovHC?

 This is discussed in
  vignette(sandwich-OOP, package = sandwich)
 one of the vignettes accompanying the sandwich package that provides
 the
 vcovHC() function. At the very least, you need an estfun() method which
 extracts the gradient contributions per observation. Then you need a
 bread()
 function, typically based on the observed Hessian. Then you can compute
 the
 basic sandwich() estimators.

 Is it possible to implement the estfun() method and the bread()
 function in the maxLik package so that vcovHC() can be easily used by
 all users of the maxLik package? If yes: should we (Eric, Achim, Ott,
 Arne) implement this feature together?

 /Arne

 --
 Arne Henningsen
 http://www.arne-henningsen.name


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read table for Fisher Exact

2010-05-13 Thread visser

i have 2 groups i want to compare: group A and group B
each group contains let's say 20 patients
i want to perform a Fisher Exact test on genotype distribution
so, see if there is a sign diff in genotpe frequency/distribution (#AA, #AB,
#BB) between group A and B
not for 1, but for 1000 different genes

my question: how should i build my table so i can do:

test - read.table(table1.txt)
fisher.test(test)

i know a lot is still missing in the syntax, but i do not know what. any
help would be soo much appreciated!!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/read-table-for-Fisher-Exact-tp2196762p2196762.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] summing items within a row

2010-05-13 Thread Q

Thank you Dennis.  That was a great idea and it worked quite well!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/summing-items-within-a-row-tp2195458p2196793.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 with interpolation

2010-05-13 Thread Jorge Nieves
Hi,

I have a two Colum matrix ( I named it holder) as shown bellow. It seems
to be three columns, but the first column contains the row names.

I am trying to fill all  NAs by linear interpolation the known values in
the matrix. I tried using the interpNA function, but I get an error
message:

 interpNA(holder, method = linear)
Error in approx(idx, x[idx], 1:n, method = method, f = f) : 
  need at least two non-NA values to interpolate
In addition: Warning message:
In xy.coords(x, y) : NAs introduced by coercion
 


I was wondering if some one could recommend another function to get the
interpolated values?

Thanks,

Jorge

20100319 2010-03-19  1626
20100320 2010-03-20NA
20100321 2010-03-21NA
20100322 2010-03-22NA
20100323 2010-03-23NA
20100324 2010-03-24NA
20100325 2010-03-25NA
20100326 2010-03-26  1638
20100327 2010-03-27NA
20100328 2010-03-28NA
20100329 2010-03-29NA
20100330 2010-03-30NA
20100331 2010-03-31NA
20100401 2010-04-01NA
20100402 2010-04-02  1669
20100403 2010-04-03NA
20100404 2010-04-04NA
20100405 2010-04-05NA
20100406 2010-04-06NA
20100407 2010-04-07NA
20100408 2010-04-08NA
20100409 2010-04-09  1756
20100410 2010-04-10NA
20100411 2010-04-11NA
20100412 2010-04-12NA
20100413 2010-04-13NA
20100414 2010-04-14NA
20100415 2010-04-15NA
20100416 2010-04-16  1829
20100417 2010-04-17NA
20100418 2010-04-18NA
20100419 2010-04-19NA
20100420 2010-04-20NA
20100421 2010-04-21NA
20100422 2010-04-22NA
20100423 2010-04-23  1912
20100424 2010-04-24NA
20100425 2010-04-25NA
20100426 2010-04-26NA
20100427 2010-04-27NA
20100428 2010-04-28NA
20100429 2010-04-29NA
20100430 2010-04-30  1995



[[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] fisher's posthock test or fisher's combination test

2010-05-13 Thread Knut Krueger

(Ted Harding) schrieb:

Thank you, for your answer,

As to Fisher's combination test, I'm not sure whether this is
meant to be something different from the above.
  


It should be the same, only another name.

Regards Knut

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


Re: [R] ff for 64 bit R for windows gui?

2010-05-13 Thread Uwe Ligges
No, it does not work and is on the exclude list for Windows 64-bit 
building on CRAN - hence no binary available. The maintainer has been 
contacted and has not yet provided a version that works. So you have to 
fix it yourself and try to convince the maintainer to do so for you.


Uwe Ligges





On 12.05.2010 21:59, Hunsicker, Lawrence wrote:

Hi, folks:

I am running 64-bit R on a 64 bit machine under 64 bit Windows 7.  I'd
like to try the package ff, but it is not clear to me whether the
current version of ff will work in a 64 bit environment.  The windows
version is compiled, which suggests that there is more than just R
p-code.  Do any of you know whether the current compiled version of ff
will work in my environment?

Many thanks in advance for any clarification that you have on this.

L. G. Hunsicker, M.D.
Professor, Internal Medicine
U. Iowa College of Medicine
Phone:  (319) 356-4763
Fax:  (319) 356-7488
lawrence-hunsic...@uiowa.edu


[[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] access objects in my environment

2010-05-13 Thread arnaud Gaboury
Wonderful!!

TY so much for the help.






 -Original Message-
 From: Patrizio Frederic [mailto:frederic.patri...@gmail.com]
 Sent: Thursday, May 13, 2010 10:47 AM
 To: arnaud Gaboury
 Cc: r-help@r-project.org
 Subject: Re: [R] access objects in my environment
 
 Hi,
 have a look at function 'get'  (and function 'assign' too)
 In your example:
 
 x - 1000
 assign(paste('Pos',x,sep=''),rnorm(100))
 Pos1000
 posa - get(paste(c(Pos,x),collapse=))
 posa
 
 hope it's help
 
 PF
 
 On Thu, May 13, 2010 at 10:37 AM, arnaud Gaboury
 arnaud.gabo...@gmail.com wrote:
  Dear group,
 
  Here are my objects in my environment:
 
  ls()
  [1] Pos100415 Pos100416 posA      pose15    pose16
  pose16t
  position  trade     x
 
  I need to pass the object Pos100415 to a function. This element is
 a
  data.frame, obtained through a function: Pos(x)-myfun(x) with x-
 100415 in
  this example.
 
  If I do this :
 
 posA-paste(c(Pos,100415),collapse=) #I can't use directly
 Pos100415.I
  need to access it via paste(c(Pos,x),collapse=) in general.
 
  Here is what I got :
 
  posA
  [1] Pos100415
 
  It is certainly not what I want, as I need to have posA as the same
  data.frame than Pos100415.
 
  Any help?
 
  TY
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 --
 +-
 | Patrizio Frederic, PhD
 | Assistant Professor,
 | Department of Economics,
 | University of Modena and Reggio Emilia,
 | Via Berengario 51,
 | 41100 Modena, Italy
 |
 | tel:  +39 059 205 6727
 | fax:  +39 059 205 6947
 | mail: patrizio.frede...@unimore.it
 +-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Finding different hues for a mosaic plot compatible with grayscale printing

2010-05-13 Thread Achim Zeileis

On Thu, 13 May 2010, Simon Kiss wrote:


Dear Colleagues,
Thanks for that JIm, but It strikes me that printing the residual values in 
the cells might be a simpler way of communicating the direction of each cell.
I can get the residuals printed via the labeling_values commands in mosaic, 
but I cannot seem to *combine* this with labeling_borders commands that I'd 
like to use to modify the rotation, font size and contents of variable names 
and labels.

The following mosaic command draws the plot with the labeling I'd like.

mosaic(~social_class+ctax_agg_scaled, pop=FALSE, shade=TRUE, main=The 
Liberals Carbon Tax Or Green Shift Would Hurt The Canadian Economy By EGP 
Class Category, main_gp=gpar(fontsize=16), gp=shading_hcl(CST21$observed, 
CST21$expected, ASR21, df=12, h=c(260,0), c=c(100,0), l=c(90,50), 
interpolate=c(1,2,3,4)), labeling_args=list(labels=TRUE, 
rot_labels=c(25,0,0,25), gp_labels=gpar(fontsize=7), just_labels=center, 
offset_labels=c(1,0,0,4), offset_varnames=c(2,0,0,4), 
set_varnames=c(ctax_agg_scaled=The Liberal Green Shift Or Carbon Tax Would 
Hurt The Canadian Economy, social_class=EGP Class Category)))


And when I take out the labeling_borders commands and insert the following,

labeling=labeling_values(value_type=c(residuals), suppress=0)


then I do get the residuals printed, but the labels are unattractive.

How do I combine labeling_borders and labeling_values commands in one 
command.


labeling_values() is a combination of labeling_borders() plus 
labeling_cells(). If you want finer control over what happens, I recommend 
to use labeling_borderes() in your mosaic() call and then call 
labeling_cells() manually afterwards. There is an example on how to do 
this in Section 4.2 of the strucplot vignette:

  vignette(strucplot, package = vcd)

hth,
Z

Yours, Simon Kiss 
On 12-May-10, at 2:42 PM, Jim Lemon wrote:



On 05/12/2010 07:34 PM, Simon Kiss wrote:

I'm working with the following code below to generate a
how do I set the h,c, and l values such that the significant, positive
residuals appear different on a grayscale printer from significant
grayscale residuals. The challenge as I see it is that one can only
distinguish the positive and negative residuals with the hue/. Varying
the chroma and the luminance only affect the distinctions between large
and small and significant and non significant. But my positive and
negative residuals are both large (absolutely) and significant, meaning
that they will have the same chroma and luminosity, but different hues.
I guess the key here is to find two separate hue values that appear
substantially different *on a grayscale printer* at the same chroma and
luminance. I have read through Zeileis et al. (2007, 2008) but can't
quite find the answer there.
I have also tried the Friendly shading to vary the line type, but I
can't find line types that are different enough to communicate the
difference between positive and negative residuals clearly.

Your assistance is appreciated.


mosaic(~educ+trade_off_scaled, shade=TRUE, main=Support For

Environmental Protection At The Expense of Creating Jobs By Education,
gp=shading_hcl(CST17$observed, CST17$expected, ASR17, df=6, h=c(260,0),
c=c(100,0), l=c(90,0)), labeling_args=list(rot_labels=c(25,90,0,0),
offset_labels=c(1,0,0,2), offset_varnames=c(2,0,0,4),
set_varnames=c(trade_off_scaled=Protecting The Environment Is More
Important Than Creating Jobs, educ=Level of Education)))


Hi Simon,
I thought that the symbolbox function might do something useful, but it 
required a bit of modification. The attached mod allows the user to fill a 
rectangle with symbols, which includes things like + and -.


Jim

symbolbox.R


*
Simon J. Kiss, PhD
SSHRC and DAAD Post-Doctoral Fellow
John F. Kennedy Institute of North America Studies
Free University of Berlin
Lansstraße 7-9
14195 Berlin, Germany
Cell: +49 (0)1525-300-2812,
Web: http://www.jfki.fu-berlin.de/index.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.__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Finding different hues for a mosaic plot compatible with grayscale printing

2010-05-13 Thread Achim Zeileis

On Wed, 12 May 2010, Simon Kiss wrote:


I'm working with the following code below to generate a
how do I set the h,c, and l values such that the significant, positive 
residuals appear different on a grayscale printer from significant grayscale 
residuals.  The challenge as I see it is that one can only distinguish the 
positive and negative residuals with the hue/. Varying the chroma and the 
luminance only affect the distinctions between large and small and 
significant and non significant.  But my positive and negative residuals are 
both large (absolutely) and significant, meaning that they will have the same 
chroma and luminosity, but different hues.
I guess the key here is to find two separate hue values that appear 
substantially different *on a grayscale printer* at the same chroma and 
luminance. I have read through Zeileis et al. (2007, 2008) but can't quite 
find the answer there.
I have also tried the Friendly shading to vary the line type, but I can't 
find line types that are different enough to communicate the difference 
between positive and negative residuals clearly.


This is difficult. In grayscale printing you have just one dimension 
available for color shading, namely the luminance/brightness. This is 
already used for the size of the residuals and so you need something else 
to code the sign. In our HCL palettes this is done by the hue but in such 
a way that the choice of hue does not change the luminance (this is the 
excellent feature of HCL color space). So, as Jim already pointed out, you 
can just do something about the type of filling or the borders etc. 
Another option would be to use a single grayscale with dark colors for 
large positive residuals and bright colors for large negative residuals 
(or vice versa). However, none of the approaches will be very intuitive 
and the color version will be much more powerful.


If you are forced to use grayscale, you might consider putting an 
assocation plot (via function assoc()) next to the mosaic plot.


Best,
Z


Your assistance is appreciated.

mosaic(~educ+trade_off_scaled, shade=TRUE, main=Support For Environmental 
Protection At The Expense of Creating Jobs By Education, 
gp=shading_hcl(CST17$observed, CST17$expected, ASR17, df=6, h=c(260,0), 
c=c(100,0), l=c(90,0)), labeling_args=list(rot_labels=c(25,90,0,0), 
offset_labels=c(1,0,0,2), offset_varnames=c(2,0,0,4), 
set_varnames=c(trade_off_scaled=Protecting The Environment Is More 
Important Than Creating Jobs, educ=Level of Education)))


*
Simon J. Kiss, PhD
SSHRC and DAAD Post-Doctoral Fellow
John F. Kennedy Institute of North America Studies
Free University of Berlin
Lansstraße 7-9
14195 Berlin, Germany
Cell: +49 (0)1525-300-2812,
Web: http://www.jfki.fu-berlin.de/index.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.__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] merge for data.frame and matrix

2010-05-13 Thread Dennis Murphy
Hi:

You've got to convert m to a data frame first:

 m - data.frame(m)
 m$nms - rownames(m)
 merge(df, m, by.x = 'col1', by.y = 'row.names')
  col1 col2.x col1 col2.y
1   kk  68  9
2   kk  38  9

HTH,
Dennis

On Wed, May 12, 2010 at 5:03 PM, Yuan Jian jayuan2...@yahoo.com wrote:

 Hello,

 how to merge a data.frame and a matrix by one column in the data.frame and
 rownames of the matrix?
 df - data.frame(col1=c(kk,yy,kk),col2=c(6,4,3))
  df
   col1 col2
 1   kk6
 2   yy4
 3   kk3
 m-matrix(c(3,8,56,9), nrow=2, dimnames =
 list(c(aa,kk),c(col1,col2)))
  m
col1 col2
 aa3   56
 kk89

 the result is expected as
 col1.x col2.x col1.y col2.y
 kk   689
 kk   389

 Yuan Jian





[[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


Re: [R] ggplot2: qplot won't work

2010-05-13 Thread Bryan Hanson
Ralf, inside a function you'll need to print the plot using qplot.  Change
it to
P - qplot(1:10, letters[1:10])
print(P)

This is good practice even at the console, as you can then modify your plots
in increments

P2 - P + more commands (text, more points, altered annotations etc)
print(P2)
etc

Bryan
*
Bryan Hanson
Acting Chair
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA




On 5/13/10 1:42 AM, Ralf B ralf.bie...@gmail.com wrote:

 I have a script running in the StatET Eclipse environment that
 executes the ggplot2 command qplot in a function:
 
 # Creates the plot
 createPlot - function(){
 print(Lets plot!)
 qplot(1:10, letters[1:10])
 }
 
 When executing the qplot line directly, it works. When executing the
 script it does not open a window and it it does not plot. Is there
 something important I have forgotten? I know that the function is
 called because I always get my 'Lets plot' When using normal
 graphics plot functions, its also works seamless.
 
 Of course I am importing the library ggplot2 at the beginning of my
 script - here is the import log:
 
  library(gdata)  # for trim function
 gdata: Unable to locate valid perl interpreter
 gdata:
 gdata: read.xls() will be unable to read Excel XLS and XLSX files
 gdata: unless the 'perl=' argument is used to specify the location of a
 gdata: valid perl intrpreter.
 gdata:
 gdata: (To avoid display of this message in the future, please ensure
 gdata: perl is installed and available on the executable search path.)
 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLX' (Excel 97-2004) files.
 
 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLSX' (Excel 2007+) files.
 
 gdata: Run the function 'installXLSXsupport()'
 gdata: to automatically download and install the perl
 gdata: libaries needed to support Excel XLS and XLSX formats.
 
 Attaching package: 'gdata'
 
 
 The following object(s) are masked from package:utils :
 
 object.size
 
 Warning message:
 package 'gdata' was built under R version 2.10.1
 library(TTR)  # for moving averages (SMA,...) smoothing
 Loading required package: xts
 Loading required package: zoo
 Warning messages:
 1: package 'TTR' was built under R version 2.10.1
 2: package 'xts' was built under R version 2.10.1
 3: package 'zoo' was built under R version 2.10.1
 library(ggplot2) # for plotting results
 Loading required package: proto
 Loading required package: grid
 Loading required package: reshape
 Loading required package: plyr
 Loading required package: digest
 
 Attaching package: 'ggplot2'
 
 
 The following object(s) are masked from package:gdata :
 
 interleave
 
 Warning messages:
 1: package 'ggplot2' was built under R version 2.10.1
 2: package 'proto' was built under R version 2.10.1
 3: package 'reshape' was built under R version 2.10.1
 4: package 'plyr' was built under R version 2.10.1
 5: package 'digest' was built under R version 2.10.1
 
 
 What is wrong here?
 
 Ralf
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] multinomial regression

2010-05-13 Thread Jean Jacques Dureau
I am developing a multinomial regression model with the function multinom.
The dependent variable is qualitative with three possible outcomes, the
independent variables are all quantitative.
I want to check the significance of predictor variables, which function I
use to run the correct test? You also have a few examples on the net to be
consulted?
thanks

jj

[[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] Compiling R with --enable-R-shlib for rpy2 error

2010-05-13 Thread Padma TAN
Hi,

I am trying to compile R with the command below in order to install rpy2.

./configure --prefix=/usr/local/R/R-2.9.2 --with-gnu-ld --with-cairo
--with-x --enable-R-shlib


However, error the I have gotten was:
/usr/bin/ld: CConverters.o: relocation R_X86_64_32S against `R_FunTab' can
not be used when making a shared object; recompile with -fPIC
CConverters.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[3]: *** [libR.so] Error 1

I don't really understand the error message. Is there anything I can change
to compile properly so that I can install rpy2?

Please help. Thanks in advance! :)


Regards,
Padma

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Solved: Input encoding problem when using sweave with xetex

2010-05-13 Thread Erich Studerus


With the kind help of Duncan Murdoch, I finally managed to correctly compile 
LyX-Sweave documents with XeTeX under Windows. In case someone else is 
struggling with a similar problem in the future, here is a small summary of 
what worked for me. I assume that you have already set up Lyx to work with 
Sweave and XeTeX according to the following instructions:

http://cran.r-project.org/contrib/extra/lyx/INSTALL
http://wiki.lyx.org/LyX/XeTeX

My original problem was that accented letters that were read from 
Excel-files or other external sources from within R during the LyX-Sweave 
document compilation were not correctly encoded in UTF-8. However, UTF-8 is 
needed for typsetting the final document with XeTeX.


Because R code chunks contained in the Lyx-Sweave document were executed by 
running R from the command line, it was necessary to start R with UTF-8 
encoding from the command line. I managed to do this by editing the 
Sweave.sh file which can be found in rhome/bin/ directory. Within sweave.sh, 
I changed the command


echo library(\utils\); Sweave(\file.Rnw\) | R --no-restore --slave

into

echo library(\utils\); options(encoding=\UTF-8\); Sweave(\file.Rnw\) 
| R --no-restore --slave


Because I wanted to run R with UTF-8 encoding only when I compile my 
documents with XeTeX and not with LaTeX, I saved the Sweave.sh file with the 
new name UTF8Sweave.sh in the same directory and changed the definition for 
the conversion of Lyx-Sweave documents to PDF (xelatex). I did this by 
defining a new file format in LyX under
Tools-Preferences-File handling-File formats. The file format that I 
defined had the same settings as LaTeX (pdflatex), but I saved it with the 
new name LaTeX (pdflatexUTF8). I then defined a new converter under 
Tools-Preferences-File handling-File formats with the following settings:

From format: Sweave
To format: LaTex (pdflatexUTF8)
Converter: R CMD /path/to/UTF8Sweave.sh $$i

Because the full path to UTF8Sweave.sh file contained blanks, I had to use 
the 8.3 filename which I determined by using the MSDOS cmd window. See this 
post for more information:

http://article.gmane.org/gmane.comp.lang.r.general/190040

Finally, I changed the converter LaTeX (pdflatex) - PDF(xelatex) which I 
had already defined for the original LyX-XeTeX installation(see 
http://wiki.lyx.org/LyX/XeTeX) to LaTeX (pdflatexUTF8) - PDF(xelatex).


I hope this helps.

Regards,
Erich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A primitive OO in R -- where next?

2010-05-13 Thread S Ellison
R OO is documented for S3 classes under section 5 (Object-oriented
programming) in the R language definition.

I guess the issue is somewhat philosophial as to how you use it. 

R philosophy _mostly_ separates data from operations on data, so the OO
model provides classes for data and essentially separate methods that
apply to those classes. This is the kind of model sometimes called a
'visitor pattern'. An alternative is to include operations on the data
within the data object, which sometimes has advantages if you want to
simplify the look of code for things like display (instead of a display
method for each class, one effectively sends a mesage to any object of
the form display yourself here). In practice, of course, one ends up
writing class-specific operations code; the difference is pretty much
where it's stored.

On balance there seems to me a rationale for a statistician to separate
data from the operations formed on it; one collects and curates data
carefuly, so it as a kind of lifecycle of its own that is unrelated to
mathematical operations performed on it. 

But I have allowed _data_ objects to include functions or at least
function names when it is a necessary part of the description of the
data. For example, in some of our interlaboratory studies labs give
uncertainty information in the form of a variance or interval, but may
additionally tell us what the assumed distribution is (eg Normal, t,
lognormal etc). It then makes sense to have the distribution as part of
the data. For these functions, the root name (norm, t, etc)_ suffices in
conjunction with do.call, but to generalise completely, one can consider
allowing a user to specify the distribution as (say) some arbitrary
density function or density/probability family. (It's pretty rare that
we'd need that, but hey - thinking ahead and all that). That would
generate data which in part consisted of a function describing the
(assumed) associated distribution. 

Steve Ellison

 Ted Harding ted.hard...@manchester.ac.uk 12/05/2010 22:48:17 
Greetings All,

Out of curiosity, I've just done a very primitive experiment:

  Obj - list(Fun=sum, Dat=c(1,2,3,4))
  Obj$Fun(Obj$Dat)
  # [1] 10

That sort of thing (much more sophisticated) must be documented
mind-blowingly somewhere. Where?

Where I stand right now: The above (and its immediately obvious
generalisations, like Obj$Fun-cos) is all I know about it so far.

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 12-May-10   Time: 22:48:14
-- XFMail --

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

***
This email and any attachments are confidential. Any use...{{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] read table for Fisher Exact

2010-05-13 Thread Frank E Harrell Jr

On 05/12/2010 03:31 PM, visser wrote:


i have 2 groups i want to compare: group A and group B
each group contains let's say 20 patients
i want to perform a Fisher Exact test on genotype distribution
so, see if there is a sign diff in genotpe frequency/distribution (#AA, #AB,
#BB) between group A and B
not for 1, but for 1000 different genes

my question: how should i build my table so i can do:

test- read.table(table1.txt)
fisher.test(test)

i know a lot is still missing in the syntax, but i do not know what. any
help would be soo much appreciated!!


Note that in this case, Fisher's exact test has a good chance of being 
less accurate than an approximate Pearson chi-square test.


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] long command line cut in 2 parts

2010-05-13 Thread arnaud Gaboury
Dear group,

I have this command line in a function:

zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,VALUE=
NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)

I want to cut it in 2 lines (just for convenient purpose). Here is what I
did :


zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
  + VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)

But when I source the function, I get an error message:

Error in source(C:\\Users\\arno\\Documents\\r\\LSC\\PLwork2.r) : 
  C:\Users\arno\Documents\r\LSC\PLwork2.r:34:10: unexpected '='
33:   zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
34:   + VALUE=
 ^

What is wrong?

TY for any 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.


Re: [R] long command line cut in 2 parts

2010-05-13 Thread Henrique Dallazuanna
Remove the plus sign.

On Thu, May 13, 2010 at 9:54 AM, arnaud Gaboury arnaud.gabo...@gmail.comwrote:

 Dear group,

 I have this command line in a function:


 zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,VALUE=
 NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)

 I want to cut it in 2 lines (just for convenient purpose). Here is what I
 did :


 zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
  + VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)

 But when I source the function, I get an error message:

 Error in source(C:\\Users\\arno\\Documents\\r\\LSC\\PLwork2.r) :
  C:\Users\arno\Documents\r\LSC\PLwork2.r:34:10: unexpected '='
 33:
 zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
 34:   + VALUE=
 ^

 What is wrong?

 TY for any 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.




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

[[alternative HTML version deleted]]

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


Re: [R] ff for 64 bit R for windows gui?

2010-05-13 Thread Hunsicker, Lawrence
Many thanks to Uwe Ligges for his response below.

ff for Windows 64 bit?  

No, it does not work and is on the exclude list for Windows 64-bit 
building on CRAN - hence no binary available. The maintainer has been 
contacted and has not yet provided a version that works. So you have to 
fix it yourself and try to convince the maintainer to do so for you.

I will contact the ff maintainer.

Larry Hunsicker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] A primitive OO in R -- where next?

2010-05-13 Thread Liaw, Andy
From: ted.hard...@manchester.ac.uk
 
 On 12-May-10 22:24:21, Erik Iverson wrote:
  (Ted Harding) wrote:
  Greetings All,
  
  Out of curiosity, I've just done a very primitive experiment:
  
Obj - list(Fun=sum, Dat=c(1,2,3,4))
Obj$Fun(Obj$Dat)
# [1] 10
  
  That sort of thing (much more sophisticated) must be documented 
  mind-blowingly somewhere. Where?
  
  Where I stand right now: The above (and its immediately obvious 
  generalisations, like Obj$Fun-cos) is all I know about it so far.
  
  Well functions are just an object in R, so lists can of 
 course contain 
  them.  My naive understanding is that you can think of 
 function calls 
  as simply lists where the first element is the function 
 name, and the 
  rest of the list are the arguments, so:
  
eval(as.call(Obj))
  [1] 10
 
 Well, that's a neat trick! (It seems to depend on my having 
 put the function name first in the list, though, which wasn't 
 done with any specific intent).

This has not much to do with OO in the usual sense, just how functions
in R work.  See:
http://stat.ethz.ch/R-manual/R-devel/doc/manual/R-lang.html#Function-obj
ects

The styles of OO in S3 and S4 do not encapsulate methods into the class
definitions.

Andy 
 In fact, the sort of thing I have in mind as possible 
 applications for the idea in that simple example, is that one 
 could encapsulate a Study in a list, which would contain as 
 components the various datasets available (quite possibly of 
 different structures etc.), and the various functions which 
 one might use to analyse different datasets, or to combine 
 analyses, etc.; and possibly also a top-level supervisor 
 function which could ensure social behaviour in that mob of 
 entities. Pretty open-ended, really.
 
 Ted.
 
 
 E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
 Fax-to-email: +44 (0)870 094 0861
 Date: 12-May-10   Time: 23:46:34
 -- XFMail --
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] long command line cut in 2 parts

2010-05-13 Thread Muhammad Rahiz

Dear Arnaud,

Wrap a pair of curly brackets around the command line and remove the + like 
the following;

zz-{merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F )}


Muhammad


arnaud Gaboury wrote:

Dear group,

I have this command line in a function:

zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,VALUE=
NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)

I want to cut it in 2 lines (just for convenient purpose). Here is what I
did :


zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
  + VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)

But when I source the function, I get an error message:

Error in source(C:\\Users\\arno\\Documents\\r\\LSC\\PLwork2.r) : 
  C:\Users\arno\Documents\r\LSC\PLwork2.r:34:10: unexpected '='

33:   zz-merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
34:   + VALUE=
 ^

What is wrong?

TY for any 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] long command line cut in 2 parts

2010-05-13 Thread arnaud Gaboury
Removing the + sign resolves the problem. 
TY


 -Original Message-
 From: Muhammad Rahiz [mailto:muhammad.ra...@ouce.ox.ac.uk]
 Sent: Thursday, May 13, 2010 3:15 PM
 To: arnaud Gaboury
 Cc: r-help@r-project.org
 Subject: Re: [R] long command line cut in 2 parts
 
 Dear Arnaud,
 
 Wrap a pair of curly brackets around the command line and remove the
 + like the following;
 
 zz-{merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
 VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F )}
 
 
 Muhammad
 
 
 arnaud Gaboury wrote:
  Dear group,
 
  I have this command line in a function:
 
  zz-
 merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,VALUE
 =
  NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)
 
  I want to cut it in 2 lines (just for convenient purpose). Here is
 what I
  did :
 
 
  zz-
 merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
+ VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F)
 
  But when I source the function, I get an error message:
 
  Error in source(C:\\Users\\arno\\Documents\\r\\LSC\\PLwork2.r) :
C:\Users\arno\Documents\r\LSC\PLwork2.r:34:10: unexpected '='
  33:   zz-
 merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL,
  34:   + VALUE=
   ^
 
  What is wrong?
 
  TY for any 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RWinEdt in WinEdt 6

2010-05-13 Thread Uwe Ligges



On 12.05.2010 18:16, Gregoire wrote:


Yes, I could do that. But the license for WinEdt 6 is not the same as the
license for WinEdt 5.x, so I would have to buy WinEdt 5.x to use RWinEdt,
which is a bit unfortunate. Maybe I'll do that though.


Oh, I do not have such a license for version 6 yet. Will see how I can 
get things working again. After finally reading the documentation and 
changes it looks like I'd need to implement RWinEdt from scratch again. :-((


Uwe







Gregory


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] merge for data.frame and matrix

2010-05-13 Thread David Winsemius


On May 13, 2010, at 5:34 AM, Dennis Murphy wrote:


Hi:

You've got to convert m to a data frame first:


Well, that would be one way, but it is not true that it is necessary.  
The Details section of the help page for merge says that row,names is  
an acceptable by specification, so without the data.frame coercion,  
this is another method:


 merge(df, m, by.x=col1, by.y=row.names)
  col1 col2.x col1 col2.y
1   kk  68  9
2   kk  38  9

--
David.




m - data.frame(m)
m$nms - rownames(m)
merge(df, m, by.x = 'col1', by.y = 'row.names')

 col1 col2.x col1 col2.y
1   kk  68  9
2   kk  38  9

HTH,
Dennis

On Wed, May 12, 2010 at 5:03 PM, Yuan Jian jayuan2...@yahoo.com  
wrote:



Hello,

how to merge a data.frame and a matrix by one column in the  
data.frame and

rownames of the matrix?
df - data.frame(col1=c(kk,yy,kk),col2=c(6,4,3))

df

 col1 col2
1   kk6
2   yy4
3   kk3
m-matrix(c(3,8,56,9), nrow=2, dimnames =
list(c(aa,kk),c(col1,col2)))

m

  col1 col2
aa3   56
kk89

the result is expected as
col1.x col2.x col1.y col2.y
kk   689
kk   389

Yuan Jian





  [[alternative HTML version deleted]]


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




[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


[R] select subset based on another variable

2010-05-13 Thread Carrie Li
Hi, dear R-helpers,

I have a simple question regarding selecting subset of a variable based on
another variable.
Here is the example:

xx=rnorm(10)
id=sample(1:10, 10)

temp=c(6, 1, 8, 2)

Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
position.

Any suggestions ?

Thank you all your help !!

Carrie

[[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] select subset based on another variable

2010-05-13 Thread David Winsemius


On May 13, 2010, at 9:48 AM, Carrie Li wrote:


Hi, dear R-helpers,

I have a simple question regarding selecting subset of a variable  
based on

another variable.
Here is the example:

xx=rnorm(10)
id=sample(1:10, 10)

temp=c(6, 1, 8, 2)

Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
position.

Any suggestions ?


xx[temp]

--
David.


Thank you all your help !!

Carrie

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] select subset based on another variable

2010-05-13 Thread Henrique Dallazuanna
Try this:

 subset(xx, id %in% temp)

On Thu, May 13, 2010 at 10:48 AM, Carrie Li carrieands...@gmail.com wrote:

 Hi, dear R-helpers,

 I have a simple question regarding selecting subset of a variable based on
 another variable.
 Here is the example:

 xx=rnorm(10)
 id=sample(1:10, 10)

 temp=c(6, 1, 8, 2)

 Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
 position.

 Any suggestions ?

 Thank you all your help !!

 Carrie

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


Re: [R] select subset based on another variable

2010-05-13 Thread jim holtman
try this:

 xx=rnorm(10)
 id=sample(1:10, 10)

 temp=c(6, 1, 8, 2)
 xx[match(temp, id)]
[1]  0.4874291 -0.6212406  1.5117812  0.5757814
 xx
 [1] -0.8204684  0.4874291  0.7383247  0.5757814 -0.3053884  1.5117812
0.3898432 -0.6212406 -2.2146999
[10]  1.1249309
 id
 [1]  5  6  4  2 10  8  9  1  7  3



On Thu, May 13, 2010 at 9:48 AM, Carrie Li carrieands...@gmail.com wrote:

 Hi, dear R-helpers,

 I have a simple question regarding selecting subset of a variable based on
 another variable.
 Here is the example:

 xx=rnorm(10)
 id=sample(1:10, 10)

 temp=c(6, 1, 8, 2)

 Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
 position.

 Any suggestions ?

 Thank you all your help !!

 Carrie

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] help! - spectral analysis - spec.pgram

2010-05-13 Thread Uwe Ligges



On 12.05.2010 07:48, vikrant wrote:


Dear Prof Brian,


This is a mailinglist, and I do not know any Prof. Brian so far (or 
maybe I should expect to be called Prof. Uwe ?).




I am new to spectral analysis. I dont know how to obtain period from
spectral periodogram.


Then you should really start to read textbooks about spectral analysis 
rather than asking a mailing list (or Prof. Brian unless he is your 
supervisor).



If u could explain me about how to obtain the period
from periodogram it will be very helpful. U can explain using the above two
examples in the discussiion.



Which examples??



Thanks in advance..



Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] select subset based on another variable

2010-05-13 Thread David Winsemius


On May 13, 2010, at 9:55 AM, David Winsemius wrote:



On May 13, 2010, at 9:48 AM, Carrie Li wrote:


Hi, dear R-helpers,

I have a simple question regarding selecting subset of a variable  
based on

another variable.
Here is the example:

xx=rnorm(10)
id=sample(1:10, 10)

temp=c(6, 1, 8, 2)

Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the
position.

Any suggestions ?


xx[temp]


I may have jumped the gun, but on reflection I am not sure that your  
question was at all clear. Is the first item desired the 6th item of  
xx or the xx item referenced by the 6th item of id? You gave a  
specification that would not allow any of us to check, since you did  
not specify a random seed. We have no way of seeing what either of  
your xx or id vectors look like since you did not provide either them  
or the desired output. If it were the second specification then  
consider this:


 set.seed(123)
 xx=rnorm(10)
 id=sample(1:10, 10)

 temp=c(6, 1, 8, 2)
 xx;id
 [1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774   
1.71506499

 [7]  0.46091621 -1.26506123 -0.68685285 -0.44566197
 [1]  9  7  6 10  4  8  3  2  1  5
 xx[id[temp]]
[1] -1.2650612 -0.6868529 -0.2301775  0.4609162



--
David.


Thank you all your help !!

Carrie

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


David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] fisher's posthock test or fisher's combination test

2010-05-13 Thread RICHARD M. HEIBERGER
Knut,

With the assumption that you are asking about Fisher's LSD for all pairwise
contrasts in ANOVA,
then it is available, along with many superior tests, in the multcomp
package in R.
See ?glht.

Since you mention Excel, please look at RExcel, a package which seamlessly
merges
R and Excel.  Any R function can be accessed through Excel and can be placed
inside
the Excel automatic recalculation model.  The Rcmdr menu has been placed on
the
Excel menu bar.  See rcom.univie.ac.at for full information.
You can install RExcel on Windows from CRAN with
 install.packages(RExcelInstaller)

For this example, the Tukey comparisons from glht in R are on the Rcmdr menu
and
hence are available to the Excel user with just a few clicks.

Rich

[[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] Whiskers on the default boxplot {graphics}

2010-05-13 Thread Robert Baer

Hi Peter,

You're absolutely correct!  The description for 'range' in 'boxplot' help 
file is a little bit confusing by using the words interquartile range. 
I think it should be changed to the length of the box to be exact and 
consistent with those in the help file for boxplot.stats.


The issue is probably that there are multiple ways (9 to be exact) of 
defining quantiles in R.  See 'type= ' arguement for ?quantile.  The 
quantile function uses type=7 by default which matches the quantile 
definition used by S-Plus(?), but differs from that used by SPSS.  Doesn't 
fivenum essentially use the equivalent of a different type=  arguement 
(maybe 2 or 5) in constructing the hinges?


It seems perfectly reasonable to talk about 'length of box' (or 'box height' 
depending how you display the boxplot), but aren't the hinges simply Q1 and 
Q3 defined by one of the possible quartile definitions (as Peter points out 
the one used by fivenum)?  The box height does not necesarily match the 
distance produced by IQR() which also seems to use the equivalent of 
quantile(..., type=7), but it is still an IQR, is it not?


Quantiles apparantly can be defined in more than one acceptable way (sort 
of like dealing with ties in rank statistics).  The OP seemed to want an 
exact explanation of the wiskers, and I think Peter has pointed us at the 
definition of quartiles used by fivenum, as opposed to the default  used 
with quantile(..., type=7).


All that said, I'm not convinced that it is wrong to speak of interquartile 
range in 'boxplot' help.


Rob

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Felipe Carrillo
HI:
If you don't mind me asking this question about latex:
Based on Duncan's comment:
The print method for latex objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file).
Where in MikTex can I change to pdflatex? everytime I use latex it displays the 
dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Duncan Murdoch murdoch.dun...@gmail.com
 To: Shi, Tao shida...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Wed, May 12, 2010 1:40:50 PM
 Subject: Re: [R] a question about latex in Hmisc
 
 On 12/05/2010 4:33 PM, Shi, Tao wrote:
 Hi Ista,
 
 Thanks 
 for the reply!
 
 You actually misunderstood me.  I never 
 objected the tmp - latex(x) method (in fact, that's what I'm doing now in 
 my .Rnw file).  As I stated in my original post, I'm simply curious about 
 what causes the error window and wanted to get to the bottom of 
 it.
  
latex(x) returns an object of class latex.  When 
 you don't assign it, it prints.  The print method for latex objects tries 
 to run latex and then display the resulting .dvi file.  (Or maybe it runs 
 pdflatex and displays the .pdf file).

If you can't run latex, you can't 
 print those objects.  That's why you're getting an error.

Duncan 
 Murdoch

__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 https://stat.ethz.ch/mailman/listinfo/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] How ls() only functions or anything else but functions?

2010-05-13 Thread John Edwards
Hello,

How ls() only functions or only data objects (basically anything other than
functions) such as data.frame, numeric ...?

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.


[R] Source code for gee

2010-05-13 Thread Joey Zhou
Dear all:

I am looking for the source code for gee(generalized estimation equations by
Liang and Zeger) package. Can you help?

Thanks much,
Joey

[[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] plot error

2010-05-13 Thread Mohsen Jafarikia
Hello All:

I am having the following error message when I increase the resolution
(res=30 to res=350) of my graph:

Error in plot.xy(xy, type, ...) : ignoring SIGPIPE signal
Calls: plot - plot.default - plot.xy
Execution halted

Here is the code:

ofn - MAY11.png
bitmap(ofn, type = png256, width = 21, height = 30, pointsize = 30, bg =
white,res=350)   If I change res=350 to res=30, everything is
fine.
par(cex.main=1.2,cex.lab=1.8,cex.axis=1.4)


Does anybody have any comment please?

Many thanks,
Mohsen

[[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] 3d surface plot

2010-05-13 Thread Uwe Ligges



On 11.05.2010 23:25, kun.z...@wmich.edu wrote:

Hi,Sir or Miss:

We meet a problem of plotting 3d, which is a part of 5D. In other word, we just 
fixed the rest of 2 variables and slice 5d into 3d.

Consider a function like Y=f(x1, x2, x3, x4). We want to  have a 3D surface 
plot in R for the fitted value Yhat (which is of course a function of x1, x2, 
x3 and x4) against x1 and x2 say, keeping x3 at its median level and fixing x4 
as =1 (note that x4 is binary which can take values of 1 or 0 only). So we plot 
yhat, x1 and x2 in 3D surface after estimating the whole model (based on all 4 
covariates) .



See ?persp.

Uwe Ligges


Awaiting your reply.
Thanks for your time,
Best
Kun

[[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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Uwe Ligges



On 13.05.2010 16:32, Felipe Carrillo wrote:

HI:
If you don't mind me asking this question about latex:
Based on Duncan's comment:
The print method for latex objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file).
Where in MikTex can I change to pdflatex? everytime I use latex it displays the 
dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks



Run pdflatex rather than latex?

Uwe Ligges



Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 

From: Duncan Murdochmurdoch.dun...@gmail.com
To: Shi, Taoshida...@yahoo.com
Cc: r-help@r-project.org
Sent: Wed, May 12, 2010 1:40:50 PM
Subject: Re: [R] a question about latex in Hmisc

On 12/05/2010 4:33 PM, Shi, Tao wrote:
Hi Ista,

Thanks
for the reply!

You actually misunderstood me.  I never
objected the tmp- latex(x) method (in fact, that's what I'm doing now in
my .Rnw file).  As I stated in my original post, I'm simply curious about
what causes the error window and wanted to get to the bottom of
it.


latex(x) returns an object of class latex.  When

you don't assign it, it prints.  The print method for latex objects tries
to run latex and then display the resulting .dvi file.  (Or maybe it runs
pdflatex and displays the .pdf file).


If you can't run latex, you can't

print those objects.  That's why you're getting an error.


Duncan

Murdoch


__

ymailto=mailto:R-help@r-project.org;
href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank

https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Duncan Murdoch

On 13/05/2010 10:48 AM, Uwe Ligges wrote:

On 13.05.2010 16:32, Felipe Carrillo wrote:
 HI:
 If you don't mind me asking this question about latex:
 Based on Duncan's comment:
 The print method for latex objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file).
 Where in MikTex can I change to pdflatex? everytime I use latex it displays 
the dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks


Run pdflatex rather than latex?
  


Or if using texify, use the --pdf option.

Duncan Murdoch

Uwe Ligges


 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA



 - Original Message 
 From: Duncan Murdochmurdoch.dun...@gmail.com
 To: Shi, Taoshida...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Wed, May 12, 2010 1:40:50 PM
 Subject: Re: [R] a question about latex in Hmisc

 On 12/05/2010 4:33 PM, Shi, Tao wrote:
 Hi Ista,

 Thanks
 for the reply!

 You actually misunderstood me.  I never
 objected the tmp- latex(x) method (in fact, that's what I'm doing now in
 my .Rnw file).  As I stated in my original post, I'm simply curious about
 what causes the error window and wanted to get to the bottom of
 it.

 latex(x) returns an object of class latex.  When
 you don't assign it, it prints.  The print method for latex objects tries
 to run latex and then display the resulting .dvi file.  (Or maybe it runs
 pdflatex and displays the .pdf file).

 If you can't run latex, you can't
 print those objects.  That's why you're getting an error.

 Duncan
 Murdoch

 __
 ymailto=mailto:R-help@r-project.org;
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank
 https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help with Loops

2010-05-13 Thread Amit Patel
Hi

I have tried many attempts but cant get the loop right, as I am not a strong 
programmer. What I am basically trying to do is compare 2 spreadsheets. The 
problem is that one of them only contain a portion of the overall data 
(TESTSAMP), where the other has a full datasetFULLSAMP. From the complete set I 
would like to remove the rows of data which are not in the TESTSAMP. Column 1 
contains the sample numbers which can be used to identify samples. Does anyone 
have any suggestions? 

I have tried various things like double loops and so on, but I am sure there is 
an easier way or function to do this.

i tried this method, but Im not sure how to only keep looping until a match is 
found. I dont understand how repeat loops work in R.

for (i in 1:length(FULLSAMP[,1])) {

if (FULLSAMP[i,1] != TESTSAMP[i,1]) {
FULLSAMP - FULLSAMP[-i,]
}


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] How ls() only functions or anything else but functions?

2010-05-13 Thread Henrique Dallazuanna
Try this:

className - data.frame
names(which(eapply(globalenv(), class) == className))

On Thu, May 13, 2010 at 11:02 AM, John Edwards jhnedwards...@gmail.comwrote:

 Hello,

 How ls() only functions or only data objects (basically anything other than
 functions) such as data.frame, numeric ...?

 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.




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

[[alternative HTML version deleted]]

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


Re: [R] Whiskers on the default boxplot {graphics}

2010-05-13 Thread David Winsemius


On May 13, 2010, at 10:25 AM, Robert Baer wrote:


Hi Peter,

You're absolutely correct!  The description for 'range' in  
'boxplot' help file is a little bit confusing by using the words  
interquartile range. I think it should be changed to the length  
of the box to be exact and consistent with those in the help file  
for boxplot.stats.


The issue is probably that there are multiple ways (9 to be exact)  
of defining quantiles in R.  See 'type= ' arguement for ?quantile.   
The quantile function uses type=7 by default which matches the  
quantile definition used by S-Plus(?), but differs from that used by  
SPSS.  Doesn't fivenum essentially use the equivalent of a different  
type=  arguement (maybe 2 or 5) in constructing the hinges?


It seems perfectly reasonable to talk about 'length of box' (or 'box  
height' depending how you display the boxplot), but aren't the  
hinges simply Q1 and Q3 defined by one of the possible quartile  
definitions (as Peter points out the one used by fivenum)?  The box  
height does not necesarily match the distance produced by IQR()  
which also seems to use the equivalent of quantile(..., type=7), but  
it is still an IQR, is it not?


Quantiles apparantly can be defined in more than one acceptable  
way (sort of like dealing with ties in rank statistics).  The OP  
seemed to want an exact explanation of the wiskers, and I think  
Peter has pointed us at the definition of quartiles used by fivenum,  
as opposed to the default  used with quantile(..., type=7).


Yes, and experimentation leads me to the conclusion that the only  
possible candidate for matching up the results of fivenum[c(2,4]  with  
quantile(y, c(1,3)/4, type=i) is for type=5. I'm not able to prove  
that to myself from mathematical arguments. since I do not quite  
understand the formalism in the quantile page. If the match is not  
exact, this would be a tenth definition of IQR.


 set.seed(123)
  y - rexp(300, .02)
 fivenum(y)
[1]   0.2183685  15.8740466  42.1147820  74.0362517 360.5503788
 for (i in 4:9) {print(quantile(y, c(1,3)/4, type=i) ) }
 25%  75%
15.82506 73.93080
 25%  75%
15.87405 74.03625
 25%  75%
15.84955 74.08898
 25%  75%
15.89854 73.98352
 25%  75%
15.86588 74.05383
 25%  75%
15.86792 74.04943

--
David.



All that said, I'm not convinced that it is wrong to speak of  
interquartile range in 'boxplot' help.


Rob


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 ls() only functions or anything else but functions?

2010-05-13 Thread Chuck Cleland
On 5/13/2010 10:02 AM, John Edwards wrote:
 Hello,
 
 How ls() only functions or only data objects (basically anything other than
 functions) such as data.frame, numeric ...?

c(ls.str(mode = function))

ls()[!(ls() %in% c(ls.str(mode=function)))]

?ls.str

 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson



Felipe Carrillo wrote:

HI:
If you don't mind me asking this question about latex:
Based on Duncan's comment:
The print method for latex objects tries to run latex and then display the 
resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file).
Where in MikTex can I change to pdflatex? everytime I use latex it displays the 
dvi file which is a problem because tables that I want to see landscaped don't 
work. Thanks


I don't work in a Windows environment, but I think the process is the 
same here.


You have to know what the print.latex function in Hmisc is doing.  It 
simply calls show.latex.  If you look at the source for show.latex, it 
looks at the latex object passed to it, and inspects the file argument. 
 If the file argument is the empty string (  ), it does not attempt 
to show the resulting output in a dvi.  If the file argument is a file 
name, show.latex will call dvi.latex on the object, which will wrap the 
latex code in some basic latex, and call optionsCmds(latex) on the file.


This is by default set to

 optionsCmds(latex)
[1] /usr/bin/latex

This will of course create a dvi and attempt to display it with 
show.dvi, which will in turn use


 optionsCmds(xdvi)
[1] xdvi

to display the resulting file.

I'm guessing MikTex comes with pdflatex, just like it comes with a 
binary called latex.  You'd just have to find it and make sure it's in 
your path.


Then, by setting the relevant options I just described above to pdflatex 
and a suitable pdf viewer, you might get what you want.  But there might 
be other things I haven't thought of that will prohibit this from 
working.  In fact, it looks like dvi.latex naturally assumes the 
extension .dvi from its output, and so this may not work.  You/I might 
have to write separate functions to carry this out it appears.  Of 
course, someone else may have already, and I just don't know about it.


--Erik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Loops

2010-05-13 Thread Sarah Goslee
You don't need a loop for this, I think. Since you don't provide an
example it's hard to know how your data are set up, but look at this:

 FULLSAMP - data.frame(A = 1:10, B=letters[1:10])
 TESTSAMP - data.frame(A = c(2,4,5,8), C=1:4)
 FULLSAMP
A B
1   1 a
2   2 b
3   3 c
4   4 d
5   5 e
6   6 f
7   7 g
8   8 h
9   9 i
10 10 j
 TESTSAMP
  A C
1 2 1
2 4 2
3 5 3
4 8 4
 FULLSAMP[FULLSAMP$A %in% TESTSAMP$A,]
  A B
2 2 b
4 4 d
5 5 e
8 8 h

Sarah

On Thu, May 13, 2010 at 10:49 AM, Amit Patel amitrh...@yahoo.co.uk wrote:
 Hi

 I have tried many attempts but cant get the loop right, as I am not a strong 
 programmer. What I am basically trying to do is compare 2 spreadsheets. The 
 problem is that one of them only contain a portion of the overall data 
 (TESTSAMP), where the other has a full datasetFULLSAMP. From the complete set 
 I would like to remove the rows of data which are not in the TESTSAMP. Column 
 1 contains the sample numbers which can be used to identify samples. Does 
 anyone have any suggestions?

 I have tried various things like double loops and so on, but I am sure there 
 is an easier way or function to do this.

 i tried this method, but Im not sure how to only keep looping until a match 
 is found. I dont understand how repeat loops work in R.

 for (i in 1:length(FULLSAMP[,1])) {

 if (FULLSAMP[i,1] != TESTSAMP[i,1]) {
 FULLSAMP - FULLSAMP[-i,]
 }


 Thanks in advance






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


Re: [R] plot error

2010-05-13 Thread Uwe Ligges



On 13.05.2010 16:49, Mohsen Jafarikia wrote:

Hello All:

I am having the following error message when I increase the resolution
(res=30 to res=350) of my graph:

Error in plot.xy(xy, type, ...) : ignoring SIGPIPE signal
Calls: plot -  plot.default -  plot.xy
Execution halted

Here is the code:

ofn- MAY11.png
bitmap(ofn, type = png256, width = 21, height = 30, pointsize = 30, bg =
white,res=350)  If I change res=350 to res=30, everything is
fine.
par(cex.main=1.2,cex.lab=1.8,cex.axis=1.4)


Does anybody have any comment please?


Does not happen for me. This may be a ghostscript issue rather than an R 
issue, though.


Hard to say since we do not know:
your R version, OS, ghostscript version etc.



Uwe Ligges




Many thanks,
Mohsen

[[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] Help with Loops

2010-05-13 Thread Steve Lianoglou
Hi,

On Thu, May 13, 2010 at 10:49 AM, Amit Patel amitrh...@yahoo.co.uk wrote:
 Hi

 I have tried many attempts but cant get the loop right, as I am not a strong 
 programmer. What I am basically trying to do is compare 2 spreadsheets. The 
 problem is that one of them only contain a portion of the overall data 
 (TESTSAMP), where the other has a full datasetFULLSAMP. From the complete set 
 I would like to remove the rows of data which are not in the TESTSAMP. Column 
 1 contains the sample numbers which can be used to identify samples. Does 
 anyone have any suggestions?

 I have tried various things like double loops and so on, but I am sure there 
 is an easier way or function to do this.

 i tried this method, but Im not sure how to only keep looping until a match 
 is found. I dont understand how repeat loops work in R.

 for (i in 1:length(FULLSAMP[,1])) {

 if (FULLSAMP[i,1] != TESTSAMP[i,1]) {
 FULLSAMP - FULLSAMP[-i,]
 }

You want to not use for loops as much as possible.

Imagine your samples are identified as letters, so FULLSAMP[,1] will
be letters A..Z, and TESTSAMP[,1] will be some random 15 letters. Now
the job is to match the rows in TESTAMP to the rows in FULLSAMP, and
remove any extra rows in FULLSAMP that don' appear in testamp.

## Making some data
R fullsamp - data.frame(id=LETTERS, something=sample(1:100,
length(letters)), stringsAsFactors=FALSE)
R testsamp - data.frame(id=sample(LETTERS, 15),
something=sample(1:100, 15), stringsAsFactors=FALSE)

## Let's find where the testamp rows appear in fullsamp
R xref - match(testsamp[,1], fullsamp[,1])

## Now reduce fullsamp to have only the data corresponding to testsamp
## (and in the same order
R fullsamp.sub - fullsamp[xref,]

Notice that fullsamp.sub now has only rows with IDs appearing in
testsamp and they are also in the same order as testsamp.

Now go ahead and read the help you'll find in ?match

-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] How ls() only functions or anything else but functions?

2010-05-13 Thread Chuck Cleland
On 5/13/2010 11:04 AM, Chuck Cleland wrote:
 On 5/13/2010 10:02 AM, John Edwards wrote:
 Hello,

 How ls() only functions or only data objects (basically anything other than
 functions) such as data.frame, numeric ...?
 
 c(ls.str(mode = function))
 
 ls()[!(ls() %in% c(ls.str(mode=function)))]
 
 ?ls.str

  Or better ...

c(lsf.str())

ls()[!(ls() %in% c(lsf.str()))]

 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Loops

2010-05-13 Thread David Winsemius


On May 13, 2010, at 10:49 AM, Amit Patel wrote:


Hi

I have tried many attempts but cant get the loop right, as I am not  
a strong programmer. What I am basically trying to do is compare 2  
spreadsheets. The problem is that one of them only contain a portion  
of the overall data (TESTSAMP), where the other has a full  
datasetFULLSAMP. From the complete set I would like to remove the  
rows of data which are not in the TESTSAMP. Column 1 contains the  
sample numbers which can be used to identify samples. Does anyone  
have any suggestions?


I have tried various things like double loops and so on, but I am  
sure there is an easier way or function to do this.


i tried this method, but Im not sure how to only keep looping until  
a match is found. I dont understand how repeat loops work in R.


for (i in 1:length(FULLSAMP[,1])) {

if (FULLSAMP[i,1] != TESTSAMP[i,1]) {
FULLSAMP - FULLSAMP[-i,]
}



Abandon the loop. Use merge.
 ... or the %in% function.
--

David Winsemius, MD
West Hartford, CT

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


Re: [R] A primitive OO in R -- where next?

2010-05-13 Thread Don MacQueen
This is not really OO at all, in my opinion. It's an example of the 
amazing flexibility of the language.


I'd like to add on to what Erik said, with an example:


 sum(1:10)

[1] 55


 foo - sum
 foo(1:10)

[1] 55


 junk - list(a=sum)
 junk$a(1:10)

[1] 55

sum is an R object; it happens to be a function.

When I do
  foo - sum
I'm creating another R object. It's also a function, so I use it with 
the same syntax.


When I do
   junk - list(a=sum)
I'm creating another R object. It's a list, and its first element, 
named 'a', is a function.
Since the element is a function, I use it just like any other 
function, i.e, follow its name with a pair of parentheses with 
arguments between them.


Note that in the last example it doesn't matter what the other 
elements in the list, if any, are. I could just as well do

  junk - list( foo=data.frame(x=1:4), b=c('x','y'), dd=sum)
Then
  junk$dd(1:10)
  junk$dd( junk$foo$x )
are valid statements. There's no connection between using 'junk' both 
inside the parentheses and outside. Since junk$dd is a function, you 
can supply it with any R object, and it doesn't matter where that R 
object comes from.


I doubt that it's documented in the way you might be expecting. It's 
a result of the generality of list elements -- they can be any R 
object.


Hope this helps.
-Don

At 10:48 PM +0100 5/12/10, Ted Harding wrote:

Greetings All,

Out of curiosity, I've just done a very primitive experiment:

  Obj - list(Fun=sum, Dat=c(1,2,3,4))
  Obj$Fun(Obj$Dat)
  # [1] 10

That sort of thing (much more sophisticated) must be documented
mind-blowingly somewhere. Where?

Where I stand right now: The above (and its immediately obvious
generalisations, like Obj$Fun-cos) is all I know about it so far.

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 12-May-10   Time: 22:48:14
-- XFMail --

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



--
--
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] R version of SAS/IntrNet

2010-05-13 Thread schuster

Hi, more links in the FAQ: 

http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces

On Thursday 13 May 2010 01:46:51 am Scott Czepiel wrote:
 I recall hearing about -- or was I just dreaming? -- a way to compile
 R as an apache module so it could stay in memory while the webserver
 was running.  The alternative is to simply use cgi in perl or python
 or whatever to gather user input, execute R in batch mode, grab the
 output file and parse it into html.  Lots of boiler-plate involved and
 I would be surprised if nobody has attempted this yet.
 
 On Wed, May 12, 2010 at 9:27 AM, Mark Lamias mlam...@yahoo.com wrote:
  Does an R package exist that is similar to SAS/Intrnet
  (http://support.sas.com/documentation/onlinedoc/intrnet/index.html) that
  will allow users to take parameters passed to it by a web request,
  produce results and return them to the web-browser in HTML format?  I
  tried looking through the package descriptions, but didnt' see anything
  like this.  Any direction or suggestions you could provide would be
  greatly appreciated.
 
  Thanks.
 
  Sincerely yours,
 
  Mark J. Lamias
  Statistical Consultant  Survey Methodologist
 
 
 
 
 [[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.
 

-- 

Friedrich Schuster
Dompfaffenweg 6
69123 Heidelberg

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Source code for gee

2010-05-13 Thread Uwe Ligges



On 13.05.2010 16:29, Joey Zhou wrote:

Dear all:

I am looking for the source code for gee(generalized estimation equations by
Liang and Zeger) package. Can you help?



 download.packages(gee, type=source, destdir=~)

Uwe Ligges



Thanks much,
Joey

[[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] Compiling R with --enable-R-shlib for rpy2 error

2010-05-13 Thread Uwe Ligges



On 13.05.2010 11:45, Padma TAN wrote:

Hi,

I am trying to compile R with the command below in order to install rpy2.

./configure --prefix=/usr/local/R/R-2.9.2 --with-gnu-ld --with-cairo
--with-x --enable-R-shlib


However, error the I have gotten was:
/usr/bin/ld: CConverters.o: relocation R_X86_64_32S against `R_FunTab' can
not be used when making a shared object; recompile with -fPIC
CConverters.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[3]: *** [libR.so] Error 1

I don't really understand the error message. Is there anything I can change
to compile properly so that I can install rpy2?

Please help. Thanks in advance! :)


Regards,
Padma

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




Note the last sentence above and try again, i.e. use a recent version of 
R and report the version number as well as the OS and the compilers in use.


Best,
Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Questions about ggplot2

2010-05-13 Thread Christopher David Desjardins

Hi I have two questions about using ggplot2.

First, I have multiple columns of data that I would like to combine into 
one histogram where each column of data would correspond to one bar in 
the histogram. Each column has 0 or 1s and I want my bars in the 
histogram to correspond to the sum of the 1s in each column. Does that 
make sense?


Second, is there a way to completely turn off the legend?

Thanks!
Chris

PS - Please cc me on the email as I'm a digest subscriber.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 make monthly time series out of daily

2010-05-13 Thread Reto
Reto Baumgartner reto.baumg at gmail.com writes:

 I am using the Rmetrics package and would like to convert a daily
 price time serie into a monthly one. In SPlus I could use:
 aggregateSeries(timeSerie, by=months,FUN=first).

I wrote now my own function. But is there an easier way?

#--
## function to make monthly time series (keep last row of each month)
#
makeMonthly = function(ts){
# ts must be a timeSeries (see: http://www.rmetrics.org/Rmetrics.R;)
ts=sort(ts) #sort
dts=rownames(ts)#get dates
months=substr(dts,6,7)  #read out month
len=length(months)  #get length of vector
b=months[1:(len-1)]!=months[2:len]  #see where month is changing
b=c(b,TRUE) #the last row we always take
mts=ts[b,]  #make monthly data and return result
}

#--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 table for Fisher Exact

2010-05-13 Thread visser

How much would that differ? And how should I build my table if I want to do a 
Pearson Chi Sqaure?


- Original Message -
From: Frank E Harrell Jr [via R] 
ml-node+2197479-2091597772-257...@n4.nabble.com
Date: Thursday, May 13, 2010 2:36 pm
Subject: Re: read table for Fisher Exact
To: visser s.m@amc.uva.nl


 On 05/12/2010 03:31 PM, visser wrote:
 
  i have 2 groups i want to compare: group A and group B
  each group contains let's say 20 patients
  i want to perform a Fisher Exact test on genotype distribution
  so, see if there is a sign diff in genotpe frequency/distribution 
 (#AA, #AB,
  #BB) between group A and B
  not for 1, but for 1000 different genes
 
  my question: how should i build my table so i can do:
 
  test- read.table(table1.txt)
  fisher.test(test)
 
  i know a lot is still missing in the syntax, but i do not know what. 
 any
  help would be soo much appreciated!!
 
 Note that in this case, Fisher's exact test has a good chance of being 
 
 less accurate than an approximate Pearson chi-square test.
 
 -- 
 Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
   Department of Biostatistics   Vanderbilt University
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://r.789695.n4.nabble.com/read-table-for-Fisher-Exact-tp2196762p2197479.html
 
 To unsubscribe from read table for Fisher Exact, click  (link removed) =

-- 
View this message in context: 
http://r.789695.n4.nabble.com/read-table-for-Fisher-Exact-tp2196762p2197720.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.


[R] Help with interpolation

2010-05-13 Thread Jorge Nieves


 Hi,
 
 I have a two Colum matrix ( I named it holder) as shown bellow. It
 seems to be three columns, but the first column contains the row
 names.
 
 I am trying to fill all  NAs by linear interpolation the known values
 in the matrix. I tried using the interpNA function, but I get an error
 message:
 
  interpNA(holder, method = linear)
 Error in approx(idx, x[idx], 1:n, method = method, f = f) : 
   need at least two non-NA values to interpolate
 In addition: Warning message:
 In xy.coords(x, y) : NAs introduced by coercion
  
 
 
 I was wondering if some one could recommend another function to get
 the interpolated values?
 
 Thanks,
 
 Jorge
 
 20100319 2010-03-19  1626
 20100320 2010-03-20NA
 20100321 2010-03-21NA
 20100322 2010-03-22NA
 20100323 2010-03-23NA
 20100324 2010-03-24NA
 20100325 2010-03-25NA
 20100326 2010-03-26  1638
 20100327 2010-03-27NA
 20100328 2010-03-28NA
 20100329 2010-03-29NA
 20100330 2010-03-30NA
 20100331 2010-03-31NA
 20100401 2010-04-01NA
 20100402 2010-04-02  1669
 20100403 2010-04-03NA
 20100404 2010-04-04NA
 20100405 2010-04-05NA
 20100406 2010-04-06NA
 20100407 2010-04-07NA
 20100408 2010-04-08NA
 20100409 2010-04-09  1756
 20100410 2010-04-10NA
 20100411 2010-04-11NA
 20100412 2010-04-12NA
 20100413 2010-04-13NA
 20100414 2010-04-14NA
 20100415 2010-04-15NA
 20100416 2010-04-16  1829
 20100417 2010-04-17NA
 20100418 2010-04-18NA
 20100419 2010-04-19NA
 20100420 2010-04-20NA
 20100421 2010-04-21NA
 20100422 2010-04-22NA
 20100423 2010-04-23  1912
 20100424 2010-04-24NA
 20100425 2010-04-25NA
 20100426 2010-04-26NA
 20100427 2010-04-27NA
 20100428 2010-04-28NA
 20100429 2010-04-29NA
 20100430 2010-04-30  1995
 
 

[[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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
Here is the full repair for the latex functions in Hmisc to make pdflatex
work in Windows.
This version is still slightly awkward.  I hope that Charles and Frank will
smooth it out
and put it in their next release.

I added two new options() and revised show.dvi so it will use them.

Rich



library(Hmisc)

show.dvi -
function (object, width = 5.5, height = 7)
{
viewer - optionsCmds(xdvi)
cmd - if (viewer == yap) {
paste(viewer, object$file)
}
else if (viewer == kdvi) {
paste(viewer, object$file)
}
else if (viewer == xdvi) {
paste(viewer,  -paper , width, x, height, in -s 0 ,
object$file, sep = )
}
else if (basename(viewer) == AcroRd32) {
  object$file - sub(dvi, pdf, object$file)
paste(viewer, object$file)
}
else {
paste(viewer, object$file)
}
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment(show.dvi) - environment(print.dvi)

options(latexcmd=pdflatex,
xdvicmd=c:/Progra~1/Adobe/Reader~1.0/Reader/AcroRd32)

x - matrix(1:24, 6,4, dimnames=list(letters[1:6], LETTERS[1:4]))
show.dvi(dvi(x.tex - latex(x)))
paste(getwd(), x.tex$file, sep=/)  ## location of the table itself
## The tex file with headers and the pdf file are in the directory
## given in the printed output from dvi().

[[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] Multiple plots; single x(y) labels

2010-05-13 Thread Xin Ge
Hi All,

Can anyone please help me with getting a single x and y-axis label while
plotting muliple plots. Here is the code:

par(mfcol=c(2,2))
plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)

also, how can remove x-tick lables using plot()?

Thanks,
Xin

[[alternative HTML version deleted]]

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


Re: [R] Help with interpolation

2010-05-13 Thread Gabor Grothendieck
On Wed, May 12, 2010 at 5:14 PM, Jorge Nieves jorge.nie...@moorecap.com wrote:
 I have a two Colum matrix ( I named it holder) as shown bellow. It seems
 to be three columns, but the first column contains the row names.

You can't have a matrix whose columns are different classes.


 I am trying to fill all  NAs by linear interpolation the known values in
 the matrix. I tried using the interpNA function, but I get an error
 message:

 interpNA(holder, method = linear)
 Error in approx(idx, x[idx], 1:n, method = method, f = f) :
  need at least two non-NA values to interpolate
 In addition: Warning message:
 In xy.coords(x, y) : NAs introduced by coercion

 I was wondering if some one could recommend another function to get the
 interpolated values?

Try this:

Lines - 20100319 2010-03-19  1626
20100320 2010-03-20NA
20100321 2010-03-21NA
20100322 2010-03-22NA
20100323 2010-03-23NA
20100324 2010-03-24NA
20100325 2010-03-25NA
20100326 2010-03-26  1638
20100327 2010-03-27NA
20100328 2010-03-28NA
20100329 2010-03-29NA
20100330 2010-03-30NA
20100331 2010-03-31NA
20100401 2010-04-01NA
20100402 2010-04-02  1669
20100403 2010-04-03NA
20100404 2010-04-04NA
20100405 2010-04-05NA
20100406 2010-04-06NA
20100407 2010-04-07NA
20100408 2010-04-08NA
20100409 2010-04-09  1756
20100410 2010-04-10NA
20100411 2010-04-11NA
20100412 2010-04-12NA
20100413 2010-04-13NA
20100414 2010-04-14NA
20100415 2010-04-15NA
20100416 2010-04-16  1829
20100417 2010-04-17NA
20100418 2010-04-18NA
20100419 2010-04-19NA
20100420 2010-04-20NA
20100421 2010-04-21NA
20100422 2010-04-22NA
20100423 2010-04-23  1912
20100424 2010-04-24NA
20100425 2010-04-25NA
20100426 2010-04-26NA
20100427 2010-04-27NA
20100428 2010-04-28NA
20100429 2010-04-29NA
20100430 2010-04-30  1995

library(zoo)
z - read.zoo(textConnection(Lines), index = 2)[,2]
na.approx(z)

Result is:

 na.approx(z)
2010-03-19 2010-03-20 2010-03-21 2010-03-22 2010-03-23 2010-03-24 2010-03-25
  1626.000   1627.714   1629.429   1631.143   1632.857   1634.571   1636.286
2010-03-26 2010-03-27 2010-03-28 2010-03-29 2010-03-30 2010-03-31 2010-04-01
  1638.000   1642.429   1646.857   1651.286   1655.714   1660.143   1664.571
2010-04-02 2010-04-03 2010-04-04 2010-04-05 2010-04-06 2010-04-07 2010-04-08
  1669.000   1681.429   1693.857   1706.286   1718.714   1731.143   1743.571
2010-04-09 2010-04-10 2010-04-11 2010-04-12 2010-04-13 2010-04-14 2010-04-15
  1756.000   1766.429   1776.857   1787.286   1797.714   1808.143   1818.571
2010-04-16 2010-04-17 2010-04-18 2010-04-19 2010-04-20 2010-04-21 2010-04-22
  1829.000   1840.857   1852.714   1864.571   1876.429   1888.286   1900.143
2010-04-23 2010-04-24 2010-04-25 2010-04-26 2010-04-27 2010-04-28 2010-04-29
  1912.000   1923.857   1935.714   1947.571   1959.429   1971.286   1983.143
2010-04-30
  1995.000

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Whiskers on the default boxplot {graphics}

2010-05-13 Thread Peter Ehlers

David,

try this:

fivenum(1:101)
quantile(1:101, c(1,3)/4, type=5)

 -Peter

On 2010-05-13 8:55, David Winsemius wrote:


On May 13, 2010, at 10:25 AM, Robert Baer wrote:


Hi Peter,

You're absolutely correct! The description for 'range' in 'boxplot'
help file is a little bit confusing by using the words interquartile
range. I think it should be changed to the length of the box to be
exact and consistent with those in the help file for boxplot.stats.


The issue is probably that there are multiple ways (9 to be exact) of
defining quantiles in R. See 'type= ' arguement for ?quantile. The
quantile function uses type=7 by default which matches the quantile
definition used by S-Plus(?), but differs from that used by SPSS.
Doesn't fivenum essentially use the equivalent of a different type= 
arguement (maybe 2 or 5) in constructing the hinges?

It seems perfectly reasonable to talk about 'length of box' (or 'box
height' depending how you display the boxplot), but aren't the hinges
simply Q1 and Q3 defined by one of the possible quartile definitions
(as Peter points out the one used by fivenum)? The box height does not
necesarily match the distance produced by IQR() which also seems to
use the equivalent of quantile(..., type=7), but it is still an IQR,
is it not?

Quantiles apparantly can be defined in more than one acceptable way
(sort of like dealing with ties in rank statistics). The OP seemed to
want an exact explanation of the wiskers, and I think Peter has
pointed us at the definition of quartiles used by fivenum, as opposed
to the default used with quantile(..., type=7).


Yes, and experimentation leads me to the conclusion that the only
possible candidate for matching up the results of fivenum[c(2,4] with
quantile(y, c(1,3)/4, type=i) is for type=5. I'm not able to prove that
to myself from mathematical arguments. since I do not quite understand
the formalism in the quantile page. If the match is not exact, this
would be a tenth definition of IQR.

  set.seed(123)
  y - rexp(300, .02)
  fivenum(y)
[1] 0.2183685 15.8740466 42.1147820 74.0362517 360.5503788
  for (i in 4:9) {print(quantile(y, c(1,3)/4, type=i) ) }
25% 75%
15.82506 73.93080
25% 75%
15.87405 74.03625
25% 75%
15.84955 74.08898
25% 75%
15.89854 73.98352
25% 75%
15.86588 74.05383
25% 75%
15.86792 74.04943



--
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] Path to R script

2010-05-13 Thread Johannes W. Dietrich

At 13:19 Uhr -0700 12.05.2010, Shi, Tao wrote:
Don't quite understand your question, but it looks like a more IT 
issue to me.  I guess you store your R scripts in a central location 
(e.g. a server) and everybody call them from their own workstation, 
right?


Thank you, but this would be an easy solution. The problem is that 
the R script and data tables are stored on the individual computers 
(and therefore on different places depending of the users' 
preferences and of course the operating system).


If it were possible to locate the files relative to the script we 
could write modular scripts that would run on any machine without 
modifications.


Thanks again,

J. W. D.
--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Dr. Johannes W. Dietrich, M.D.
-- Laboratory XU 44, Endocrine Research
-- Medical Hospital I, Bergmannsheil University Hospitals
-- Ruhr University of Bochum
-- Buerkle-de-la-Camp-Platz 1, D-44789 Bochum, NRW, Germany
-- Phone: +49:234:302-6400, Fax: +49:234:302-6403
-- eMail: j.w.dietr...@medical-cybernetics.de
-- WWW: http://medical-cybernetics.de
-- WWW: http://www.bergmannsheil.de
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 interpolation

2010-05-13 Thread Bert Gunter
... and what package is interpNA in, pray tell? (Such information is
requested in the posting guide).

Base R does it with a bit of fiddling:

?approx

But please read the Help carefully. Here is a simple example of how it is
used:

 x - 1:5
 y - c(2,rep(NA,3),7)
 approx(x,y, xout =1:5)## Note the xout argument
$x
[1] 1 2 3 4 5

$y
[1] 2.00 3.25 4.50 5.75 7.00

So you'll have to convert your dates into a suitable numeric series using
whatever date functions you need (e.g. as.Date() ). There are, no doubt,
several packages (perhaps zoo) that can do it at one gulp.

Bert Gunter
Genentech Nonclinical Biostatistics
 
 -Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Jorge Nieves
Sent: Thursday, May 13, 2010 8:52 AM
To: R-help@r-project.org
Subject: [R] Help with interpolation



 Hi,
 
 I have a two Colum matrix ( I named it holder) as shown bellow. It
 seems to be three columns, but the first column contains the row
 names.
 
 I am trying to fill all  NAs by linear interpolation the known values
 in the matrix. I tried using the interpNA function, but I get an error
 message:
 
  interpNA(holder, method = linear)
 Error in approx(idx, x[idx], 1:n, method = method, f = f) : 
   need at least two non-NA values to interpolate
 In addition: Warning message:
 In xy.coords(x, y) : NAs introduced by coercion
  
 
 
 I was wondering if some one could recommend another function to get
 the interpolated values?
 
 Thanks,
 
 Jorge
 
 20100319 2010-03-19  1626
 20100320 2010-03-20NA
 20100321 2010-03-21NA
 20100322 2010-03-22NA
 20100323 2010-03-23NA
 20100324 2010-03-24NA
 20100325 2010-03-25NA
 20100326 2010-03-26  1638
 20100327 2010-03-27NA
 20100328 2010-03-28NA
 20100329 2010-03-29NA
 20100330 2010-03-30NA
 20100331 2010-03-31NA
 20100401 2010-04-01NA
 20100402 2010-04-02  1669
 20100403 2010-04-03NA
 20100404 2010-04-04NA
 20100405 2010-04-05NA
 20100406 2010-04-06NA
 20100407 2010-04-07NA
 20100408 2010-04-08NA
 20100409 2010-04-09  1756
 20100410 2010-04-10NA
 20100411 2010-04-11NA
 20100412 2010-04-12NA
 20100413 2010-04-13NA
 20100414 2010-04-14NA
 20100415 2010-04-15NA
 20100416 2010-04-16  1829
 20100417 2010-04-17NA
 20100418 2010-04-18NA
 20100419 2010-04-19NA
 20100420 2010-04-20NA
 20100421 2010-04-21NA
 20100422 2010-04-22NA
 20100423 2010-04-23  1912
 20100424 2010-04-24NA
 20100425 2010-04-25NA
 20100426 2010-04-26NA
 20100427 2010-04-27NA
 20100428 2010-04-28NA
 20100429 2010-04-29NA
 20100430 2010-04-30  1995
 
 

[[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] Whiskers on the default boxplot {graphics}

2010-05-13 Thread Robert Baer
And try this (which seems to leave us with type=2) and is listed in 
?quantile as Discontinuous sample quantile types 1, 2, and 3

quantile(1:101, c(1,3)/4, type=2)

25% 75%
26  76


David,

try this:

fivenum(1:101)
quantile(1:101, c(1,3)/4, type=5)

 -Peter

On 2010-05-13 8:55, David Winsemius wrote:


On May 13, 2010, at 10:25 AM, Robert Baer wrote:


Hi Peter,

You're absolutely correct! The description for 'range' in 'boxplot'
help file is a little bit confusing by using the words interquartile
range. I think it should be changed to the length of the box to be
exact and consistent with those in the help file for boxplot.stats.


The issue is probably that there are multiple ways (9 to be exact) of
defining quantiles in R. See 'type= ' arguement for ?quantile. The
quantile function uses type=7 by default which matches the quantile
definition used by S-Plus(?), but differs from that used by SPSS.
Doesn't fivenum essentially use the equivalent of a different type= 
arguement (maybe 2 or 5) in constructing the hinges?

It seems perfectly reasonable to talk about 'length of box' (or 'box
height' depending how you display the boxplot), but aren't the hinges
simply Q1 and Q3 defined by one of the possible quartile definitions
(as Peter points out the one used by fivenum)? The box height does not
necesarily match the distance produced by IQR() which also seems to
use the equivalent of quantile(..., type=7), but it is still an IQR,
is it not?

Quantiles apparantly can be defined in more than one acceptable way
(sort of like dealing with ties in rank statistics). The OP seemed to
want an exact explanation of the wiskers, and I think Peter has
pointed us at the definition of quartiles used by fivenum, as opposed
to the default used with quantile(..., type=7).


Yes, and experimentation leads me to the conclusion that the only
possible candidate for matching up the results of fivenum[c(2,4] with
quantile(y, c(1,3)/4, type=i) is for type=5. I'm not able to prove that
to myself from mathematical arguments. since I do not quite understand
the formalism in the quantile page. If the match is not exact, this
would be a tenth definition of IQR.

  set.seed(123)
  y - rexp(300, .02)
  fivenum(y)
[1] 0.2183685 15.8740466 42.1147820 74.0362517 360.5503788
  for (i in 4:9) {print(quantile(y, c(1,3)/4, type=i) ) }
25% 75%
15.82506 73.93080
25% 75%
15.87405 74.03625
25% 75%
15.84955 74.08898
25% 75%
15.89854 73.98352
25% 75%
15.86588 74.05383
25% 75%
15.86792 74.04943



--
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] Path to R script

2010-05-13 Thread Johannes W. Dietrich

At 19:29 Uhr -0400 12.05.2010, Gabor Grothendieck wrote:

If you are running the file via source(myfile.R) then just put this
in the file:

this.dir - dirname(sys.frame(1)$ofile)

This is a bit fragile since changes to the internals of source could
break it but it does currently work.


Great, this is the solution. It works if the script has been saved 
before running.


Thank you,

J. W. D.
--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Dr. Johannes W. Dietrich, M.D.
-- Laboratory XU 44, Endocrine Research
-- Medical Hospital I, Bergmannsheil University Hospitals
-- Ruhr University of Bochum
-- Buerkle-de-la-Camp-Platz 1, D-44789 Bochum, NRW, Germany
-- Phone: +49:234:302-6400, Fax: +49:234:302-6403
-- eMail: j.w.dietr...@medical-cybernetics.de
-- WWW: http://medical-cybernetics.de
-- WWW: http://www.bergmannsheil.de
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Multiple plots; single x(y) labels

2010-05-13 Thread David Winsemius


?plot  # ylim

and you need to have the data in a form (before plotting) where you  
can determine the shared max and min for the y limits


On May 13, 2010, at 12:04 PM, Xin Ge wrote:


Hi All,

Can anyone please help me with getting a single x and y-axis label  
while

plotting muliple plots. Here is the code:

par(mfcol=c(2,2))
plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)


opar - par(mfcol=c(2,2))
randlist - list(); randlist[[1]] - sort(rnorm(7))
randlist[[2]] - sort(rnorm(27))
randlist[[3]] - sort(rnorm(47))
randlist[[4]] - sort(rnorm(67))
lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),  
max(rapply(randlist,max))),
   type = s, xaxt=n, main = , ylab=,  
xlab=); par(opar)




also, how can remove x-tick lables using plot()?


?par  # xaxt=n



Thanks,
Xin

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Whiskers on the default boxplot {graphics}

2010-05-13 Thread David Winsemius


On May 13, 2010, at 12:18 PM, Robert Baer wrote:

And try this (which seems to leave us with type=2) and is listed in ? 
quantile as Discontinuous sample quantile types 1, 2, and 3

quantile(1:101, c(1,3)/4, type=2)

25% 75%
26  76


I think Peter may be right,. If I do it with the rnorm function I  
repeatedly get the same result for fivenum[2] and the type 2 first  
quartile. I did not test those types because they were designed for  
discrete values variables, but I suppose everything is really discrete  
on computers, eh?


 fivenum(x - rnorm(101) )
[1] -2.6224338 -0.9682586 -0.1897377  0.5999332  2.5409711
 quantile(x, c(1,3)/4, type=2)
   25%75%
-0.9682586  0.5999332

 fivenum(x - rnorm(101) )
[1] -3.8251928 -0.6495966  0.1816233  0.7101774  2.3789054
 quantile(x, c(1,3)/4, type=2)
   25%75%
-0.6495966  0.7101774

--
David.



David,

try this:

fivenum(1:101)
quantile(1:101, c(1,3)/4, type=5)

-Peter

On 2010-05-13 8:55, David Winsemius wrote:


On May 13, 2010, at 10:25 AM, Robert Baer wrote:


Hi Peter,

You're absolutely correct! The description for 'range' in  
'boxplot'
help file is a little bit confusing by using the words  
interquartile
range. I think it should be changed to the length of the box  
to be
exact and consistent with those in the help file for  
boxplot.stats.


The issue is probably that there are multiple ways (9 to be  
exact) of

defining quantiles in R. See 'type= ' arguement for ?quantile. The
quantile function uses type=7 by default which matches the quantile
definition used by S-Plus(?), but differs from that used by SPSS.
Doesn't fivenum essentially use the equivalent of a different  
type= 

arguement (maybe 2 or 5) in constructing the hinges?

It seems perfectly reasonable to talk about 'length of box' (or  
'box
height' depending how you display the boxplot), but aren't the  
hinges
simply Q1 and Q3 defined by one of the possible quartile  
definitions
(as Peter points out the one used by fivenum)? The box height  
does not

necesarily match the distance produced by IQR() which also seems to
use the equivalent of quantile(..., type=7), but it is still an  
IQR,

is it not?

Quantiles apparantly can be defined in more than one acceptable  
way
(sort of like dealing with ties in rank statistics). The OP  
seemed to

want an exact explanation of the wiskers, and I think Peter has
pointed us at the definition of quartiles used by fivenum, as  
opposed

to the default used with quantile(..., type=7).


Yes, and experimentation leads me to the conclusion that the only
possible candidate for matching up the results of fivenum[c(2,4]  
with
quantile(y, c(1,3)/4, type=i) is for type=5. I'm not able to prove  
that
to myself from mathematical arguments. since I do not quite  
understand

the formalism in the quantile page. If the match is not exact, this
would be a tenth definition of IQR.

 set.seed(123)
 y - rexp(300, .02)
 fivenum(y)
[1] 0.2183685 15.8740466 42.1147820 74.0362517 360.5503788
 for (i in 4:9) {print(quantile(y, c(1,3)/4, type=i) ) }
25% 75%
15.82506 73.93080
25% 75%
15.87405 74.03625
25% 75%
15.84955 74.08898
25% 75%
15.89854 73.98352
25% 75%
15.86588 74.05383
25% 75%
15.86792 74.04943



--
Peter Ehlers
University of Calgary




David Winsemius, MD
West Hartford, CT

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


Re: [R] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson
Looks good.  I came up with something on my own which was basically to 
re-write print.latex.  I call pdflatex a few times because with the 
longtable package, sometimes things don't line up right until you run 
pdflatex multiple times.  I think mine is less flexible though, and I 
like your solution better.


The only thing I can see to make your solution more flexible is to note 
that there is already options(pdfviewer) in R, so maybe you could just 
use whatever that is for options(xdvicmd) and then in show.dvi, you 
can test


if(viewer == options(pdfviewer)) {
...
}

--Erik

RICHARD M. HEIBERGER wrote:
Here is the full repair for the latex functions in Hmisc to make 
pdflatex work in Windows.
This version is still slightly awkward.  I hope that Charles and Frank 
will smooth it out

and put it in their next release.
 
I added two new options() and revised show.dvi so it will use them.


Rich
 
 
 
library(Hmisc)
 
show.dvi -

function (object, width = 5.5, height = 7)
{
viewer - optionsCmds(xdvi)
cmd - if (viewer == yap) {
paste(viewer, object$file)
}
else if (viewer == kdvi) {
paste(viewer, object$file)
}
else if (viewer == xdvi) {
paste(viewer,  -paper , width, x, height, in -s 0 ,
object$file, sep = )
}
else if (basename(viewer) == AcroRd32) {
  object$file - sub(dvi, pdf, object$file)
paste(viewer, object$file)
}
else {
paste(viewer, object$file)
}
system(cmd, intern = TRUE, wait = TRUE)
invisible(NULL)
}
environment(show.dvi) - environment(print.dvi)
 
options(latexcmd=pdflatex,

xdvicmd=c:/Progra~1/Adobe/Reader~1.0/Reader/AcroRd32)
 
x - matrix(1:24, 6,4, dimnames=list(letters[1:6], LETTERS[1:4]))

show.dvi(dvi(x.tex - latex(x)))
paste(getwd(), x.tex$file, sep=/)  ## location of the table itself
## The tex file with headers and the pdf file are in the directory
## given in the printed output from dvi().


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Multiple plots; single x(y) labels

2010-05-13 Thread David Winsemius


On May 13, 2010, at 12:35 PM, David Winsemius wrote:



?plot  # ylim

and you need to have the data in a form (before plotting) where you  
can determine the shared max and min for the y limits


On May 13, 2010, at 12:04 PM, Xin Ge wrote:


Hi All,

Can anyone please help me with getting a single x and y-axis label  
while

plotting muliple plots.


I'm still not sure what a single x-label might mean for such disparate  
series.



Here is the code:

par(mfcol=c(2,2))
plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)



randlist - list(); randlist[[1]] - sort(rnorm(7))
randlist[[2]] - sort(rnorm(27))
randlist[[3]] - sort(rnorm(47))
randlist[[4]] - sort(rnorm(67))
lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),  
max(rapply(randlist,max))),
  type = s, xaxt=n, main = , ylab=,  
xlab=); par(opar)


A minor refinement:

opar - par(mfcol=c(2,2))
lapply(randlist, plot, ylim=c(Reduce(min, randlist), Reduce(max,  
randlist)),
  type = s, xaxt=n, main = , ylab=,  
xlab=)

par(opar)




also, how can remove x-tick lables using plot()?


?par  # xaxt=n



Thanks,
Xin

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


David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


[R] Help with reading information of summary-Object

2010-05-13 Thread Tino Schöllhorn

Hi,

I am quite new to R - but quite expierience in programming. Nonetheless 
I have some problemes in accessing information of the summary object. 
Here is what I do:


model - lm ( y ~ myVariable )

summary(model) gives me an object which has a lot of information about 
the regression. Now I'd like to access programmatically the level of 
significance which is marked with *** and (**) according to its 
confidence-interval. As I can access all information of the coefficients 
via


summary(model)$coeff[myVariable]

I am now struggling to access the information of the level of significance.

Does anyone has an idea how I could achieve that? Or where I could find 
a similar example?


Thanks in advance for any hint,
Tino

--
Tino Schöllhorn
Wittelsbachstr. 7
67061 Ludwigshafen

Tel: 0621-4255570
E-Mail: t.schoellh...@gmx.de

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Multiple plots; single x(y) labels

2010-05-13 Thread Xin Ge
Hi David,

Thanks for your reply. By single x and y-labels I meant something like this:

http://zoonek.free.fr/blosxom//R/2006-08-10_lattice_xyplot_quakes.png

which lattice gives by default. The code you sent doesn't seem to solve the
problem, I'm sorry if I havent' explained it clearly before.

Any comments?

Thanks,
Xin

On Thu, May 13, 2010 at 12:51 PM, David Winsemius dwinsem...@comcast.netwrote:


 On May 13, 2010, at 12:35 PM, David Winsemius wrote:


 ?plot  # ylim

 and you need to have the data in a form (before plotting) where you can
 determine the shared max and min for the y limits

 On May 13, 2010, at 12:04 PM, Xin Ge wrote:

  Hi All,

 Can anyone please help me with getting a single x and y-axis label while
 plotting muliple plots.


 I'm still not sure what a single x-label might mean for such disparate
 series.

  Here is the code:

 par(mfcol=c(2,2))
 plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)



 randlist - list(); randlist[[1]] - sort(rnorm(7))
 randlist[[2]] - sort(rnorm(27))
 randlist[[3]] - sort(rnorm(47))
 randlist[[4]] - sort(rnorm(67))
 lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),
 max(rapply(randlist,max))),
  type = s, xaxt=n, main = , ylab=, xlab=);
 par(opar)


 A minor refinement:


 opar - par(mfcol=c(2,2))
 lapply(randlist, plot, ylim=c(Reduce(min, randlist), Reduce(max,
 randlist)),

  type = s, xaxt=n, main = , ylab=, xlab=)
 par(opar)



 also, how can remove x-tick lables using plot()?


 ?par  # xaxt=n


 Thanks,
 Xin

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


 David Winsemius, MD
 West Hartford, CT

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


 David Winsemius, MD
 West Hartford, CT



[[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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER
On Thu, May 13, 2010 at 12:46 PM, Erik Iverson er...@ccbr.umn.edu wrote:

 Looks good.


Thank you.


   I came up with something on my own which was basically to re-write
 print.latex.  I call pdflatex a few times because with the longtable
 package, sometimes things don't line up right until you run pdflatex
 multiple times.  I think mine is less flexible though, and I like your
 solution better.

 The only thing I can see to make your solution more flexible is to note
 that there is already options(pdfviewer) in R, so maybe you could just use
 whatever that is for options(xdvicmd) and then in show.dvi, you can test

I set the value of xdvicmd correctly for the pdf viewer on my machine.  It
would be possible
to use options()$pdfviewer instead.  That is part of the smoothing that I
have implicitly
asked Charles and Frank to do.  Also, to make things more automatic.
Notice that I didn't quite get my function into the Hmisc environment
and that is why you need the awkward phrase
show.dvi(dvi(x.tex - latex(x)))
instead of the smooth phrase
latex(x)

Rich

[[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] pnmath on windows

2010-05-13 Thread Alexander Shenkin
Hello All,

I'd like to enable threaded computing on my system (windows 7 pro x64)
if possible.  pnmath seems to be the most accepted solution out there
for the time being, but it requires compiling.  Are there binaries for
windows available that don't require manual compiliation?  If not, does
anyone know what the bottleneck there is?  That is, what keeps me from
compiling it myself and handing it to a friend with another windows system?

Thanks,
Allie

-- 
Alexander Shenkin
PhD Candidate
School of Natural Resources and Environment
University of Florida

http://snre.ufl.edu/people/students.asp

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 reading information of summary-Object

2010-05-13 Thread Erik Iverson

Hello,

Tino Schöllhorn wrote:

Hi,

I am quite new to R - but quite expierience in programming. 


Welcome to R!  It's easiest if you give reproducible examples so we can 
help you.  You can include code to create objects, or use the ?dput 
function.



Nonetheles 
I have some problemes in accessing information of the summary object. 
Here is what I do:


model - lm ( y ~ myVariable )

summary(model) gives me an object which has a lot of information about 
the regression. Now I'd like to access programmatically the level of 
significance which is marked with *** and (**) according to its 
confidence-interval. As I can access all information of the coefficients 
via


summary(model)$coeff[myVariable]


Use the ?coef function for this.



I am now struggling to access the information of the level of significance.

Does anyone has an idea how I could achieve that? Or where I could find 
a similar example?





In this case, you need to know one of the most important R functions, 
str, which tells you the structure of any object.  This will let you 
know what is available in your objects.  Assign your summary object to a 
variable, say summary.model, and then do:


 str(coef(summary(model)))

You can then get at the p.values through the usual indexing techniques, 
by name or by row, column numbering.


From the statistical point of view, we're not sure what you're working 
on, but there are many considerations to take into account if you're 
using p-values from regression fits as some sort of screening tool.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Multiple plots; single x(y) labels

2010-05-13 Thread David Winsemius


On May 13, 2010, at 12:59 PM, Xin Ge wrote:


Hi David,

Thanks for your reply. By single x and y-labels I meant something  
like this:


http://zoonek.free.fr/blosxom//R/2006-08-10_lattice_xyplot_quakes.png

which lattice gives by default. The code you sent doesn't seem to  
solve the problem, I'm sorry if I havent' explained it clearly before.


Any comments?


Yes. If you want lattice output, then don't use base graphics  
functions


--
David.



Thanks,
Xin

On Thu, May 13, 2010 at 12:51 PM, David Winsemius dwinsem...@comcast.net 
 wrote:


On May 13, 2010, at 12:35 PM, David Winsemius wrote:


?plot  # ylim

and you need to have the data in a form (before plotting) where you  
can determine the shared max and min for the y limits


On May 13, 2010, at 12:04 PM, Xin Ge wrote:

Hi All,

Can anyone please help me with getting a single x and y-axis label  
while

plotting muliple plots.

I'm still not sure what a single x-label might mean for such  
disparate series.


Here is the code:

par(mfcol=c(2,2))
plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)


randlist - list(); randlist[[1]] - sort(rnorm(7))
randlist[[2]] - sort(rnorm(27))
randlist[[3]] - sort(rnorm(47))
randlist[[4]] - sort(rnorm(67))
lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),  
max(rapply(randlist,max))),
 type = s, xaxt=n, main = , ylab=,  
xlab=); par(opar)


A minor refinement:


opar - par(mfcol=c(2,2))
lapply(randlist, plot, ylim=c(Reduce(min, randlist), Reduce(max,  
randlist)),


 type = s, xaxt=n, main = , ylab=,  
xlab=)

par(opar)


also, how can remove x-tick lables using plot()?

?par  # xaxt=n


Thanks,
Xin

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

David Winsemius, MD
West Hartford, CT

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

David Winsemius, MD
West Hartford, CT




David Winsemius, MD
West Hartford, CT

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


Re: [R] a question about latex in Hmisc and .dvi file

2010-05-13 Thread Erik Iverson

snip

Notice that I didn't quite get my function into the Hmisc environment
and that is why you need the awkward phrase
show.dvi(dvi(x.tex - latex(x)))
instead of the smooth phrase
latex(x)



Somehow with my own data and not using the awkward bit, it worked on my 
Linux machine?  At least I thought it did, since I believe show.dvi is 
an exported function, can't you just overwrite it in your global 
environment and anything that calls it will use your copy?  I'll have to 
 look into how I got your code working on my system, because I know I 
didn't use that trick!


--Erik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 reading information of summary-Object

2010-05-13 Thread Phil Spector

Tino -
   When you call summary for an lm object, the function
that actually gets called is summary.lm.  This function
has a help page, and, if you type

?summary.lm

and look at the Value section, you'll see the following:

coefficients: a p x 4 matrix with columns for the estimated
  coefficient, its standard error, t-statistic and
  corresponding (two-sided) p-value.  Aliased coefficients are
  omitted.

Here's an example of how you could extract the probabilities:


set.seed(12)
df = data.frame(y=rnorm(100),x1=rnorm(100),x2=rnorm(100))
df.lm = lm(y~x1+x2,df)
sdf.lm = summary(df.lm)
sdf.lm$coefficients[,4]

(Intercept)  x1  x2
  0.7445605   0.8081874   0.2535098

or


sdf.lm$coefficients[,Pr(|t|)]

(Intercept)  x1  x2
  0.7445605   0.8081874   0.2535098

Hope this helps

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu
On Thu, 13 May 2010, Tino Schöllhorn wrote:


Hi,

I am quite new to R - but quite expierience in programming. Nonetheless I 
have some problemes in accessing information of the summary object. Here is 
what I do:


model - lm ( y ~ myVariable )

summary(model) gives me an object which has a lot of information about the 
regression. Now I'd like to access programmatically the level of significance 
which is marked with *** and (**) according to its confidence-interval. 
As I can access all information of the coefficients via


summary(model)$coeff[myVariable]

I am now struggling to access the information of the level of significance.

Does anyone has an idea how I could achieve that? Or where I could find a 
similar example?


Thanks in advance for any hint,
Tino

--
Tino Schöllhorn
Wittelsbachstr. 7
67061 Ludwigshafen

Tel: 0621-4255570
E-Mail: t.schoellh...@gmx.de

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] a question about latex in Hmisc and .dvi file

2010-05-13 Thread RICHARD M. HEIBERGER

  At least I thought it did, since I believe show.dvi is an exported
 function, can't you just overwrite it in your global environment and
 anything that calls it will use your copy?  I'll have to  look into how I
 got your code working on my system, because I know I didn't use that trick!

I thought so, but it didn't work that way on my machine.  Usually when
functions inside a
namespace call each other, any replacement must also be in the namespace.
When I do
this type of thing, I usually need to rebuild a local copy of the package to
get into the
namespace.

Rich

[[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] Multiple plots; single x(y) labels

2010-05-13 Thread Xin Ge
Hi David (and Others),

I think I messed it up. Lets start afresh, I do not want to use lattice for
this. I'm using multiple plot commands and then eventually would like to
get a *combine* x-label and y-label for this plot.

Like for example, the following plot has a combine x-label (Height) and
one y-label (Weight)

http://support.sas.com/documentation/cdl/en/grstateditug/61951/HTML/default/images/multi-panel-data.gif

Is it possible to get a graph similar to above one using base R only ?

# R code (this is just a sample data and not actual data I'm using)

par(mfcol=c(2,2))
plot(1:3, 4:6, type = s, main = , ylab=, xlab=)
plot(2:5, 5:8, type = s, main = , ylab=, xlab=)
plot(3:6, 6:9, type = s, main = , ylab=, xlab=)
plot(4:7, 6:9, type = s, main = , ylab=, xlab=)

Thanks in advance,
Xin

On Thu, May 13, 2010 at 1:10 PM, David Winsemius dwinsem...@comcast.netwrote:


 On May 13, 2010, at 12:59 PM, Xin Ge wrote:

  Hi David,

 Thanks for your reply. By single x and y-labels I meant something like
 this:

 http://zoonek.free.fr/blosxom//R/2006-08-10_lattice_xyplot_quakes.png

 which lattice gives by default. The code you sent doesn't seem to solve
 the problem, I'm sorry if I havent' explained it clearly before.

 Any comments?


 Yes. If you want lattice output, then don't use base graphics functions

 --
 David.



 Thanks,
 Xin

 On Thu, May 13, 2010 at 12:51 PM, David Winsemius dwinsem...@comcast.net
 wrote:

 On May 13, 2010, at 12:35 PM, David Winsemius wrote:


 ?plot  # ylim

 and you need to have the data in a form (before plotting) where you can
 determine the shared max and min for the y limits

 On May 13, 2010, at 12:04 PM, Xin Ge wrote:

 Hi All,

 Can anyone please help me with getting a single x and y-axis label while
 plotting muliple plots.

 I'm still not sure what a single x-label might mean for such disparate
 series.

 Here is the code:

 par(mfcol=c(2,2))
 plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)


 randlist - list(); randlist[[1]] - sort(rnorm(7))
 randlist[[2]] - sort(rnorm(27))
 randlist[[3]] - sort(rnorm(47))
 randlist[[4]] - sort(rnorm(67))
 lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),
 max(rapply(randlist,max))),
 type = s, xaxt=n, main = , ylab=, xlab=);
 par(opar)

 A minor refinement:


 opar - par(mfcol=c(2,2))
 lapply(randlist, plot, ylim=c(Reduce(min, randlist), Reduce(max,
 randlist)),

 type = s, xaxt=n, main = , ylab=, xlab=)
 par(opar)


 also, how can remove x-tick lables using plot()?

 ?par  # xaxt=n


 Thanks,
 Xin

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

 David Winsemius, MD
 West Hartford, CT

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

 David Winsemius, MD
 West Hartford, CT



 David Winsemius, MD
 West Hartford, CT



[[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] Whiskers on the default boxplot {graphics}

2010-05-13 Thread Joshua Wiley
On Thu, May 13, 2010 at 7:55 AM, David Winsemius dwinsem...@comcast.net wrote:
 Yes, and experimentation leads me to the conclusion that the only possible
 candidate for matching up the results of fivenum[c(2,4]  with quantile(y,
 c(1,3)/4, type=i) is for type=5. I'm not able to prove that to myself from
 mathematical arguments. since I do not quite understand the formalism in the
 quantile page. If the match is not exact, this would be a tenth definition
 of IQR.

David,

Here is some sample data, and the most parsimonious code I could come
up with for how quantile() computes the quartiles when using type=5.
The code for fivenum() seems simple enough, but I am not quite able to
make enough sense of the code for type=5 from quantile() to say
confidently why they are different.

I am open to the possibility that my attempts to extract relevant code
from quantile were flawed, but my tentative conclusion is that
quantile(x, type=5) != fivenum(x).

##
x - c(0.643796386452606, -0.605277531056206, -0.339239367816402,
1.12408365699422, 0.615753476531243, -1.10545696568758,
0.666533406841698, 1.42794492209271, 0.624752921945051,
2.02317205214712, -0.365586657432646, 0.821742701084307,
-0.874753498321076, -0.0298783402061118, 1.18037670706428,
-0.178274986836195, 0.308703365439049, 0.619700844646392,
0.54977981430092, -1.82161514610448, -1.28413556650749,
-0.0443852992196351, 0.704196760556652, -1.88596816676741,
-0.420811351737096)
oldx - x #this is just a backup because x will be transformed

##Start from quantile()
probs - c(0, 0.25, 0.5, 0.75, 1)
type - 5
n - length(x)
switch(type - 3, {
  a - 0
  b - 1
}, a - b - 0.5, a - b - 0, a - b - 1, a - b - 1/3, a - b - 3/8)
fuzz - 4 * .Machine$double.eps
nppm - a + probs * (n + 1 - a - b)
j - floor(nppm + fuzz)
h - nppm - j
h - ifelse(abs(h)  fuzz, 0, h)
x - sort(x, partial = unique(c(1, j[j  0L  j = n], (j + 1)[j  0L
 j  n], n)))
x - c(x[1L], x[1L], x, x[n], x[n])
qs - x[j + 2L]
qs[h == 1] - x[j + 3L][h == 1]
other - (h  0)  (h  1)
if (any(other)) qs[other] - ((1 - h) * x[j + 2L] + h * x[j + 3L])[other]
##End from quantile

qs # from the calculations above
quantile(oldx, type=5) #this should match qs
fivenum(oldx) #the 25% does not match


everything else snipped

Josh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Whiskers on the default boxplot {graphics}

2010-05-13 Thread David Winsemius
I agree. I was convinced by Ehlers' example that type =2 was a better  
match to fivenum's result


--
David..


On May 13, 2010, at 1:36 PM, Joshua Wiley wrote:

On Thu, May 13, 2010 at 7:55 AM, David Winsemius dwinsem...@comcast.net 
 wrote:
Yes, and experimentation leads me to the conclusion that the only  
possible
candidate for matching up the results of fivenum[c(2,4]  with  
quantile(y,
c(1,3)/4, type=i) is for type=5. I'm not able to prove that to  
myself from
mathematical arguments. since I do not quite understand the  
formalism in the
quantile page. If the match is not exact, this would be a tenth  
definition

of IQR.


David,

Here is some sample data, and the most parsimonious code I could come
up with for how quantile() computes the quartiles when using type=5.
The code for fivenum() seems simple enough, but I am not quite able to
make enough sense of the code for type=5 from quantile() to say
confidently why they are different.

I am open to the possibility that my attempts to extract relevant code
from quantile were flawed, but my tentative conclusion is that
quantile(x, type=5) != fivenum(x).

##
x - c(0.643796386452606, -0.605277531056206, -0.339239367816402,
1.12408365699422, 0.615753476531243, -1.10545696568758,
0.666533406841698, 1.42794492209271, 0.624752921945051,
2.02317205214712, -0.365586657432646, 0.821742701084307,
-0.874753498321076, -0.0298783402061118, 1.18037670706428,
-0.178274986836195, 0.308703365439049, 0.619700844646392,
0.54977981430092, -1.82161514610448, -1.28413556650749,
-0.0443852992196351, 0.704196760556652, -1.88596816676741,
-0.420811351737096)
oldx - x #this is just a backup because x will be transformed

##Start from quantile()
probs - c(0, 0.25, 0.5, 0.75, 1)
type - 5
n - length(x)
switch(type - 3, {
 a - 0
 b - 1
}, a - b - 0.5, a - b - 0, a - b - 1, a - b - 1/3, a - b -  
3/8)

fuzz - 4 * .Machine$double.eps
nppm - a + probs * (n + 1 - a - b)
j - floor(nppm + fuzz)
h - nppm - j
h - ifelse(abs(h)  fuzz, 0, h)
x - sort(x, partial = unique(c(1, j[j  0L  j = n], (j + 1)[j  0L
 j  n], n)))
x - c(x[1L], x[1L], x, x[n], x[n])
qs - x[j + 2L]
qs[h == 1] - x[j + 3L][h == 1]
other - (h  0)  (h  1)
if (any(other)) qs[other] - ((1 - h) * x[j + 2L] + h * x[j + 3L]) 
[other]

##End from quantile

qs # from the calculations above
quantile(oldx, type=5) #this should match qs
fivenum(oldx) #the 25% does not match


everything else snipped

Josh


David Winsemius, MD
West Hartford, CT

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


Re: [R] Multiple plots; single x(y) labels

2010-05-13 Thread schuster

Hello Xin,

If you need to recreate plots from different systems you need full control over 
the graphics output. This is not always easy with traditional graphics, better 
have a look at the plotting functions from lattice (based on grid graphics 
system in R) or maybe ggplot2. 

http://www.google.de/search?hl=ensafe=offclient=firefox-
ahs=VpIrls=com.ubuntu%3Aen-
US%3Aofficialq=R+grid+graphics+aq=faqi=aql=oq=gs_rfai=

On Thursday 13 May 2010 07:24:56 pm Xin Ge wrote:
 Hi David (and Others),
 
 I think I messed it up. Lets start afresh, I do not want to use lattice for
 this. I'm using multiple plot commands and then eventually would like to
 get a *combine* x-label and y-label for this plot.
 
 Like for example, the following plot has a combine x-label (Height) and
 one y-label (Weight)
 
 http://support.sas.com/documentation/cdl/en/grstateditug/61951/HTML/default
 /images/multi-panel-data.gif
 
 Is it possible to get a graph similar to above one using base R only ?
 
 # R code (this is just a sample data and not actual data I'm using)
 
 par(mfcol=c(2,2))
 plot(1:3, 4:6, type = s, main = , ylab=, xlab=)
 plot(2:5, 5:8, type = s, main = , ylab=, xlab=)
 plot(3:6, 6:9, type = s, main = , ylab=, xlab=)
 plot(4:7, 6:9, type = s, main = , ylab=, xlab=)
 
 Thanks in advance,
 Xin
 
 On Thu, May 13, 2010 at 1:10 PM, David Winsemius 
dwinsem...@comcast.netwrote:
  On May 13, 2010, at 12:59 PM, Xin Ge wrote:
 
   Hi David,
 
  Thanks for your reply. By single x and y-labels I meant something like
  this:
 
  http://zoonek.free.fr/blosxom//R/2006-08-10_lattice_xyplot_quakes.png
 
  which lattice gives by default. The code you sent doesn't seem to solve
  the problem, I'm sorry if I havent' explained it clearly before.
 
  Any comments?
 
  Yes. If you want lattice output, then don't use base graphics
  functions
 
  --
  David.
 
  Thanks,
  Xin
 
  On Thu, May 13, 2010 at 12:51 PM, David Winsemius
  dwinsem...@comcast.net wrote:
 
  On May 13, 2010, at 12:35 PM, David Winsemius wrote:
 
 
  ?plot  # ylim
 
  and you need to have the data in a form (before plotting) where you can
  determine the shared max and min for the y limits
 
  On May 13, 2010, at 12:04 PM, Xin Ge wrote:
 
  Hi All,
 
  Can anyone please help me with getting a single x and y-axis label while
  plotting muliple plots.
 
  I'm still not sure what a single x-label might mean for such disparate
  series.
 
  Here is the code:
 
  par(mfcol=c(2,2))
  plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
  plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
  plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
  plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)
 
 
  randlist - list(); randlist[[1]] - sort(rnorm(7))
  randlist[[2]] - sort(rnorm(27))
  randlist[[3]] - sort(rnorm(47))
  randlist[[4]] - sort(rnorm(67))
  lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),
  max(rapply(randlist,max))),
  type = s, xaxt=n, main = , ylab=, xlab=);
  par(opar)
 
  A minor refinement:
 
 
  opar - par(mfcol=c(2,2))
  lapply(randlist, plot, ylim=c(Reduce(min, randlist), Reduce(max,
  randlist)),
 
  type = s, xaxt=n, main = , ylab=, xlab=)
  par(opar)
 
 
  also, how can remove x-tick lables using plot()?
 
  ?par  # xaxt=n
 
 
  Thanks,
  Xin
 
[[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.
 
  David Winsemius, MD
  West Hartford, CT
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  David Winsemius, MD
  West Hartford, CT
 
  David Winsemius, MD
  West Hartford, CT
 
   [[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] Multiple plots; single x(y) labels

2010-05-13 Thread David Winsemius

On May 13, 2010, at 1:24 PM, Xin Ge wrote:

 Hi David (and Others),

 I think I messed it up. Lets start afresh, I do not want to use  
 lattice for this. I'm using multiple plot commands and then  
 eventually would like to get a *combine* x-label and y-label for  
 this plot.

 Like for example, the following plot has a combine x-label  
 (Height) and one y-label (Weight)

 http://support.sas.com/documentation/cdl/en/grstateditug/61951/HTML/default/images/multi-panel-data.gif

If you want to re-invent the wheel using only hammer and chisel, then  
I suggest the place to start would be examining the code from  
pairs.default(). It's not even hidden so just type:

  pairs.default


 Is it possible to get a graph similar to above one using base R only ?

 # R code (this is just a sample data and not actual data I'm using)

 par(mfcol=c(2,2))
 plot(1:3, 4:6, type = s, main = , ylab=, xlab=)
 plot(2:5, 5:8, type = s, main = , ylab=, xlab=)
 plot(3:6, 6:9, type = s, main = , ylab=, xlab=)
 plot(4:7, 6:9, type = s, main = , ylab=, xlab=)

 Thanks in advance,
 Xin

 On Thu, May 13, 2010 at 1:10 PM, David Winsemius dwinsem...@comcast.net 
  wrote:

 On May 13, 2010, at 12:59 PM, Xin Ge wrote:

 Hi David,

 Thanks for your reply. By single x and y-labels I meant something  
 like this:

 http://zoonek.free.fr/blosxom//R/2006-08-10_lattice_xyplot_quakes.png

 which lattice gives by default. The code you sent doesn't seem to  
 solve the problem, I'm sorry if I havent' explained it clearly before.

 Any comments?

 Yes. If you want lattice output, then don't use base graphics  
 functions

 -- 
 David.



 Thanks,
 Xin

 On Thu, May 13, 2010 at 12:51 PM, David Winsemius dwinsem...@comcast.net 
  wrote:

 On May 13, 2010, at 12:35 PM, David Winsemius wrote:


 ?plot  # ylim

 and you need to have the data in a form (before plotting) where you  
 can determine the shared max and min for the y limits

 On May 13, 2010, at 12:04 PM, Xin Ge wrote:

 Hi All,

 Can anyone please help me with getting a single x and y-axis label  
 while
 plotting muliple plots.

 I'm still not sure what a single x-label might mean for such  
 disparate series.

 Here is the code:

 par(mfcol=c(2,2))
 plot(x - sort(rnorm(7)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(27)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(47)), type = s, main = , ylab=, xlab=)
 plot(x - sort(rnorm(67)), type = s, main = , ylab=, xlab=)


 randlist - list(); randlist[[1]] - sort(rnorm(7))
 randlist[[2]] - sort(rnorm(27))
 randlist[[3]] - sort(rnorm(47))
 randlist[[4]] - sort(rnorm(67))
 lapply(randlist, plot, ylim=c(min(rapply(randlist, min)),  
 max(rapply(randlist,max))),
 type = s, xaxt=n, main = , ylab=,  
 xlab=); par(opar)

 A minor refinement:


 opar - par(mfcol=c(2,2))
 lapply(randlist, plot, ylim=c(Reduce(min, randlist), Reduce(max,  
 randlist)),

 type = s, xaxt=n, main = , ylab=, xlab=)
 par(opar)


 also, how can remove x-tick lables using plot()?

 ?par  # xaxt=n


 Thanks,
 Xin

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

 David Winsemius, MD
 West Hartford, CT

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

 David Winsemius, MD
 West Hartford, CT



 David Winsemius, MD
 West Hartford, CT



David Winsemius, MD
West Hartford, CT


[[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] aggregate.zoo

2010-05-13 Thread Hutchinson,David [PYR]
I have been using aggregate function to determine the annual minimum in
a daily time series. However, I was also hoping to determine the date of
occurrence without having to loop through each year to identify the date
of each minimum returned from aggregate(). Is there a more convenient
way of doing so?
 
Thanks in advance,

Dave
 
library(zoo)
n - 1000
dly - zoo(  x = rnorm(n),   order.by = seq.Date(as.Date('1970-01-01'),
by = 'day', length.out = n)   )  
year - as.numeric( format(index(dly), '%Y') )
annual.min - aggregate( dly, by = year, FUN = min )


[[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] Whiskers on the default boxplot {graphics}

2010-05-13 Thread Shi, Tao
Hi Robert,

Your points are well taken.  However, I reserve mine, b/c I think without this 
detailed discussion, an average R user would simply confused the interquartile 
range said in boxplot help file with the results of IQR.  Changing it to 
length of box makes it more exact and consistent, as I stated earlier.  With 
all these being said, this is up to the R core team to decide.

...Tao





- Original Message 
 From: Robert Baer rb...@atsu.edu
 To: Shi, Tao shida...@yahoo.com; Peter Ehlers ehl...@ucalgary.ca
 Cc: R Project Help R-help@r-project.org
 Sent: Thu, May 13, 2010 7:25:09 AM
 Subject: Re: [R] Whiskers on the default boxplot {graphics}
 
  Hi Peter,
 
 You're absolutely correct!  The description 
 for 'range' in 'boxplot' help file is a little bit confusing by using the 
 words 
 interquartile range. I think it should be changed to the length of the 
 box 
 to be exact and consistent with those in the help file for 
 boxplot.stats.

The issue is probably that there are multiple ways (9 to 
 be exact) of defining quantiles in R.  See 'type= ' arguement for 
 ?quantile.  The quantile function uses type=7 by default which matches the 
 quantile definition used by S-Plus(?), but differs from that used by SPSS.  
 Doesn't fivenum essentially use the equivalent of a different type=  
 arguement 
 (maybe 2 or 5) in constructing the hinges?

It seems perfectly reasonable 
 to talk about 'length of box' (or 'box height' depending how you display the 
 boxplot), but aren't the hinges simply Q1 and Q3 defined by one of the 
 possible 
 quartile definitions (as Peter points out the one used by fivenum)?  The 
 box height does not necesarily match the distance produced by IQR() which 
 also 
 seems to use the equivalent of quantile(..., type=7), but it is still an IQR, 
 is 
 it not?

Quantiles apparantly can be defined in more than one acceptable 
 way (sort of like dealing with ties in rank statistics).  The OP seemed to 
 want an exact explanation of the wiskers, and I think Peter has pointed us 
 at 
 the definition of quartiles used by fivenum, as opposed to the default  
 used with quantile(..., type=7).

All that said, I'm not convinced that 
 it is wrong to speak of interquartile range in 'boxplot' 
 help.

Rob

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] More complex historgram

2010-05-13 Thread Blue.Egg

CID DISTRICTSCHOOL  YRofSTUDY   DATE.ENTRY  SEX AGE 
EGGS.M  EGGS.MIIEGGS.H
POBADN0130  PO  Badongo 0   18.1.08 2   11  0   -1  
73
POBADN0117  PO  Badongo 0   18.1.08 1   10  0   -1  
59
POBADN0160  PO  Badongo 0   18.1.08 1   11  0   -1  
56
POBADN0112  PO  Badongo 0   18.1.08 2   10  0   -1  
47
POBADN0053  PO  Badongo 0   18.1.08 1   8   0   -1  
42
POBADN0141  PO  Badongo 0   18.1.08 2   11  0   -1  
36
POBADN0056  PO  Badongo 0   18.1.08 1   8   0   -1  
26
POBADN0127  PO  Badongo 0   18.1.08 1   10  0   -1  
26
POBADN0136  PO  Badongo 0   18.1.08 2   11  0   -1  
24
POBADN0153  PO  Badongo 0   18.1.08 1   11  0   -1  
22
POBADN0092  PO  Badongo 0   18.1.08 1   9   0   -1  
21
POBADN0087  PO  Badongo 0   18.1.08 1   9   0   -1  
17
POBADN0145  PO  Badongo 0   18.1.08 1   11  0   -1  
16
POBADN0107  PO  Badongo 0   18.1.08 2   10  0   -1  
15
POBADN0118  PO  Badongo 0   18.1.08 1   10  0   -1  
14
POBADN0150  PO  Badongo 0   18.1.08 1   11  0   -1  
14
POBADN0079  PO  Badongo 0   18.1.08 2   9   0   -1  
12
POBADN0121  PO  Badongo 0   18.1.08 1   10  0   -1  
11
POBADN0158  PO  Badongo 0   18.1.08 1   11  0   -1  
10
POBADN0148  PO  Badongo 0   18.1.08 1   11  0   -1  
7
POBADN0155  PO  Badongo 0   18.1.08 1   11  0   -1  
6
POBADN0063  PO  Badongo 0   18.1.08 1   8   0   -1  
4
POBADN0144  PO  Badongo 0   18.1.08 2   11  0   -1  
2
POBADN0002  PO  Badongo 0   18.1.08 2   7   0   -1  0
POBADN0003  PO  Badongo 0   18.1.08 2   7   0   -1  0

I need to find out how can I on R, plot the mean egg of EGGS.H according to
the district, or sex.

Also how to compare the eggs of females on year of study x (in t.test)

Thank you!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/More-complex-historgram-tp2197823p2197823.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] Comparing histograms?

2010-05-13 Thread Jonathan Greenberg
Rhelpers:

I'm curious what the appropriate analysis to use for testing the
hypothesis that two histograms are statistically different from one
another?  Thanks!

--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] Creating data frames in a loop

2010-05-13 Thread Nish

Thank yoy. this works.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Creating-data-frames-in-a-loop-tp2195527p2197780.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] Access to files downloaded

2010-05-13 Thread Joey Zhou
Dear All:

I downloaded gee source code and now I am having problem accessing the
file.


 download.packages(gee, type=source, destdir=~)

--- Please select a CRAN mirror for use in this session ---
trying URL '
http://www.ibiblio.org/pub/languages/R/CRAN/src/contrib/gee_4.13-14.tar.gz'
Content type 'application/x-gzip' length 55417 bytes (54 Kb)
opened URL
downloaded 54 Kb
 [,1]  [,2]
[1,] gee ~/gee_4.13-14.tar.gz

How to access the file and open it?

Thanks much,
Jeoy

[[alternative HTML version deleted]]

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


[R] How to display data values for points in a plot?

2010-05-13 Thread Nish

Hello,

I would like to know how to display values for points in a plot funtion. For
example,

plot( y=dat$a,
  x=dat$b,
main=plot1, 
ylab=a,
  xlab=b,
ylim=c(-10, 10),
xlim=c(-10, 10),
type = p,
pch=17,
col=vector of colors depending on the value of b,
cex=1.5
 )

How can I add a label to each of points here, if I have a list of values
associated with the point.

Thanks in advance.




-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-display-data-values-for-points-in-a-plot-tp2197796p2197796.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] need help in igraph package of R

2010-05-13 Thread bababasi

hi 

I am struck with a problem in igraph package of R. My problem is as follows

I want to plot a power law fit for my data (in .net format --- pajek format)

syntax for that in R is

g - read.graph(filename.net, pajek)
d - degree (g, mode=in)
power.law.fit (d+1, 2)

it gives me desired out put if my if input a single file

but I want to use a  variable file name ( such as name1, name2 ) so that I
can read all my 100 files at a single stretch if I put this entire code in a
loop.

names = name1 name2 name3.

while (i = 100)
g - read.graph(names[i], pajek)
d - degree (g, mode=in)
power.law.fit (d+1, 2)
i - i + 1
}

but names[i] does n't seem to work. Is there any alternative ?

I want to know how to use  a variable file name in this syntax

Any help is greately appreciated

barabasi
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/need-help-in-igraph-package-of-R-tp2197863p2197863.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] need help in igraph package of R

2010-05-13 Thread bababasi

hi 

I am struck with a problem in igraph package of R. My problem is as follows

I want to plot a power law fit for my data (in .net format --- pajek format)

syntax for that in R is

g - read.graph(filename.net, pajek)
d - degree (g, mode=in)
power.law.fit (d+1, 2)

it gives me desired out put if my if input a single file

but I want to use a  variable file name ( such as name1, name2 ) so that I
can read all my 100 files at a single stretch if I put this entire code in a
loop.

names = name1 name2 name3.

while (i = 100)
g - read.graph(names[i], pajek)
d - degree (g, mode=in)
power.law.fit (d+1, 2)
i - i + 1
}

but names[i] does n't seem to work. Is there any alternative ?

I want to know how to use  a variable file name in this syntax

Any help is greately appreciated

barabasi
 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/need-help-in-igraph-package-of-R-tp2197869p2197869.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] install.packages Error

2010-05-13 Thread Trojan

Hi all!

I am trying to install package - GenABEL in a Linux (RedHat) environment
using R 2.6.2. 
The CRAN Mirror starts up, I select the site, but I end up with the
following error:

**
Warning: unable to access index for repository
http://cran.stat.ucla.edu/src/contrib
Warning messages:
1: In open.connection(con, r) : unable to resolve 'cran.r-project.org'
2: In install.packages(GenABEL, lib = /home/software) :
  package âGenABELâ is not available


The code in command line: install.packages(GenABEL, lib=/home/software)

**

I have tried to use other sites, but it comes back with the same error. I
have checked the CRAN files and GenABEL is available for use

This problem has just popped up in the last couple of days - I have
previously been able to successfully install other packages

Where am I going wrong? Any input will be much appreciated! Thanks!

(Also, I have searched the forum for other similar posts - I have tried the
suggested tips but they do not work)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/install-packages-Error-tp2201914p2201914.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.


  1   2   >