[R] Populate matrix from data.frame

2007-06-28 Thread Andrej Kastrin
Dear all,

I have a data frame
a - data.frame(cbind(x=c('a','a','a','b','c'), 
y=c('a','b','c','d','e'),z=c(1,2,3,4,5)))
  a
  x y z
1 a a 1
2 a b 2
3 a c 3
4 b d 4
5 c e 5

and a matrix
mm - matrix(0,5,5)
colnames(mm) - c('a','b','c','d','e')
rownames(mm) - c('a','b','c','d','e')
  mm
  a b c d e
a 0 0 0 0 0
b 0 0 0 0 0
c 0 0 0 0 0
d 0 0 0 0 0
e 0 0 0 0 0

How to populate matrix in a way that first column of data frame 'a' 
correspond to rownames(mm), second column to colnames(mm) and the third 
column is the element of matrix 'mm'?

Thanks in advance,
Andrej

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


Re: [R] no applicable method

2007-06-28 Thread Prof Brian Ripley
On Wed, 27 Jun 2007, Kyle Ellrott wrote:

 I'm getting started in R, and I'm trying to use one of the gradient
 boosting packages, mboost.  I'm already installed the package with
 install.packages(mboost) and loaded it with library(mboost).
 My problem is that when I attempt to call glmboost, I get a message
 that  Error in glmboost() : no applicable method for glmboost .
 Does anybody have an idea of what kind of problem this is indicative of?

The wrong class of input object 'x'.  The help page for glmboost is 
written obscurely, but it seems to imply that it has methods for 'formula' 
and 'matrix'.

Perhaps you passed a data frame?

 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

is pertinent.  With an example and its output we would have been much 
better placed to help you.

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

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


Re: [R] Populate matrix from data.frame

2007-06-28 Thread Prof Brian Ripley
On Thu, 28 Jun 2007, Andrej Kastrin wrote:

 Dear all,

 I have a data frame
 a - data.frame(cbind(x=c('a','a','a','b','c'),
 y=c('a','b','c','d','e'),z=c(1,2,3,4,5)))
  a
  x y z
 1 a a 1
 2 a b 2
 3 a c 3
 4 b d 4
 5 c e 5

 and a matrix
 mm - matrix(0,5,5)
 colnames(mm) - c('a','b','c','d','e')
 rownames(mm) - c('a','b','c','d','e')
  mm
  a b c d e
 a 0 0 0 0 0
 b 0 0 0 0 0
 c 0 0 0 0 0
 d 0 0 0 0 0
 e 0 0 0 0 0

 How to populate matrix in a way that first column of data frame 'a'
 correspond to rownames(mm), second column to colnames(mm) and the third
 column is the element of matrix 'mm'?

mm[cbind(a$x, a$y)] - a$z

Please read about the forms of indexing matrices in 'An Introduction to 
R'.

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

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


[R] : regular expressions: escaping a dot

2007-06-28 Thread Wolfram Fischer
What's really the problem with:

 regexpr( '\.odt$', Yodt, perl=TRUE )
Warning: '\.' is an unrecognized escape in a character string
Warning: unrecognized escape removed from \.odt$
[1] 5
attr(,match.length)
[1] 4

I know that I could use:
 regexpr( '[.]odt$', Yodt, perl=TRUE )

But it seems to me that the first expression is also
an accepted regular expression in accordance with perl.

Regards - Wolfram

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


Re: [R] : regular expressions: escaping a dot

2007-06-28 Thread Tobias Verbeke
Wolfram Fischer wrote:

 What's really the problem with:
 
 regexpr( '\.odt$', Yodt, perl=TRUE )
   Warning: '\.' is an unrecognized escape in a character string
   Warning: unrecognized escape removed from \.odt$
   [1] 5
   attr(,match.length)
   [1] 4
 
 I know that I could use:
 regexpr( '[.]odt$', Yodt, perl=TRUE )
 
 But it seems to me that the first expression is also
 an accepted regular expression in accordance with perl.

In R you have to escape the \.

 From the help page of regexpr:

## Double all 'a' or 'b's;  \ must be escaped, i.e., 'doubled'
gsub(([ab]), \\1_\\1_, abc and ABC)

HTH,
Tobias

-- 

Tobias Verbeke - Consultant
Business  Decision Benelux
Rue de la révolution 8
1000 Brussels - BELGIUM

+32 499 36 33 15
[EMAIL PROTECTED]

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


[R] Re : restructuring matrix

2007-06-28 Thread justin bem
se reshape package
 
Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé.
Tél (00237)9597295.

- Message d'origine 
De : yoo [EMAIL PROTECTED]
À : r-help@stat.math.ethz.ch
Envoyé le : Jeudi, 28 Juin 2007, 2h15mn 52s
Objet : Re: [R] restructuring matrix


Yea... let's say I constructed a matrix with rownames/colnames be those
unique elements.. then what should I do? I don't want to do mapply, etc to
find the field.. I'm wondering if there's a smarter way using row/col..
etc... Thanks!




Moshe Olshansky-2 wrote:
 
 If your original matrix is A then 
 unique(A$People) and unique(A$Desc) 
 will produce a vector of different people and a vector
 of different descriptions.
 
 --- yoo [EMAIL PROTECTED] wrote:
 
 
 Hi all, 
 
 let's say I have matrix
 
 PeopleDescValue
 Mary  Height50
 Mary  Weight   100
 FannyHeight 60
 Fanny Height200
 
 Is there a quick way to form the following matrix? 
 
 People   HeightWeight
 Mary  50 100
 Fanny 60200
 
 (Assuming I don't know the length of people/desc and
 let's say these are
 characters matrix.. I tried play with row(), col(),
 etc.. but I don't seem
 to find like a duplicate match function... 
 I'm trying to write some one/two liner that convert
 my resulting matrix to
 vector and pick the appropriate fields.. etc )
 
 Thanks!
 
 -- 
 View this message in context:

 http://www.nabble.com/restructuring-matrix-tf3991741.html#a11334950
 Sent from the R help mailing list archive at
 Nabble.com.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.

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

-- 
View this message in context: 
http://www.nabble.com/restructuring-matrix-tf3991741.html#a11335437
Sent from the R help mailing list archive at Nabble.com.

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







  
_ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
[[alternative HTML version deleted]]

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


[R] Meta-Analysis of proportions

2007-06-28 Thread Monica Malta
Dear colleagues,

I'm conducting a meta-analysis of studies evaluating adherence of HIV-positive 
drug users into AIDS treatment, therefore I'm looking for some advice and 
syntax suggestion for running the meta-regression using proportions, not the 
usual OR/RR frequently used on RCT studies.

Have already searched already several handbooks, R-manuals, mailing lists, 
professors, but... not clue at all...

Does anyone have already tried this? A colleague of mine recently published a 
similar study on JAMA, but he used OpenBUGS - a software I'm not familiar 
with...

If there is any tip/suggestion for a possible syntax, could someone send me? I 
need to finish this paper before my PhD qualify, but I'm completely stuck...

So, any tip will be more than welcome...I will really appreciate it!!! 

Thanks in advance and congrats on the amazing mailing-list.



Bests from Rio de Janeiro, Brazil.

Monica

 

 

Monica Malta
Researcher
Oswaldo Cruz Foundation - FIOCRUZ
Social Science Department - DCS/ENSP
Rua Leopoldo Bulhoes, 1480 - room 905
Manguinhos
Rio de Janeiro - RJ 21041-210
Brazil
phone +55.21.2598-2715
fax +55.21.2598-2779
[[alternative HTML version deleted]]

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


Re: [R] : regular expressions: escaping a dot

2007-06-28 Thread Prof Brian Ripley
On Thu, 28 Jun 2007, Wolfram Fischer wrote:

 What's really the problem with:

 regexpr( '\.odt$', Yodt, perl=TRUE )
   Warning: '\.' is an unrecognized escape in a character string
   Warning: unrecognized escape removed from \.odt$
   [1] 5
   attr(,match.length)
   [1] 4

 I know that I could use:
 regexpr( '[.]odt$', Yodt, perl=TRUE )

 But it seems to me that the first expression is also
 an accepted regular expression in accordance with perl.

This is explained in ?regexp (in the See Also of ?regexpr):

  Patterns are described here as they would be printed by 'cat': _do
  remember that backslashes need to be doubled when entering R
  character strings from the keyboard_.

and in the R FAQ and 

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

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


Re: [R] Meta-Analysis of proportions

2007-06-28 Thread Chung-hong Chan
OpenBUGS should be something related to Bayesian statistics.

You may refer to Chapter 12 of Handbook
http://cran.r-project.org/doc/vignettes/HSAUR/Ch_meta_analysis.pdf
It talks about meta-regression.



On 6/28/07, Monica Malta [EMAIL PROTECTED] wrote:
 Dear colleagues,

 I'm conducting a meta-analysis of studies evaluating adherence of 
 HIV-positive drug users into AIDS treatment, therefore I'm looking for some 
 advice and syntax suggestion for running the meta-regression using 
 proportions, not the usual OR/RR frequently used on RCT studies.

 Have already searched already several handbooks, R-manuals, mailing lists, 
 professors, but... not clue at all...

 Does anyone have already tried this? A colleague of mine recently published a 
 similar study on JAMA, but he used OpenBUGS - a software I'm not familiar 
 with...

 If there is any tip/suggestion for a possible syntax, could someone send me? 
 I need to finish this paper before my PhD qualify, but I'm completely stuck...

 So, any tip will be more than welcome...I will really appreciate it!!!

 Thanks in advance and congrats on the amazing mailing-list.



 Bests from Rio de Janeiro, Brazil.

 Monica





 Monica Malta
 Researcher
 Oswaldo Cruz Foundation - FIOCRUZ
 Social Science Department - DCS/ENSP
 Rua Leopoldo Bulhoes, 1480 - room 905
 Manguinhos
 Rio de Janeiro - RJ 21041-210
 Brazil
 phone +55.21.2598-2715
 fax +55.21.2598-2779
 [[alternative HTML version deleted]]

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



-- 
The scientists of today think deeply instead of clearly. One must be
sane to think clearly, but one can think deeply and be quite insane.
Nikola Tesla
http://www.macgrass.com

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


Re: [R] Populate matrix from data.frame

2007-06-28 Thread Patrick Burns
You need some caution with Brian's solution as it
depends on the matrix being in the same order as
the factors in the data frame.

a - data.frame(cbind(x=c('a','a','a','b','c'), 
y=c('a','b','c','d','e'),z=c(1,2,3,4,5)))

mm - matrix(0,5,5)
colnames(mm) - c('a','b','c','d','e')
rownames(mm) - c('a','b','c','d','e')

pp - mm[5:1, 5:1]

mm[cbind(a$x, a$y)] - a$z # desired result

pp[cbind(a$x, a$y)] - a$z # not desired result

It would be nice if the following worked:

mm[cbind(as.character(a$x), as.character(a$y))] - a$z


Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and A Guide for the Unwilling S User)

Prof Brian Ripley wrote:

On Thu, 28 Jun 2007, Andrej Kastrin wrote:

  

Dear all,

I have a data frame
a - data.frame(cbind(x=c('a','a','a','b','c'),
y=c('a','b','c','d','e'),z=c(1,2,3,4,5)))


a
  

 x y z
1 a a 1
2 a b 2
3 a c 3
4 b d 4
5 c e 5

and a matrix
mm - matrix(0,5,5)
colnames(mm) - c('a','b','c','d','e')
rownames(mm) - c('a','b','c','d','e')


mm
  

 a b c d e
a 0 0 0 0 0
b 0 0 0 0 0
c 0 0 0 0 0
d 0 0 0 0 0
e 0 0 0 0 0

How to populate matrix in a way that first column of data frame 'a'
correspond to rownames(mm), second column to colnames(mm) and the third
column is the element of matrix 'mm'?



mm[cbind(a$x, a$y)] - a$z

Please read about the forms of indexing matrices in 'An Introduction to 
R'.

  


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


[R] maximum difference between two ECDF's

2007-06-28 Thread Bart Vandewoestyne
Hello,

I have a vector of samples x of length N.  Associated with each
sample x_i is a certain weight w_i.  All the weights are in another
vector w of the same length N.

I have another vector of samples y of length n (small n).  All
these samples have equal weights 1/n.  The ECDF of these samples
is defined as for example at
http://en.wikipedia.org/wiki/Empirical_distribution_function and
I can compute it using the ecdf() function in R.

I define the 'ECDF' of the samples x with their associated
weights in the following way:

F_N(x) = 1/N * sum_{i=1}^{N}w_i * Indicator(x_i = x)

(does this 'ECDF' have another name???)

So it's basically the same formula as the one on the above URL, but the
only difference is that I multiply the indicator function for x_i with
the weight w_i.

Now suppose F_n(x) is the ECDF of the n samples with equal
weights 1/n, and F_N(x) is the 'ECDF' of the other samples with
their associated weights.

What I now would like to compute is the maximum difference
between these two, so:

max(abs(F_N(x)-F_n(x)))

So it's like computing the Kolmogorov-Smirnov statistic of two
discrete CDF's.

If i didn't have these weights, or if one of the two was a
continuous CDF, then I could simply use the ks.test() function.
However, my situation is different... my first set of samples has
associated weights and therefore the 'ECDF' has a slightly
different definition.

How can I compute max(abs(F_N(x)-F_n(x))) ?  Do there exist
standard functions for this?

Thanks,
Bart

-- 
Share what you know.  Learn what you don't.

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


[R] Repeat if

2007-06-28 Thread Birgit Lemcke
Hello,
(Power Book G4, Mac OS X, R 2.5.0)

I would like to repeat the function range for 85 Vectors (V1-V85).
I tried with this code:

i-0
  repeat {
+ i-i+1
+ if (i85) next
+ range (Vi, na.rm = TRUE)
+ if (i==85) break
+ }

I presume that the Vi is wrong, because in this syntax i is not known  
as a variable. But I don´t know how to say that it is a variable here.
Would be nice if somebody could help me.
Perhaps I´m thinking too complicated and there is an easier way to do  
this.

Thanks in advance

Greetings

Birgit

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






[[alternative HTML version deleted]]

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


[R] compare 2 vectors

2007-06-28 Thread João Fadista
Dear all,
 
I would like to take out the values from one vector that are equal to the 
values in another vector. 
 
Example:
a - c(1,2,3,4,5,6,7,8,9)
b - c(3,10,20,5,6)
b_noRepeats = c(10,20)

So I would like to have the vector b without the same values as vector a.
 
 
Kind regards,
João Fadista
 
 

 

[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread Jacques VESLOT
sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , 
na.rm=T), sep=

Jacques VESLOT

INRA - Biostatistique  Processus Spatiaux
Site Agroparc 84914 Avignon Cedex 9, France

Tel: +33 (0) 4 32 72 21 58
Fax: +33 (0) 4 32 72 21 84



Birgit Lemcke a écrit :
 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
   repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not known  
 as a variable. But I don´t know how to say that it is a variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way to do  
 this.

 Thanks in advance

 Greetings

 Birgit

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






   [[alternative HTML version deleted]]

   
 

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


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


Re: [R] compare 2 vectors

2007-06-28 Thread Christophe Pallier
On 6/28/07, João Fadista [EMAIL PROTECTED] wrote:

 I would like to take out the values from one vector that are equal to the
 values in another vector.

 Example:
 a - c(1,2,3,4,5,6,7,8,9)
 b - c(3,10,20,5,6)
 b_noRepeats = c(10,20)



 b[!(b %in% intersect(a,b))]

See ?intersect


-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


Re: [R] compare 2 vectors

2007-06-28 Thread Antonio, Fabio Di Narzo
setdiff(b, a)

2007/6/28, João Fadista [EMAIL PROTECTED]:
 Dear all,

 I would like to take out the values from one vector that are equal to the 
 values in another vector.

 Example:
 a - c(1,2,3,4,5,6,7,8,9)
 b - c(3,10,20,5,6)
 b_noRepeats = c(10,20)

 So I would like to have the vector b without the same values as vector a.


 Kind regards,
 João Fadista





 [[alternative HTML version deleted]]


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




-- 
Antonio, Fabio Di Narzo
Ph.D. student at
Department of Statistical Sciences
University of Bologna, Italy

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


Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Thanks that was really a quick answer.

It works but I get this warning message anyway:

1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None not- 
lacking argument for min; give Inf back)
2: kein nicht-fehlendes Argument für max; gebe -Inf zurück

what does this mean?

Greeting and thanks for your help!

Birgit

Am 28.06.2007 um 12:05 schrieb Jacques VESLOT:

 sapply(1:85, function(i) eval(parse(text=paste(range(V, i, ,  
 na.rm=T), sep=

 Jacques VESLOT

 INRA - Biostatistique  Processus Spatiaux
 Site Agroparc 84914 Avignon Cedex 9, France

 Tel: +33 (0) 4 32 72 21 58
 Fax: +33 (0) 4 32 72 21 84



 Birgit Lemcke a écrit :
 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
   repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not  
 known  as a variable. But I don´t know how to say that it is a  
 variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way to  
 do  this.

 Thanks in advance

 Greetings

 Birgit

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






  [[alternative HTML version deleted]]


 - 
 ---

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


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






[[alternative HTML version deleted]]

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


Re: [R] compare 2 vectors

2007-06-28 Thread Christophe Pallier
setdiff(b,a) is even simpler.

On 6/28/07, Christophe Pallier [EMAIL PROTECTED] wrote:



 On 6/28/07, João Fadista [EMAIL PROTECTED] wrote:
 
  I would like to take out the values from one vector that are equal to
  the values in another vector.
 
  Example:
  a - c(1,2,3,4,5,6,7,8,9)
  b - c(3,10,20,5,6)
  b_noRepeats = c(10,20)
 
 

  b[!(b %in% intersect(a,b))]

 See ?intersect


 --
 Christophe Pallier (http://www.pallier.org)




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread john seers \(IFR\)
 
Hi

I think a for loop would be more what you want.

Something along the lines of:


V-list(a=c(1,2,3), b=c(2,3,4)) # list of 2 vectors

for ( i in 1:2 ) {  # 2 vectors (replace with 85 ...)
print(range (V[i], na.rm = TRUE))
}


Regards

JS
 
---

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
Sent: 28 June 2007 10:48
To: R Hilfe
Subject: [R] Repeat if

Hello,
(Power Book G4, Mac OS X, R 2.5.0)

I would like to repeat the function range for 85 Vectors (V1-V85).
I tried with this code:

i-0
  repeat {
+ i-i+1
+ if (i85) next
+ range (Vi, na.rm = TRUE)
+ if (i==85) break
+ }

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


[R] using self-written functions

2007-06-28 Thread R. Leenders
Hi, I am pretty new to R, so I apologize for the obvious question.
I
have worked with R for a few months now and in the process have written
several functions that I frequently use in various data analysis
projects. I tend to give each project a directory of its own and set
the working directory to that.
Since there are several tasks that
need to be accomplished in many of my projects, I frequently want to
use functions I have written previously. My question is, how do I get
access to them? The way I do it now is copy the relevant code to the
script file of the project I am working on at the time and then run it
so as to make the functions available. But that seems to be
unnecessarily cumbersome. I used to work a lot with gauss, which had
the opportunity of putting one's own functions is one directory and
gauss would then have that directory in its search path always. How can
I access my own functions in R without having to copy-paste them
everytime and run them manually so I can call them later? Do I need to
learn how to write a package and attach the package to make the
functions available at all times? Is there another way?

thanks, James




   



[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread Christophe Pallier
Your V1 to V85 are probably coming from a data.frame, aren't they?

If yes, and if this data.frame is named 'a', you can use 'sapply(a,range)'

Otherwise, see ?get (get(paste(V,1,sep=)) returns V1)

Christophe


On 6/28/07, Birgit Lemcke [EMAIL PROTECTED] wrote:

 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
  repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not known
 as a variable. But I don´t know how to say that it is a variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way to do
 this.

 Thanks in advance

 Greetings

 Birgit

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






 [[alternative HTML version deleted]]


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




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


Re: [R] compare 2 vectors

2007-06-28 Thread Dimitris Rizopoulos
look at setdiff(), e.g.,

setdiff(b, a)


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: João Fadista [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, June 28, 2007 11:55 AM
Subject: [R] compare 2 vectors


Dear all,

I would like to take out the values from one vector that are equal to 
the values in another vector.

Example:
a - c(1,2,3,4,5,6,7,8,9)
b - c(3,10,20,5,6)
b_noRepeats = c(10,20)

So I would like to have the vector b without the same values as vector 
a.


Kind regards,
João Fadista





[[alternative HTML version deleted]]







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


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

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


[R] prior covariance in Mclust

2007-06-28 Thread Dieter Vanderelst
Hello,

I'm trying to use Mclust to fit a Gaussian Mixture Model to a
mulitdimensional data set.

Because  of the specific source of my data, I know that all components
have the same variance and that the covariance between dimensions is
zero (modelname=VII).
Furthermore, I have a reliable estimate of the variance of the components.

I want to to use this estimate as a prior in mclust, hoping that
exploiting this knowledge will yield better estimates of the number of
components and their means (which are the unknowns).

First I have a general question: Is this a sensible thing to do? As
far as I can see (which might be not too far), this will indeed lead
to more robust estimates. But is this true?

Another question concerns the practical side of things. How can I do
this in mclust? I've read through the manual but this leaves me
uncertain about the exact implementation (and earlier posts about this
problem seem not to have been answered by the mailing list).

If specifying a prior for the covariance matrix is possible (and
sensible) in mclust, could someone provide an example of how to
specify a prior on the covariance matrix?

Thank you,
Dieter

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


Re: [R] compare 2 vectors

2007-06-28 Thread Romain Francois
Christophe Pallier wrote:
 On 6/28/07, João Fadista [EMAIL PROTECTED] wrote:
   
 I would like to take out the values from one vector that are equal to the
 values in another vector.

 Example:
 a - c(1,2,3,4,5,6,7,8,9)
 b - c(3,10,20,5,6)
 b_noRepeats = c(10,20)


 
  b[!(b %in% intersect(a,b))]

 See ?intersect
   
Hi,

There is also a pretty useful operator %w/o% in the help page of %in%. see :

  ?`%in%`
  a - c(1,2,3,4,5,6,7,8,9)
  b - c(3,10,20,5,6)
  b %w/o% a
[1] 10 20

Cheers,

Romain

-- 
Mango Solutions
data analysis that delivers

Tel:  +44(0) 1249 467 467
Fax:  +44(0) 1249 467 468
Mob:  +44(0) 7813 526 123

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


[R] aov and lme differ with interaction in oats example of MASS?

2007-06-28 Thread Karl Knoblick
Dear R-Community!

The example oats in MASS (2nd edition, 10.3, p.309) is calculated for aov and 
lme without interaction term and the results are the same. 
But I have problems to reproduce the example aov with interaction in MASS 
(10.2, p.301) with lme. Here the script:

library(MASS)
library(nlme)
options(contrasts = c(contr.treatment, contr.poly))
# aov: Y ~ N + V
oats.aov - aov(Y ~ N + V + Error(B/V), data = oats, qr = T)
summary(oats.aov)
# now lme
oats.lme-lme(Y ~ N + V, random = ~1 | B/V, data = oats)
anova(oats.lme, type=m) # Ok!
# aov:Y ~ N * V + Error(B/V)
oats.aov2 - aov(Y ~ N * V + Error(B/V), data = oats, qr = T)
summary(oats.aov2)
# now lme - my trial!
oats.lme2-lme(Y ~ N * V, random = ~1 | B/V, data = oats)
anova(oats.lme2, type=m)
# differences!!! (except of interaction term)

My questions:
1) Is there a possibility to reproduce the result of aov with interaction using 
lme?
2) If not, which result of the above is the correct one for the oats example? 

Thanks a lot!
Karl


  __  Alles was der Gesundheit und 
Entspannung dient. BE A BETTER MEDIZINMANN! www.yahoo.de/clever

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


Re: [R] using self-written functions

2007-06-28 Thread Christophe Pallier
One quick and dirty way is to put all your functions inside a file, say
/home/me/R/myfuncs.R, and add  the following line at the beginning of your
scripts:

source('/home/me/R/myfuncs.R')

This is dirty because if you need to change the location of this file, your
scripts will cease to work.
Alternatively, you can add this command to your Rprofile (see the Annex B of
An introduction to R Invoking R)

Christophe




On 6/28/07, R. Leenders [EMAIL PROTECTED] wrote:

 Hi, I am pretty new to R, so I apologize for the obvious question.
 I
 have worked with R for a few months now and in the process have written
 several functions that I frequently use in various data analysis
 projects. I tend to give each project a directory of its own and set
 the working directory to that.
 Since there are several tasks that
 need to be accomplished in many of my projects, I frequently want to
 use functions I have written previously. My question is, how do I get
 access to them? The way I do it now is copy the relevant code to the
 script file of the project I am working on at the time and then run it
 so as to make the functions available. But that seems to be
 unnecessarily cumbersome. I used to work a lot with gauss, which had
 the opportunity of putting one's own functions is one directory and
 gauss would then have that directory in its search path always. How can
 I access my own functions in R without having to copy-paste them
 everytime and run them manually so I can call them later? Do I need to
 learn how to write a package and attach the package to make the
 functions available at all times? Is there another way?

 thanks, James






 


 [[alternative HTML version deleted]]

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




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


[R] Writing - specyfic format

2007-06-28 Thread jastar

Hi all,
I have a trouble - I need to write file in a very specyfic format.
I have two vectors which different lengths and one data.frame (or matrix).
I want to write it to *.txt file in following way:
1st row of file is my 1st vector (separate by spacebar)
2nd row of file is 2nd vector (also separate by spacebar)
Rest of this file should be a matrix with elements separated by tab.
For example: a=1, 2, 3, b=4, 5, c=[1, 2, 3, 4, 5, 6;
7, 8, 9, 10, 11, 12,]
and I want to have file (it have to be .txt file) like:
1 2 3
4 5
1 2 3 4 5 6
7 8 9 10   1112

This thing have to be done automaticly from R.
Is it possible?
Thank you in advance
-- 
View this message in context: 
http://www.nabble.com/Writing---specyfic-format-tf3994017.html#a11341784
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] using self-written functions

2007-06-28 Thread Gavin Simpson
On Thu, 2007-06-28 at 17:29 +0800, R. Leenders wrote:
 Hi, I am pretty new to R, so I apologize for the obvious question.
 I
 have worked with R for a few months now and in the process have written
 several functions that I frequently use in various data analysis
 projects. I tend to give each project a directory of its own and set
 the working directory to that.
 Since there are several tasks that
 need to be accomplished in many of my projects, I frequently want to
 use functions I have written previously. My question is, how do I get
 access to them? The way I do it now is copy the relevant code to the
 script file of the project I am working on at the time and then run it
 so as to make the functions available. But that seems to be
 unnecessarily cumbersome. I used to work a lot with gauss, which had
 the opportunity of putting one's own functions is one directory and
 gauss would then have that directory in its search path always. How can
 I access my own functions in R without having to copy-paste them
 everytime and run them manually so I can call them later? Do I need to
 learn how to write a package and attach the package to make the
 functions available at all times? Is there another way?

Building a package is one way, and not that difficult once you've read
the Writing R Extensions manual.

An alternative is to have a directory where you keep R function scripts.
Put your functions in here in text files with say a .R extension. Then
in R you can source one or more of these R scripts as required, using
the source() function.

Say you have a directory, myScripts at the base of file system
(/home/user say on Linux or C:\ on Windows). in this directory there is
a file called my_r_function.R. To use this script/function in an R
session, you would issue:

## replace /home/user/ with what ever is the correct path for your
## system
source(/home/user/myScripts/my_r_function.R)

Which would make available to your current session any functions defined
in my_r_function.R.

Read ?source for more information.

HTH

G

 
 thanks, James
 
 
 
 

 
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] compare 2 vectors

2007-06-28 Thread Alberto Monteiro
Romain Francois wrote:
 
 There is also a pretty useful operator %w/o% in the help page of 
 %in%. see :
 
   ?`%in%`
   a - c(1,2,3,4,5,6,7,8,9)
   b - c(3,10,20,5,6)
   b %w/o% a
 [1] 10 20
 
I don't like the example. It's not obvious, in the expression...

  x[!x %in% y]

... that this is the same as x[!(x %in% y)] and not x[(!x) %in% y]

Alberto Monteiro

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


Re: [R] lme correlation structures

2007-06-28 Thread Gareth Hughes
Thanks for your help. I can weight the variances in the 2 groups using
weights, as in

lme(Y~1+time+sex+age, random=~1|indv,
correlation=corAR1(form=~time|indv),
weights=varIdent(form=~1|sex),method=ML)

but what I would like is to have a different phi estimate for each
gender, not just different variances. Will track down a copy of the
Pinheiro and Bates book...



On 6/27/07, Bert Gunter [EMAIL PROTECTED] wrote:
 Please read ?lme carefully -- the info you seek is there. In particular, the
 weights argument for changing variance weighting by covariates and the
 correlation argument for specifying correlation structures.

 Pinheiro and Bates's MIXED EFFECT MODELS IN S... is the canonical reference
 (which you should get if you want to use R as you said) that exposits the
 ideas at greater length.


 Bert Gunter
 Genentech Nonclinical Statistics

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Gareth Hughes
 Sent: Wednesday, June 27, 2007 7:50 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] lme correlation structures

 Hi all,

 I've been using SAS proc mixed to fit linear mixed models and would
 like to be able to fit the same models in R. Two things in particular:

 1) I have longitudinal data and wish to allow for different repeated
 measures covariance parameter estimates for different groups (men and
 women), each covariance matrix having the same structure. In proc
 mixed this would be done by specifying group= in the REPEATED
 statement. Is this simple to do in R? (I've tried form=~time|indv/sex
 for example but this doesn't seem to do the job).

 2) I've read that other correlation structures can be specified. Does
 anyone have any examples of how toeplitz or (first-order)
 ante-dependence structures can be specified?

 Many thanks,

 Gareth

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



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


Re: [R] Meta-Analysis of proportions

2007-06-28 Thread Chuck Cleland
Monica Malta wrote:
 Dear colleagues,
 
 I'm conducting a meta-analysis of studies evaluating adherence of 
 HIV-positive drug users into AIDS treatment, therefore I'm looking for some 
 advice and syntax suggestion for running the meta-regression using 
 proportions, not the usual OR/RR frequently used on RCT studies.
 
 Have already searched already several handbooks, R-manuals, mailing lists, 
 professors, but... not clue at all...
 
 Does anyone have already tried this? A colleague of mine recently published a 
 similar study on JAMA, but he used OpenBUGS - a software I'm not familiar 
 with...
 
 If there is any tip/suggestion for a possible syntax, could someone send me? 
 I need to finish this paper before my PhD qualify, but I'm completely stuck...
 
 So, any tip will be more than welcome...I will really appreciate it!!! 
 
 Thanks in advance and congrats on the amazing mailing-list.

  Specifying adherence as the effect size, if you can also specify a
sampling variance perhaps you can use a tool like mima
(http://www.wvbauer.com/downloads/mima_tutorial.pdf).  For example,
working with logits rather than proportions directly, consider the
following example data:

 df
   ntot nadhere mod  prop  logitse
1   100  76   0 0.760 -1.1526795 0.2341463
2   125  98   0 0.784 -1.2891306 0.2173501
350  37   0 0.740 -1.0459686 0.3224127
4   200 159   0 0.795 -1.3553321 0.1751557
5   150 114   0 0.760 -1.1526795 0.1911796
680  56   1 0.700 -0.8472979 0.2439749
7   160 113   1 0.7062500 -0.8772402 0.1735688
8   200 130   1 0.650 -0.6190392 0.1482498
9   120  75   1 0.625 -0.5108256 0.1885618
10  105  78   1 0.7428571 -1.0608720 0.2232879

  Then do the meta-regression as follows:

 source(http://www.wvbauer.com/downloads/mima.ssc;)

 with(df, mima(yi=logit, vi=se, mods=mod))

Estimate of (Residual) Heterogeneity: 0

Test for (Residual) Heterogeneity:

QE  =  1.2419
df  =  8
p-value =  0.9962

Parameter Estimates:

   [,1]
intrcpt -1.2161
mods 0.4520

Variance-Covariance Matrix of Parameter Estimates:

intrcptmods
intrcpt  0.0436 -0.0436
mods-0.0436  0.0815

Omnibus Test of all Moderators:

QME =  2.5058
df  =  1
p-value =  0.1134

Individual Moderator Tests:

estimate SEzval   pvalCI_LCI_U
intrcpt  -1.2161 0.2089 -5.8213 0. -1.6256 -0.8067
mods  0.4520 0.2856  1.5830 0.1134 -0.1077  1.0117

 Bests from Rio de Janeiro, Brazil.
 
 Monica  
 
 Monica Malta
 Researcher
 Oswaldo Cruz Foundation - FIOCRUZ
 Social Science Department - DCS/ENSP
 Rua Leopoldo Bulhoes, 1480 - room 905
 Manguinhos
 Rio de Janeiro - RJ 21041-210
 Brazil
 phone +55.21.2598-2715
 fax +55.21.2598-2779
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] R 2.5.1 is released

2007-06-28 Thread Peter Dalgaard
I've rolled up R-2.5.1.tar.gz a short while ago. This is a maintenance
release and fixes a number of mostly minor bugs and platform issues. See 
the full list of changes below.

You can get it (in a short while) from

http://cran.r-project.org/src/base/R-2/R-2.5.1.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you. Binaries
for various platforms will appear in due course.
 
For the R Core Team

Peter Dalgaard

These are the md5sums for the freshly created files, in case you wish
to check that they are uncorrupted:

a8efde35b940278de19730d326f58449  AUTHORS
eb723b61539feef013de476e68b5c50a  COPYING
a6f89e2100d9b6cdffcea4f398e37343  COPYING.LIB
24ad9647e525609bce11f6f6ff9eac2d  FAQ
70447ae7f2c35233d3065b004aa4f331  INSTALL
f04bdfaf8b021d046b8040c8d21dad41  NEWS
88bbd6781faedc788a1cbd434194480c  ONEWS
4f004de59e24a52d0f500063b4603bcb  OONEWS
162f6d5a1bd7c60fd652145e050f3f3c  R-2.5.1.tar.gz
162f6d5a1bd7c60fd652145e050f3f3c  R-latest.tar.gz
433182754c05c2cf7a04ad0da474a1d0  README
020479f381d5f9038dcb18708997f5da  RESOURCES
4eaf8a3e428694523edc16feb0140206  THANKS


Here is the relevant bit of the NEWS file:

CHANGES IN R VERSION 2.5.1

NEW FEATURES

o   density(1:20, bw = SJ) now works as bw.SJ() now tries a larger
search interval than the default (lower, upper) if it does not
find a solution within the latter.

o   The output of library() (no arguments) is now sorted by library
trees in the order of .libPaths() and not alphabetically.

o   R_LIBS_USER and R_LIBS_SITE feature possible expansion of
specifiers for R version specific information as part of the
startup process.

o   C-level warning calls now print a more informative context,
as C-level errors have for a while.

o   There is a new option rl_word_breaks to control the way the
input line is tokenized in the readline-based terminal
interface for object- and file-name completion.
This allows it to be tuned for people who use their space bar
vs those who do not.  The default now allows filename-completion
with +-* in the filenames.

o   If the srcfile argument to parse() is not NULL, it will be added
to the result as a srcfile attribute.

o   It is no longer possible to interrupt lazy-loading (which was
only at all likely when lazy-loading environments), which
would leave the object being loaded in an unusable state.
This is a temporary measure: error-recovery when evaluating
promises will be tackled more comprehensively in 2.6.0.

INSTALLATION

o   'make check' will work with --without-iconv, to accommodate
building on AIX where the system iconv conflicts with
libiconv and is not compatible with R's requirements.

o   There is support for 'DESTDIR': see the R-admin manual.

o   The texinfo manuals are now converted to HTML with a style
sheet: in recent versions of makeinfo the markup such as @file
was being lost in the HTML rendering.

o   The use of inlining has been tweaked to avoid warnings from
gcc = 4.2.0 when compiling in C99 mode (which is the default
from configure).

BUG FIXES

o   as.dendrogram() failed on objects of class dendrogram.

o   plot(type =s) (or S) with many (hundreds of thousands)
of points could overflow the stack.  (PR#9629)

o   Coercing an S4 classed object to matrix (or other basic class)
failed to unset the S4 bit.

o   The 'useS4' argument of print.default() had been broken by an
unrelated change prior to 2.4.1.  This allowed print() and
show() to bounce badly constructed S4 objects between
themselves indefinitely.

o   Prediction of the seasonal component in HoltWinters() was one
step out at one point in the calculations.

decompose() incorrectly computed the 'random' component for a
multiplicative fit.

o   Wildcards work again in unlink() on Unix-alikes (they did not
in 2.5.0).

o   When qr() used pivoting, the coefficient names in qr.coef() were
not pivoted to match.  (PR#9623)

o   UseMethod() could crash R if the first argument was not a
character string.

o   R and Rscript on Unix-alikes were not accepting spaces in -e
arguments (even if quoted).

o   Hexadecimal integer constants (e.g. 0x10L) were not being parsed
correctly on platforms where the C function atof did not
accept hexadecimal prefixes (as required by C99, but not
implemented in MinGW as used by R on Windows).  (PR#9648)

o   libRlapack.dylib on Mac OS X had no version information and
sometimes an invalid identification name.

o   Rd conversion of \usage treated '\\' as a single backslash in
all but latex: it now acts consistently with the other
verbatim-like environments (it was never 'verbatim' 

Re: [R] : regular expressions: escaping a dot

2007-06-28 Thread Peter Dalgaard
Prof Brian Ripley wrote:


 This is explained in ?regexp (in the See Also of ?regexpr):

   Patterns are described here as they would be printed by 'cat': _do
   remember that backslashes need to be doubled when entering R
   character strings from the keyboard_.

 and in the R FAQ and 

   
Hmm, that's not actually correct, is it? Perhaps this is better

...entering R character string literals (i.e., between quote symbols.)

The counterexample would be

 readLines()
\\abc
[1] abc

(of course it is more important to get people to read the documentation
at all...)

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

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


Re: [R] Repeat if

2007-06-28 Thread Jacques VESLOT
you may have a vector with only NA values in it...

max(c(NA,NA), na.rm=T)
[1] -Inf
Warning message:
aucun argument pour max ; -Inf est renvoyé

Jacques VESLOT

INRA - Biostatistique  Processus Spatiaux
Site Agroparc 84914 Avignon Cedex 9, France

Tel: +33 (0) 4 32 72 21 58
Fax: +33 (0) 4 32 72 21 84



Birgit Lemcke a écrit :
 Thanks that was really a quick answer.

 It works but I get this warning message anyway:

 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None 
 not-lacking argument for min; give Inf back)
 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück 

 what does this mean?

 Greeting and thanks for your help!

 Birgit

 Am 28.06.2007 um 12:05 schrieb Jacques VESLOT:

 sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , 
 na.rm=T), sep=

 Jacques VESLOT

 INRA - Biostatistique  Processus Spatiaux
 Site Agroparc 84914 Avignon Cedex 9, France

 Tel: +33 (0) 4 32 72 21 58
 Fax: +33 (0) 4 32 72 21 84



 Birgit Lemcke a écrit :
 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
   repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not 
 known  as a variable. But I don´t know how to say that it is a 
 variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way to 
 do  this.

 Thanks in advance

 Greetings

 Birgit

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






 [[alternative HTML version deleted]]

   
 

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

   


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





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


Re: [R] aov and lme differ with interaction in oats example of MASS?

2007-06-28 Thread Peter Dalgaard
Karl Knoblick wrote:
 Dear R-Community!

 The example oats in MASS (2nd edition, 10.3, p.309) is calculated for aov 
 and lme without interaction term and the results are the same. 
 But I have problems to reproduce the example aov with interaction in MASS 
 (10.2, p.301) with lme. Here the script:

 library(MASS)
 library(nlme)
 options(contrasts = c(contr.treatment, contr.poly))
 # aov: Y ~ N + V
 oats.aov - aov(Y ~ N + V + Error(B/V), data = oats, qr = T)
 summary(oats.aov)
 # now lme
 oats.lme-lme(Y ~ N + V, random = ~1 | B/V, data = oats)
 anova(oats.lme, type=m) # Ok!
 # aov:Y ~ N * V + Error(B/V)
 oats.aov2 - aov(Y ~ N * V + Error(B/V), data = oats, qr = T)
 summary(oats.aov2)
 # now lme - my trial!
 oats.lme2-lme(Y ~ N * V, random = ~1 | B/V, data = oats)
 anova(oats.lme2, type=m)
 # differences!!! (except of interaction term)

 My questions:
 1) Is there a possibility to reproduce the result of aov with interaction 
 using lme?
  2) If not, which result of the above is the correct one for the oats 
 example? 
   

The issue is that you are using marginal tests which will do strange
things when contrasts are not coded right, and in particular treatment
contrasts are not. Switch to e.g. contr.helmert and the results become
similar. Marginal tests of main effects in the presence of interaction
is not necessarily a good idea and they have been debated here and
elsewhere a number of times before. People don't agree entirely, but the
dividing line is essentially whether it is uniformly or just mostly a
bad idea. It is essentially the discussion of type III SS.

 fortune(type III)

Some of us feel that type III sum of squares and so-called ls-means are
statistical nonsense which should have been left in SAS.
   -- Brian D. Ripley
  s-news (May 1999)


 Thanks a lot!
 Karl


   __  Alles was der Gesundheit und 
 Entspannung dient. BE A BETTER MEDIZINMANN! www.yahoo.de/clever

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


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

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


[R] Help in Bootstrapping

2007-06-28 Thread Regina Verghis
I have a time series (count) data.. Can you tell me the command for the
parametric bootstrapping. My parameters are var to mean ratio and mean run
length...
-- 
[EMAIL PROTECTED]
Regina M.Verghis,

[[alternative HTML version deleted]]

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


Re: [R] aov and lme differ with interaction in oats example of MASS?

2007-06-28 Thread Prof Brian Ripley
On Thu, 28 Jun 2007, Karl Knoblick wrote:

 Dear R-Community!

 The example oats in MASS (2nd edition, 10.3, p.309) is calculated for aov 
 and lme without interaction term and the results are the same.
 But I have problems to reproduce the example aov with interaction in MASS 
 (10.2, p.301) with lme. Here the script:

 library(MASS)
 library(nlme)
 options(contrasts = c(contr.treatment, contr.poly))

That is the problem.  You need true contrasts, so use contr.helmert.  When 
I did so I got the same results from lme and aov for the anovas.

The question of what a 'marginal' AoV means without orthogonality is moot.
The sequential version is fine here.

 # aov: Y ~ N + V
 oats.aov - aov(Y ~ N + V + Error(B/V), data = oats, qr = T)
 summary(oats.aov)
 # now lme
 oats.lme-lme(Y ~ N + V, random = ~1 | B/V, data = oats)
 anova(oats.lme, type=m) # Ok!
 # aov:Y ~ N * V + Error(B/V)
 oats.aov2 - aov(Y ~ N * V + Error(B/V), data = oats, qr = T)
 summary(oats.aov2)
 # now lme - my trial!
 oats.lme2-lme(Y ~ N * V, random = ~1 | B/V, data = oats)
 anova(oats.lme2, type=m)
 # differences!!! (except of interaction term)

 My questions:
 1) Is there a possibility to reproduce the result of aov with interaction 
 using lme?
 2) If not, which result of the above is the correct one for the oats example?

 Thanks a lot!
 Karl

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

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


[R] Installing an old package in R-2.4.1

2007-06-28 Thread vladimir
I am new to R.   We have a binary package that was not maintained for
about a year, and the original maintainer is not around anymore.
The package used to work in R-1.5.1.  I used the following steps
to install this package in R-2.4 on WinXP:

  Started the GUI
  Went into the menu Packages and selected Install packages from
  local zip files
  Clicked on the zip file with the package, and clicked Open
  
R responded with the message Updating HTML package descriptions.
I can see the package files in the library subdirectory of
R installation:

cd c:/program files/R/R-2.4.1/library
find . -name 'Rproj' -print
./file72ae2cd6/Rproj
./file72ae2cd6/Rproj/help/Rproj
./file72ae2cd6/Rproj/R/Rproj
./Rproj
./Rproj/help/Rproj
./Rproj/R/Rproj

( Please don't get confused by the UNIX-style paths, I am using cygwin
shell on Windows ).
However when I go to Packages-Load package menu, the Rproj 
package is not listed there.   How would I find out what went wrong?

Thanks,
Vlad

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


Re: [R] Repeat if

2007-06-28 Thread Peter Dalgaard
Birgit Lemcke wrote:
 Thanks that was really a quick answer.

 It works but I get this warning message anyway:

 1: kein nicht-fehlendes Argument f�r min; gebe Inf zur�ck (None not- 
 lacking argument for min; give Inf back)
 2: kein nicht-fehlendes Argument f�r max; gebe -Inf zur�ck

 what does this mean?

   

Same as this

 max(c(NA, NA), na.rm=T)
[1] -Inf
Warning message:
no non-missing arguments to max; returning -Inf

which is related to the issues of empty sum(), prod(), any(), and all()
in that it allows a consistent concatenation rule:

max(c(x1,x2)) == max(max(x1), max(x2))

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

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


Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Thats not the case.

I have two vectosr with a lot of NAs, but not only NAs.

But nevertheless as i saw the results are accurate.

Birgit


Am 28.06.2007 um 15:17 schrieb Jacques VESLOT:

 you may have a vector with only NA values in it...

 max(c(NA,NA), na.rm=T)
 [1] -Inf
 Warning message:
 aucun argument pour max ; -Inf est renvoyé

 Jacques VESLOT

 INRA - Biostatistique  Processus Spatiaux
 Site Agroparc 84914 Avignon Cedex 9, France

 Tel: +33 (0) 4 32 72 21 58
 Fax: +33 (0) 4 32 72 21 84



 Birgit Lemcke a écrit :
 Thanks that was really a quick answer.

 It works but I get this warning message anyway:

 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None  
 not-lacking argument for min; give Inf back)
 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück
 what does this mean?

 Greeting and thanks for your help!

 Birgit

 Am 28.06.2007 um 12:05 schrieb Jacques VESLOT:

 sapply(1:85, function(i) eval(parse(text=paste(range(V, i, ,  
 na.rm=T), sep=

 Jacques VESLOT

 INRA - Biostatistique  Processus Spatiaux
 Site Agroparc 84914 Avignon Cedex 9, France

 Tel: +33 (0) 4 32 72 21 58
 Fax: +33 (0) 4 32 72 21 84



 Birgit Lemcke a écrit :
 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
   repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not  
 known  as a variable. But I don´t know how to say that it is a  
 variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way  
 to do  this.

 Thanks in advance

 Greetings

 Birgit

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






 [[alternative HTML version deleted]]


 --- 
 -

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



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





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






[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Hello John,

I tried this code. But I got only the ranges of V1 and V2 what is  
easily understandable.
Do I have to write in all 85 vectors in the first line?

V-list(a=c(V1), b=c(V2))

for ( i in 1:85 ) {  # 2 vectors (replace with 85 ...)
+ print(range (V[i], na.rm = TRUE))
+ }


sapply(1:85, function(i) eval(parse(text=paste(range(V, i, ,  
na.rm=T), sep=

But thanks anyway.

Greetings

Birgit


Am 28.06.2007 um 12:23 schrieb john seers ((IFR)):


 Hi

 I think a for loop would be more what you want.

 Something along the lines of:


 V-list(a=c(1,2,3), b=c(2,3,4)) # list of 2 vectors

 for ( i in 1:2 ) {  # 2 vectors (replace with 85 ...)
 print(range (V[i], na.rm = TRUE))
 }


 Regards

 JS

 ---

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
 Sent: 28 June 2007 10:48
 To: R Hilfe
 Subject: [R] Repeat if

 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
 repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

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






[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Thanks Christophe,

I received already an answer with a similar suggestion.

But thanks for your answer.

Birgit


Am 28.06.2007 um 12:34 schrieb Christophe Pallier:

 Your V1 to V85 are probably coming from a data.frame, aren't they?

 If yes, and if this data.frame is named 'a', you can use 'sapply 
 (a,range)'

 Otherwise, see ?get (get(paste(V,1,sep=)) returns V1)

 Christophe


 On 6/28/07, Birgit Lemcke [EMAIL PROTECTED] wrote:
 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
  repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not known
 as a variable. But I don´t know how to say that it is a variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way to do
 this.

 Thanks in advance

 Greetings

 Birgit

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






 [[alternative HTML version deleted]]


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




 -- 
 Christophe Pallier (http://www.pallier.org)

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






[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Hello Patrick,

this does not work and gives following warning message:

for(i in 1:85) range(get(paste(V, i, sep=)), na.rm=TRUE)
Warning messages:
1: kein nicht-fehlendes Argument für min; gebe Inf zurück
2: kein nicht-fehlendes Argument für max; gebe -Inf zurück

This works but also with the warning message:

Vranges - array(NA, c(85, 2))
for(i in 1:85) Vranges[i,] - range(get(paste(V, i, sep=)),  
na.rm=TRUE)


Greetings

Birgit


Am 28.06.2007 um 12:27 schrieb Patrick Burns:

 In your code the 'range' call is only seen when i is 85.
 I think the following is what you want:

 for(i in 1:85) range(get(paste(V, i, sep=)), na.rm=TRUE)

 Except that nothing is done with the results of 'range'.  More
 likely is:

 Vranges - array(NA, c(85, 2))
 for(i in 1:85) Vranges[i,] - range(get(paste(V, i, sep=)),  
 na.rm=TRUE)

 See S Poetry for details.

 Patrick Burns
 [EMAIL PROTECTED]
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of S Poetry and A Guide for the Unwilling S User)

 Birgit Lemcke wrote:

 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
  repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not  
 known  as a variable. But I don´t know how to say that it is a  
 variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way to  
 do  this.

 Thanks in advance

 Greetings

 Birgit

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






  [[alternative HTML version deleted]]


 - 
 ---

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


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






[[alternative HTML version deleted]]

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


Re: [R] : regular expressions: escaping a dot

2007-06-28 Thread Prof Brian Ripley
On Thu, 28 Jun 2007, Peter Dalgaard wrote:

 Prof Brian Ripley wrote:


 This is explained in ?regexp (in the See Also of ?regexpr):

   Patterns are described here as they would be printed by 'cat': _do
   remember that backslashes need to be doubled when entering R
   character strings from the keyboard_.

 and in the R FAQ and 


 Hmm, that's not actually correct, is it? Perhaps this is better

 ...entering R character string literals (i.e., between quote symbols.)

 The counterexample would be

 readLines()
 \\abc
 [1] abc

 (of course it is more important to get people to read the documentation
 at all...)

The definition of 'character string' used throughout the help is your 
'character string literal', as distinct from an element of a character 
vector.

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

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


[R] Adding different output to different lattice panels

2007-06-28 Thread alxsal
I would like to add a reference line to lattice graphs, with the reference line
being different according to the factor level.

Example : Draw 3 dotplots for a,b and c factors, and then add an
horizontal line at y=10 for panel a, y=8 for panel b and y=6 for panel 4

I tried the code below, but this draw all three reference lines for each panel.
How do I index the current panel to chose the right reference vector value ?

dat-data.frame(id=rep(c(a,b,c),4),val=1:12,quand=rep(c(t1,t2,t3,t4),each=3))
ref-c(10,8,6)
plot.new()
datplot-dotplot(val~quand|id,data=dat,panel=function(...){
panel.dotplot(...)
panel.abline(h=ref)
})
print(datplot)

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


Re: [R] Repeat if

2007-06-28 Thread john seers \(IFR\)
 

Hi Birgit

No, you do not have to write all 85 vectors in the first line. I just did not 
fully appreciate what you were trying to do. 

You could use the get option as was suggested somewhere else.

So, if your vectors are V1 to V2 (i.e. 85) say, something like:


V1-c(1,2,3)
V2-c(5,2,7)

...

V-paste(V, 1:2, sep=)
for ( i in 1:length(V) ) { 
print(range (get(V[i]), na.rm = TRUE))
}


Regards

JS

 
---
 
Web sites:

www.ifr.ac.uk   
www.foodandhealthnetwork.com

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
Sent: 28 June 2007 15:12
To: john seers (IFR)
Cc: R Hilfe
Subject: Re: [R] Repeat if

Hello John,

I tried this code. But I got only the ranges of V1 and V2 what is easily 
understandable.
Do I have to write in all 85 vectors in the first line?

V-list(a=c(V1), b=c(V2))

for ( i in 1:85 ) {  # 2 vectors (replace with 85 ...)
+ print(range (V[i], na.rm = TRUE))
+ }


sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), 
sep=

But thanks anyway.

Greetings

Birgit


Am 28.06.2007 um 12:23 schrieb john seers ((IFR)):


 Hi

 I think a for loop would be more what you want.

 Something along the lines of:


 V-list(a=c(1,2,3), b=c(2,3,4)) # list of 2 vectors

 for ( i in 1:2 ) {  # 2 vectors (replace with 85 ...)
 print(range (V[i], na.rm = TRUE))
 }


 Regards

 JS

 ---

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
 Sent: 28 June 2007 10:48
 To: R Hilfe
 Subject: [R] Repeat if

 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
 repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

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






[[alternative HTML version deleted]]

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


[R] align() function missing in R ?

2007-06-28 Thread Markus Loecher
Dear list members,
I switched from Splus to R a few years ago and so far found no 
functionality missing.
However, I am struggling to find the equivalent align() function for 
time series. I did find some reduced functionality such as 
alignDailySeries in package:fCalendar but the full capability of 
aligning two timeseries seems to be missing.
Could this be true ? I am sure there must be a need for this useful function.
Any help would be greatly appreciated.

Thanks !

Markus

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


[R] embedFonts() and bounding box

2007-06-28 Thread Christoph Buser
Dear R gurus

I have a question regarding the function embedFonts().  
I assume the in that function which calls gs, the bounding box
of the eps file is changed. Is that by intention? Do I have
call explicitly some gs-options to avoid it and if yes, how?
Thank you very much for your help.

Best regards,

Christoph Buser

## R example
postscript(test.eps, width = 14, height = 8, 
 onefile = FALSE, horizontal=FALSE, paper=special)
plot(1:10)
dev.off()
embedFonts(file = test.eps, outfile = test1.eps)


--
Christoph Buser [EMAIL PROTECTED]
Seminar fuer Statistik, LEO C13
ETH Zurich  8092 Zurich  SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/

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


Re: [R] Adding different output to different lattice panels

2007-06-28 Thread hadley wickham
On 6/28/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I would like to add a reference line to lattice graphs, with the reference 
 line
 being different according to the factor level.

 Example : Draw 3 dotplots for a,b and c factors, and then add an
 horizontal line at y=10 for panel a, y=8 for panel b and y=6 for panel 4

It's quite easy to do this with ggplot2 (http://had.co.nz/ggplot2) -
see http://had.co.nz/ggplot2/geom_vline.html for examples of both
common and specific reference lines.

Hadley

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


Re: [R] TukeyHSD

2007-06-28 Thread Christophe Pallier
Are you sure that Tukey's HSD (or any other usual multiple comparison
procedure) applies to within-subject factors?
I do not have my stats books (e.g. Winer or Kirk)  to check.

You can get some output with:

TukeyHSD(aov(hand:gaze+subject))

(assuming you ant to compare the cells defined by hand:gaze)
but I am not sure wheter this is meaningful/correct in the context of the
within-subject design.
(Actually, I write this email because I am interested to know whether it is
a legitimate approach or not.)

Christophe

On 6/28/07, Patrick Bedard [EMAIL PROTECTED] wrote:

 Hello everyone,

 So I ran an anova with aov and then I want to run post-hoc comparisons but
 keep receiving this message :
  no applicable method for TukeyHSD

 Here is my code:

  d-read.table(d.txt)
  d
 Obs subj Hand GazeRT
  11   s111 401.4
  22   s211 363.3..

  summary(ano - aov(RT~(Hand*Gaze)+Error(subj/(Hand*Gaze)),data=d ))


 This seems to work fine, but then I use
  fm1Tukey=TukeyHSD(fm1,Hand) ; fm1Tukey

 And receive
  no applicable method for TukeyHSD


 I can¹t seem to find the error nor anyone ever answering that question
 which
 seems to pop-up here and there on other websites (eg, Nabble)


 Tnaks in advance for your help,

 __
 Patrick Bédard Ph.D.
 Dept. of Neuroscience
 Brown University



 [[alternative HTML version deleted]]


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




-- 
Christophe Pallier (http://www.pallier.org)

[[alternative HTML version deleted]]

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


Re: [R] Repeat if

2007-06-28 Thread Birgit Lemcke
Sorry Jacques and all the other helpful people!

I made a mistake because I didn´t realize that I have a vector only  
containing NAs. That happened during standardization and i didn´t  
check this.
I apologize for that.

Greetings

Birgit

Am 28.06.2007 um 15:17 schrieb Jacques VESLOT:

 you may have a vector with only NA values in it...

 max(c(NA,NA), na.rm=T)
 [1] -Inf
 Warning message:
 aucun argument pour max ; -Inf est renvoyé

 Jacques VESLOT

 INRA - Biostatistique  Processus Spatiaux
 Site Agroparc 84914 Avignon Cedex 9, France

 Tel: +33 (0) 4 32 72 21 58
 Fax: +33 (0) 4 32 72 21 84



 Birgit Lemcke a écrit :
 Thanks that was really a quick answer.

 It works but I get this warning message anyway:

 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None  
 not-lacking argument for min; give Inf back)
 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück
 what does this mean?

 Greeting and thanks for your help!

 Birgit

 Am 28.06.2007 um 12:05 schrieb Jacques VESLOT:

 sapply(1:85, function(i) eval(parse(text=paste(range(V, i, ,  
 na.rm=T), sep=

 Jacques VESLOT

 INRA - Biostatistique  Processus Spatiaux
 Site Agroparc 84914 Avignon Cedex 9, France

 Tel: +33 (0) 4 32 72 21 58
 Fax: +33 (0) 4 32 72 21 84



 Birgit Lemcke a écrit :
 Hello,
 (Power Book G4, Mac OS X, R 2.5.0)

 I would like to repeat the function range for 85 Vectors (V1-V85).
 I tried with this code:

 i-0
   repeat {
 + i-i+1
 + if (i85) next
 + range (Vi, na.rm = TRUE)
 + if (i==85) break
 + }

 I presume that the Vi is wrong, because in this syntax i is not  
 known  as a variable. But I don´t know how to say that it is a  
 variable here.
 Would be nice if somebody could help me.
 Perhaps I´m thinking too complicated and there is an easier way  
 to do  this.

 Thanks in advance

 Greetings

 Birgit

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






 [[alternative HTML version deleted]]


 --- 
 -

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



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





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






[[alternative HTML version deleted]]

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


Re: [R] TukeyHSD

2007-06-28 Thread Richard M. Heiberger
TukeyHSD takes an aov object, not an aovlist object.
The result of aov() with an Error() term is an aovlist object.

In the HH package, see ?MMC for an example of how to work
around this limitation.  See the maiz example.

Rich

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


[R] R.matlab questions

2007-06-28 Thread Spencer Graves
Hello:

  Two questions about R.matlab:

  1.  How to break a hung R-Matlab connection?

  2.  How to execute R.matlab commands from within a function?


BREAKING AN R-Matlab CONNECTION

  Sometimes an attempted R.matlab command locks up my computer.  The 
standard R break process interrupts the R command.  However, when I do 
that, the command to Matlab is still pending, and I don't know an easy 
way to interrupt that.  A simple, self-contained example appears below.

  The easiest way I've found so far to interrupt Matlab is to quit R. 
This will finally release Matlab.


CALLING R.matlab FUNCTIONS FROM WITHIN A FUNCTION

  An R.matlab function call that works as a direct R command hangs for 
me when executed within an R function.  A simple, self-contained example 
appears below.

How can I work around this?


  Thanks,
  Spencer Graves
Using Matlab 7.3.0 (R2006b) under Windows XP Pro.
 sessionInfo()
R version 2.5.0 (2007-04-23)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

other attached packages:
R.matlab R.oo  fda  zoo
  1.1.3  1.2.7  1.2.1  1.3-1

###

#EXAMPLE:  CALLING R.matlab FROM WITHIN A FUCTION?

# 1.  library(R.matlab)
library(R.matlab)
# 2.  Create a Matlab client object to support communications
(matlab - Matlab())
# Optionally set setVerbose(..., -2) to get max info
setVerbose(matlab, -2)

# 3.  Start Matlab
# 4.  Ask Matlab to become a slave

#Matlab MatlabServer

# 5.  Open the connection from R to MatlabServer
(isOpenMatlab - open(matlab))

# NOTE:  If Matlab is not frozen:
#R close(matlab)
# returns local control to Matlab.
# Control of Matlab can be returned to R at any time
# by repeating steps 4  5.

# 6.  matlab.compute.a
compute - evaluate(matlab, a = 1+2)
(a0 - getVariable(matlab, a))

# The above works fine for me.

# 7.  R.matlab.compute.a function
R.matlab.compute.a - function(text=a=1+2, matlabClient=matlab){
# text = a Matlab expression that stores 'a'
   ev0 - evaluate(matlabClient, text)
   getVariable(matlabClient, a)
}

# The following locks up both R and Matlab for me:
R.matlab.compute.a()

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


Re: [R] Adding different output to different lattice panels

2007-06-28 Thread deepayan . sarkar
On 6/28/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I would like to add a reference line to lattice graphs, with the reference
 line
 being different according to the factor level.

 Example : Draw 3 dotplots for a,b and c factors, and then add an
 horizontal line at y=10 for panel a, y=8 for panel b and y=6 for panel
 4

 I tried the code below, but this draw all three reference lines for each
 panel.
 How do I index the current panel to chose the right reference vector value ?

 dat-data.frame(id=rep(c(a,b,c),4),val=1:12,quand=rep(c(t1,t2,t3,t4),each=3))
 ref-c(10,8,6)
 plot.new()
 datplot-dotplot(val~quand|id,data=dat,panel=function(...){
 panel.dotplot(...)
 panel.abline(h=ref)
 })
 print(datplot)

dotplot(val~quand|id,data=dat,panel=function(...){
panel.dotplot(...)
panel.abline(h = ref[packet.number()])
})

(Things are more complicated if you have more than one conditioning variable.)

-Deepayan

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


Re: [R] Writing - specyfic format

2007-06-28 Thread Earl F. Glynn
jastar [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Hi all,
 I have a trouble - I need to write file in a very specyfic format.
 I have two vectors which different lengths and one data.frame (or matrix).
 I want to write it to *.txt file in following way:
 1st row of file is my 1st vector (separate by spacebar)
 2nd row of file is 2nd vector (also separate by spacebar)
 Rest of this file should be a matrix with elements separated by tab.
 For example: a=1, 2, 3, b=4, 5, c=[1, 2, 3, 4, 5, 6;
7, 8, 9, 10, 11, 12,]
 and I want to have file (it have to be .txt file) like:
 1 2 3
 4 5
 1 2 3 4 5 6
 7 8 9 10   1112

 This thing have to be done automaticly from R.
 Is it possible?

Try this:

a - 1:3
b - 4:5
c - matrix(1:12, 2,6, byrow=TRUE)

outFile - file(SpecificFormat.txt, w)
cat(paste(a, sep= ), \n, file=outFile)
cat(paste(b, sep= ), \n, file=outFile)

for (j in 1:nrow(c))
{
  cat(paste(c[j,], collapse=\t), \n, file=outFile)
}

close(outFile)


Resulting output file (with spaces or tabs as specified):
1 2 3
4 5
1 2 3 4 5 6
7 8 9 10 11 12


[But I normally avoid tabs since you cannot see them easily with many 
editors.]

efg

Earl F. Glynn
Stowers Institute for Medical Research

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


[R] Method dispatch in functions?

2007-06-28 Thread John McHenry
Hi,

Could someone point me in the right direction for documentation on the 
following question? 

Let's say I have two objects a and b of classes A and B, respectively.
Now let's say I write a function foo that does something similar to 
objects of type A and B. Basically I want to overload the function
in C++ talk, so if I give foo and object of type A something (and this
is my question) dispatches the call to, say, foo.A, and if I give foo
and object of type B something dispatches the call to, say, foo.B.

I want to write foo.A and foo.B. How to I perform the method 
dispatch? From what I understand there are two ways in R:
S3 and S4. What is the simple S3 way?

Thanks!

Jack.

   
-

[[alternative HTML version deleted]]

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


[R] Error en assign(mname, def, where)

2007-06-28 Thread Martín Gastón

Hi R users,
I am working with the fda package but when I call the function pca.fd I
obtain a message error, which I cann't identify. The error say That :
 error in assihn(mname,def,where), is not possible to add links to a
blockade enviroment.
The orther that I'm writting is:

 cp1 - pca.fd(ind.fd1,nharm=3)

and before it I can to plot the functional data object ind.fd1.
¿Have anybody seen this error or any similar message?,
¿Any idea?

Thancks for your help
-- 
View this message in context: 
http://www.nabble.com/Error-en-assign%28mname%2C-def%2C-where%29-tf3995432.html#a11346689
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Meta-Analysis of proportions

2007-06-28 Thread Michael Dewey
At 09:58 28/06/2007, Chung-hong Chan wrote:
OpenBUGS should be something related to Bayesian statistics.

You may refer to Chapter 12 of Handbook
http://cran.r-project.org/doc/vignettes/HSAUR/Ch_meta_analysis.pdf
It talks about meta-regression.



On 6/28/07, Monica Malta [EMAIL PROTECTED] wrote:
Dear colleagues,

I'm conducting a meta-analysis of studies evaluating adherence of 
HIV-positive drug users into AIDS treatment, therefore I'm looking 
for some advice and syntax suggestion for running the 
meta-regression using proportions, not the usual OR/RR frequently 
used on RCT studies.

Monica, you have a number of options.
1 - weight each study equally
2 - weight each individual equally
3 - use the usual inverse variance procedure, possibly transforming 
the proportions first
4 - something else I have not though of

You could do 3 using rmeta which is available from CRAN. Programming 
1 or 2 is straightforward.
Of course, you do need to decide which corresponds to your scientific question.


Have already searched already several handbooks, R-manuals, mailing 
lists, professors, but... not clue at all...

Does anyone have already tried this? A colleague of mine recently 
published a similar study on JAMA, but he used OpenBUGS - a 
software I'm not familiar with...

If there is any tip/suggestion for a possible syntax, could someone 
send me? I need to finish this paper before my PhD qualify, but I'm 
completely stuck...

So, any tip will be more than welcome...I will really appreciate it!!!

Thanks in advance and congrats on the amazing mailing-list.



Bests from Rio de Janeiro, Brazil.

Monica





Monica Malta
Researcher
Oswaldo Cruz Foundation - FIOCRUZ
Social Science Department - DCS/ENSP
Rua Leopoldo Bulhoes, 1480 - room 905
Manguinhos
Rio de Janeiro - RJ 21041-210
Brazil
phone +55.21.2598-2715
fax +55.21.2598-2779
 [[alternative HTML version deleted]]

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


--
The scientists of today think deeply instead of clearly. One must be
sane to think clearly, but one can think deeply and be quite insane.
Nikola Tesla
http://www.macgrass.com



Michael Dewey
[EMAIL PROTECTED]
http://www.aghmed.fsnet.co.uk/home.html

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


[R] R function command on a list

2007-06-28 Thread G E
Hello R:
   I am working with a self-defined function and I wish to subject a list
(t) to this function. My list is a list of tables:
$rs7609589
2/2 2/4 4/4 2/2 2/4 4/4
 89 188  87  89 188  87

$rs3909907

1/1 1/4 4/4
 94 178  92

$rs12748004

0/0 1/3 3/3
 37 150 177

$rs6695928

2/2 2/4 4/4
 35 129 200

My function looks as follows:
delete_nocall_listoftables-function(i){
names-names(i)
i
if (names[1] == 0/0){
i[-(1:1)]
}else{
i
}
}


Within the function, how can I access the table name of a given element (e.g.
$rs3909907)? Using names(i) I get the header of the table...

Thanking you!
Georg.

[[alternative HTML version deleted]]

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


[R] TukeyHSD

2007-06-28 Thread Patrick Bedard
Hello everyone,

So I ran an anova with aov and then I want to run post-hoc comparisons but
keep receiving this message :
 no applicable method for TukeyHSD

Here is my code:

 d-read.table(d.txt)
 d
Obs subj Hand GazeRT
 11   s111 401.4
 22   s211 363.3..

 summary(ano - aov(RT~(Hand*Gaze)+Error(subj/(Hand*Gaze)),data=d ))


This seems to work fine, but then I use
 fm1Tukey=TukeyHSD(fm1,Hand) ; fm1Tukey

And receive 
 no applicable method for TukeyHSD


I can¹t seem to find the error nor anyone ever answering that question which
seems to pop-up here and there on other websites (eg, Nabble)


Tnaks in advance for your help,

__ 
Patrick Bédard Ph.D.
Dept. of Neuroscience
Brown University



[[alternative HTML version deleted]]

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


Re: [R] R function command on a list

2007-06-28 Thread Henrique Dallazuanna
Try whit rownames.

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

On 28/06/07, G E [EMAIL PROTECTED] wrote:

 Hello R:
I am working with a self-defined function and I wish to subject a list
 (t) to this function. My list is a list of tables:
 $rs7609589
 2/2 2/4 4/4 2/2 2/4 4/4
 89 188  87  89 188  87

 $rs3909907

 1/1 1/4 4/4
 94 178  92

 $rs12748004

 0/0 1/3 3/3
 37 150 177

 $rs6695928

 2/2 2/4 4/4
 35 129 200

 My function looks as follows:
 delete_nocall_listoftables-function(i){
 names-names(i)
 i
 if (names[1] == 0/0){
 i[-(1:1)]
 }else{
 i
 }
 }


 Within the function, how can I access the table name of a given element (
 e.g.
 $rs3909907)? Using names(i) I get the header of the table...

 Thanking you!
 Georg.

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] stack multiple plots on one page

2007-06-28 Thread Jiong Zhang, PhD
Hi All,

I typed pairs to see its code but did not get what I want.  How do I
see its code?

What I am trying to do, is to stack about 10 scatter plots on one page
as the way pairs does.  I have about 150 variables in my table.
Instead of plotting 150X150 pairs using pairs, I only need to plot 10
pairs.

Thanks.

jiong
 The email message (and any attachments) is for the sole use of the intended 
recipient(s) and may contain confidential information.  Any unauthorized 
review, use, disclosure or distribution is prohibited.  If you are not the 
intended recipient, please contact the sender by reply email and destroy all 
copies of the original message (and any attachments).  Thank You.



[[alternative HTML version deleted]]

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


Re: [R] stack multiple plots on one page

2007-06-28 Thread Henrique Dallazuanna
https://svn.r-project.org/R/branches/R-2-5-branch/src/library/graphics/R/pairs.R

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

On 28/06/07, Jiong Zhang, PhD [EMAIL PROTECTED] wrote:

 Hi All,

 I typed pairs to see its code but did not get what I want.  How do I
 see its code?

 What I am trying to do, is to stack about 10 scatter plots on one page
 as the way pairs does.  I have about 150 variables in my table.
 Instead of plotting 150X150 pairs using pairs, I only need to plot 10
 pairs.

 Thanks.

 jiong
 The email message (and any attachments) is for the sole use of the
 intended recipient(s) and may contain confidential information.  Any
 unauthorized review, use, disclosure or distribution is prohibited.  If you
 are not the intended recipient, please contact the sender by reply email and
 destroy all copies of the original message (and any attachments).  Thank
 You.



 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] Evaluating predictive power with no intercept-statistics question - not R question

2007-06-28 Thread Leeds, Mark \(IED\)
I realize that the following has been talked about on this list many
times before in some related way but I
am going to ask for help anyway because I still don't know what to do. 

Suppose I have no intercept models such as the following :

Y = B*X_1 + error
Y = B*X_2 + error
Y = B*X_3 + error
Y = B*X_4 + error

and I run regressions on each ( over the same sample of Y ) and now I
want to evaluate which X has the greatest predictive power.
I'm fairly certain that R squared is not applicable because of the lack
of an intercept but I was wondering what was ? 
Any references to this particular problem or suggestions are
appreciated. I honestly believe that including an intercept is incorrect
For my particular problem. Thanks.

Maybe I could put all the X's in one regression and some kind of
topdownselect or StepAIC algorithm for example ?  Thanks.


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

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


[R] Course in Boston** R/Splus Fundamentals and Programming Techniques

2007-06-28 Thread elvis
XLSolutions Corporation (www.xlsolutions-corp.com) is making a last call
for our July 2007 R/S-plus Fundamentals and
Programming
Techniques : www.xlsolutions-corp.com/Rfund.htm

In Boston ***   July 16 - 17, 2007


Reserve your seat now at the early bird rates! Payment due AFTER
the class

Course Description:

This two-day beginner to intermediate R/S-plus course focuses on a
broad spectrum of topics, from reading raw data to a comparison of R
and S. We will learn the essentials of data manipulation, graphical
visualization and R/S-plus programming. We will explore statistical
data analysis tools,including graphics with data sets. How to enhance
your plots, build your own packages (librairies) and connect via
ODBC,etc.
We will perform some statistical modeling and fit linear regression
models. Participants are encouraged to bring data for interactive
sessions

With the following outline:

- An Overview of R and S
- Data Manipulation and Graphics
- Using Lattice Graphics
- A Comparison of R and S-Plus
- How can R Complement SAS?
- Writing Functions
- Avoiding Loops
- Vectorization
- Statistical Modeling
- Project Management
- Techniques for Effective use of R and S
- Enhancing Plots
- Using High-level Plotting Functions
- Building and Distributing Packages (libraries)
- Connecting; ODBC, Rweb, Orca via sockets and via Rjava


Email us for group discounts.
Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578
Visit us: www.xlsolutions-corp.com/courselist.htm

Please let us know if you and your colleagues are interested in this
classto take advantage of group discount. Register now to secure your
seat!

Interested in R/Splus Advanced course? email us.


Cheers,
Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.com
[EMAIL PROTECTED]

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


Re: [R] stack multiple plots on one page

2007-06-28 Thread Benilton Carvalho
or just type:

pairs.default

b

On Jun 28, 2007, at 2:36 PM, Henrique Dallazuanna wrote:

 https://svn.r-project.org/R/branches/R-2-5-branch/src/library/ 
 graphics/R/pairs.R

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

 On 28/06/07, Jiong Zhang, PhD [EMAIL PROTECTED] wrote:

 Hi All,

 I typed pairs to see its code but did not get what I want.  How  
 do I
 see its code?

 What I am trying to do, is to stack about 10 scatter plots on one  
 page
 as the way pairs does.  I have about 150 variables in my table.
 Instead of plotting 150X150 pairs using pairs, I only need to  
 plot 10
 pairs.

 Thanks.

 jiong
 The email message (and any attachments) is for the sole use of the
 intended recipient(s) and may contain confidential information.  Any
 unauthorized review, use, disclosure or distribution is  
 prohibited.  If you
 are not the intended recipient, please contact the sender by reply  
 email and
 destroy all copies of the original message (and any attachments).   
 Thank
 You.



 [[alternative HTML version deleted]]

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


   [[alternative HTML version deleted]]

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

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


Re: [R] no applicable method

2007-06-28 Thread Kyle Ellrott
You actually got it right.
I didn't realize there was a difference between a data frame and  
matrix.  What is the difference any way?  Seems like all two  
dimensional arrays should be equivalent.

Kyle



 On Wed, 27 Jun 2007, Kyle Ellrott wrote:

 I'm getting started in R, and I'm trying to use one of the gradient
 boosting packages, mboost.  I'm already installed the package with
 install.packages(mboost) and loaded it with library(mboost).
 My problem is that when I attempt to call glmboost, I get a message
 that  Error in glmboost() : no applicable method for glmboost .
 Does anybody have an idea of what kind of problem this is  
 indicative of?

 The wrong class of input object 'x'.  The help page for glmboost is  
 written obscurely, but it seems to imply that it has methods for  
 'formula' and 'matrix'.

 Perhaps you passed a data frame?

 PLEASE do read the posting guide http://www.R-project.org/posting- 
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

 is pertinent.  With an example and its output we would have been  
 much better placed to help you.

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

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


Re: [R] R function command on a list

2007-06-28 Thread Georg Ehret
Thank you Henrique,
rownames also gives me the header of the table, but not the name of the
list-element...
Any other idea?

Wishing you a good day, Georg.
**
Georg Ehret
Johns Hopkins University
Baltimore

On 6/28/07, Henrique Dallazuanna [EMAIL PROTECTED] wrote:

 Try whit rownames.

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

 On 28/06/07, G E [EMAIL PROTECTED] wrote:

  Hello R:
 I am working with a self-defined function and I wish to subject a
  list
  (t) to this function. My list is a list of tables:
  $rs7609589
  2/2 2/4 4/4 2/2 2/4 4/4
  89 188  87  89 188  87
 
  $rs3909907
 
  1/1 1/4 4/4
  94 178  92
 
  $rs12748004
 
  0/0 1/3 3/3
  37 150 177
 
  $rs6695928
 
  2/2 2/4 4/4
  35 129 200
 
  My function looks as follows:
  delete_nocall_listoftables-function(i){
  names-names(i)
  i
  if (names[1] == 0/0){
  i[-(1:1)]
  }else{
  i
  }
  }
 
 
  Within the function, how can I access the table name of a given element
  ( e.g.
  $rs3909907)? Using names(i) I get the header of the table...
 
  Thanking you!
  Georg.
 
  [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



[[alternative HTML version deleted]]

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


Re: [R] Loading problem with XML_1.9

2007-06-28 Thread Martin Morgan
Weijun --

If memory is a problem, you might try using the 'handler' argument of
xmlTreeParse. This provides access to each node as it is processed, so
that you can, for instance, choose to ignore nodes, or save only
numeric values, or ... I'm not sure whether the entire document is
read into a C 'external pointer', or whether the savings is just in
the R representation of the document.

Also, depending on how you use the resulting document, you might want
to watch out for the memory leak mentioned in
http://www.omegahat.org/RSXML/Changes

Martin

Luo Weijun [EMAIL PROTECTED] writes:

 Hello all,
 I have loading problem with XML_1.9 under 64 bit
 R2.3.1, which I got from http://R.research.att.com/.
 XML_1.9 works fine under 32 bit R2.5.0. I thought that
 could be installation problem, and I tried
 install.packages or biocLite, every time the package
 installed fine, except some warning messages below:
 ld64 warning: in /usr/lib/libxml2.dylib, file does not
 contain requested architecture
 ld64 warning: in /usr/lib/libz.dylib, file does not
 contain requested architecture
 ld64 warning: in /usr/lib/libiconv.dylib, file does
 not contain requested architecture
 ld64 warning: in /usr/lib/libz.dylib, file does not
 contain requested architecture
 ld64 warning: in /usr/lib/libxml2.dylib, file does not
 contain requested architecture

 Here is the error messages I got, when XML is loaded:
 library(XML)
 Error in dyn.load(x, as.logical(local),
 as.logical(now)) : 
 unable to load shared library
 '/usr/local/lib64/R/library/XML/libs/XML.so':
   dlopen(/usr/local/lib64/R/library/XML/libs/XML.so,
 6): Symbol not found: _xmlMemDisplay
   Referenced from:
 /usr/local/lib64/R/library/XML/libs/XML.so
   Expected in: flat namespace
 Error: .onLoad failed in 'loadNamespace' for 'XML'
 Error: package/namespace load failed for 'XML'

 I understand that it has been pointed out that
 Sys.getenv(PATH) needs to be revised in the file
 XML/R/zzz.R, but I canâ�t even find that file under
 XML/R/ directory. Does anybody have any idea what
 might be the problem, and how to solve it? Thanks a
 lot!
 BTW, the reason I need to use R64 is that I have
 memory limitation issue with R 32 bit version when I
 load some very large XML trees. 

 Session information
 sessionInfo()
 Version 2.3.1 Patched (2006-06-27 r38447) 
 powerpc64-apple-darwin8.7.0 

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

 Weijun

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

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

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


[R] Function call within a function.

2007-06-28 Thread John Kane
I am trying to call a funtion within another function
and I clearly am misunderstanding what I should do. 
Below is a simple example.
I know lstfun works on its own but I cannot seem to
figure out how to get it to work within ukn. Basically
I need to create the variable nts. I have probably
missed something simple in the Intro or FAQ.

Any help would be much appreciated.

EXAMPLE
---
# create data.frame
cata - c( 1,1,6,1,1,4)
catb - c( 1,2,3,4,5,6)
id - c('a', 'b', 'b', 'a', 'a', 'b')
dd1  -  data.frame(id, cata,catb)

# function to create list from data.frame
lstfun  - function(file, alpha , beta ) {
cda  -  subset(file, file[,1] == alpha)
cdb  -  subset (file, file[,1]== beta)
list1 - list(cda,cdb)
}

# funtion to operate on list
ukn  -  function(file, alpha, beta, nam1){
aa  - alpha
bb  - beta
myfile  - file
nts - lstfun(myfile, aa, bb)
mysum - nam1[,3]*5
return(mysum)
}

results - ukn(dd1, a, b, nts$cda)

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


Re: [R] Error en assign(mname, def, where)

2007-06-28 Thread hadley wickham
Hi Martin,

Could you please provide a minimal replicable example so that we can
investigate further.

Thanks,

Hadley

On 6/28/07, Martín Gastón [EMAIL PROTECTED] wrote:

 Hi R users,
 I am working with the fda package but when I call the function pca.fd I
 obtain a message error, which I cann't identify. The error say That :
  error in assihn(mname,def,where), is not possible to add links to a
 blockade enviroment.
 The orther that I'm writting is:

  cp1 - pca.fd(ind.fd1,nharm=3)

 and before it I can to plot the functional data object ind.fd1.
 ¿Have anybody seen this error or any similar message?,
 ¿Any idea?

 Thancks for your help
 --
 View this message in context: 
 http://www.nabble.com/Error-en-assign%28mname%2C-def%2C-where%29-tf3995432.html#a11346689
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] R function command on a list

2007-06-28 Thread Henrique Dallazuanna
Perhaps, you can get the name of list element whit:

unlist(lapply(list_name, rownames))



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

On 28/06/07, Georg Ehret [EMAIL PROTECTED] wrote:

 Thank you Henrique,
 rownames also gives me the header of the table, but not the name of the
 list-element...
 Any other idea?

 Wishing you a good day, Georg.
 **
 Georg Ehret
 Johns Hopkins University
 Baltimore

 On 6/28/07, Henrique Dallazuanna [EMAIL PROTECTED] wrote:
 
  Try whit rownames.
 
  --
  Henrique Dallazuanna
  Curitiba-Paraná-Brasil
  25° 25' 40 S 49° 16' 22 O
 
  On 28/06/07, G E [EMAIL PROTECTED] wrote:
 
   Hello R:
  I am working with a self-defined function and I wish to subject a
   list
   (t) to this function. My list is a list of tables:
   $rs7609589
   2/2 2/4 4/4 2/2 2/4 4/4
   89 188  87  89 188  87
  
   $rs3909907
  
   1/1 1/4 4/4
   94 178  92
  
   $rs12748004
  
   0/0 1/3 3/3
   37 150 177
  
   $rs6695928
  
   2/2 2/4 4/4
   35 129 200
  
   My function looks as follows:
   delete_nocall_listoftables-function(i){
   names-names(i)
   i
   if (names[1] == 0/0){
   i[-(1:1)]
   }else{
   i
   }
   }
  
  
   Within the function, how can I access the table name of a given
 element
   ( e.g.
   $rs3909907)? Using names(i) I get the header of the table...
  
   Thanking you!
   Georg.
  
   [[alternative HTML version deleted]]
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 

 [[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


[R] mixed-effects model using lmer

2007-06-28 Thread hlynch
Hello R-users,

I have been trying to fit what I think is a simple mixed-effects model using 
lmer (from lme4), but I've run into some difficulty that I have not been able 
to resolve using the existing archives or Pinheiro and Bates (2000).

I am measuring populations (of birds) which change with time at a number of 
different sites. These sites are grouped into regions. Sites are not measured 
with any regularity, so each site has a different number of observations. I 
want to treat the effect of year (i.e. the rate of population change) as a 
fixed effect which is modeled separately for each region, but I want to allow 
sites within regions to be random effects. I've come up with the following 
model, but I'm not sure its correct. Any help would be most appreciated.

fit-lmer(log.count~site+month+year:region-1+(year:region-1|site))

What my variables mean:
log.count=log(count)
site=factor for the different sites, each site is associated with exactly one 
region
month=fixed effect for the month of the survey
year:region = allows me to model different year effects for each region

Each site should have a completely separate intercept, so I have chosen to 
suppress the intercept and use all the factors of site instead.

The difficulty is, of course, with the last term. I want to have sites vary 
randomly *within* a region, but I don't want them to vary randomly throughout 
all the regions, i.e. I want the random effects to sum to zero for each region 
separately. 

My output looks like (using the display() function from Gelman and Hill (2007)):

***
lmer(formula = log.count ~ site + month + year:region - 1 + (year:region - 
1 | site))
  coef.est coef.se
siteAITC   7.25 0.15  
siteALMI   4.57 0.29  
siteBENE   5.98 0.29  
siteBOOT   7.08 0.17  
siteBROW   6.47 0.14  
(I cut some out here for space) 
siteUSEF   6.97 0.21  
siteWATE   7.38 0.15  
siteYANK   8.31 0.11  
monthJAN  -0.15 0.07  
monthNOV  -0.01 0.07  
year:regionNE -0.16 0.12  
year:regionNW  0.04 0.01  
year:regionSH  0.02 0.02  
year:regionSW  0.07 0.01  

Error terms:
 Groups   Name  Std.Dev. Corr   
 site year:regionNE 0.12
  year:regionNW 0.03 0.00   
  year:regionSH 0.00 0.00 0.00  
  year:regionSW 0.00 0.00 0.00 0.00 
 Residual   0.26
---
number of obs: 110, groups: site, 23
AIC = 157.8, DIC = -72.6
deviance = 3.6 



The coefficients look totally reasonable given all the analysis I've already 
done on the system. My confusion comes about when I look at the random effects 
using ranef(fit) and se.ranef(fit):


ranef(fit)

An object of class ranef.lmer
[[1]]
 year:regionNE year:regionNW year:regionSH year:regionSW
AITC   0.0e+00   0.0e+00   5.8e-10   0.0e+00
ALMI   0.0e+00  -2.3e-04   0.0e+00   0.0e+00
BENE   0.0e+00  -2.1e-17   0.0e+00   0.0e+00
BOOT   0.0e+00   0.0e+00   0.0e+00  -2.4e-09
BROW   3.0e-15   0.0e+00   0.0e+00   0.0e+00
BRYE   0.0e+00  -1.3e-02   0.0e+00   0.0e+00
BRYS   0.0e+00  -8.9e-17   0.0e+00   0.0e+00
CUVE   0.0e+00  -1.7e-02   0.0e+00   0.0e+00
DAMO   0.0e+00  -5.0e-03   0.0e+00   0.0e+00
DANC   0.0e+00  -5.2e-03   0.0e+00   0.0e+00
DOBE   0.0e+00   8.1e-04   0.0e+00   0.0e+00
GEOR   0.0e+00  -9.3e-03   0.0e+00   0.0e+00
HANN   0.0e+00   0.0e+00   3.2e-10   0.0e+00
HERO  -6.3e-16   0.0e+00   0.0e+00   0.0e+00
JOUG   0.0e+00  -2.3e-02   0.0e+00   0.0e+00
MADD   7.3e-16   0.0e+00   0.0e+00   0.0e+00
MOOT   0.0e+00   0.0e+00   0.0e+00   8.7e-11
NEKO   0.0e+00  -2.1e-03   0.0e+00   0.0e+00
PETE   0.0e+00   0.0e+00   0.0e+00   2.5e-09
PLEN   0.0e+00   0.0e+00   0.0e+00  -2.0e-10
USEF   0.0e+00   5.6e-02   0.0e+00   0.0e+00
WATE   0.0e+00   1.8e-02   0.0e+00   0.0e+00
YANK   0.0e+00   0.0e+00  -9.0e-10   0.0e+00

se.ranef(fit)

$site
 year:regionNE year:regionNW year:regionSH year:regionSW
AITC 0.1200.0296   5.8e-06   5.8e-06
ALMI 0.1200.0204   5.8e-06   5.8e-06
BENE 0.1200.0196   5.8e-06   5.8e-06
BOOT 0.1200.0296   5.8e-06   5.8e-06
BROW 0.0160.0296   5.8e-06   5.8e-06
BRYE 0.1200.0144   5.8e-06   5.8e-06
BRYS 0.1200.0231   5.8e-06   5.8e-06
CUVE 0.1200.0136   5.8e-06   5.8e-06
DAMO 0.1200.0086   5.8e-06   5.8e-06
DANC 

[R] sampling question

2007-06-28 Thread Kirsten Beyer
I am interested in locating a script to implement a sampling scheme
that would basically make it more likely that a particular observation
is chosen based on a weight associated with the observation.  I am
trying to select a sample of ~30 census blocks from each ZIP code area
based on the proportion of women in a ZCTA living in a particular
block.  I want to make it more likely that a block will be chosen if
the proportion of women in a patient's age group in a particular block
is high. Any ideas are appreciated!

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


[R] applying max elementwise to two vectors

2007-06-28 Thread Afshartous, David
 
All,

Is there one liner way to obtain the max per observation for two
vectors?
I looked at apply and lapply but it seems that groundwork would have to
be done before applying either of those.  The code below does it but
seems
like overkill.

Thanks!
Dave

x = rnorm(10)
y = rnorm(10)

ind = which(x  y)
z = x
z[ind] - y[ind]  ## z now contains the max's

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


[R] Wilcoxon Rank Sum Test.

2007-06-28 Thread Marcus Vinicius
Dear,

I'm using R software to evaluate Wilcoxon Rank Sum Test and I' getting one
Warning message as this:

 C1dea_com
 [1] 1.000 0.345 0.200 0.208 0.508 0.480 0.545 0.563 0.451 0.683 0.380 0.913
1.000 0.506
 C1dea_sem
 [1] 1.000 0.665 0.284 0.394 0.509 0.721 0.545 0.898 0.744 0.683 0.382 0.913
1.000 0.970


 wilcox.test(C1dea_sem,C1dea_com, paired = TRUE, alternative = two.sided)

Wilcoxon signed rank test with continuity correction

data:  C1dea_sem and C1dea_com
V = 45, p-value = 0.009152
alternative hypothesis: true mu is not equal to 0

Warning message:
Cannot compute exact p-value with zeroes in: wilcox.test.default(C1dea_sem,
C1dea_com, paired = TRUE, alternative = two.sided)

What is happening?

Best Regards,

Marcus Vinicius

[[alternative HTML version deleted]]

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


Re: [R] Sweave bug? when writing figures / deleting variable in chunk

2007-06-28 Thread D G Rossiter
Thanks to the four distinguished R'ers who answered. I have used  
Sweave intensively for over a year, and have poured through all the  
doc. as well as the help archives, and could find nothing on this. It  
is now well known to me! since it bit me, but it did cost me a day  
of head-scratching and putting it in the shortest possible form for  
the list (the original example where this happened was a lot more  
complicated). Perhaps it could be documented in Sweave- 
manual-20060104.pdf or its successor?

Now I see the reasoning behind it, thanks. I had already determined  
the work-around. The problem is that I distribute the Tangled .R  
files along with the Sweaved PDF doc, so that students etc. can run  
the code. Anything unintuitive in the code confuses people. In this  
case I think it's good pratice to delete temporary variables right  
after they are no longer needed (as in my original example), so  
that's why I want to put it in the same chunk.

Having said that, I am a Sweave devotee, it has radically improved my  
productivity in writing R-based tech. notes.

David Rossiter
ITC Enschede (NL)

On 27 Jun2007, at 21:34, Achim Zeileis wrote:

 On Wed, 27 Jun 2007 21:06:04 -0400 D G Rossiter wrote:

 I have found a quite strange (to me) behaviour in Sweave. It only
 occurs in the following situation:

 1. define a variable in one chunk
 2. use it within a subsequent figure-generating chunk
 3. delete it at the end of that same chunk
 Then the Sweave driver chokes, not finding the variable name when
 generating the figure

 Sweave() executes figure chunks more than once because they might
 also create printed output. If you create both EPS and PDF  
 graphics, it
 executes them three times (print + EPS + PDF). Hence, data
 manipulations should be avoided in figure chunks.

 I was also once bitten by this when I permuted columns of a table  
 prior
 to plotting and never obtained the desired order...

 Fritz, maybe this is worth an entry in the FAQ?
 Z

 Example:

 % document bug2.Rnw
 \documentclass{article}
 \usepackage{Sweave}
 \begin{document}
 \SweaveOpts{eps=false}
 =
 sel - 1:5
 @
 fig=T=
 plot(trees[sel,])
 rm(sel)
 @
 \end{document}

 Try to sweave:

 Sweave(bug2.Rnw)
 Writing to file bug2.tex
 Processing code chunks ...
 1 : echo term verbatim
 2 : echo term verbatim pdf
 Error: no function to return from, jumping to top level
 Error in plot(trees[sel, ]) : error in evaluating the argument 'x'
 in selecting a method for function 'plot'
 Error in driver$runcode(drobj, chunk, chunkopts) :
  Error in plot(trees[sel, ]) : error in evaluating the
 argument 'x' in selecting a method for function 'plot'

 The generated .tex is complete up through the rm() but no figure is
 generated. The file bug2-002.pdf is incomplete (corrupt).

 ...
 \begin{Schunk}
 \begin{Sinput}
 plot(trees[sel, ])
 rm(sel)
 \end{Sinput}
 \end{Schunk}

 The following ALL eliminate the problem:

 0. Executing the code directly, also with ESS
 1. fig=F
 2. moving rm(sel) to a separate, later code chunk
 3. Stangle the source and then source it
 4. don't use a variable, i.e. in this case:  plot(trees[1:5,])

 It seems that Sweave is executing the rm(sel)  before it uses it in
 the trees[sel,].

 Technical details: R 2.5.0, Mac OS X 10.4.10, PPC
 Same behaviour in stand-alone R for Mac and for R within Aquamacs
 using ESS

 Workaround: I am putting any deletions into a later code chunk. This
 only has the disadvantage of making more chunks, so now that I know
 what's happening it's no big deal. But it's driving me crazy... am I
 missing something? Thanks!

 D. G. Rossiter
 Senior University Lecturer
 Department of Earth Systems Analysis
 International Institute for Geo-Information Science and Earth
 Observation (ITC)
 Hengelosestraat 99
 PO Box 6, 7500 AA Enschede, The Netherlands
 Phone:   +31-(0)53 4874 499
 Fax: +31-(0)53 4874 336
 mailto:rossiter--at--itc.nl,  Internet: http://www.itc.nl/personal/
 rossiter

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


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


Re: [R] Sweave bug? when writing figures / deleting variable in chunk

2007-06-28 Thread Friedrich Leisch
 On Thu, 28 Jun 2007 08:14:44 -0400,
 D G Rossiter (DGR) wrote:

   Thanks to the four distinguished R'ers who answered. I have used  
   Sweave intensively for over a year, and have poured through all the  
   doc. as well as the help archives, and could find nothing on this. It  
   is now well known to me! since it bit me, but it did cost me a day  
   of head-scratching and putting it in the shortest possible form for  
   the list (the original example where this happened was a lot more  
   complicated).

Sorry!

   Perhaps it could be documented in Sweave- 
   manual-20060104.pdf or its successor?

Yes, I'll put it in ASAP.

Best,
Fritz

-- 
---
Prof. Dr. Friedrich Leisch 

Institut für Statistik  Tel: (+49 89) 2180 3165
Ludwig-Maximilians-Universität  Fax: (+49 89) 2180 5308
Ludwigstraße 33
D-80539 München http://www.stat.uni-muenchen.de/~leisch

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


[R] Changing graphics height when using grid and lattice

2007-06-28 Thread Jim Price

Hi,

I have recently been playing with the grid package in an attempt to create
some pages containing multiple lattice plots on the same page. However, when
I specify a grid layout with different widths, such as:

pushViewport(viewport(layout = grid.layout(1, 2, unit(c(2, 1), null

the individual graphs do not end up as the same height - which is a feature
I would prefer to have. 

A complete example is as follows:

### Start of example

library(lattice)
library(Hmisc)
library(grid)


# Incidence data
testData - data.frame(
strata = rep(c(CHF : Yes, CHF : No), each = 20),
ae = rep(paste(Adverse Event, 1:10), each = 2),
trt = rep(c(Active, Placebo), 20),
pct = runif(40, 1, 30)
)

# RR data
testData2 - data.frame(
strata = rep(c(CHF : Yes, CHF : No), each = 10),
ae = paste(Adverse Event, 1:10),
rr = runif(20, 0.5, 5)
)
testData2$lower = testData2$rr / 2
testData2$upper = testData2$rr * 2


# Combined plot
testPlots - function(relativeWidth)
{

plot1- dotplot(
ae ~ pct | strata, 
groups = trt, 
data = testData,  
layout = c(1, 2),
xlab = Percent,
auto.key = list(space = top, columns = 2)
)


plot2 - Dotplot(
ae ~ Cbind(rr, log10(lower), log10(upper)) | strata,
data = testData2,
panel = function(...)
{
panel.Dotplot(...)
panel.abline(v = 0, col = 'red', lty = 2)
},
layout = c(1, 2), 
scales = list(
x = list(log = T, at = c(0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 32)),
y = list(draw = F)
),
xlab = Relative Risk with 95% CI,
ylab = ,
key = list(text = list())
)


grid.newpage()

pushViewport(viewport(layout = grid.layout(2, 1, heights = unit(c(1, 6),
null

pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1))
grid.text(Analysis of Relative Risks of various Adverse Events)
upViewport()

pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 2))


### Change the relative width of the 2 presented graphics
pushViewport(viewport(layout = grid.layout(1, 2, unit(c(relativeWidth, 1),
null

pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1))
print(plot1, newpage = F)
upViewport()

pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 1))
print(plot2, newpage = F)
upViewport()

}


# Everything is fine, both graphs maintain the same y-axis
testPlots(1)

# The second graph is now taller than the first one
win.graph()
testPlots(3)

# End of example

I've been through the documentation of both lattice and grid, and I have not
been able to find the answer. I would appreciate any solution!

Regards,

James Price.
-- 
View this message in context: 
http://www.nabble.com/Changing-graphics-height-when-using-grid-and-lattice-tf3996724.html#a11350733
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Wilcoxon Rank Sum Test.

2007-06-28 Thread Nordlund, Dan (DSHS/RDA)

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Marcus Vinicius
 Sent: Thursday, June 28, 2007 1:32 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Wilcoxon Rank Sum Test.
 
 Dear,
 
 I'm using R software to evaluate Wilcoxon Rank Sum Test and 
 I' getting one
 Warning message as this:
 
  C1dea_com
  [1] 1.000 0.345 0.200 0.208 0.508 0.480 0.545 0.563 0.451 
 0.683 0.380 0.913
 1.000 0.506
  C1dea_sem
  [1] 1.000 0.665 0.284 0.394 0.509 0.721 0.545 0.898 0.744 
 0.683 0.382 0.913
 1.000 0.970
 
 
  wilcox.test(C1dea_sem,C1dea_com, paired = TRUE, alternative 
 = two.sided)
 
 Wilcoxon signed rank test with continuity correction
 
 data:  C1dea_sem and C1dea_com
 V = 45, p-value = 0.009152
 alternative hypothesis: true mu is not equal to 0
 
 Warning message:
 Cannot compute exact p-value with zeroes in: 
 wilcox.test.default(C1dea_sem,
 C1dea_com, paired = TRUE, alternative = two.sided)
 
 What is happening?
 
 Best Regards,
 
 Marcus Vinicius
 

Marcus,

It means that you have one or more pairs of observations (5 in your case) where 
the difference is 0.  The wilcox.test can only compute an approximate p-value 
under these circumstances.

Hope this is helpful,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

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


Re: [R] applying max elementwise to two vectors

2007-06-28 Thread Sebastian P. Luque
On Thu, 28 Jun 2007 16:19:39 -0400,
Afshartous, David [EMAIL PROTECTED] wrote:

 All,

 Is there one liner way to obtain the max per observation for two
 vectors?  I looked at apply and lapply but it seems that groundwork
 would have to be done before applying either of those.  The code below
 does it but seems like overkill.

 Thanks!  Dave

 x = rnorm(10) y = rnorm(10)

 ind = which(x  y) z = x z[ind] - y[ind] ## z now contains the max's

?pmax


-- 
Seb

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


Re: [R] sampling question

2007-06-28 Thread Greg Snow
The sample function has a prob argument that determines the
probabilities of each element being sampled, put your proportion of
women in there and see if that works for you.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Kirsten Beyer
 Sent: Thursday, June 28, 2007 2:00 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] sampling question
 
 I am interested in locating a script to implement a sampling 
 scheme that would basically make it more likely that a 
 particular observation is chosen based on a weight associated 
 with the observation.  I am trying to select a sample of ~30 
 census blocks from each ZIP code area based on the proportion 
 of women in a ZCTA living in a particular block.  I want to 
 make it more likely that a block will be chosen if the 
 proportion of women in a patient's age group in a particular 
 block is high. Any ideas are appreciated!
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Function call within a function.

2007-06-28 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of John Kane
 Sent: Thursday, June 28, 2007 12:04 PM
 To: R R-help
 Subject: [R] Function call within a function.
 
 I am trying to call a funtion within another function
 and I clearly am misunderstanding what I should do. 
 Below is a simple example.
 I know lstfun works on its own but I cannot seem to
 figure out how to get it to work within ukn. Basically
 I need to create the variable nts. I have probably
 missed something simple in the Intro or FAQ.
 
 Any help would be much appreciated.
 
 EXAMPLE
 --
 -
 # create data.frame
 cata - c( 1,1,6,1,1,4)
 catb - c( 1,2,3,4,5,6)
 id - c('a', 'b', 'b', 'a', 'a', 'b')
 dd1  -  data.frame(id, cata,catb)
 
 # function to create list from data.frame
 lstfun  - function(file, alpha , beta ) {
 cda  -  subset(file, file[,1] == alpha)
 cdb  -  subset (file, file[,1]== beta)
 list1 - list(cda,cdb)
 }
 
 # funtion to operate on list
 ukn  -  function(file, alpha, beta, nam1){
 aa  - alpha
 bb  - beta
 myfile  - file
 nts - lstfun(myfile, aa, bb)
 mysum - nam1[,3]*5
 return(mysum)
 }
 
 results - ukn(dd1, a, b, nts$cda)

John,

The first problem I see is one of scope.  nts$cda refers to an object called 
nts which does not exist in the calling environment (it is local to the 
function ukn).  So trying to call ukn() with nts results in an error.  Second, 
even if you pass the name of the object, you will not be able to use it in 
ukn() in the manner that you are trying.  Your ukn() function definition also 
requires that it know the inner workings of function lstfun().  Functions 
generally shouldn't require knowing how other functions work, they should only 
rely on what value is returned.

You can get what you want by redefining ukn in the following way

# funtion to operate on list
ukn  -  function(file, alpha, beta, nam1){
aa  - alpha
bb  - beta
myfile  - file
nts - lstfun(myfile, aa, bb)
mysum - nts[[nam1]][,3]*5
return(mysum)
}

And change the function call to

results - ukn(dd1, a, b, 1) 

This still leaves the functions coupled in a way that I don't like, but I'm not 
a good enough R programmer to solve that problem at the moment.  Maybe someone 
else will come along with a better solution.

Hope this is helpful,

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

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


Re: [R] applying max elementwise to two vectors

2007-06-28 Thread Afshartous, David

thanks all.  yes, pmax(x,y) gets it straight away.  sorry for missing
this
when I checked the docs. 

-Original Message-
From: Greg Snow [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 28, 2007 5:26 PM
To: Afshartous, David; r-help@stat.math.ethz.ch
Subject: RE: [R] applying max elementwise to two vectors

Are you looking for pmax? (look at the help ?pmax and the examples and
see if that does what you want).

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Afshartous, 
 David
 Sent: Thursday, June 28, 2007 2:20 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] applying max elementwise to two vectors
 
 
  
 All,
 
 Is there one liner way to obtain the max per observation for two 
 vectors?
 I looked at apply and lapply but it seems that groundwork would have 
 to be done before applying either of those.  The code below does it 
 but seems like overkill.
 
 Thanks!
 Dave
 
 x = rnorm(10)
 y = rnorm(10)
 
 ind = which(x  y)
 z = x
 z[ind] - y[ind]  ## z now contains the max's
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] applying max elementwise to two vectors

2007-06-28 Thread Bert Gunter
Please... use and **read** the docs:

?max   --- pmax 


Bert Gunter


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Afshartous, David
Sent: Thursday, June 28, 2007 1:20 PM
To: r-help@stat.math.ethz.ch
Subject: [R] applying max elementwise to two vectors

 
All,

Is there one liner way to obtain the max per observation for two
vectors?
I looked at apply and lapply but it seems that groundwork would have to
be done before applying either of those.  The code below does it but
seems
like overkill.

Thanks!
Dave

x = rnorm(10)
y = rnorm(10)

ind = which(x  y)
z = x
z[ind] - y[ind]  ## z now contains the max's

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

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


Re: [R] Wilcoxon Rank Sum Test.

2007-06-28 Thread Achim Zeileis
On Thu, 28 Jun 2007 14:18:52 -0700 Nordlund, Dan (DSHS/RDA) wrote:

 
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of Marcus
  Vinicius Sent: Thursday, June 28, 2007 1:32 PM
  To: r-help@stat.math.ethz.ch
  Subject: [R] Wilcoxon Rank Sum Test.
  
  Dear,
  
  I'm using R software to evaluate Wilcoxon Rank Sum Test and 
  I' getting one
  Warning message as this:
  
   C1dea_com
   [1] 1.000 0.345 0.200 0.208 0.508 0.480 0.545 0.563 0.451 
  0.683 0.380 0.913
  1.000 0.506
   C1dea_sem
   [1] 1.000 0.665 0.284 0.394 0.509 0.721 0.545 0.898 0.744 
  0.683 0.382 0.913
  1.000 0.970
  
  
   wilcox.test(C1dea_sem,C1dea_com, paired = TRUE, alternative 
  = two.sided)
  
  Wilcoxon signed rank test with continuity correction
  
  data:  C1dea_sem and C1dea_com
  V = 45, p-value = 0.009152
  alternative hypothesis: true mu is not equal to 0
  
  Warning message:
  Cannot compute exact p-value with zeroes in: 
  wilcox.test.default(C1dea_sem,
  C1dea_com, paired = TRUE, alternative = two.sided)
  
  What is happening?
  
  Best Regards,
  
  Marcus Vinicius
  
 
 Marcus,
 
 It means that you have one or more pairs of observations (5 in your
 case) where the difference is 0.  The wilcox.test can only compute an
 approximate p-value under these circumstances.

...while wilcox.exact() from package exactRankTests can evaluate the
permutation distribution correctly.
Z

 Hope this is helpful,
 
 Dan
 
 Daniel J. Nordlund
 Research and Data Analysis
 Washington State Department of Social and Health Services
 Olympia, WA  98504-5204
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.


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


Re: [R] Adding different output to different lattice panels

2007-06-28 Thread Alexandre Salvador
Selon [EMAIL PROTECTED]:

 On 6/28/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  I would like to add a reference line to lattice graphs, with the reference
  line
  being different according to the factor level.
 
  Example : Draw 3 dotplots for a,b and c factors, and then add an
  horizontal line at y=10 for panel a, y=8 for panel b and y=6 for panel
  4
 
  I tried the code below, but this draw all three reference lines for each
  panel.
  How do I index the current panel to chose the right reference vector value
 ?
 
 

dat-data.frame(id=rep(c(a,b,c),4),val=1:12,quand=rep(c(t1,t2,t3,t4),each=3))
  ref-c(10,8,6)
  plot.new()
  datplot-dotplot(val~quand|id,data=dat,panel=function(...){
  panel.dotplot(...)
  panel.abline(h=ref)
  })
  print(datplot)

 dotplot(val~quand|id,data=dat,panel=function(...){
 panel.dotplot(...)
 panel.abline(h = ref[packet.number()])
 })

 (Things are more complicated if you have more than one conditioning
 variable.)

 -Deepayan


I tried you solution, but the following error appears when I print(datplot):

   Erreur dans as.numeric(h) : impossible de trouver la fonction packet.number

I have lattice and grid libraries loaded. The exact code I use is
datplot-dotplot(val~quand|id,data=dat,panel=function(...){
panel.dotplot(...)
panel.abline(h=ref[packet.number()])
})
print(datplot)
What do I do wrong ?

Note : I usually need to use the indirect datplot-dotplot(...  and then
print(datplot) when I store my code in a file and use it through
source(myfile.R). The direct dotplot(... does not open a device whereas it
does if I type directly dotplot(... at the R command line...
Is this normal ?

--
Alexandre Salvador
Tel: +33(0)6.8214.7733

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


Re: [R] Adding different output to different lattice panels

2007-06-28 Thread Alexandre Salvador
Selon Deepayan Sarkar [EMAIL PROTECTED]:

 On 6/28/07, Alexandre Salvador [EMAIL PROTECTED] wrote:
  Selon [EMAIL PROTECTED]:
 
   On 6/28/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I would like to add a reference line to lattice graphs, with the
 reference
line
being different according to the factor level.
   
Example : Draw 3 dotplots for a,b and c factors, and then add an
horizontal line at y=10 for panel a, y=8 for panel b and y=6 for
 panel
4
   
I tried the code below, but this draw all three reference lines for
 each
panel.
How do I index the current panel to chose the right reference vector
 value
   ?
   
   
  
 

dat-data.frame(id=rep(c(a,b,c),4),val=1:12,quand=rep(c(t1,t2,t3,t4),each=3))
ref-c(10,8,6)
plot.new()
datplot-dotplot(val~quand|id,data=dat,panel=function(...){
panel.dotplot(...)
panel.abline(h=ref)
})
print(datplot)
  
   dotplot(val~quand|id,data=dat,panel=function(...){
   panel.dotplot(...)
   panel.abline(h = ref[packet.number()])
   })
  
   (Things are more complicated if you have more than one conditioning
   variable.)
  
   -Deepayan
  
 
  I tried you solution, but the following error appears when I
 print(datplot):
 
 Erreur dans as.numeric(h) : impossible de trouver la fonction
 packet.number
 
  I have lattice and grid libraries loaded. The exact code I use is
  datplot-dotplot(val~quand|id,data=dat,panel=function(...){
  panel.dotplot(...)
  panel.abline(h=ref[packet.number()])
  })
  print(datplot)
  What do I do wrong ?

 You are using a very old version of R (or at least old enough that the
 packet.number number didn't exist). You haven't told us what version
 you are using.

 I would encourage you to upgrade, but this might work for now:

 dotplot(val~quand|id,data=dat,
 panel=function(..., panel.number){
 panel.dotplot(...)
 panel.abline(h = ref[panel.number])
 })

  Note : I usually need to use the indirect datplot-dotplot(...  and then
  print(datplot) when I store my code in a file and use it through
  source(myfile.R). The direct dotplot(... does not open a device whereas
 it
  does if I type directly dotplot(... at the R command line...
  Is this normal ?

 Yes, and a FAQ:


http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

 -Deepayan

Works all right,
I use Version 2.3.1 (2006-06-01)
I'll upgrade to the newer versions...
Thanks very much,
Cheers

--
Alexandre Salvador
Tel: +33(0)6.8214.7733

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


Re: [R] applying max elementwise to two vectors

2007-06-28 Thread Greg Snow
Are you looking for pmax? (look at the help ?pmax and the examples and
see if that does what you want).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Afshartous, David
 Sent: Thursday, June 28, 2007 2:20 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] applying max elementwise to two vectors
 
 
  
 All,
 
 Is there one liner way to obtain the max per observation for 
 two vectors?
 I looked at apply and lapply but it seems that groundwork 
 would have to be done before applying either of those.  The 
 code below does it but seems like overkill.
 
 Thanks!
 Dave
 
 x = rnorm(10)
 y = rnorm(10)
 
 ind = which(x  y)
 z = x
 z[ind] - y[ind]  ## z now contains the max's
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Writing - specyfic format

2007-06-28 Thread jastar

That's exactly what I need.
Thank's a lot!!


Earl F. Glynn wrote:
 
 jastar [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]

 Hi all,
 I have a trouble - I need to write file in a very specyfic format.
 I have two vectors which different lengths and one data.frame (or
 matrix).
 I want to write it to *.txt file in following way:
 1st row of file is my 1st vector (separate by spacebar)
 2nd row of file is 2nd vector (also separate by spacebar)
 Rest of this file should be a matrix with elements separated by tab.
 For example: a=1, 2, 3, b=4, 5, c=[1, 2, 3, 4, 5, 6;
7, 8, 9, 10, 11, 12,]
 and I want to have file (it have to be .txt file) like:
 1 2 3
 4 5
 1 2 3 4 5 6
 7 8 9 10   1112

 This thing have to be done automaticly from R.
 Is it possible?
 
 Try this:
 
 a - 1:3
 b - 4:5
 c - matrix(1:12, 2,6, byrow=TRUE)
 
 outFile - file(SpecificFormat.txt, w)
 cat(paste(a, sep= ), \n, file=outFile)
 cat(paste(b, sep= ), \n, file=outFile)
 
 for (j in 1:nrow(c))
 {
   cat(paste(c[j,], collapse=\t), \n, file=outFile)
 }
 
 close(outFile)
 
 
 Resulting output file (with spaces or tabs as specified):
 1 2 3
 4 5
 1 2 3 4 5 6
 7 8 9 10 11 12
 
 
 [But I normally avoid tabs since you cannot see them easily with many 
 editors.]
 
 efg
 
 Earl F. Glynn
 Stowers Institute for Medical Research
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Writing---specyfic-format-tf3994017.html#a11351319
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Function call within a function.

2007-06-28 Thread Stephen Tucker
Dear John,

Perhaps I am mistaken in what you are trying to accomplish but it seems like
what is required is that you call lstfun() outside of ukn(). [and remove the
call to lstfun() in ukn()].

nts - lstfun(myfile, aa, bb)
results - ukn(dd1, a, b, nts$cda)

Alternatively, you can eliminate the fourth argument in ukn() and assign (via
'-') the results of lstfun() to 'nam1' within ukn() instead of saving to
'nts'...

--- John Kane [EMAIL PROTECTED] wrote:

 I am trying to call a funtion within another function
 and I clearly am misunderstanding what I should do. 
 Below is a simple example.
 I know lstfun works on its own but I cannot seem to
 figure out how to get it to work within ukn. Basically
 I need to create the variable nts. I have probably
 missed something simple in the Intro or FAQ.
 
 Any help would be much appreciated.
 
 EXAMPLE

---
 # create data.frame
 cata - c( 1,1,6,1,1,4)
 catb - c( 1,2,3,4,5,6)
 id - c('a', 'b', 'b', 'a', 'a', 'b')
 dd1  -  data.frame(id, cata,catb)
 
 # function to create list from data.frame
 lstfun  - function(file, alpha , beta ) {
 cda  -  subset(file, file[,1] == alpha)
 cdb  -  subset (file, file[,1]== beta)
 list1 - list(cda,cdb)
 }
 
 # funtion to operate on list
 ukn  -  function(file, alpha, beta, nam1){
 aa  - alpha
 bb  - beta
 myfile  - file
 nts - lstfun(myfile, aa, bb)
 mysum - nam1[,3]*5
 return(mysum)
 }
 
 results - ukn(dd1, a, b, nts$cda)
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Function call within a function.

2007-06-28 Thread Jason Barnhart
The problem isn't the function call.

First, list1 returned by lstfun does not name its elements so nts$cda 
won't work. See code change in lstfun.

Second, specifying nts$cda as the nam1 argument tells R to look for 
the nts object in the environment in which ukn is called.  However, 
the nts object is not created in the parent environment, it is created 
in the ukn's environment.

Third, nam1[,3] should be nam1[2] as there is no third element to this 
list (although and this doesn't resolve the environment issue).

I've modified your code below to work, but there are better ways to go 
about this.  Thomas Lumley has a famous quote regarding parse.  See 
http://tolstoy.newcastle.edu.au/R/e2/help/07/01/8059.html among 
others.

I was once referred to Patrick Burns' S Poetry to learn about the 
eval(parse(text=))) paradigm which was very helpful. You may also 
want to brush up on environments (see ?environment) to learn more 
about lexical scoping.

Hope this helps.
-jason

#MODIFIED CODE
# create data.frame
cata - c( 1,1,6,1,1,4)
catb - c( 1,2,3,4,5,6)
id - c('a', 'b', 'b', 'a', 'a', 'b')
dd1 - data.frame(id, cata,catb)

# function to create list from data.frame
lstfun - function(file, alpha , beta ) {
cda - subset(file, file[,1] == alpha)
cdb - subset (file, file[,1]== beta)
### CODE ADDED HERE
list1 - list(cda=cda,cdb=cdb)
}

# funtion to operate on list
ukn - function(file, alpha, beta, nam1){
aa - alpha
bb - beta
myfile - file
nts - lstfun(myfile, aa, bb)
### CODE ADDED HERE
mysum - eval(parse(text=nam1))
#mysum - nam1[,3]*5
return(mysum)
}

results - ukn(dd1, a, b, nts$cda) ### modified how called.

- Original Message - 
From: John Kane [EMAIL PROTECTED]
To: R R-help r-help@stat.math.ethz.ch
Sent: Thursday, June 28, 2007 12:03 PM
Subject: [R] Function call within a function.


I am trying to call a funtion within another function
 and I clearly am misunderstanding what I should do.
 Below is a simple example.
 I know lstfun works on its own but I cannot seem to
 figure out how to get it to work within ukn. Basically
 I need to create the variable nts. I have probably
 missed something simple in the Intro or FAQ.

 Any help would be much appreciated.

 EXAMPLE
 ---
 # create data.frame
 cata - c( 1,1,6,1,1,4)
 catb - c( 1,2,3,4,5,6)
 id - c('a', 'b', 'b', 'a', 'a', 'b')
 dd1  -  data.frame(id, cata,catb)

 # function to create list from data.frame
 lstfun  - function(file, alpha , beta ) {
 cda  -  subset(file, file[,1] == alpha)
 cdb  -  subset (file, file[,1]== beta)
 list1 - list(cda,cdb)
 }

 # funtion to operate on list
 ukn  -  function(file, alpha, beta, nam1){
 aa  - alpha
 bb  - beta
 myfile  - file
 nts - lstfun(myfile, aa, bb)
 mysum - nam1[,3]*5
 return(mysum)
 }

 results - ukn(dd1, a, b, nts$cda)

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


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


Re: [R] Adding different output to different lattice panels

2007-06-28 Thread Deepayan Sarkar
On 6/28/07, Alexandre Salvador [EMAIL PROTECTED] wrote:
 Selon [EMAIL PROTECTED]:

  On 6/28/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
   I would like to add a reference line to lattice graphs, with the reference
   line
   being different according to the factor level.
  
   Example : Draw 3 dotplots for a,b and c factors, and then add an
   horizontal line at y=10 for panel a, y=8 for panel b and y=6 for panel
   4
  
   I tried the code below, but this draw all three reference lines for each
   panel.
   How do I index the current panel to chose the right reference vector value
  ?
  
  
 
 dat-data.frame(id=rep(c(a,b,c),4),val=1:12,quand=rep(c(t1,t2,t3,t4),each=3))
   ref-c(10,8,6)
   plot.new()
   datplot-dotplot(val~quand|id,data=dat,panel=function(...){
   panel.dotplot(...)
   panel.abline(h=ref)
   })
   print(datplot)
 
  dotplot(val~quand|id,data=dat,panel=function(...){
  panel.dotplot(...)
  panel.abline(h = ref[packet.number()])
  })
 
  (Things are more complicated if you have more than one conditioning
  variable.)
 
  -Deepayan
 

 I tried you solution, but the following error appears when I print(datplot):

Erreur dans as.numeric(h) : impossible de trouver la fonction 
 packet.number

 I have lattice and grid libraries loaded. The exact code I use is
 datplot-dotplot(val~quand|id,data=dat,panel=function(...){
 panel.dotplot(...)
 panel.abline(h=ref[packet.number()])
 })
 print(datplot)
 What do I do wrong ?

You are using a very old version of R (or at least old enough that the
packet.number number didn't exist). You haven't told us what version
you are using.

I would encourage you to upgrade, but this might work for now:

dotplot(val~quand|id,data=dat,
panel=function(..., panel.number){
panel.dotplot(...)
panel.abline(h = ref[panel.number])
})

 Note : I usually need to use the indirect datplot-dotplot(...  and then
 print(datplot) when I store my code in a file and use it through
 source(myfile.R). The direct dotplot(... does not open a device whereas it
 does if I type directly dotplot(... at the R command line...
 Is this normal ?

Yes, and a FAQ:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

-Deepayan

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


Re: [R] sampling question

2007-06-28 Thread Adaikalavan Ramasamy
Lets assume your zcta data looks like this

set.seed(12345) ## temporary for reproducibility
zcta - data.frame( zipcode=LETTERS[1:5], prop=runif(5) )
zcta
zipcode  prop
1   A 0.7209039
2   B 0.8757732
3   C 0.7609823
4   D 0.8861246
5   E 0.4564810

This says that 72.1% of the population in zipcode A is female, ..., and 
45.6% in zipcode E is female.


Now suppose you sampled 20 people and you recorded the zipcode (and 
other variables) and stored in 'samp'

samp - data.frame( id=1:20,
zipcode=LETTERS[ sample(1:5, 20, replace=TRUE) ])


Now, I am not sure what you want to do. But I could see two possible 
meanings from your message.

1) If you want to sample 10 observation, with each observation weighted 
INDEPENDENTLY by the proportion of women in its zipcode, try something 
like the following. The problem with this option is that it depends on 
the prevalence of the zipcodes of the observations.

comb - merge( samp, zcta, all.x=T )
comb - comb[ order(comb$id), ]
comb[ sample( comb$id, 10, prob=comb$prop ), ]



2) If you want to sample x% in each zipcode, where x is the proportion 
of women in that zipcode. Then this is what I would call stratified 
sampling. Try this:

tmp - split( samp, samp$zipcode )
out - NULL

for( z in names(tmp) ){
   df - tmp[[z]]
   p  - zcta[ zcta$zipcode == z, prop ]
   out[[z]] - df[ sample( 1:nrow(df), p*nrow(df) ), ]
}
do.call(rbind, out)

You probably need a variant of these but if you need further help, you 
will need to provide more information and better yet examples.

Regards, Adai



Kirsten Beyer wrote:
 I am interested in locating a script to implement a sampling scheme
 that would basically make it more likely that a particular observation
 is chosen based on a weight associated with the observation.  I am
 trying to select a sample of ~30 census blocks from each ZIP code area
 based on the proportion of women in a ZCTA living in a particular
 block.  I want to make it more likely that a block will be chosen if
 the proportion of women in a patient's age group in a particular block
 is high. Any ideas are appreciated!
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


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


[R] exaustive subgrouping or combination

2007-06-28 Thread David Duffy
 Waverley [EMAIL PROTECTED] asked:
 
 Dear Colleagues,
 
 I am looking for a package or previous implemented R to subgroup and
 exaustively divide a vector of squence into 2 groups.
 
 -- 
 Waverley @ Palo Alto

Google [R] Generating all possible partitions and you will find some R code
from 2002 or so.

David Duffy.

-- 
| David Duffy (MBBS PhD) ,-_|\
| email: [EMAIL PROTECTED]  ph: INT+61+7+3362-0217 fax: -0101  / *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v

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


Re: [R] Changing graphics height when using grid and lattice

2007-06-28 Thread Deepayan Sarkar
On 6/28/07, Jim Price [EMAIL PROTECTED] wrote:

 Hi,

 I have recently been playing with the grid package in an attempt to create
 some pages containing multiple lattice plots on the same page. However, when
 I specify a grid layout with different widths, such as:

 pushViewport(viewport(layout = grid.layout(1, 2, unit(c(2, 1), null

 the individual graphs do not end up as the same height - which is a feature
 I would prefer to have.

The default padding between components of a graph is defined as a
proportion of the plot area. In particular, it's unit(0.01, snpc),
which makes it the same on both axes. The problem is that when you
have two grid viewports, unit(0.01, snpc) may give different
physical length.

One option is to set all paddings to 0, which can be done with

myLatticeSettings - function()
list(layout.heights =
 list(top.padding = 0,
  main.key.padding = 0,
  key.axis.padding = 0,
  axis.xlab.padding = 0,
  xlab.key.padding = 0,
  key.sub.padding = 0,
  bottom.padding = 0),
 layout.widths =
 list(left.padding = 0,
  key.ylab.padding = 0,
  ylab.axis.padding = 0,
  axis.key.padding = 0,
  right.padding = 0)
 )

trellis.par.set(myLatticeSettings())

This may not be what you want, so another option is to set the
paddings to something absolute; e.g.


myLatticeOptions - function()
list(layout.heights =
 list(top.padding = list(x = 1, units = mm, data = NULL),
  main.key.padding = list(x = 1, units = mm, data = NULL),
  key.axis.padding = list(x = 1, units = mm, data = NULL),
  axis.xlab.padding = list(x = 1, units = mm, data = NULL),
  xlab.key.padding = list(x = 1, units = mm, data = NULL),
  key.sub.padding = list(x = 1, units = mm, data = NULL),
  bottom.padding = list(x = 1, units = mm, data = NULL)),
 layout.widths =
 list(left.padding = list(x = 1, units = mm, data = NULL),
  key.ylab.padding = list(x = 1, units = mm, data = NULL),
  ylab.axis.padding = list(x = 1, units = mm, data = NULL),
  axis.key.padding = list(x = 1, units = mm, data = NULL),
  right.padding = list(x = 1, units = mm, data = NULL))
 )

lattice.options(myLatticeOptions())

I'm not particularly attached to the snpc solution, so I may change
them at some point.

-Deepayan

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


[R] logistic regression and dummy variable coding

2007-06-28 Thread Bingshan Li
Hello everyone,

I have a variable with several categories and I want to convert this  
into dummy variables and do logistic regression on it. I used  
model.matrix to create dummy variables but it always picked the  
smallest one as the reference. For example,

model.matrix(~.,data=as.data.frame(letters[1:5]))

will code 'a' as '0 0 0 0'. But I want to code another category as  
reference, say 'b'. How to do it in R using model.matrix? Is there  
other way to do it if model.matrix  has no such functionality?

Thanks!



[[alternative HTML version deleted]]

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


Re: [R] logistic regression and dummy variable coding

2007-06-28 Thread Marc Schwartz
On Thu, 2007-06-28 at 18:16 -0500, Bingshan Li wrote:
 Hello everyone,
 
 I have a variable with several categories and I want to convert this  
 into dummy variables and do logistic regression on it. I used  
 model.matrix to create dummy variables but it always picked the  
 smallest one as the reference. For example,
 
 model.matrix(~.,data=as.data.frame(letters[1:5]))
 
 will code 'a' as '0 0 0 0'. But I want to code another category as  
 reference, say 'b'. How to do it in R using model.matrix? Is there  
 other way to do it if model.matrix  has no such functionality?
 
 Thanks!

See ?relevel

Note that this (creating dummy variables) will be done automatically in
R's modeling functions, which default to treatment contrasts on factors.
model.matrix() is used internally by model functions such as glm().

For example using a single factor:

FL - factor(letters[1:5])

 FL
[1] a b c d e
Levels: a b c d e

 contrasts(FL)
  b c d e
a 0 0 0 0
b 1 0 0 0
c 0 1 0 0
d 0 0 1 0
e 0 0 0 1



FL.b - relevel(FL, b)

 FL.b
[1] a b c d e
Levels: b a c d e

 contrasts(FL.b)
  a c d e
b 0 0 0 0
a 1 0 0 0
c 0 1 0 0
d 0 0 1 0
e 0 0 0 1



See ?contrasts and the Statistical Models section in An Introduction to
R.

HTH,

Marc Schwartz

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


Re: [R] logistic regression and dummy variable coding

2007-06-28 Thread Seyed Reza Jafarzadeh
NewVar - relevel( factor(OldVar), ref = b)
should create a dummy variable, and change the reference category for the model.

Reza


On 6/28/07, Bingshan Li [EMAIL PROTECTED] wrote:
 Hello everyone,

 I have a variable with several categories and I want to convert this
 into dummy variables and do logistic regression on it. I used
 model.matrix to create dummy variables but it always picked the
 smallest one as the reference. For example,

 model.matrix(~.,data=as.data.frame(letters[1:5]))

 will code 'a' as '0 0 0 0'. But I want to code another category as
 reference, say 'b'. How to do it in R using model.matrix? Is there
 other way to do it if model.matrix  has no such functionality?

 Thanks!



 [[alternative HTML version deleted]]

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


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


Re: [R] logistic regression and dummy variable coding

2007-06-28 Thread Bingshan Li
Hi All,

Now it works. Thanks for all your answers and the explanations are  
very clear.

Bingshan

On Jun 28, 2007, at 7:44 PM, Seyed Reza Jafarzadeh wrote:

 NewVar - relevel( factor(OldVar), ref = b)
 should create a dummy variable, and change the reference category  
 for the model.

 Reza


 On 6/28/07, Bingshan Li [EMAIL PROTECTED] wrote:
 Hello everyone,

 I have a variable with several categories and I want to convert this
 into dummy variables and do logistic regression on it. I used
 model.matrix to create dummy variables but it always picked the
 smallest one as the reference. For example,

 model.matrix(~.,data=as.data.frame(letters[1:5]))

 will code 'a' as '0 0 0 0'. But I want to code another category as
 reference, say 'b'. How to do it in R using model.matrix? Is there
 other way to do it if model.matrix  has no such functionality?

 Thanks!



 [[alternative HTML version deleted]]

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


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


  1   2   >