[R] R-2.6.2 installation (64bit) falling over with the grid package

2008-02-24 Thread Patrick Connolly
It's a long time since I had a problem compiling R, but I've now
encountered one with R-2.6.2 on Fedora Core 6 (64bit).

The problem arises when the installation process gets to the grid
package, the unit.c part in particular.  This is the output I get:


gcc -std=gnu99 -I../../../../include -I../../../../include  
-I/usr/local/include   -fvisibility=hidden -fpic  -g -O2 -c unit.c -o unit.o
unit.c: In function ��pureNullUnit��:
unit.c:332: error: stray ��#�� in program
unit.c:332: error: �?R_fcall�� undeclared (first use in this function)
unit.c:332: error: (Each undeclared identifier is reported only once
unit.c:332: error: for each function it appears in.)
make[5]: *** [unit.o] Error 1
make[5]: Leaving directory `/usr/local/R-2.6.2/src/library/grid/src'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/usr/local/R-2.6.2/src/library/grid/src'
make[3]: *** [all] Error 1
make[3]: Leaving directory `/usr/local/R-2.6.2/src/library/grid'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/usr/local/R-2.6.2/src/library'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/usr/local/R-2.6.2/src'
make: *** [R] Error 1


I installed the same tgz file on a 32-bit Mepis machine and on a
CentOS5 machine without such any problem .  All previous 64bit
compilations have also been without a problem.

There has been a problem with one PCI slot on the machine in question
after an electrical misadventure.  If nobody else has had a problem on
64 bit machines, could it be that I have a hardware problem?  Seems a
bit unlikely it would get as far as it did were that the case, but I
could be convinced otherwise.

Ideas? Other experience?

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-2.6.2 installation (64bit) falling over with the grid package

2008-02-24 Thread Prof Brian Ripley

It's your system: try unpacking the tarball again.  That line is

eval(R_fcall3, R_gridEvalEnv);

and has no # there.

I suspect FC6 systems are thin on the ground (it is end-of-life, I 
believe), but R-2.6.2.tar.gz has been installed on many, many 64-bit Linux 
systems (e.g. CRAN tests on one), including an FC5 system (which we still, 
just, have for testing compatibility with an old OS).


People seem to fail to appreciate the effort that goes into checking that 
the release tarballs are complete and uncorrupted.


On Sun, 24 Feb 2008, Patrick Connolly wrote:


It's a long time since I had a problem compiling R, but I've now
encountered one with R-2.6.2 on Fedora Core 6 (64bit).

The problem arises when the installation process gets to the grid
package, the unit.c part in particular.  This is the output I get:


gcc -std=gnu99 -I../../../../include -I../../../../include  
-I/usr/local/include   -fvisibility=hidden -fpic  -g -O2 -c unit.c -o unit.o
unit.c: In function pureNullUnit:
unit.c:332: error: stray # in program
unit.c:332: error: ÿÿ?R_fcall undeclared (first use in this function)
unit.c:332: error: (Each undeclared identifier is reported only once
unit.c:332: error: for each function it appears in.)
make[5]: *** [unit.o] Error 1
make[5]: Leaving directory `/usr/local/R-2.6.2/src/library/grid/src'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/usr/local/R-2.6.2/src/library/grid/src'
make[3]: *** [all] Error 1
make[3]: Leaving directory `/usr/local/R-2.6.2/src/library/grid'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/usr/local/R-2.6.2/src/library'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/usr/local/R-2.6.2/src'
make: *** [R] Error 1


I installed the same tgz file on a 32-bit Mepis machine and on a
CentOS5 machine without such any problem .  All previous 64bit
compilations have also been without a problem.

There has been a problem with one PCI slot on the machine in question
after an electrical misadventure.  If nobody else has had a problem on
64 bit machines, could it be that I have a hardware problem?  Seems a
bit unlikely it would get as far as it did were that the case, but I
could be convinced otherwise.

Ideas? Other experience?




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


[R] problem with ML estimation

2008-02-24 Thread souvik banerjee
dear list,
as a part my problem. I have to estimate some parameters using ML
estimation. The form of the likelihood function
is not straight forward and I had to use a for loop to define the function.
I used optim to maximise the result but
was not sure of the programme.
To validate my results, I tried to write a function to obtain the MLE of a
bivariate normal in the same manner.
On generating a simulated data and running the script, I am getting results
which are very inaccurate.
I am sending my programme. It would be of great help if someone can point
me, where I am going wrong.






library(MASS)
Sigma - matrix(c(4,2.8,2.8,4),2,2)
y-mvrnorm(n=1000, rep(0, 2), Sigma)

mlebinorm- function(startval, y)# startval = Initial Values to be passed ,
y= data
{
 startval-as.numeric(startval)
 oneside=matrix(c(0,0,0,0,-1,0,0,0,0,1),5,2)
 otherside = c(-0.999,-0.99)
 n- ncol(y)
 nf- function(x)
 {
  mu1-x[1]
  mu2-x[2]
  sig1-x[3]
  sig2-x[4]
  rho-x[5]
  nf-(-n/2)*(log(sig1*sig2*(1-rho^2)))-(0.5/(1-rho^2)*
   (((y[1,1]-mu1)^2/sig1)-
   (2*rho*(y[1,1]-mu1)*(y[1,2]-mu2))/sqrt(sig1*sig2)+
   (y[1,2]-mu2)^2/sig2))
  for(i in 2:n)
  {
   nf- nf - (0.5*(1-rho^2)*
   (((y[i,1]-mu1)^2/sig1)-
   (2*rho*(y[i,1]-mu1)*(y[i,2]-mu2))/sqrt(sig1*sig2)+
   (y[i,2]-mu2)^2/sig2))

  }
 return(nf)

 }

 constrOptim(startval,nf,NULL,ui=t(oneside),
ci=otherside,control=list(fnscale=-1))

}

mlebinorm(c(1,1,2,2,0.3),y)



Souvik Banerjee
Lecturer
Department of statistics
Memari College
Burdwan
India

[[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] Generic Functions

2008-02-24 Thread Dominik Locher
Hi

I have some problems in defining new generic functions and classes. Just
have a look at the following example:


require(fPortfolio)

setClass(PROBECLASS,   
  representation(   
type=character
  ) 
)   

isGeneric(setType-)
#Returns 
TRUE

#I would like to define a specific function for class PROBECLASS with other
arguments than for the generic function setType of fPortfolio.
setGeneric(setType-, function(object, value)
standardGeneric(setType-))

#Returns
Fehler in makeGeneric(name, fdef, fdeflt, group = group, valueClass =
valueClass,  : 
  the formal arguments of the generic function for setType- (object,
value) differ from those of the non-generic to be used as the default (spec,
value)

setReplaceMethod(setType, PROBECLASS, function(object, value){

  [EMAIL PROTECTED] - value   
  object

})   

#Example
obj = new(PROBECLASS)
setType(obj) = test
obj 


##
If I don't require fPortfolio it works fine. However, is it not possible to
create two generic functions with the same name but different arguments?
setType for fPortfolio may be differ completely from setType of
PROBECLASS...
What's the best way to have functions which belongs to an object of a
specific class? I had a look at the paper S4 Classes in 15 pages, more or
less (feb12, 2003), however, I could not found what I did wrong...

Any help is highly appreciated. 

Thanks
Dominik

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


Re: [R] Newbie: Measuring distance between clusters.

2008-02-24 Thread Keizer_71

It works! I was banging my head for a week. 

thank you so much.



Bill.Venables wrote:
 
 One way to do it is to find the distances between ther centers (=
 centres in English) of the clusters.  
 
 dist(kc$centers)
 
 It rather depends on how you define distances between clusters, though.
 There are many possibilities.
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Keizer_71
 Sent: Saturday, 23 February 2008 7:40 PM
 To: r-help@r-project.org
 Subject: [R] Newbie: Measuring distance between clusters.
 
 
 Hi,
 
 I had 1 genes, and I clustered them using K-means clustering in R.
 
 kc-kmeans(data.sub,7)
 
 kc
 n cluster sum of squares by cluster:
 [1]  60631.76 135886.19 159049.71 101783.27  90040.72 183335.60
 158867.81
 
 Available components:
 [1] cluster  centers  withinss size
 
 I am very new to R. How do i measure the distance between those cluster?
 
 I tried
 
 I am trying to do a complete linkage
 
z-hclust(kc,method=complete)
 
 Error in if (n  2) stop(must have n = 2 objects to cluster) : 
 argument is of length zero
 
 thanks.
 
   
 -- 
 View this message in context:
 http://www.nabble.com/Newbie%3A-Measuring-distance-between-clusters.-tp1
 5650066p15650066.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-Measuring-distance-between-clusters.-tp15650066p15665075.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] [R-pkgs] Announcement: obsSens Package

2008-02-24 Thread Greg Snow
The new package obsSens is now on the CRAN mirrors.  This package has tools for 
doing senstitivity analysis for observational studies.
 
The common criticism of observational studies is that there is the possibility 
of an unmeasured variable that is related to both the response and the 
predictor of interst that could explain the observed relationship.  The 
sensitivity analysis is a What If? game where you specify potential 
relationships between the unmeasured variable and the response and predictor 
variable and see how that affects the relationship between predictor and 
response.
 
 

[[alternative HTML version deleted]]

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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


[R] mixed model nested ANOVA (part two)

2008-02-24 Thread Stephen Cole
First of all thank you for the responses.  I appreciate the
suggestions i have received thus far.

Just to reiterate

I am trying to analyze a data set that has been collected from a
hierarchical sampling design.  The model should be a mixed model
nested ANOVA.  The purpose of my study is to analyze the variability
at each spatial scale in my design (random factors, variance
components), and say something about the variability between regions
(fixed factor, contrast of means).  The data is as follows;

region (fixed)
Location (random)
Site(random)

site nested in location nested in region.

Also i have read in Quinn and Keough 2002, design and analysis of
experiments for biologists, that a variance component analysis should
only be conducted after a rejection of the null hypothesis of no
variance at that level.

I have tried to implement
mod1-lmer(density ~ 1 + (1|site) + (1|location) + (1|region))

However, as i understand it, this treats all my factors as random.
Plus I do not know how to extract SS or MS from this model.

anova(mod1) gives me
Analysis of Variance Table
 Df Sum Sq Mean Sq

and summary(mod1) gives me
Linear mixed-effects model fit by REML
Formula: density ~ 1 + (1 | site) + (1 | location) + (1 | region)
   AIC   BIC logLik MLdeviance REMLdeviance
 15658 15678  -7825  1566215650
Random effects:
 Groups   NameVariance Std.Dev.
 site (Intercept)  22191   148.97
 location (Intercept)  33544   183.15
 region   (Intercept)  41412   203.50
 Residual 696189   834.38
number of obs: 960, groups: site, 4; location, 4; region, 3

Fixed effects:
Estimate Std. Error t value
(Intercept)261.3  168.7   1.549

from what i understand the variance in the penultimate column are my
variance components.  But how do i conduct my significance test?

I have also tried
mod1-lmer(density ~ region + (1|site) + (1|location))

Which i think is the correct mixed model for my design.  However once
again i do not know how to evaluate significance for the random
factors.

Thank-you again for any additional advice i receive

Stephen Cole

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


[R] what missed ----- CART

2008-02-24 Thread o ha wang
Hi all,
   
  Can anyone who is familar with CART tell me what I missed in my tree code? 
   
  library (MASS)
  myfit - tree (y ~ x1 + x2 + x3 + x4 )  
  # tree.screens ()   # useless
  plot(myfit);  text (myfit, all= TRUE, cex=0.5, pretty=0)
  # tile.tree (myfit, fgl$type)   # useless
  # close.screen (all= TRUE)  # useless

   
  My current tree plot resulted from above code shows as: 
  1. overlapped #s caused by unsuitable length of branch.
  2. no misclassification rates:  'misclass.tree' only brings up the error of ' 
misclassification error rate is appropriate for factor responses only', but my 
response y is 0/1 data.
  3. Unsuitable location of notations: there are not two notation of splitting 
criteria on the two branches when a node is split, instead only one notation of 
splitting criteria  is on the node location. 
   
  thanks,
  xiao yue

   
-

[[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] Standard method for S4 object

2008-02-24 Thread Christophe Genolini

 /I think your question should be more relevant on Rdev./
ok, I will
 Personnally I would find stuff like names,  $, $-, or [ 
 useful as these are usual operation with S3 objects.
Is it possible in S4 to define $- ? If there is a slot name 'a' in 
object 'B', I find (in S4 in 15 pages more or less)

setGeneric(a-, function(x, value) standardGeneric(a-))
setReplaceMethod(a, .

Then we can use

obj - new(B)
a(obj)- 3

But I did not find how to define

obj$a - 3

Is it possible ? Is it the 'usual' way ?


Christophe

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


Re: [R] Standard method for S4 object

2008-02-24 Thread Martin Morgan
Christophe Genolini wrote:
 /I think your question should be more relevant on Rdev./
 ok, I will
 Personnally I would find stuff like names,  $, $-, or [ 
 useful as these are usual operation with S3 objects.
 Is it possible in S4 to define $- ? If there is a slot name 'a' in 

Possible yes, see below. Usual? It implies to the user that this is a 
list- or data.frame-like object (where $ is used most commonly). Maybe 
your object is not like that? It also seems like a short step from 
direct slot access (although it doesn't have to be), which might be 
breaking the abstraction layer that object orientation provides. And it 
shifts the responsibility for confirming that 'name' is a slot, and 
dispatching on different values of 'name' (e.g. for some slots perhaps 
one doesn't want to allow access, and then the code inside the '$' 
method has to check that), back to the developer (instead of allowing 
the method definition and dispatch to do its work). Generally these seem 
like backward steps to me.

  setClass(A, representation(x=numeric))
[1] A
  setReplaceMethod($,
+   signature=signature(
+ x=A,
+ name=ANY,
+ value=ANY),
+   function(x, name, value) {
+ slot(x, name) - value
+ x
+   })
[1] $-
  a - new(A)
  a$x - 1:5
  a
An object of class A
Slot x:
[1] 1 2 3 4 5

 object 'B', I find (in S4 in 15 pages more or less)
 
 setGeneric(a-, function(x, value) standardGeneric(a-))
 setReplaceMethod(a, .
 
 Then we can use
 
 obj - new(B)
 a(obj)- 3
 
 But I did not find how to define
 
 obj$a - 3
 
 Is it possible ? Is it the 'usual' way ?
 
 
 Christophe
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Generic Functions

2008-02-24 Thread Martin Morgan
See the 'useAsDefault' argument to setGeneric.

As an aside, if 'setType-' is meant to be a 'setter' to change the 
value of a slot 'type', then I find the syntax a little redundant -- 
it's use

  setType(x) - foo

implies that it is already a 'setter' without 'set' at the front. Why 
not just

  type(x) - foo

(though perhaps 'type' is not such a good name, either)?

As a second aside, if you're writing code that you expect to be used 
with fPortfolio, then having two functions with the same name but 
different signatures or overall goals will confuse your user -- with 
fPortfolio, setType- works fine, but then for mysterious reasons (i.e., 
when your package is loaded, with a different definition of setType-) 
code that worked before no longer works! So I'd either use setType in a 
way consistent with it's use in fPortfolio, or define a new generic for 
your own purposes (setType- is not a generic in my version of fPortfolio,

  packageDescription('fPortfolio')$Version
[1] 260.72

).

As a third aside, I think questions about S4 probably belong on R-devel, 
as they seem to fall in the realm of 'questions likely to prompt 
discussion unintelligible to non-programmers' (from the R-devel mailing 
list description).

Martin

Dominik Locher wrote:
 Hi
 
 I have some problems in defining new generic functions and classes. Just
 have a look at the following example:
 
 
 require(fPortfolio)
 
 setClass(PROBECLASS,   
   representation(   
 type=character
   ) 
 )   
 
 isGeneric(setType-)
 #Returns 
 TRUE
 
 #I would like to define a specific function for class PROBECLASS with other
 arguments than for the generic function setType of fPortfolio.
 setGeneric(setType-, function(object, value)
 standardGeneric(setType-))
 
 #Returns
 Fehler in makeGeneric(name, fdef, fdeflt, group = group, valueClass =
 valueClass,  : 
   the formal arguments of the generic function for setType- (object,
 value) differ from those of the non-generic to be used as the default (spec,
 value)
 
 setReplaceMethod(setType, PROBECLASS, function(object, value){
 
   [EMAIL PROTECTED] - value   
   object
 
 })   
 
 #Example
 obj = new(PROBECLASS)
 setType(obj) = test
 obj 
 
 
 ##
 If I don't require fPortfolio it works fine. However, is it not possible to
 create two generic functions with the same name but different arguments?
 setType for fPortfolio may be differ completely from setType of
 PROBECLASS...
 What's the best way to have functions which belongs to an object of a
 specific class? I had a look at the paper S4 Classes in 15 pages, more or
 less (feb12, 2003), however, I could not found what I did wrong...
 
 Any help is highly appreciated. 
 
 Thanks
 Dominik
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Minor tick marks

2008-02-24 Thread Saptarshi Guha
Hello,
Is there a way to add minor tick marks to the Y-axis of  a lattice  
plots?
Thank you
Saptarshi

Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha


[[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] Standard method for S4 object

2008-02-24 Thread Thibaut Jombart
Martin Morgan wrote:

 Christophe Genolini wrote:

 Personnally I would find stuff like names,  $, $-, or [ 
 useful as these are usual operation with S3 objects.

 Is it possible in S4 to define $- ? If there is a slot name 'a' in 


 Possible yes, see below. Usual? It implies to the user that this is a 
 list- or data.frame-like object (where $ is used most commonly). Maybe 
 your object is not like that? It also seems like a short step from 
 direct slot access (although it doesn't have to be), which might be 
 breaking the abstraction layer that object orientation provides. And 
 it shifts the responsibility for confirming that 'name' is a slot, and 
 dispatching on different values of 'name' (e.g. for some slots perhaps 
 one doesn't want to allow access, and then the code inside the '$' 
 method has to check that), back to the developer (instead of allowing 
 the method definition and dispatch to do its work). Generally these 
 seem like backward steps to me.

Yes, to me too. But it is nonetheless useful when you convert an 'old' 
S3 class to S4 and want to re-use your old code as much as possible (or 
want users to be able to do so). I don't know if this is the case here. 
Plus, as $ and $- are just wrappers for @ and @-, the procedure 
checking the validity of a value assigned to a slot is still called when 
using $-. Another, maybe interesting option is to use accessors to 
change the values of the slots. This might be more object-oriented, and 
would allow for more control on the content of the object.

Cheers,

Thibaut.

-- 
##
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
Tél. : 04.72.43.29.35
Fax : 04.72.43.13.88
[EMAIL PROTECTED]
http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en
http://pbil.univ-lyon1.fr/software/adegenet/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] running R as a web service

2008-02-24 Thread [Ricardo Rodriguez] Your XEN ICT Team
Hi all,

As R is gaining space in our research group as language and environment 
for statistical computing and graphics it will be really helpful to have 
the option of using R as a web service.

We are currently using a collaborative edition wiki tool (XWiki) to 
develop R code. And we can call this code with source() from any R 
installation. But it will be great to be able to send this code to a web 
service and get back just the result (textual or graphics).

Rserver seems to fit into this requirement. Please, could anybody using 
any of this or other option share with us his/her experience? Is it 
feasible to run such a service with the current R release? Thanks!

Best regards,

Ricardo

-- 
Ricardo Rodríguez
Your XEN ICT Team

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


[R] [R-pkgs] Bayesian Prediction with High-order Interactions

2008-02-24 Thread Longhai Li
Hi Everybody,

A new package called ``Bayesian Prediction with High-order
Interactions'' is available from CRAN. The description of this package
is as follows

This R package is used in two situations. The first is to predict the
next outcome based on the previous states of a discrete sequence. The
second is to classify a discrete response based on a number of
discreate covariates. In both situations, we use Bayesian logistic
regression models that consider the high-order interactions. The time
arising from using high-order interactions is reduced greatly by our
compression technique that represents a group of original parameters
as a single one in MCMC step. In this version, we use log-normal prior
for the hyperparameters. When it is used for the second situation ---
classification, we consider the full set of interaction patterns up to
a specified order.

The website of this package is

http://fisher.utstat.toronto.edu/~longhai/software/BPHO/release.html

-- 

Longhai Li, PhD

Assistant Professor
Department of Mathematics and  Statistics
University of Saskatchewan

Homepage: http://math.usask.ca/~longhai

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] what missed ----- CART

2008-02-24 Thread Uwe Ligges


o ha wang wrote:
 Hi all,

   Can anyone who is familar with CART tell me what I missed in my tree code? 

   library (MASS)
   myfit - tree (y ~ x1 + x2 + x3 + x4 )  

There is not function tree() in MASS. I guess you have loaded package 
tree?
Note that the author and maintainer of the tree package suggests to use 
package rpart instead.



   # tree.screens ()   # useless
   plot(myfit);  text (myfit, all= TRUE, cex=0.5, pretty=0)
   # tile.tree (myfit, fgl$type)   # useless
   # close.screen (all= TRUE)  # useless
 

   My current tree plot resulted from above code shows as: 
   1. overlapped #s caused by unsuitable length of branch.
   2. no misclassification rates:  'misclass.tree' only brings up the error of 
 ' misclassification error rate is appropriate for factor responses only', but 
 my response y is 0/1 data.

If you data is 0/1, you should make it a factor otherwise the cose will 
assume you want a regression rather than a classification tree.


   3. Unsuitable location of notations: there are not two notation of 
 splitting criteria on the two branches when a node is split, instead only one 
 notation of splitting criteria  is on the node location. 

It indicates which items go into the left branch.

Uwe Ligges



   thanks,
   xiao yue
 

 -
 
   [[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] Split a matrix for mixture distribution

2008-02-24 Thread Uwe Ligges


Evgenia wrote:
 Hello,
  I have a matrix with 4000 rows and 8 columns with 1 and zeros 
 Every 1000 rows comes for a different rule, f1,f2,f3,f4.
 
 1 1 1 1 0 0 0 0
 1 1 1 1 0 0 0 0 
 
 0 0 0 0 1 1 1 1
 0 0 0 0 1 1 1 1
 ...
 1 1 0 0 1 1 0 0
 1 1 0 0 1 1 0 0
 ...
 0 0 1 1 0 0 1 1 
 0 0 1 1 0 0 1 1
 
 How can I extract 4 matrices each one containes 1000 elements from a certain
 rule,since i want to 
 a) choose between f1, f2, f3 and f4 at random according to the
probabilities p1, p2, p3 ,p4 (it is assumed p1+p2+p3=1).
 b) sample 1 value from whichever of f1, f2, f3 ,f4 was chosen

I guess we need some better explanations or examples - at least I do not 
understand your aims.

Uwe Ligges

 Thanks a lot
 Evgenia


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


Re: [R] ginv and matlab's pinv give different results

2008-02-24 Thread Uwe Ligges


Pedro Mardones wrote:
 Dear all;
 I'm kind of confused with the results obtained using the ginv function
 from package MASS and pinv function from Matlab. Accroding to the
 documentation both functions performs a Moore-Penrose generalized
 inverse of a matrix X. The problem is when I change the tolerance
 value, say to 1E-3.
 
 Here is some output from ginv
 195.2674402   235.6758714 335.0830253 8.977515484 -291.7798965
 428.8266383   165.9809056 284.0561017 -74.35007018-210.3373981
 440.6537582   42.44715935 290.4538488 -58.74366626-86.71457799
 246.4469887   -36.24936825397.6034028 -107.757444810.7545897
 -17.07138404  30.43896492 399.3831596 -88.4968195912.33524917
 
 
 ad here from pinv
 1.988794963   4.931306729 -12.72706642-3.903229019-4.516082822
 3.017403231   4.799144574 -14.43317599-5.388596501-5.872449411
 4.951830097   4.684716091 -17.13075023-6.584430072-7.142673623
 7.457154317   2.896685565 -21.59318352-11.38286985-10.58210901
 7.841116927   0.836247791 -23.12560946-13.99460333-11.8333927
 
 I'm sure it must be some explanation that I'm not aware of. If anyone
 can (want) to run the test I can email the data set

Without the original data we cannot say if one or both of them are wrong 
or correct. Hence, please make the data and the code you have used 
available - as the posting guide suggests.

Uwe Ligges


 Thanks for any idea
 
 PM
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] projection.matrix() {popbio} for more than one matrix

2008-02-24 Thread Uwe Ligges


Michelle DePrenger-Levin wrote:
 Hello,
 
  
 
 I am trying to use the projection.matrix( ) function and am following the
 example given. I have my data formatted very similar to the test.census
 example. 
 
  
 
 str(AsMi05mat)
 
 `data.frame':   1854 obs. of  6 variables:
 
  $ Tag  : num  501 502 503 504 505 506 507 508 509 510 ...
 
  $ Year : int  1995 1995 1995 1995 1995 1995 1995 1995 1995 1995 ...
 
  $ Length   : num  34 37 11 24 7 44 4 7 12 20 ...
 
  $ Flowering: int  1 1 0 1 0 1 0 0 0 1 ...
 
  $ Fruits   : int  22 22 0 89 0 15 0 0 0 0 ...
 
  $ Stage: Factor w/ 5 levels ,Dead,Dormant,..: 4 4 5 4 5 4 5 5 5 4
 ...
 
  
 
 The example data includes three years but only shows how to create a matrix
 from year 1 to 2. I have 13 years of data and would like to automate creating
 all matrices for each pair of years. 
 
  
 
 I tried a for( ) loop but don't know how to assign new names for each matrix
 so end up with only the final comparison (2005 to 2006). I assume an apply( )
 function is the way to go but can't see how to do it. 

Well, we cannot help to improve your code if we have neither, code nor 
data. Please read the posting guide and specify your code. If something 
is wrong in your code, we might be able to help.

Uwe Ligges




  
 
 Thanks for any help!
 
  
 
 Michelle
 
  
 
 
   [[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] Combining Data Frames

2008-02-24 Thread Uwe Ligges


stephen sefick wrote:
 I have two dataframes in R that were tab seperated .txt files
 
 y-read.table(foo.txt, header=T)
 x-read.table(foo.txt, header=T)
 
 these are set up like this:
 
 Datetime Temp
 01/01/07 00:01 11.5
 01/01/07 00:16 11.6
 
 etc etc to 66000 rows in y and 33000 rows in x
 
 The two files overlap with the same data for a period of time but
 contain different values outside of these.  Is there a way to merge
 these two data sets based on the shared date time column into one
 large dataset of ~90,000 lines.  I want to eventually make this into a
 time series with frequency= 1/15.


Have you tried ?merge.

Uwe Ligges


 Thanks
 
 Stephen

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


Re: [R] R-2.6.2 installation (64bit) falling over with the grid package

2008-02-24 Thread Patrick Connolly
On Sun, 24-Feb-2008 at 10:00AM +, Prof Brian Ripley wrote:

| It's your system: try unpacking the tarball again. 

No surprises there: Brian is spot on again.  Thank you Brian.

I'd not have thought of trying unpacking again.  I thought there would
be no stochastic element to such a process.  Perhaps the hardware
could introduce a stochastic element.  (This machine is only 3 years
old, but already it's impossible to buy a replacement mobo.)



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

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


Re: [R] Error in ma.svd(X, 0, 0) : 0 extent dimensions

2008-02-24 Thread Uwe Ligges
I guess you don't have any degrees of freedom left ...
How much observations versus how much estimated parameters do you have 
for estimating your model parameters?

Uwe Ligges



Marcelo Luiz de Laia wrote:
 Hi,
 
 I run a maanova analysis and found this message error:
 
 Error in ma.svd(X, 0, 0) : 0 extent dimensions
 
 I did a google search and found this:
 
 \item ma.svd: function to compute the sigular-value decomposition 
 of a rectangular matrix by using LAPACK routines DEGSVD AND ZGESVD.
 \item fdr: function to calculate the adjusted P values for FDR control.
 
 I did a search for LAPACK and not found a package.
 
 Could you help me on how I could solve this problem?
 
 I am try to do this:
 
 library(maanova)
 read the data file and design
 # Make the full model based on the design
 anova.full.mix - fitmaanova(data, formula=~
 Var+ind+Trat+Time+
 Var:ind+Var:Trat+Var:Time+
 ind:Trat+ind:Time+
 Trat:Time+
 Var:ind:Trat+
 Var:ind:Time+
 Sample,random=~Sample)
 
 If I remove the Var:ind:Trat and Var:ind:Time from formula the script runs 
 very
 well.
 
 Did is not possible to do that interactions (Var:ind:Trat and Var:ind:Time)?
 
 What you suggest me to do that?
 
 Thank you very much!
 
 Marcelo
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] rapply on a data.frame

2008-02-24 Thread Michael Hoffman
Is it possible to get something like rapply for a data.frame? For 
example, if I do this:

  x - list(a=mtcars, b=mtcars)
  str(rapply(x, nrow, classes=data.frame, how=replace))
List of 2
  $ a:List of 11
   ..$ mpg : num [1:32] 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
   ..$ cyl : num [1:32] 6 6 4 6 8 6 8 4 4 6 ...
   ..$ disp: num [1:32] 160 160 108 258 360 ...
   ..$ hp  : num [1:32] 110 110 93 110 175 105 245 62 95 123 ...
   ..$ drat: num [1:32] 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
   ..$ wt  : num [1:32] 2.62 2.88 2.32 3.21 3.44 ...
   ..$ qsec: num [1:32] 16.5 17.0 18.6 19.4 17.0 ...
   ..$ vs  : num [1:32] 0 0 1 1 0 1 0 1 1 1 ...
   ..$ am  : num [1:32] 1 1 1 0 0 0 0 0 0 0 ...
   ..$ gear: num [1:32] 4 4 4 3 3 3 3 4 4 4 ...
   ..$ carb: num [1:32] 4 4 1 1 2 1 4 2 2 4 ...
  $ b:List of 11
   ..$ mpg : num [1:32] 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
   ..$ cyl : num [1:32] 6 6 4 6 8 6 8 4 4 6 ...
   ..$ disp: num [1:32] 160 160 108 258 360 ...
   ..$ hp  : num [1:32] 110 110 93 110 175 105 245 62 95 123 ...
   ..$ drat: num [1:32] 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
   ..$ wt  : num [1:32] 2.62 2.88 2.32 3.21 3.44 ...
   ..$ qsec: num [1:32] 16.5 17.0 18.6 19.4 17.0 ...
   ..$ vs  : num [1:32] 0 0 1 1 0 1 0 1 1 1 ...
   ..$ am  : num [1:32] 1 1 1 0 0 0 0 0 0 0 ...
   ..$ gear: num [1:32] 4 4 4 3 3 3 3 4 4 4 ...
   ..$ carb: num [1:32] 4 4 1 1 2 1 4 2 2 4 ...

I was hoping to get something like list(a=11, b=11). I suspect this is 
because the data.frame is actually implemented as a list.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bootstrapping data with a regression model

2008-02-24 Thread Felipe Carrillo
Hello all:
Just wondering if I can get advice on what kind of
bootstrapping I should use when using a regression
model to estimate juvenile fish passage data. I use
rotary screw traps to do fish mark-recapture trials
and the efficiency of every trial is added to the
graph generating a different R-square and equation
everytime. I plot river flows along the X axis and %
trap efficiency along the Y axis. I have read about
the different bootstrapping approaches but I am not
sure how to do it..any help is appreciated.

Felipe D. Carrillo
  Fishery Biologist
  US Fish  Wildlife Service
  California, USA



  

Never miss a thing.  Make Yahoo your home page.

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


Re: [R] Bootstrapping data with a regression model

2008-02-24 Thread Chuck Cleland
On 2/24/2008 4:03 PM, Felipe Carrillo wrote:
 Hello all:
 Just wondering if I can get advice on what kind of
 bootstrapping I should use when using a regression
 model to estimate juvenile fish passage data. I use
 rotary screw traps to do fish mark-recapture trials
 and the efficiency of every trial is added to the
 graph generating a different R-square and equation
 everytime. I plot river flows along the X axis and %
 trap efficiency along the Y axis. I have read about
 the different bootstrapping approaches but I am not
 sure how to do it..any help is appreciated.

   You might check out the the relevant web appendix by John Fox in the 
Contributed Documentation section of CRAN:

http://cran.r-project.org/doc/contrib/Fox-Companion/appendix.html

http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-bootstrapping.pdf

 Felipe D. Carrillo
   Fishery Biologist
   US Fish  Wildlife Service
   California, USA
 
 
 
   
 
 Never miss a thing.  Make Yahoo your home page.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.
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] Newbie: Where is lmFit function?

2008-02-24 Thread Gabor Csardi
It's in the 'limma' Bioconductor package.
Next time you can try

help.search(lmFit)
RSiteSearch(lmFit)

Gabor

On Sun, Feb 24, 2008 at 01:02:41PM -0800, Keizer_71 wrote:
 
 Hi Everyone,
 
 I am trying to use lmFit function; however, i cannot find it function
 anywhere.
 
 I have been trying to find the function in Bioconductor and elsewhere. I
 re-install bioconductor source, update package and update R as well. no luck
 
 Is there a command in R where i can just type, and it will download it for
 me?
 -- 
 View this message in context: 
 http://www.nabble.com/Newbie%3A-Where-is-lmFit-function--tp15669332p15669332.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.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] rapply on a data.frame

2008-02-24 Thread Michael Hoffman
Michael Hoffman wrote:
 Is it possible to get something like rapply for a data.frame?

On second thought, I can do something like this:

happly - function(x, fun) {
   if (class(x) == list) {
 lapply(x, happly, fun)
   } else {
 fun(x)
   }
}

  happly(list(a=list(c=mtcars, d=Titanic), x=mtcars), nrow)
$a
$a$c
[1] 32

$a$d
[1] 4


$x
[1] 32

Better suggestions welcome.

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


Re: [R] Newbie: Where is lmFit function?

2008-02-24 Thread Keizer_71

thank you.



Chuck Cleland wrote:
 
 On 2/24/2008 4:02 PM, Keizer_71 wrote:
 Hi Everyone,
 
 I am trying to use lmFit function; however, i cannot find it function
 anywhere.
 
 I have been trying to find the function in Bioconductor and elsewhere. I
 re-install bioconductor source, update package and update R as well. no
 luck
 
 Is there a command in R where i can just type, and it will download it
 for
 me?
 
RSiteSearch(lmFit) shows there is a function with that name in the 
 limma package.
 
 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-Where-is-lmFit-function--tp15669332p15669414.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Newbie: Where is lmFit function?

2008-02-24 Thread Chuck Cleland
On 2/24/2008 4:02 PM, Keizer_71 wrote:
 Hi Everyone,
 
 I am trying to use lmFit function; however, i cannot find it function
 anywhere.
 
 I have been trying to find the function in Bioconductor and elsewhere. I
 re-install bioconductor source, update package and update R as well. no luck
 
 Is there a command in R where i can just type, and it will download it for
 me?

   RSiteSearch(lmFit) shows there is a function with that name in the 
limma package.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
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] mixed model nested ANOVA (part two)

2008-02-24 Thread Mark Difford

Hi Stephen,

 Also i have read in Quinn and Keough 2002, design and analysis of
 experiments for
 biologists, that a variance component analysis should only be conducted
 after a rejection
 of the null hypothesis of no variance at that level.

Once again the caveat: there are experts on this list who really know about
this stuff, and I am not one of them.  Your general strategy would be to set
up two models with the same fixed effects, one of which doesn't have random
effects.  You then test the two models using anova(mod.withRandom,
modWithoutRandom).

I haven't tried this using lmer/2(), but with lme() you do this by fitting
your fixed+random effects model using lme() and your fixed-only effects
model using lm().  If you are using weights to model heteroskedasticity,
then it's better to use gls(), as this will accept the same weights argument
as the call to lme().

Then you simply do anova(lme.model, lm/gls.model).  This tells you about the
significance of your random effects, i.e. whether you need a random-effects
component.

To recap:
mod.rand - lme(fixed=y ~ x, random=~x|Site, data=...)
mod,fix - lm(fixed=y ~ x, data=...)

anova(mod.rand, mod.fix)

HTH, Mark.


Stephen Cole-2 wrote:
 
 First of all thank you for the responses.  I appreciate the
 suggestions i have received thus far.
 
 Just to reiterate
 
 I am trying to analyze a data set that has been collected from a
 hierarchical sampling design.  The model should be a mixed model
 nested ANOVA.  The purpose of my study is to analyze the variability
 at each spatial scale in my design (random factors, variance
 components), and say something about the variability between regions
 (fixed factor, contrast of means).  The data is as follows;
 
 region (fixed)
 Location (random)
 Site(random)
 
 site nested in location nested in region.
 
 Also i have read in Quinn and Keough 2002, design and analysis of
 experiments for biologists, that a variance component analysis should
 only be conducted after a rejection of the null hypothesis of no
 variance at that level.
 
 I have tried to implement
 mod1-lmer(density ~ 1 + (1|site) + (1|location) + (1|region))
 
 However, as i understand it, this treats all my factors as random.
 Plus I do not know how to extract SS or MS from this model.
 
 anova(mod1) gives me
 Analysis of Variance Table
  Df Sum Sq Mean Sq
 
 and summary(mod1) gives me
 Linear mixed-effects model fit by REML
 Formula: density ~ 1 + (1 | site) + (1 | location) + (1 | region)
AIC   BIC logLik MLdeviance REMLdeviance
  15658 15678  -7825  1566215650
 Random effects:
  Groups   NameVariance Std.Dev.
  site (Intercept)  22191   148.97
  location (Intercept)  33544   183.15
  region   (Intercept)  41412   203.50
  Residual 696189   834.38
 number of obs: 960, groups: site, 4; location, 4; region, 3
 
 Fixed effects:
 Estimate Std. Error t value
 (Intercept)261.3  168.7   1.549
 
 from what i understand the variance in the penultimate column are my
 variance components.  But how do i conduct my significance test?
 
 I have also tried
 mod1-lmer(density ~ region + (1|site) + (1|location))
 
 Which i think is the correct mixed model for my design.  However once
 again i do not know how to evaluate significance for the random
 factors.
 
 Thank-you again for any additional advice i receive
 
 Stephen Cole
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/mixed-model-nested-ANOVA-%28part-two%29-tp15665478p15669384.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] Newbie: Where is lmFit function?

2008-02-24 Thread Keizer_71

Hi Everyone,

I am trying to use lmFit function; however, i cannot find it function
anywhere.

I have been trying to find the function in Bioconductor and elsewhere. I
re-install bioconductor source, update package and update R as well. no luck

Is there a command in R where i can just type, and it will download it for
me?
-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-Where-is-lmFit-function--tp15669332p15669332.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to put n and yprob on the tree plot ----- Re: what missed ----- CART

2008-02-24 Thread Uwe Ligges


o ha wang wrote:
 Thanks!

   Yes, you were right. I loaded package 'tree'.

   I tried 'tree' and 'rpart' respectively, it looks like results for 
 regression tree are same, and very similar for classification tree. (more 
 biref using 'rpart' than using 'tree').

   But my problems are still not been solved using rpart.

   1. how to put number (n, ie. class counts) and probability (yprob) on the 
 plot for classification tree. There are only 0/1 on the plot.  n and yprob 
 can be seen using 'myfit' but not on the plot.

   2. The notation of Numbers are overlapped for regression tree. 

   please see my rpart code:

   library (rpart) 
 myfit - rpart (y ~ x1 + x2 + x3 + x4 ) 
 plot (myfit)); text (myfit, all= TRUE, cex=0.5, pretty=0)
 myfit
   summary(myfit)


I still cannot reproduce without y, x1, x2, x3, x4

Uwe Ligges


 thanks, xiao yue

   
 Uwe Ligges [EMAIL PROTECTED] wrote:
   
 
 o ha wang wrote:
 Hi all,

 Can anyone who is familar with CART tell me what I missed in my tree code? 

 library (MASS) 
 myfit - tree (y ~ x1 + x2 + x3 + x4 ) 
 
 There is not function tree() in MASS. I guess you have loaded package 
 tree?
 Note that the author and maintainer of the tree package suggests to use 
 package rpart instead.
 
 
 
 # tree.screens () # useless
 plot(myfit); text (myfit, all= TRUE, cex=0.5, pretty=0)
 # tile.tree (myfit, fgl$type) # useless
 # close.screen (all= TRUE) # useless


 My current tree plot resulted from above code shows as: 
 1. overlapped #s caused by unsuitable length of branch.
 2. no misclassification rates: 'misclass.tree' only brings up the error of ' 
 misclassification error rate is appropriate for factor responses only', but 
 my response y is 0/1 data.
 
 If you data is 0/1, you should make it a factor otherwise the cose will 
 assume you want a regression rather than a classification tree.
 
 
 3. Unsuitable location of notations: there are not two notation of splitting 
 criteria on the two branches when a node is split, instead only one notation 
 of splitting criteria is on the node location. 
 
 It indicates which items go into the left branch.
 
 Uwe Ligges
 
 
 thanks,
 xiao yue


 -

 [[alternative HTML version deleted]]

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

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

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


Re: [R] mixed model nested ANOVA (part two)

2008-02-24 Thread Mark Difford

Hi Stephen,

Slip of the dactylus: lm() does not, of course, take a fixed=arg.  So you
need

To recap: 
mod.rand - lme(fixed=y ~ x, random=~x|Site, data=...) 
mod,fix - lm(y ~ x, data=...)   ## or
##mod,fix - lm(formula=y ~ x, data=...)

Bye.



Mark Difford wrote:
 
 Hi Stephen,
 
 Also i have read in Quinn and Keough 2002, design and analysis of
 experiments for
 biologists, that a variance component analysis should only be conducted
 after a rejection
 of the null hypothesis of no variance at that level.
 
 Once again the caveat: there are experts on this list who really know
 about this stuff, and I am not one of them.  Your general strategy would
 be to set up two models with the same fixed effects, one of which doesn't
 have random effects.  You then test the two models using
 anova(mod.withRandom, modWithoutRandom).
 
 I haven't tried this using lmer/2(), but with lme() you do this by fitting
 your fixed+random effects model using lme() and your fixed-only effects
 model using lm().  If you are using weights to model heteroskedasticity,
 then it's better to use gls(), as this will accept the same weights
 argument as the call to lme().
 
 Then you simply do anova(lme.model, lm/gls.model).  This tells you about
 the significance of your random effects, i.e. whether you need a
 random-effects component.
 
 To recap:
 mod.rand - lme(fixed=y ~ x, random=~x|Site, data=...)
 mod,fix - lm(fixed=y ~ x, data=...)
 
 anova(mod.rand, mod.fix)
 
 HTH, Mark.
 
 
 Stephen Cole-2 wrote:
 
 First of all thank you for the responses.  I appreciate the
 suggestions i have received thus far.
 
 Just to reiterate
 
 I am trying to analyze a data set that has been collected from a
 hierarchical sampling design.  The model should be a mixed model
 nested ANOVA.  The purpose of my study is to analyze the variability
 at each spatial scale in my design (random factors, variance
 components), and say something about the variability between regions
 (fixed factor, contrast of means).  The data is as follows;
 
 region (fixed)
 Location (random)
 Site(random)
 
 site nested in location nested in region.
 
 Also i have read in Quinn and Keough 2002, design and analysis of
 experiments for biologists, that a variance component analysis should
 only be conducted after a rejection of the null hypothesis of no
 variance at that level.
 
 I have tried to implement
 mod1-lmer(density ~ 1 + (1|site) + (1|location) + (1|region))
 
 However, as i understand it, this treats all my factors as random.
 Plus I do not know how to extract SS or MS from this model.
 
 anova(mod1) gives me
 Analysis of Variance Table
  Df Sum Sq Mean Sq
 
 and summary(mod1) gives me
 Linear mixed-effects model fit by REML
 Formula: density ~ 1 + (1 | site) + (1 | location) + (1 | region)
AIC   BIC logLik MLdeviance REMLdeviance
  15658 15678  -7825  1566215650
 Random effects:
  Groups   NameVariance Std.Dev.
  site (Intercept)  22191   148.97
  location (Intercept)  33544   183.15
  region   (Intercept)  41412   203.50
  Residual 696189   834.38
 number of obs: 960, groups: site, 4; location, 4; region, 3
 
 Fixed effects:
 Estimate Std. Error t value
 (Intercept)261.3  168.7   1.549
 
 from what i understand the variance in the penultimate column are my
 variance components.  But how do i conduct my significance test?
 
 I have also tried
 mod1-lmer(density ~ region + (1|site) + (1|location))
 
 Which i think is the correct mixed model for my design.  However once
 again i do not know how to evaluate significance for the random
 factors.
 
 Thank-you again for any additional advice i receive
 
 Stephen Cole
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/mixed-model-nested-ANOVA-%28part-two%29-tp15665478p15669608.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] how to put n and yprob on the tree plot ----- Re: what missed ----- CART

2008-02-24 Thread o ha wang
Thanks!
   
  Yes, you were right. I loaded package 'tree'.
   
  I tried 'tree' and 'rpart' respectively, it looks like results for regression 
tree are same, and very similar for classification tree. (more biref using 
'rpart' than using 'tree').
   
  But my problems are still not been solved using rpart.
   
  1. how to put number (n, ie. class counts) and probability (yprob) on the 
plot for classification tree. There are only 0/1 on the plot.  n and yprob can 
be seen using 'myfit' but not on the plot.
   
  2. The notation of Numbers are overlapped for regression tree. 
   
  please see my rpart code:
   
  library (rpart) 
myfit - rpart (y ~ x1 + x2 + x3 + x4 ) 
plot (myfit)); text (myfit, all= TRUE, cex=0.5, pretty=0)
myfit
  summary(myfit)
  
thanks, xiao yue
   
  
Uwe Ligges [EMAIL PROTECTED] wrote:
  

o ha wang wrote:
 Hi all,
 
 Can anyone who is familar with CART tell me what I missed in my tree code? 
 
 library (MASS) 
 myfit - tree (y ~ x1 + x2 + x3 + x4 ) 

There is not function tree() in MASS. I guess you have loaded package 
tree?
Note that the author and maintainer of the tree package suggests to use 
package rpart instead.



 # tree.screens () # useless
 plot(myfit); text (myfit, all= TRUE, cex=0.5, pretty=0)
 # tile.tree (myfit, fgl$type) # useless
 # close.screen (all= TRUE) # useless
 
 
 My current tree plot resulted from above code shows as: 
 1. overlapped #s caused by unsuitable length of branch.
 2. no misclassification rates: 'misclass.tree' only brings up the error of ' 
 misclassification error rate is appropriate for factor responses only', but 
 my response y is 0/1 data.

If you data is 0/1, you should make it a factor otherwise the cose will 
assume you want a regression rather than a classification tree.


 3. Unsuitable location of notations: there are not two notation of splitting 
 criteria on the two branches when a node is split, instead only one notation 
 of splitting criteria is on the node location. 

It indicates which items go into the left branch.

Uwe Ligges


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


   
-

[[alternative HTML version deleted]]

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


[R] Color of CI bars in Hmisc::Dotplot()

2008-02-24 Thread Michael Kubovy
Dear R-helpers,

(1) I can't figure out how to tell Dotplot that I want the colors of  
the CI bars to be the same as the colors of the dots.

For example:
t2a.ci3 - data.frame(est = c(7, 20, 75), lower = c(-9, 0.5, 42),  
upper = c(22, 39, 109))
mypal - c('skyblue3', 'mistyrose3')
condNames - c('noise', 'horn', 'marimba')
Dotplot(1:2 ~ Cbind(est, lower, upper), data = t2a.ci3,
scales = list(y = list(at = 1:2, labels = condNames)),
ylab = '',
xlab = 'rated duration', aspect = 0.2,
ylim = c(0.5, 2.5), panel = function(x, y){
panel.Dotplot(
x, y, col = mypal[c(1, 2)],
col.segments = mypal[c(1, 2)])
panel.abline(v = 50, col.line = 'red', lty = 2)}
)

My guess was col.segments but that doesn't do the trick.

(2) How do I insure that as I change the number of lines and  ylim I  
just change the the height of the y-axis, keep the distance between  
horizontal lines constant, and do not add white space above and below  
the figure? This shows how white space changes:

Dotplot(1:3 ~ Cbind(est, lower, upper), data = t2a.ci3,
scales = list(y = list(at = 1:3, labels = condNames)),
ylab = '',
xlab = 'rated duration', aspect = 0.3,
ylim = c(0.5, 3.5), panel = function(x, y){
panel.Dotplot(
x, y, col = mypal[c(1, 2, 1)],
col.segments = mypal[c(1, 2, 1)])
panel.abline(v = 50, col.line = 'red', lty = 2)}
)

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

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


Re: [R] mixed model nested ANOVA (part two)

2008-02-24 Thread S Ellison
 Also i have read in Quinn and Keough 2002, design and analysis of
 experiments for
 biologists, that a variance component analysis should only be conducted
 after a rejection
 of the null hypothesis of no variance at that level.

Hmmm...

This does rather assume that 'no significant result' means 'near-zero variance 
contribution'.

These are not identical statements if the anova has low power; an 
'insignificant' term can conceal practically important sizes of effect. So if 
you have a smallish number of groups (say, ten or less) you might want to find 
out what that estimated between-group variance could have been before you throw 
it away. That's especially important if you're expecting to say something about 
standard errors or confidence intervals of fixed effects. 

I may well be biased, here, though. In the kinds of nested design I get 
involved in (often inter-laboratory or homogeneity studies in chemistry), there 
is nearly always a between-group  effect; the only question is its size. Under 
those circumstances, the null hypothesis is not a particularly compelling 
starting point.  I'd rather have a variance component estimate and know how 
vague it was than assume it wasn't there at all.

But if you have good power and a good reason for believing there's no case to 
answer, sure; assume zero unless proven otherwise.

S


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


[R] Jitter in correlation matrix?

2008-02-24 Thread Mehmet Atif Ergun
Hi,

I am just starting to use R for a graduate course, and I like how the
correlation matrix at
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=137

I did something similar by copying from the examples(pairs), but it
seems that I need to jitter the bottom panel...  and I have no idea how
to do that, and I mean no idea at all. I'd appreciate any help... 

Here are the graphs: 
http://socy602.pbwiki.com/f/dep_correlationmatrix.jpeg
http://socy602.pbwiki.com/f/indep_correlationmatrix.jpeg

And this is the code I used to produce the graphs (not that I
understand it, but):

##
# Primary Component Analyses
##

##
# Dependent variables
##

# List of these variables: 
#  langfamr , ethdifxx , catness , gc7 , gc8r , gc12 , culdifxx , poldifxx , 
ecdifxx 
##
# Look at correlation matrix for these
cor(MAR[,c(langfamr , ethdifxx , catness , gc7 , gc8r , gc12 , 
culdifxx , poldifxx , ecdifxx )], use=complete.obs)
# Big time correlation matrix
 panel.cor - function(x, y, digits=2, prefix=, cex.cor)
{
usr - par(usr); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r - abs(cor(x, y))
txt - format(c(r, 0.123456789), digits=digits)[1]
txt - paste(prefix, txt, sep=)
if(missing(cex.cor)) cex - 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex * r)
}
MAR.omitdep - na.omit(MAR[,c(langfamr , ethdifxx , catness , gc7 , 
gc8r , gc12 , culdifxx , poldifxx , ecdifxx )])
pairs(MAR.omitdep[,c(langfamr , ethdifxx , catness , gc7 , gc8r , 
gc12 , culdifxx , poldifxx , ecdifxx )], lower.panel=panel.smooth, 
upper.panel=panel.cor)
# Save it
dev.copy(jpeg,filename=dep_correlationmatrix.jpeg,height=600, 
width=800,bg=white)
dev.off()

##
# Independent variables
##

# List of variables
#  poldis , polres , ecdis , culres , gcc1 
##
# Look at the correlation matrix
cor(MAR[,c(poldis , polres , ecdis , culres , gcc1 )], 
use=complete.obs)
# Big time correlation matrix
 panel.cor - function(x, y, digits=2, prefix=, cex.cor)
{
usr - par(usr); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r - abs(cor(x, y))
txt - format(c(r, 0.123456789), digits=digits)[1]
txt - paste(prefix, txt, sep=)
if(missing(cex.cor)) cex - 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex * r)
}
MAR.omitindep - na.omit(MAR[,c(poldis , polres , ecdis , culres , 
gcc1 )])
pairs(MAR.omitindep[,c(poldis , polres , ecdis , culres , gcc1 )], 
lower.panel=panel.smooth, upper.panel=panel.cor)
# Save it
dev.copy(jpeg,filename=indep_correlationmatrix.jpeg,height=600, 
width=800,bg=white)
dev.off()

Thanks a lot in advance,
Sincerely,
Mehmet.

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

2008-02-24 Thread Christophe Genolini
Hi the list

Is it possible to define a method with a signature that will have more 
argument than the generic method?
For exemple, print has only one argument, plot has two, can I do 
something like :

setMethod(print,signature=c(x=numeric,y=character),function(x,y,...) 
..
setMethod(plot,signature=c(x=numeric,y=character,z=numeric),function(x,y,z,...)
 
..

Thanks

Christophe

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


[R] color area between two time-series via polygon()?

2008-02-24 Thread Jan.Verbesselt
Hi all,

 

I would like to color the area between two time-series. I tried it by
using the polygon() function but I keeps drawing lines between beginning
and end points.

Is there another more appropriate function or how could I close the
polygon at the end en the beginning of the time series (e.g., drawing a
straight line)?

 

The following doesn't plot a polygon between the two time-series:

z - ts(matrix(rnorm(200), 100), start=c(1961, 1), frequency=12)

plot(z, plot.type=single, lty=1:2)

xx - cbind(time(z[,1]),rev(z[,2]))

yy - cbind(as.vector(z[,1]),rev(as.vector(z[,2])))

polygon(xx,yy, col=gray, border = red)

 

I would like to make it look like this (but then for time series)

n - 100
xx - c(0:n, n:0)
yy - c(c(0,cumsum(stats::rnorm(n))), rev(c(0,cumsum(stats::rnorm(n)
plot   (xx, yy, type=n, xlab=Time, ylab=Distance)
polygon(xx, yy, col=gray, border = red)

 

Thanks for your help,

Jan

 


[[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] A more idiomatic way to write this

2008-02-24 Thread Andre Nathan
Hello,

I have a vector of 1,000,000 numbers and another vector of 1,000
divisors. What I'd like to do is to divide the first 1,000 numbers of
the first vector by the first divisor, then the next 1,000 by the second
divisor and so on. I came up with this, but I was wondering if there is
a more idiomatic, R-like way to write it:

x - ...
divs - ...

for (i in seq(from = 1, to = 100, by = 1000)) {
  x[i:(i - 1 + 1000)] - x[i:(i - 1 + 1000)] / divs[i %/% 1000 + 1]
}

Any suggestions are welcome.

Thanks in advance,
Andre

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 more idiomatic way to write this

2008-02-24 Thread Rolf Turner

x/rep(divs,each=1000)

cheers,

Rolf Turner

On 25/02/2008, at 2:36 PM, Andre Nathan wrote:

 Hello,

 I have a vector of 1,000,000 numbers and another vector of 1,000
 divisors. What I'd like to do is to divide the first 1,000 numbers of
 the first vector by the first divisor, then the next 1,000 by the  
 second
 divisor and so on. I came up with this, but I was wondering if  
 there is
 a more idiomatic, R-like way to write it:

 x - ...
 divs - ...

 for (i in seq(from = 1, to = 100, by = 1000)) {
   x[i:(i - 1 + 1000)] - x[i:(i - 1 + 1000)] / divs[i %/% 1000 + 1]
 }

 Any suggestions are welcome.

 Thanks in advance,
 Andre

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


##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 more idiomatic way to write this

2008-02-24 Thread Bill.Venables
x - x/rep(divs, each = 1000) 


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Andre Nathan
Sent: Monday, 25 February 2008 11:36 AM
To: r-help@r-project.org
Subject: [R] A more idiomatic way to write this

Hello,

I have a vector of 1,000,000 numbers and another vector of 1,000
divisors. What I'd like to do is to divide the first 1,000 numbers of
the first vector by the first divisor, then the next 1,000 by the second
divisor and so on. I came up with this, but I was wondering if there is
a more idiomatic, R-like way to write it:

x - ...
divs - ...

for (i in seq(from = 1, to = 100, by = 1000)) {
  x[i:(i - 1 + 1000)] - x[i:(i - 1 + 1000)] / divs[i %/% 1000 + 1]
}

Any suggestions are welcome.

Thanks in advance,
Andre

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 more idiomatic way to write this

2008-02-24 Thread Andrew Robinson
How about

x - x / rep(divs, rep(1000, 1000))

?

Cheers,

Andrew


On Sun, Feb 24, 2008 at 10:36:23PM -0300, Andre Nathan wrote:
 Hello,
 
 I have a vector of 1,000,000 numbers and another vector of 1,000
 divisors. What I'd like to do is to divide the first 1,000 numbers of
 the first vector by the first divisor, then the next 1,000 by the second
 divisor and so on. I came up with this, but I was wondering if there is
 a more idiomatic, R-like way to write it:
 
 x - ...
 divs - ...
 
 for (i in seq(from = 1, to = 100, by = 1000)) {
   x[i:(i - 1 + 1000)] - x[i:(i - 1 + 1000)] / divs[i %/% 1000 + 1]
 }
 
 Any suggestions are welcome.
 
 Thanks in advance,
 Andre
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

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


Re: [R] color area between two time-series via polygon()?

2008-02-24 Thread jim holtman
I think you have to change one statement in your program:

 xx - cbind(time(z[,1]),rev(time(z[,2])))



On Sun, Feb 24, 2008 at 7:44 PM,  [EMAIL PROTECTED] wrote:
 Hi all,



 I would like to color the area between two time-series. I tried it by
 using the polygon() function but I keeps drawing lines between beginning
 and end points.

 Is there another more appropriate function or how could I close the
 polygon at the end en the beginning of the time series (e.g., drawing a
 straight line)?



 The following doesn't plot a polygon between the two time-series:

 z - ts(matrix(rnorm(200), 100), start=c(1961, 1), frequency=12)

 plot(z, plot.type=single, lty=1:2)

 xx - cbind(time(z[,1]),rev(z[,2]))

 yy - cbind(as.vector(z[,1]),rev(as.vector(z[,2])))

 polygon(xx,yy, col=gray, border = red)



 I would like to make it look like this (but then for time series)

 n - 100
 xx - c(0:n, n:0)
 yy - c(c(0,cumsum(stats::rnorm(n))), rev(c(0,cumsum(stats::rnorm(n)
 plot   (xx, yy, type=n, xlab=Time, ylab=Distance)
 polygon(xx, yy, col=gray, border = red)



 Thanks for your help,

 Jan




[[alternative HTML version deleted]]

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




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

What is the problem you are trying to solve?  Tell me what you want to
do, not how you want to do 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.


[R] How do I use as.Date when day values are missing?

2008-02-24 Thread Anupa Fabian
I have a data frame which contains some valuable date information. But for a 
few of the dates, the day information missing .

Viz:
 interesting.data$date 
[1] 1/22/93 1/22/93 1/23/93 1/00/93 1/28/93 1/31/93 1/12/93

i.e. for dates where the day info is missing, the %d part of the %m/%d/%yy 
format is simply represented as 00.

When I apply as.Date to the date information, the dates which don't contain 
exact day information are converted to NA.

Viz:
 as.Date(interesting.data$date)
[1] 1993-01-22 1993-01-22 1993-01-23 NA 1993-01-28 1993-01-31 
1993-01-12

Is there a way of using the as.Date function when I only have partial dates (eg 
missing day information  which is represented as 00, as above) such
 that the date isn't represented as NA?

Thanks, 
Anupa







  

Never miss a thing.  Make Yahoo your home page. 

[[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 more idiomatic way to write this

2008-02-24 Thread Andre Nathan
On Mon, 2008-02-25 at 11:52 +1000, [EMAIL PROTECTED] wrote:
 x - x/rep(divs, each = 1000) 

Fantastic :)

Thanks Bill, Andrew and Rolf

Andre

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


Re: [R] Geometric progression

2008-02-24 Thread Andre Nathan
On Sun, 2008-02-24 at 23:26 -0300, Andre Nathan wrote:
  gp(1, 2, 10)
  [1]1248   16   32   64  128  256  512 1024
 

Actually,

[1]1248   16   32   64  128  256  512


Andre

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


Re: [R] Geometric progression

2008-02-24 Thread Charilaos Skiadas
On Feb 24, 2008, at 9:36 PM, Andre Nathan wrote:

 On Sun, 2008-02-24 at 23:26 -0300, Andre Nathan wrote:
 gp(1, 2, 10)
  [1]1248   16   32   64  128  256  512 1024


 Actually,

 [1]1248   16   32   64  128  256  512


2^(0:9)


 Andre

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 do I use as.Date when day values are missing?

2008-02-24 Thread Gabor Grothendieck
It really depends on what you want to do with them but one possibility
might be to represent them as chron dates and use a time of 0 for true dates
and noon for missing dates replacing the missing day with 01 or 15 or some
other day:

 library(chron)
 x - c(01/00/05, 01/22/06)
 no.day - regexpr(/00/, x)  0
 as.chron(ifelse(no.day, sub(/00/, /15/, x), x )) + no.day/2
[1] (01/15/05 12:00:00) (01/22/06 00:00:00)

We can then tell which have the incomplete dates with as.numeric(xx) %% 1  0


On Sun, Feb 24, 2008 at 9:00 PM, Anupa Fabian [EMAIL PROTECTED] wrote:
 I have a data frame which contains some valuable date information. But for a 
 few of the dates, the day information missing .

 Viz:
  interesting.data$date
 [1] 1/22/93 1/22/93 1/23/93 1/00/93 1/28/93 1/31/93 1/12/93

 i.e. for dates where the day info is missing, the %d part of the 
 %m/%d/%yy format is simply represented as 00.

 When I apply as.Date to the date information, the dates which don't contain 
 exact day information are converted to NA.

 Viz:
  as.Date(interesting.data$date)
 [1] 1993-01-22 1993-01-22 1993-01-23 NA 1993-01-28 1993-01-31 
 1993-01-12

 Is there a way of using the as.Date function when I only have partial dates 
 (eg missing day information  which is represented as 00, as above) such
  that the date isn't represented as NA?

 Thanks,
 Anupa







  
 
 Never miss a thing.  Make Yahoo your home page.

[[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] Geometric progression

2008-02-24 Thread Andre Nathan
On Sun, 2008-02-24 at 21:39 -0500, Charilaos Skiadas wrote:
 2^(0:9)

I guess it's so simple that I'd never think of that...

Thanks!

Andre

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

2008-02-24 Thread Andre Nathan
Hi

I'm pretty sure there's some built-in function to do the equivalent of
this, but I couldn't find one anywhere:

gp - function(init, mult, n)
{ 
  if (n == 1)
init
  else
pg(c(init, init[length(init)] * mult), mult, n-1)
}

 gp(1, 2, 10)
 [1]1248   16   32   64  128  256  512 1024

Any pointers?

Thanks,
Andre

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 do I use as.Date when day values are missing?

2008-02-24 Thread Gabor Grothendieck
In looking at this again here is a slight simplification.  Its now
only one line:

 library(chron)
 x - c(01/00/05, 01/22/06)
 as.chron(sub(/00/, /15/, x)) + (regexpr(/00/, x)  0) / 2
[1] (01/15/05 12:00:00) (01/22/06 00:00:00)


On Sun, Feb 24, 2008 at 9:45 PM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 It really depends on what you want to do with them but one possibility
 might be to represent them as chron dates and use a time of 0 for true dates
 and noon for missing dates replacing the missing day with 01 or 15 or some
 other day:

  library(chron)
  x - c(01/00/05, 01/22/06)
  no.day - regexpr(/00/, x)  0
  as.chron(ifelse(no.day, sub(/00/, /15/, x), x )) + no.day/2
 [1] (01/15/05 12:00:00) (01/22/06 00:00:00)

 We can then tell which have the incomplete dates with as.numeric(xx) %% 1  0



 On Sun, Feb 24, 2008 at 9:00 PM, Anupa Fabian [EMAIL PROTECTED] wrote:
  I have a data frame which contains some valuable date information. But for 
  a few of the dates, the day information missing .
 
  Viz:
   interesting.data$date
  [1] 1/22/93 1/22/93 1/23/93 1/00/93 1/28/93 1/31/93 1/12/93
 
  i.e. for dates where the day info is missing, the %d part of the 
  %m/%d/%yy format is simply represented as 00.
 
  When I apply as.Date to the date information, the dates which don't contain 
  exact day information are converted to NA.
 
  Viz:
   as.Date(interesting.data$date)
  [1] 1993-01-22 1993-01-22 1993-01-23 NA 1993-01-28 1993-01-31 
  1993-01-12
 
  Is there a way of using the as.Date function when I only have partial dates 
  (eg missing day information  which is represented as 00, as above) such
   that the date isn't represented as NA?
 
  Thanks,
  Anupa
 
 
 
 
 
 
 
   
  
  Never miss a thing.  Make Yahoo your home page.
 
 [[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] projection.matrix() {popbio} for more than one matrix

2008-02-24 Thread Chris Stubben

Michelle,

I would probably run a loop as well and save all matrices to a single list
(see hudsonia and calathea on working with lists of matrices).

First, run the example(test.census) to get the stage-fate data frame trans
and then run this code to save the matrices into a list all.

years-2001:2002   #or unique(trans$year)
all-vector(list, length(years) )
names(all)-years

## loop through years
for (s.year in years)
{
   ## Add individual fertilities 
   test.trans - subset(trans, year==s.year)
   seedlings-nrow(subset(test.census, year==s.year+1  stage==seedling))
   test.trans$seedling-test.trans$fruits/sum(test.trans$fruits) * seedlings
## save test.trans to another list if needed for bootstrapping,
calculating pooled matrix etc.
## test.trans  
 
   ## either one will work to get list index 
   all[[as.character(s.year)]] -projection.matrix(test.trans)
   ##all[[ s.year- (years[1]-1) ]]  -projection.matrix(test.trans)

}

all


$`2001`
  
   seedling vegetative reproductive
  seedling  0.00.0   1.6667
  vegetative0.50.5   0.
  reproductive  0.00.5   0.6667

$`2002`
  
   seedling vegetative reproductive
  seedling  0.00.0   0.6667
  vegetative0.20.5   0.
  reproductive  0.00.0   0.



There's also a loop in the demo(fillmore) example that uses the aq.census
data to create matrices for seven years.


Chris





Michelle DePrenger-Levin wrote:
 
 Hello,
 
  
 
 I am trying to use the projection.matrix( ) function and am following the
 example given. I have my data formatted very similar to the test.census
 example. 
 
  
 
 str(AsMi05mat)
 
 `data.frame':   1854 obs. of  6 variables:
 
  $ Tag  : num  501 502 503 504 505 506 507 508 509 510 ...
 
  $ Year : int  1995 1995 1995 1995 1995 1995 1995 1995 1995 1995 ...
 
  $ Length   : num  34 37 11 24 7 44 4 7 12 20 ...
 
  $ Flowering: int  1 1 0 1 0 1 0 0 0 1 ...
 
  $ Fruits   : int  22 22 0 89 0 15 0 0 0 0 ...
 
  $ Stage: Factor w/ 5 levels ,Dead,Dormant,..: 4 4 5 4 5 4 5 5 5
 4
 ...
 
  
 
 The example data includes three years but only shows how to create a
 matrix
 from year 1 to 2. I have 13 years of data and would like to automate
 creating
 all matrices for each pair of years. 
 
  
 
 I tried a for( ) loop but don't know how to assign new names for each
 matrix
 so end up with only the final comparison (2005 to 2006). I assume an
 apply( )
 function is the way to go but can't see how to do it. 
 
  
 
 Thanks for any help!
 
  
 
 Michelle
 
  
 
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/projection.matrix%28%29-%7Bpopbio%7D-for-more-than-one-matrix-tp15646115p15673408.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] including data frames in R packages

2008-02-24 Thread dxc13

useR's,

Does any one know if there is a size limitation on the data frames that can
be included in R packages.  I have a data set in a text file that I would
like to include in a package I am building and it is 8.5 MB in size.  Will
this be problematic?  Is the process for including data sets in packages
documented in WRE?

Thanks,
dxc
-- 
View this message in context: 
http://www.nabble.com/including-data-frames-in-R-packages-tp15672705p15672705.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] Plotting series marked with a symbol on every nth data point, preferably in ggplot...

2008-02-24 Thread Tribo Laboy
Hello!

I am working with signals and a plot of several signals on the same
axes can get quite messy. With lines that are very fractured,
distinction by only the linestyle is not very clear. If I add symbols
to the plot however, there are so many symbols, that they overplot and
the whole plot is unreadable once again. I am looking for advice on
how to make a plot with continuous lines and symbols appearing at
every  nth point. An example of this problem and a solution in SAS can
be found here:
www2.sas.com/proceedings/sugi26/p072-26.pdf

The obvious solution would be to extract the n-th point from the
dataset and overplot as a new line with symbols, but this does not
change the legend, does it? How can I then have a line+symbol in the
legend represent my curve?

Now, ideally I would prefer a solution in ggplot, because of the ease
of plotting and changing the plot labels and other properties.
However, I  remember, Hadley mentioned that he is still working on a
new version to have combined line+symbol plots, and probably he hasn't
finished that yet. So any advice is welcome.

Regards,

TL

PS. I did RTFM and I am not posting code, because at this time I
expect a general outline how to do it and what commands to lookup, not
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] Plotting series marked with a symbol on every nth data point, preferably in ggplot...

2008-02-24 Thread Gabor Grothendieck
Try this:

pch - c(+, ); lwd - 1
plot(1:10, type = o, pch = pch, lwd = lwd)
legend(topleft, legend = data, pch = pch, lwd = lwd)


On Sun, Feb 24, 2008 at 11:01 PM, Tribo Laboy [EMAIL PROTECTED] wrote:
 Hello!

 I am working with signals and a plot of several signals on the same
 axes can get quite messy. With lines that are very fractured,
 distinction by only the linestyle is not very clear. If I add symbols
 to the plot however, there are so many symbols, that they overplot and
 the whole plot is unreadable once again. I am looking for advice on
 how to make a plot with continuous lines and symbols appearing at
 every  nth point. An example of this problem and a solution in SAS can
 be found here:
 www2.sas.com/proceedings/sugi26/p072-26.pdf

 The obvious solution would be to extract the n-th point from the
 dataset and overplot as a new line with symbols, but this does not
 change the legend, does it? How can I then have a line+symbol in the
 legend represent my curve?

 Now, ideally I would prefer a solution in ggplot, because of the ease
 of plotting and changing the plot labels and other properties.
 However, I  remember, Hadley mentioned that he is still working on a
 new version to have combined line+symbol plots, and probably he hasn't
 finished that yet. So any advice is welcome.

 Regards,

 TL

 PS. I did RTFM and I am not posting code, because at this time I
 expect a general outline how to do it and what commands to lookup, not
 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] To get more digits in precision of predict function of randomForests

2008-02-24 Thread Nagu
Hi,

I am using randomForests for a classification problem. The predict
function in the randomForest library, when asked to return the
probabilities, has precision of two digits after the decimal. I need
at least four digits of precision for the predicted probabilities. How
do I achieve this?

Thank you,
Nagu

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

2008-02-24 Thread Sungsu
  Dear R users.

  I have written my R code. It runs in the version
  2.3.1, but not in the version 2.5.1. The error
  message is shown below.

  Error in .Fortran(DEPTH, u, v, as.integer(size),
  as.single(x), as.single(y),  :
  Fortran symbol name depth not in load
  table

  Could any one advise me what I could do to run my
  code in 2.5.1?

   

Sincerely,
 
 SUNGSU KIM

[[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] Odp: version 2.5.1 and version 2.3.1

2008-02-24 Thread Petr PIKAL
Hi

I can not help you to run your code in R 2.5.1 but I would recommend to 
use even more recent R version (2.6.1) or even maybe R 2.7.0.

Regards
Petr
[EMAIL PROTECTED]

[EMAIL PROTECTED] napsal dne 25.02.2008 06:18:10:

   Dear R users.
 
   I have written my R code. It runs in the version
   2.3.1, but not in the version 2.5.1. The error
   message is shown below.
 
   Error in .Fortran(DEPTH, u, v, as.integer(size),
   as.single(x), as.single(y),  :
   Fortran symbol name depth not in load
   table
 
   Could any one advise me what I could do to run my
   code in 2.5.1?
 
 
 
 Sincerely, 
 
  SUNGSU KIM
 
[[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] Plotting series marked with a symbol on every nth data point, preferably in ggplot...

2008-02-24 Thread Tribo Laboy
Hello Gabor and Charilaos

Thanks for the help. I did not realize that the legend argument can
take both the symbol and the line. Following your suggestions I have
come with the code that follows.

I realized that I can use the 'legend' function to draw over ggplot2
produced plot, so that is a good start, but I am not quite sure how to
prepare the data and plot it in ggplot. If I use print with option
pretty = FALSE on the object produced by ggplot, it displays the graph
without legend, so I can overlay the legend from traditional graphics.
This option (pretty = FALSE), however, also removes the X-label and
Y-label from the plot.

Thanks again.

Maybe someone can help with the ggplot version of this thing?

Regards,

TL.


#---START CODE SNIPPET---

#-
#Try traditional graphics first
#-
#   1 . Generate signal-like data
#
x1 - c(26:300)
y1- sin(0.1*x1) + rnorm(275,mean = 0,sd = 0.1);
x2 - c(1:350)
y2-sin(0.1*x2+10) + rnorm(350,mean = 0,sd = 0.1);
x3 - c(41:280)
y3-sin(0.1*x3+30) + rnorm(240,mean = 0,sd = 0.1);



#   2 . Plot the three signals (and symbols)
#
# How many points to skip:
N = 15;


# Draw empty axes with limits and labels
plot(NA, NA,type=n, xlim = c(0,400),ylim = c(-1.5,1.5),xlab
=Time,ylab =Amplitude )

# Draw the lines
pch1 - c(15,rep(NA,N));
pch2 - c(16,rep(NA,N));
pch3 - c(17,rep(NA,N));
lines(x1, y1, type = o, col = red, pch=pch1, cex=1.5, lwd=1.5, lty=1);
lines(x2, y2, type = o, col = green, pch = pch2, cex=1.5, lwd=1.5, lty=2)
lines(x3, y3, type = o, col = blue, pch = pch3, cex=1.5, lwd=1.5, lty=3)

#
#   4 . Add the legend
#
legend(topright,col=c(red,green,blue), pch=c(15,16,17),
lty=c(1,2,3), legend=c(series 1, series 2, series 3),
inset=0.05, bg='white')

#-
#Try the same thing with GGPLOT
#-

dataset - rbind(data.frame(Test = Test 1, x = x1, y = y1),
 data.frame(Test = Test 2, x = x2, y = y2),
 data.frame(Test = Test 3, x = x3, y = y3));


#   2 . Plot the three signals (and every point as a symbol)
#

ggp - ggplot(data = dataset, aes(x = x, y = y, colour = Test),) + geom_line() +
geom_point()
print(ggp,pretty = FALSE)  #Do not plot the legend, but this also
removes the x and y labels

#
#   4 . Add the legend   (Traditional graphics) over the GGPLOT
#
legend(topright,col=c(red,green,blue), pch=c(15,16,17),
lty=c(1,2,3), legend=c(Test 1, Test 2, Test 3), inset=0.05,
bg='white')



#--END CODE SNIPPET---



On Mon, Feb 25, 2008 at 2:05 PM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 Try this:

  pch - c(+, ); lwd - 1
  plot(1:10, type = o, pch = pch, lwd = lwd)
  legend(topleft, legend = data, pch = pch, lwd = lwd)




  On Sun, Feb 24, 2008 at 11:01 PM, Tribo Laboy [EMAIL PROTECTED] wrote:
   Hello!
  
   I am working with signals and a plot of several signals on the same
   axes can get quite messy. With lines that are very fractured,
   distinction by only the linestyle is not very clear. If I add symbols
   to the plot however, there are so many symbols, that they overplot and
   the whole plot is unreadable once again. I am looking for advice on
   how to make a plot with continuous lines and symbols appearing at
   every  nth point. An example of this problem and a solution in SAS can
   be found here:
   www2.sas.com/proceedings/sugi26/p072-26.pdf
  
   The obvious solution would be to extract the n-th point from the
   dataset and overplot as a new line with symbols, but this does not
   change the legend, does it? How can I then have a line+symbol in the
   legend represent my curve?
  
   Now, ideally I would prefer a solution in ggplot, because of the ease
   of plotting and changing the plot labels and other properties.
   However, I  remember, Hadley mentioned that he is still working on a
   new version to have combined line+symbol plots, and probably he hasn't
   finished that yet. So any advice is welcome.
  
   Regards,
  
   TL
  
   PS. I did RTFM and I am not posting code, because at this time I
   expect a general outline how to do it and what commands to lookup, not
   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] Course: STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R

2008-02-24 Thread BXC (Bendix Carstensen)
Course in
 
STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R



Tartu, Estonia, Wednesday 28 May to Monday 2 June 2008.

Aimed at young statisticians and epidemiologists wishing to broaden
their epidemiological skills, in particular with respect to practical
statistical analysis. Participants will gain access to the versatile
analysis tool R which has good analytical in particular graphical 
capabilities. The Epi-package for R will be extensively used.

Participants are required to have a fairly good understanding of
statistical principles and some familiarity with epidemiological
concepts. The course will be mainly practically oriented with more
than half the time at the computer.

Price: Commercial: 1000 EUR, Academic: 750 EUR / 500 EUR.
The 750 EUR are for particpants from the EU pre-2004, North America
and the like. 500 for particants from other countries.

Application deadline: 15 April 2004.

Send an application by mail to the organizers, briefly stating your
qualifications in epidemiology and statistics and a brief reason to
participate: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]

Further information at the course homepage: www.biostat.ku.dk/~bxc/SPE

--
Krista Fischer, University of Tartu, Estonia
Esa Läärä, University of Oulu, Finland
Bendix Carstensen, Steno Diabetes Center, Denmark 
(Organizers)

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