[R] Cochran-Armitage

2008-12-12 Thread robert-mcfadden
Hello,
Which package allows to use Cochrana-Armitage trend test? I tried to search for 
but I found only package coin in which there is no explicit function.
Best,
RobMac 

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


Re: [R] Complex integration in R

2008-12-12 Thread Robin Hankin

Hi Borja

library(elliptic)
?myintegrate

HTH

rksh



Borja Soto Varela wrote:

Dear R-user

I need a function to approximate a complex integration. My function is:

aprox2=function(s,x,rate){
dexp(x,rate)*exp(-s*x)
}

where argument s is a complex number. I can't use the integrate function
because it's only used with numeric arguments

Does anyone know some function to approximate complex integrals?

Thanks
Borja

[[alternative HTML version deleted]]

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



--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

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


Re: [R] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
 On 11/12/2008 9:45 PM, Mike Rowe wrote:
 Greetings!

 I come to R by way of Matlab.  One feature in Matlab I miss is its
 end keyword.  When you put end inside an indexing expression, it
 is interpreted as the length of the variable along the dimension being
 indexed.  For example, if the same feature were implemented in R:

 my.vector[5:end]

 would be equivalent to:

 my.vector[5:length(my.vector)]

 And if my.vector is of length less than 5?

 or:

 this.matrix[3:end,end]

 would be equivalent to:

 this.matrix[3:nrow(this.matrix),ncol(this.matrix)]   # or
 this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]

 As you can see, the R version requires more typing, and I am a lousy
 typist.

 It doesn't save typing, but a more readable version would be

 rows - nrow(this.matrix)
 cols - ncol(this.matrix)
 this.matrix[3:rows, cols]


and if nrow(this.matrix) is less than 3?



 With this in mind, I wanted to try to implement something like this in
 R.  It seems like that in order to be able to do this, I would have to
 be able to access the parse tree of the expression currently being
 evaluated by the interpreter from within my End function-- is this
 possible?  Since the [ and [[ operators are primitive I can't see
 their arguments via the call stack functions...

 Anyone got a workaround?  Would anybody else like to see this feature
 added to R?

 I like the general rule that subexpressions have values that can be
 evaluated independent of context, so I don't think this is a good idea.


but this 'general rule' is not really adhered to in r!  one example
already discussed here at length is subset:

subset(data.frame(...), select=a)

what will be selected?  column named a, or columns named by the
components of the vector a?  this is an example of how you can't say
what an expression means in a context-independent manner.  and this is
an ubiquitous problem in r.


vQ

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


Re: [R] i graph library: how can generates a fully connected graph from a similarity matrix

2008-12-12 Thread Gábor Csárdi
On Fri, Dec 12, 2008 at 2:10 AM, dinesh kumar baru...@gmail.com wrote:
 Dear R users

 I have a similarity matrix 100X100. I used this matrix as adjacency matrix
 to generate igraph graph object. Its a fully connected graph. The similarity
 score is the weight of the edge. Now I want to remove all possible lowest
 scores (edges) but I want to get back a fully connected graph (dont want any
 isolated vertex).How can I do it?

Actually your matrix is only 87x87.

If you mean that you want a graph with 87 vertices, and some edge
weights being zero, then you can simply do (assuming there are no
negative edge weights)

G - graph.adjacency(adjmat+1, mode=undirected, weighted=TRUE)
E(G)$weight - E(G)$weight - 1

If you mean that you want to remove isolate vertices after creating
the graph, that would be:

G - graph.adjacency(adjmat, mode=undirected, weighted=TRUE)
G - remove.vertices(G, V(G)[ degree(G)==0 ])

(For your data nothing really happens, there are no isolate vertices.)

 Also is there any possibility that I can remove the edges which dont pass a
 threshold (below 70% similarity score).

You can remove it initially, from the matrix:

adjmat2 - adjmat
adjmat2[ adjmat2  0.7 ] - 0
G - graph.adjacency(adjmat2, mode=undirected, weighted=TRUE)

or after, from the graph itself:

G - graph.adjacency(adjmat+1, mode=undirected, weighted=TRUE)
E(G)$weight - E(G)$weight - 1
G2 - delete.edges(G, E(G)[ weight  0.7 ])

Gabor

ps. there is also an igraph mailing list, you can find it from the
igraph homepage. Just in case I miss your messages here.

 I attached the similarity matrix.

 I would appreciate the reply

 Thanks in advance

 Dinesh



 --
 Dinesh Kumar Barupal
 Junior Specialist
 Metabolomics Fiehn Lab
 UCD Genome Center
 451 East Health Science Drive
 GBSF Builidng
 University of California
 DAVIS
 95616
 http://fiehnlab.ucdavis.edu/staff/kumar

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





-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

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


Re: [R] The end of Matlab

2008-12-12 Thread Prof Brian Ripley

On Fri, 12 Dec 2008, Duncan Murdoch wrote:


On 11/12/2008 9:45 PM, Mike Rowe wrote:

Greetings!

I come to R by way of Matlab.  One feature in Matlab I miss is its
end keyword.  When you put end inside an indexing expression, it
is interpreted as the length of the variable along the dimension being
indexed.  For example, if the same feature were implemented in R:

my.vector[5:end]

would be equivalent to:

my.vector[5:length(my.vector)]


And if my.vector is of length less than 5?


Also consider

my.vector[-(1:4)]


or:

this.matrix[3:end,end]

would be equivalent to:

this.matrix[3:nrow(this.matrix),ncol(this.matrix)]   # or
this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]

As you can see, the R version requires more typing, and I am a lousy
typist.


It doesn't save typing, but a more readable version would be

rows - nrow(this.matrix)
cols - ncol(this.matrix)
this.matrix[3:rows, cols]


I would have used

this.matrix[-(1:2), ncol(this.matrix)]

which I find much clearer as to its intentions.


With this in mind, I wanted to try to implement something like this in
R.  It seems like that in order to be able to do this, I would have to
be able to access the parse tree of the expression currently being
evaluated by the interpreter from within my End function-- is this
possible?  Since the [ and [[ operators are primitive I can't see
their arguments via the call stack functions...

Anyone got a workaround?  Would anybody else like to see this feature
added to R?


Learning to use the power of R's indexing and functios like head() and 
tail() (which are just syntactic sugar) will probably lead you not to miss 
this.


I like the general rule that subexpressions have values that can be evaluated 
independent of context, so I don't think this is a good idea.


Also, '[' is generic, so it would need to be done in such a way that it 
applied to all methods.  As arguments other than the first are passed 
unevaluated to the methods, I don't think this is really possible (you 
don't even know if the third argument to `[` is a dimension for a method).


Also, this would effectively make 'end' a reserved word, or 3:end is 
ambiguous (or at best context-dependent).


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

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


Re: [R] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 3:41 AM, Wacek Kusnierczyk wrote:

Duncan Murdoch wrote:

On 11/12/2008 9:45 PM, Mike Rowe wrote:

Greetings!

I come to R by way of Matlab.  One feature in Matlab I miss is its
end keyword.  When you put end inside an indexing expression, it
is interpreted as the length of the variable along the dimension being
indexed.  For example, if the same feature were implemented in R:

my.vector[5:end]

would be equivalent to:

my.vector[5:length(my.vector)]

And if my.vector is of length less than 5?

or:

this.matrix[3:end,end]

would be equivalent to:

this.matrix[3:nrow(this.matrix),ncol(this.matrix)]   # or
this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]

As you can see, the R version requires more typing, and I am a lousy
typist.

It doesn't save typing, but a more readable version would be

rows - nrow(this.matrix)
cols - ncol(this.matrix)
this.matrix[3:rows, cols]



and if nrow(this.matrix) is less than 3?



With this in mind, I wanted to try to implement something like this in
R.  It seems like that in order to be able to do this, I would have to
be able to access the parse tree of the expression currently being
evaluated by the interpreter from within my End function-- is this
possible?  Since the [ and [[ operators are primitive I can't see
their arguments via the call stack functions...

Anyone got a workaround?  Would anybody else like to see this feature
added to R?

I like the general rule that subexpressions have values that can be
evaluated independent of context, so I don't think this is a good idea.



but this 'general rule' is not really adhered to in r!  one example
already discussed here at length is subset:

subset(data.frame(...), select=a)

what will be selected?  column named a, or columns named by the
components of the vector a?  this is an example of how you can't say
what an expression means in a context-independent manner.  


From which you might conclude that I don't like the design of subset, 
and you'd be right.  However, I don't think this is a counterexample to 
my general rule.  In the subset function, the select argument is treated 
as an unevaluated expression, and then there are rules about what to do 
with it.  (I.e. try to look up name `a` in the data frame, if that 
fails, ...)


For the requested behaviour to similarly fall within the general rule, 
we'd have to treat all indices to all kinds of things (vectors, 
matrices, dataframes, etc.) as unevaluated expressions, with special 
handling for the particular symbol `end`.  But Mike wanted an End 
function, so presumably he wanted the old behaviour of indexing, but to 
have a function whose value depended on where it was called from.  We do 
have those (e.g. the functions for examining the stack that Mike wanted 
to make use of), and they're needed for debugging and a few special 
cases, but as a general rule they should be avoided.


 and this is

an ubiquitous problem in r.


I don't think so.

Duncan Murdoch

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


Re: [R] problem with legend

2008-12-12 Thread Jim Lemon

valeria pedrina wrote:

hi all,
I want to do a plot and put the legend on the left of y axis this is my
code:

x-seq(1980,2005,1)

plot(x,tfa_ita,type=l,col=1,xlim=c(1979,2005),ylim=c(0.2,1.7),xlab=,ylab=,main=Totale
Attivita` Finanziarie)
lines(x,tfa_spa,type=l,col=2)
lines(x,tfa_aus,type=l,col=3)
lines(x,tfa_uk,type=l,col=4)
lines(x,tfa_ger,type=l,col=5)
lines(x,tfa_usa,type=l,col=1,lty=4)
lines(x,tfa_jap,type=l,col=2,lty=4)
lines(x,tfa_can,type=l,col=3,lty=4)
lines(x,tfa_fra,type=l,col=4,lty=4)

legend(locator[1],c(ita,spa,aus,uk,ger,usa,jap,can,fra),col=c(1,2,3,4,5,1,2,3,4),lty=c(1,1,1,1,1,4,4,4,4))


when I touch the graphics to put the legend, R puts it on my lines and not
on the left of y axis
  

Hi Valeria,
The legend command should start with locator(1) using parentheses and 
not square brackets. This is probably just a typo in your email, or you 
wouldn't have gotten a legend at all. By default, the legend is placed 
with the upper left corner at the user coordinates specified. If you 
want to place it partly outside the plot, use par(xpd=TRUE) and 
box.col=(parbg).


Jim

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

2008-12-12 Thread Dominik.Cullmann
Dear all,
I've got a list 
L - list(L1 = list
  (foo = bar
   , SL = NULL
   )
  , L2 = list
  (
   foo = bar
   , SL = list
   (SSL1 = list
(DF = data.frame(val = 21, foo = bar)
 , DFOO = list(foo = foo, bar = bar)
 )
, SSL2 = list
(DF = data.frame(val = 22, foo = bar)
 , DFOO = list(foo = foo, bar = bar)
 )
)

   )
  , L3 = list
  (
   foo = bar
   , SL = list
   (SSL1 = list
(DF = data.frame(val=31, foo=bar)
 , DFOO = list(foo=foo, bar=bar)
 )
)
   )
  )
from which I'ld like to extract the values 21,22 and 31.

lapply(
   lapply(
  lapply(
 lapply(L, [[,SL)
 ,[[,1)
  ,[[,DF)
   ,[[,val) 

gives me 21 and 31. Because of lapply(...,[[,1), it searches  through
the first element of each SL, which are the SSL1. It misses SSL2. Is
there a way to replace the ,[[,1), with a regex or the like to get the
job done? Does anybody now any other solution? 
Thanks and regards,
Dominik


--
Andreas Dominik Cullmann
Forstliche Versuchs- und Forschungsanstalt 
Wonnhalde 4 
79100 Freiburg 
Tel. +49 761 4018 204 
Email: dominik.cullm...@forst.bwl.de
mailto:dominik.cullm...@forst.bwl.de 
Homepage: www.fva-bw.de http://www.fva-bw.de 

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


Re: [R] snowfall sfInit error

2008-12-12 Thread chibco
Thanks

On Thu, Dec 11, 2008 at 10:19 AM, Jochen Knaus j...@imbi.uni-freiburg.dewrote:

 Dear Mr. Ripley,

 indeed that it true. sfInit() currently have a bug on Windows depending on
 the usage of the Linux tools and the broken Exceptionhandling. Too bad I
 never tested it accordingly on Windows (as we do not have any Windows
 machines in our institute).

 snowfall 1.62 is in the pipe with many other fixes (e.g. NetWorkSpaces
 usage) and I will include a Windows workaround in it.

 It will go out for testing at the beginning of the week and should be on
 CRAN end of the week.

 Best regards, Jochen Knaus




  On Sat, 6 Dec 2008, chi...@gmail.com wrote:

  Dear all,

 I am trying to execute the simple example in snowfall
 http://cran.r-project.org/web/packages/snowfall/vignettes/snowfall.pdf...

 require(snow)
 require(snowfall)
 sfInit( parallel=TRUE, cpus=2 )
 sfLapply( 1:10, exp )
 sfStop()

 I have installed the snow and snowfall packages in R on a machine with
 windows xp, however, after running the sfInit( parallel=TRUE, cpus=2 )
 line I get an error ...

 Error in system(whoami, intern = TRUE, ignore.stderr = TRUE) :
  whoami not found
 Error in paste(sep = _, R, uname, format(Sys.time(),
 %H%M%S_%m%d%y)) :
  object uname not found

 I am the only (administrator) user of the computer. It has a dual core
 processor, and is not networked.

 I would be greatful if someone could tell me how to proceed.


 Follow the posting guide (see the footer of this message) and talk to the
 maintainer of 'snowfall'.  Most likely it is not intended to be used on
 Windows, but has not declared that.  'whoami' and 'uname' are Unix programs,
 not Windows ones, but R's Sys.info() provides equivalent information.


 Kind regards

 Chibisi

[[alternative HTML version deleted]]

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





[[alternative HTML version deleted]]

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


[R] repeated two ways anova

2008-12-12 Thread Cecilia Chandra
Hi there,



I have a question regarding a data set that looks like the following: 



8 repeated measurements for 3 dosage levels. However, the measurements
for each dosage levels are taken on a different group of subjects. 



example:

subject time dosage measure

11    
1 
1  154

11    
2 
1  150

: 
:  
:
:

11    
8 
1  158

12    
1 
1  154

12    
2 
1  150

: 
:  
:
:

12    
8 
1  158

21    
1 
2  138

21    
3 
2  130

: 
:  
:
:

21    
8  2
 145

22    
1 
2  138

22    
3 
2  130

: 
:  
:
:

22    
8  2
 145

31    
1  3
 148


31    
3  3
 150

: 
:  
:
:

31    
8  3
 155

32    
1  3
 148

32    
3  3
 150

: 
:  
:
:

32    
8  3
 155



Should I analyze this using repeated two ways anova? 

And what is the function to do this?



Thank you.

Cecilia




  
[[alternative HTML version deleted]]

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


[R] Concordance Index - interpretation

2008-12-12 Thread K F Pearce
Hello everyone.
 
This is a question regarding generation of the concordance index (c
index) in R using the function rcorr.cens.  In particular about
interpretation of its direction and form of the 'predictor'.
 
One of the arguments is a numeric predictor variable ( presumably
this is just a *single* predictor variable).  Say this variable takes
numeric values  Am I correct in thinking that if the c index is 
0.5 (with Somers D positive) then  this tells us that the higher the
numeric values of the 'predictor', the  greater the survival probability
and similarly if the c index is 0.5 (with Somers D negative) then  this
tells us that the higher the numeric values of the 'predictor' the
lower  the survival probability ?
 
The c index  estimates the probability of concordance between predicted
and observed responsesHarrel et al (1996) says in predicting time
until death, concordance is calculated by considering all possible pairs
of patients, at least one of whom has died.  If the *predicted* survival
time (probability) is larger for the patient who (actually) lived
longer, the predictions for that pair are said to be concordant with the
(actual) outcomes.  .  I have read that the c index is defined by the
proportion of all usable patients in which the predictions and outcomes
are concordant.
 
Now, secondly, I'd like to ask what form the predictor can take.
Presumably if the predictor was a continuous-type variable e.g. 'age'
then predicted survival probability (calculated internally via Cox
regression?) would be compared with actual survival time for each
specific age to get the c index?  Now, if the predictor was an *ordinal
categorical variable* where 1=worst group and 5=best group - I presume
that the c index would be calculated similarly but this time there would
be many ties in the predictor (as regards predicted survival
probability) - hence  if I wanted to count all ties in such a case I
would keep the default argument outx=FALSE? 

Does anyone have a clear reference which gives the formula used to
generate the concordance index (with worked examples)? 
 
Many thanks for your help on these interpretations
Kind Regards,
Kim
 

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


Re: [R] The end of Matlab

2008-12-12 Thread Claudia Beleites
Dear list,

 Learning to use the power of R's indexing and functios like head() and
 tail() (which are just syntactic sugar) will probably lead you not to miss
 this.
However, how do I exclude the last columns of a data.frame or matrix (or, in 
general, head and tail for given dimensions of an array)?

I.e. something nicer than 
t (head (t (x), -n))
for excluding the last n columns of matrix x

THX, Claudia


-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] recursive List extraction question

2008-12-12 Thread Henrique Dallazuanna
Try this:

rapply(L, c)[grep(\\.val$, names(rapply(L, c)))]

On Fri, Dec 12, 2008 at 7:55 AM, dominik.cullm...@forst.bwl.de wrote:

 Dear all,
 I've got a list
 L - list(L1 = list
  (foo = bar
   , SL = NULL
   )
  , L2 = list
  (
   foo = bar
   , SL = list
   (SSL1 = list
(DF = data.frame(val = 21, foo = bar)
 , DFOO = list(foo = foo, bar = bar)
 )
, SSL2 = list
(DF = data.frame(val = 22, foo = bar)
 , DFOO = list(foo = foo, bar = bar)
 )
)

   )
  , L3 = list
  (
   foo = bar
   , SL = list
   (SSL1 = list
(DF = data.frame(val=31, foo=bar)
 , DFOO = list(foo=foo, bar=bar)
 )
)
   )
  )
 from which I'ld like to extract the values 21,22 and 31.

 lapply(
   lapply(
  lapply(
 lapply(L, [[,SL)
 ,[[,1)
  ,[[,DF)
   ,[[,val)

 gives me 21 and 31. Because of lapply(...,[[,1), it searches  through
 the first element of each SL, which are the SSL1. It misses SSL2. Is
 there a way to replace the ,[[,1), with a regex or the like to get the
 job done? Does anybody now any other solution?
 Thanks and regards,
 Dominik


 --
 Andreas Dominik Cullmann
 Forstliche Versuchs- und Forschungsanstalt
 Wonnhalde 4
 79100 Freiburg
 Tel. +49 761 4018 204
 Email: dominik.cullm...@forst.bwl.de
 mailto:dominik.cullm...@forst.bwl.de
 Homepage: www.fva-bw.de http://www.fva-bw.de

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




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

[[alternative HTML version deleted]]

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


Re: [R] Downloading Reuters data from R

2008-12-12 Thread Shubha Vishwanath Karanth
Thank you very much for this. But since I don't know much of DLL, I am
kind of a stuck with how to proceed with 'reuters_ts1.zip'. This zip
file contains the 'reuters_ts.dll' file.

dyn.load(reuters_ts.dll) generates the error,

 dyn.load(Z:\\reuters_ts1\\package\\reuters_ts.dll)
Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared library 'C:/Documents and
Settings/shubhak/reuters_ts1/package/reuters_ts.dll':
  LoadLibrary failure:  This application has failed to start because the
application configuration is incorrect. Reinstalling the application may
fix this problem.

Where should the 'reuters_ts1.zip' to be stored? And how can I access
'reuters_ts.dll' file for my use? Even checked ?dyn.load, but a bit
confused. How do we use this?

I am sorry, if this troubles. Mine is a Windows XP Config.


Thanks again,
Shubha
 

-Original Message-
From: rory.wins...@rbs.com [mailto:rory.wins...@rbs.com] 
Sent: Thursday, December 11, 2008 9:44 PM
To: Shubha Vishwanath Karanth; r-h...@stat.math.ethz.ch
Subject: RE: Downloading Reuters data from R

Hi Shubha

I have created an extension DLL for downloading time series data from
Reuters. You can download it from here:

http://www.theresearchkitchen.com/blog/archives/287

There is also a short manual available at the same location:

http://www.theresearchkitchen.com/blog/wp-content/uploads/2008/12/intro.
pdf

I am currently in the process of uploading a separate extension DLL for
retrieval of real-time data from Reuters.

Thanks
Rory


Rory Winston
RBS Global Banking  Markets
Office: +44 20 7085 4476

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Shubha Vishwanath Karanth
Sent: 11 December 2008 07:41
To: r-h...@stat.math.ethz.ch
Subject: [R] Downloading Reuters data from R

Hi R,



Can we download Reuters (3000 Xtra) data from R? Does ODBC package help
me in this? Or otherwise, is there a way to extract daily closing prices
data of Reuters from R?





Thank you very much,

Shubha

This e-mail may contain confidential and/or privileged
i...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Royal Bank of Scotland plc. Registered in Scotland No 90312.
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority 

This e-mail message is confidential and for use by the 
addressee only. If the message is received by anyone other 
than the addressee, please return the message to the sender 
by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The 
Royal Bank of Scotland plc does not accept responsibility for 
changes made to this message after it was sent. 

Whilst all reasonable care has been taken to avoid the 
transmission of viruses, it is the responsibility of the recipient to 
ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its 
systems or data. No responsibility is accepted by The 
Royal Bank of Scotland plc in this regard and the recipient should carry

out such virus and other checks as it considers appropriate. 
Visit our websites at: 
www.rbs.com
www.rbs.com/gbm
www.rbsgc.com

***

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this
e-mail in error) please notify the sender immediately and destroy this e-mail. 
Any unauthorized copying, disclosure or distribution of
the material in this e-mail is strictly forbidden.  Any views or opinions 
presented are solely those of the author and do not
necessarily represent those of Amba Holdings Inc., and/or its affiliates.  
Important additional terms relating to this email can be obtained
at  http://www.ambaresearch.com/disclaimer

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


Re: [R] Downloading Reuters data from R

2008-12-12 Thread Rory.WINSTON
Shubha

I suspect it may be because it cannot find a dependent DLL. I'll email you 
off-list and we can work through it.

Cheers
Rory


Rory Winston
RBS Global Banking  Markets
Office: +44 20 7085 4476

-Original Message-
From: Shubha Vishwanath Karanth [mailto:shub...@ambaresearch.com]
Sent: 12 December 2008 11:29
To: WINSTON, Rory, GBM; r-h...@stat.math.ethz.ch
Subject: RE: Downloading Reuters data from R

Thank you very much for this. But since I don't know much of DLL, I am kind of 
a stuck with how to proceed with 'reuters_ts1.zip'. This zip file contains the 
'reuters_ts.dll' file.

dyn.load(reuters_ts.dll) generates the error,

 dyn.load(Z:\\reuters_ts1\\package\\reuters_ts.dll)
Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library 'C:/Documents and
Settings/shubhak/reuters_ts1/package/reuters_ts.dll':
  LoadLibrary failure:  This application has failed to start because the 
application configuration is incorrect. Reinstalling the application may fix 
this problem.

Where should the 'reuters_ts1.zip' to be stored? And how can I access 
'reuters_ts.dll' file for my use? Even checked ?dyn.load, but a bit confused. 
How do we use this?

I am sorry, if this troubles. Mine is a Windows XP Config.


Thanks again,
Shubha


-Original Message-
From: rory.wins...@rbs.com [mailto:rory.wins...@rbs.com]
Sent: Thursday, December 11, 2008 9:44 PM
To: Shubha Vishwanath Karanth; r-h...@stat.math.ethz.ch
Subject: RE: Downloading Reuters data from R

Hi Shubha

I have created an extension DLL for downloading time series data from Reuters. 
You can download it from here:

http://www.theresearchkitchen.com/blog/archives/287

There is also a short manual available at the same location:

http://www.theresearchkitchen.com/blog/wp-content/uploads/2008/12/intro.
pdf

I am currently in the process of uploading a separate extension DLL for 
retrieval of real-time data from Reuters.

Thanks
Rory


Rory Winston
RBS Global Banking  Markets
Office: +44 20 7085 4476

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Shubha Vishwanath Karanth
Sent: 11 December 2008 07:41
To: r-h...@stat.math.ethz.ch
Subject: [R] Downloading Reuters data from R

Hi R,



Can we download Reuters (3000 Xtra) data from R? Does ODBC package help me in 
this? Or otherwise, is there a way to extract daily closing prices data of 
Reuters from R?





Thank you very much,

Shubha

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Royal Bank of Scotland plc. Registered in Scotland No 90312.
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority

This e-mail message is confidential and for use by the a...{{dropped:30}}

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


Re: [R] Cochran-Armitage

2008-12-12 Thread Chuck Cleland
On 12/12/2008 3:29 AM, robert-mcfad...@o2.pl wrote:
 Hello,
 Which package allows to use Cochrana-Armitage trend test? I tried to search 
 for but I found only package coin in which there is no explicit function.

  But there is this example in coin:

### Cochran-Armitage trend test for proportions
### Lung tumors in female mice exposed to 1,2-dichloroethane
### Encyclopedia of Biostatistics (Armitage  Colton, 1998),
### Chapter Trend Test for Counts and Proportions, page 4578, Table 2
lungtumor - data.frame(dose = rep(c(0, 1, 2), c(40, 50, 48)),
tumor = c(rep(c(0, 1), c(38, 2)),
  rep(c(0, 1), c(43, 7)),
  rep(c(0, 1), c(33, 15
table(lungtumor$dose, lungtumor$tumor)

### Cochran-Armitage test (permutation equivalent to correlation
### between dose and tumor), cf. Table 2 for results
independence_test(tumor ~ dose, data = lungtumor, teststat = quad)

  See the following:

http://finzi.psych.upenn.edu/R/library/coin/html/ContingencyTests.html

  There also is an implementation in the GeneticsBase package
(Bioconductor).

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

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

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


Re: [R] ref card for data manipulation?

2008-12-12 Thread Liviu Andronic
On Thu, Dec 11, 2008 at 1:38 PM, Vitalie Spinu vitosm...@rambler.ru wrote:
 Tom Short's card is an excellent one but it does not cover high level
 packages like plyr, reshape, DoBy, and a few base data.manip functions are
 not there as well.

I'm not sure whether this can (partially) fill the gap, but Quick-R
[1] has a decent overview of data manipulation, and is essentially a
reference card. The maintainer of the Web site is open to
improvements, so it might make sense to contribute relevant
documentation to those pages.

Regards,
Liviu

[1] http://www.statmethods.net/


-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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

2008-12-12 Thread Rina Oldager Miehs
Hello r-help

I want to save my dataframe as an ascii file.

a bit of my data frame:

 vmsrina[1:100,]
  CKRDYRNR CHRNR cowno dek lakt  flow peakflow
1   3596600182 35966   182 9383 3.0527442 3.18
2   3596600182 35966   182 9393 1.8978755 3.06
3   3596600182 35966   182 9403 2.1215936 2.79
4   3596600182 35966   182 9413 1.2411489 2.79
5   3596600182 35966   182 9423 2.1456878 2.85
6   3596600182 35966   182 9433 2.0810122 3.03
7   3596600182 35966   182 9443 1.8588443 3.12
8   3596600182 35966   182 9453 1.8986586 2.82
9   3596600182 35966   182 9463 2.2081765 1.29
10  3596600182 35966   182 9473 1.7747261 2.85
11  3596600182 35966   182 9483 1.7764401 2.73

I would like to have it out as an ascii file, with no colnames or rownames.
Just a simple flat file only containing the data.
Something like this:

3596600182 35966 182 938 3 3.0527442 3.18
3596600182 35966 182 939 3 1.8978755 3.06
3596600182 35966 182 940 3 2.1215936 2.79
3596600182 35966 182 941 3 1.2411489 2.79
3596600182 35966 182 942 3 2.1456878 2.85
3596600182 35966 182 943 3 2.0810122 3.03

Does anyone have an idea which function i should use?
I have tried write.table(), save(), dput(), drop() with no succes for what i
want.

thanks
Rina

[[alternative HTML version deleted]]

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


Re: [R] The end of Matlab

2008-12-12 Thread Patrick Burns

How about:

x[, -seq(to=ncol(x), length=n)]


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

Claudia Beleites wrote:

Dear list,

  

Learning to use the power of R's indexing and functios like head() and
tail() (which are just syntactic sugar) will probably lead you not to miss
this.

However, how do I exclude the last columns of a data.frame or matrix (or, in 
general, head and tail for given dimensions of an array)?


I.e. something nicer than 
t (head (t (x), -n))

for excluding the last n columns of matrix x

THX, Claudia





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 1st Call for Papers - 2nd International Symposium on Distributed Computing and Artificial Intelligence (DCAI'09)

2008-12-12 Thread Nora Muda
To the R users community:

(We apologize for multiples copies) (Please distribute)
---

1st Call for Papers - 2nd International Symposium on Distributed Computing
and Artificial Intelligence (DCAI'09)
June 10th - 12th , 2009 - Salamanca - Spain 
http://dcai.usal.es/

The International Symposium on Distributed Computing and Artificial
Intelligence 2009 is an annual forum that will bring together ideas,
projects, lessons, etc. associated with distributed computing, artificial
intelligence and its applications in different themes. This meeting will be
held at the University of Salamanca in June 10-12th, 2009.

This symposium will be organized by the Biomedicine, Intelligent System and
Educational Technology Research Group (http://bisite.usal.es/) of the
University of Salamanca. The technology transfer in this field is still a
challenge and for that reason this type of contributions will be specially
considered in this symposium. This conference is the forum in which to
present application of innovative techniques to complex problems.

The workshop will be organized into the 10th International Work-Conference
on Artificial Neural Networks (IWANN2009). (http://iwann.usal.es/)

SUBMISSION INSTRUCTIONS
---
Everyone interested in participating and presenting his/her work in this
workshop may do it by sending a contribution. The papers should be written
in English. There are three possibilities: 

1- Long papers:
A maximum length of 8 pages. They must consist of original, relevant and
previously unpublished sound research results related to any of the topics
of the conference. 

2- Short papers: 
A maximum length of 4 pages. They can be project report, a summary of a PhD
thesis, or work in progress. 

3- Doctoral consortium:
PhD students are invited to present the topic and progress of their
research, in order to obtain feedback from a panel of experts. The length of
these papers should be no longer than 8 pages.

- Papers Format 
Papers must be prepared according to the LNCS template of Springer (MS-WORD
or LaTex format) without page numbers.

- Publication
All papers accepted will be published in an special volume of IWANN in
Lecture Notes in Computer Science ( LNCS Springer Verlag) . IWANN is
included in the ranking of the best conferences established by the Computer
Science Conference Ranking based on the Estimated Impact of Conference
(EIC), concretely in position 55 among 620 considered (in the Artificial
Intelligence field). Therefore the papers will be indexed by CiteSeer.IST ,
and by the organization Computing Research and Education Association (CORE)
.

- Submitting papers 
In order to submit a paper you must register as an author at DCAI 2009
conference management system http://gsii.usal.es/conftoolDCAI. All papers
for DCAI 2009 must be submitted in electronic form (PDF format, original
document word or latex and images).

IMPORTANT DATES
---
- Paper submission deadline: 14th February, 2009 
- Acceptance notification: 2nd March, 2009
- Final version submission, March 16th, 2009 
- (DCAI'09 celebration: 10th-12th June, 2009 

TOPICS
---
Distributed applications ICTs: trade, medicine, industry, the Internet, etc.. 
Implementation of the AI Bioinformatics 
Implementation of the AI Biotechnology 
Implementation of AI in the development of mobile devices 
Networks 
Intelligence Environment 
distributed Algorithms 
Computer GRID 
Distributed databases 
Systems multimedia and animation distributed 
Distributed Operating Systems 
Real Time Systems 
Trade and Electronic Business 
Systems and fault-tolerant real-time systems 
Distributed Architectures 
Multiagent Systems
High-performance Computing 
Languages, Compilers, planning, load balancing 
E-learning 
Technology for Internet 
Middleware 
Systems mobile and wireless 
Security 
Parallel Computing 
Software Engineering and Formal Methods 
Distributed Intelligent Information Systems 
Robotics and Control 
Satisfaction of restrictions 
Search heuristics 
Reasoning based on models 
Reasoning not monotonic 
Planning and scheduling tasks 
Qualitative Reasoning 
Reasoning with uncertainty 
Reasoning temporal and spatial 
Other models reasoning 
Reasoning based on cases 
Data Analysis 
Evolutionary Computation 
Networks of neurons 
Learning through reinforcement 
Other models of learning 
Applications of AI (TTIA) 
Logic 
Systems support for the decision 
Intelligent Interaction 
Knowledge Management 
Knowledge Representation 
Ontologies and semantic web 
Natural Language Processing 
Perception (vision, speech recognition,…) 
Other items (creativity, games,…)

GENERAL CO-CHAIRS
---
Sigeru Omatu - Osaka Prefecture University, Japan (Chairman)

Re: [R] save as ascii

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 6:58 AM, Rina Oldager Miehs wrote:

Hello r-help

I want to save my dataframe as an ascii file.

a bit of my data frame:


vmsrina[1:100,]

  CKRDYRNR CHRNR cowno dek lakt  flow peakflow
1   3596600182 35966   182 9383 3.0527442 3.18
2   3596600182 35966   182 9393 1.8978755 3.06
3   3596600182 35966   182 9403 2.1215936 2.79
4   3596600182 35966   182 9413 1.2411489 2.79
5   3596600182 35966   182 9423 2.1456878 2.85
6   3596600182 35966   182 9433 2.0810122 3.03
7   3596600182 35966   182 9443 1.8588443 3.12
8   3596600182 35966   182 9453 1.8986586 2.82
9   3596600182 35966   182 9463 2.2081765 1.29
10  3596600182 35966   182 9473 1.7747261 2.85
11  3596600182 35966   182 9483 1.7764401 2.73

I would like to have it out as an ascii file, with no colnames or rownames.
Just a simple flat file only containing the data.
Something like this:

3596600182 35966 182 938 3 3.0527442 3.18
3596600182 35966 182 939 3 1.8978755 3.06
3596600182 35966 182 940 3 2.1215936 2.79
3596600182 35966 182 941 3 1.2411489 2.79
3596600182 35966 182 942 3 2.1456878 2.85
3596600182 35966 182 943 3 2.0810122 3.03

Does anyone have an idea which function i should use?
I have tried write.table(), save(), dput(), drop() with no succes for what i
want.


You want write.table.  For example:

 test - data.frame(letters=letters[1:5], numbers=1:5)
 write.table(test,col.names=FALSE,row.names=FALSE,quote=FALSE)
a 1
b 2
c 3
d 4
e 5

Duncan Murdoch

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


Re: [R] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
 On 12/12/2008 3:41 AM, Wacek Kusnierczyk wrote:

 but this 'general rule' is not really adhered to in r!  one example
 already discussed here at length is subset:

 subset(data.frame(...), select=a)

 what will be selected?  column named a, or columns named by the
 components of the vector a?  this is an example of how you can't say
 what an expression means in a context-independent manner.  

 From which you might conclude that I don't like the design of subset,
 and you'd be right.  However, I don't think this is a counterexample
 to my general rule.  In the subset function, the select argument is
 treated as an unevaluated expression, and then there are rules about
 what to do with it.  (I.e. try to look up name `a` in the data frame,
 if that fails, ...)

 For the requested behaviour to similarly fall within the general rule,
 we'd have to treat all indices to all kinds of things (vectors,
 matrices, dataframes, etc.) as unevaluated expressions, with special
 handling for the particular symbol `end`.  But Mike wanted an End
 function, so presumably he wanted the old behaviour of indexing, but
 to have a function whose value depended on where it was called from. 
 We do have those (e.g. the functions for examining the stack that Mike
 wanted to make use of), and they're needed for debugging and a few
 special cases, but as a general rule they should be avoided.

  and this is
 an ubiquitous problem in r.

 I don't think so.


i'd think that neither the 'evaluate' nor the 'deparse' approaches to
establishing the values of arguments are particularly rare in r.

vQ

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


Re: [R] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk
Duncan Murdoch wrote:
 On 11/12/2008 9:45 PM, Mike Rowe wrote:


 this.matrix[3:end,end]

 would be equivalent to:

 this.matrix[3:nrow(this.matrix),ncol(this.matrix)]   # or
 this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]

 As you can see, the R version requires more typing, and I am a lousy
 typist.

 It doesn't save typing, but a more readable version would be

 rows - nrow(this.matrix)
 cols - ncol(this.matrix)
 this.matrix[3:rows, cols]


 With this in mind, I wanted to try to implement something like this in
 R.  It seems like that in order to be able to do this, I would have to
 be able to access the parse tree of the expression currently being
 evaluated by the interpreter from within my End function-- is this
 possible?  Since the [ and [[ operators are primitive I can't see
 their arguments via the call stack functions...

 Anyone got a workaround?  Would anybody else like to see this feature
 added to R?

 I like the general rule that subexpressions have values that can be
 evaluated independent of context, so I don't think this is a good idea.

if 'end' poses a problem to the general rule of context-free
establishment of the values of expressions, the python way might be
another option:

x[3:] 

instead of 

x[3:length(x)]
x[3:end]

(modulo 0-based indexing in python)  could this be considered?  laziness
seems to be considered a virtue here, and r is stuffed with 'features'
designed by lazy programmers to avoid, e.g., typing quotes; why would
not having to type 'length(...)' or 'nrows(...)' etc. be considered
annoying?

vQ

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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
 From which you might conclude that I don't like the design of subset, and
 you'd be right.  However, I don't think this is a counterexample to my
 general rule.  In the subset function, the select argument is treated as an
 unevaluated expression, and then there are rules about what to do with it.
  (I.e. try to look up name `a` in the data frame, if that fails, ...)

 For the requested behaviour to similarly fall within the general rule, we'd
 have to treat all indices to all kinds of things (vectors, matrices,
 dataframes, etc.) as unevaluated expressions, with special handling for the
 particular symbol `end`.

Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions.  This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].

Hadley

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

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


Re: [R] Extracting the name of an object into a character string and vice versa

2008-12-12 Thread Philip Whittall

I am still struggling to map a character string to an object name and
vice versa in R.
I thought the as.name() function might work, but observe the following
behaviour ...

 attach(warpbreaks)
 levels(tension)
[1] L M H 
 levels(as.name(tension))
NULL
 objectname-as.name(tension)
 objectname
tension
 levels(objectname)
NULL

So even though it sets up a symbol, this symbol isn't recognised as an
object name by functions such as levels().

I need 2 functions, call them A and B such that A(tension) yields the
object name tension which is recognised by functions and
B(tension) yields the character result tension.

Any suggestions would be greatly appreciated,

Philip



 





This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy by 
an authorised signatory.  The contents of this email may relate to dealings 
with other companies within the Detica Group plc group of companies.

Detica Limited is registered in England under No: 1337451.

Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.



[[alternative HTML version deleted]]

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


Re: [R] Extracting the name of an object into a character string and vice versa

2008-12-12 Thread Gabor Grothendieck
Its a FAQ:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f

On Fri, Dec 12, 2008 at 8:30 AM, Philip Whittall
philip.whitt...@detica.com wrote:

 I am still struggling to map a character string to an object name and
 vice versa in R.
 I thought the as.name() function might work, but observe the following
 behaviour ...

 attach(warpbreaks)
 levels(tension)
 [1] L M H
 levels(as.name(tension))
 NULL
 objectname-as.name(tension)
 objectname
 tension
 levels(objectname)
 NULL

 So even though it sets up a symbol, this symbol isn't recognised as an
 object name by functions such as levels().

 I need 2 functions, call them A and B such that A(tension) yields the
 object name tension which is recognised by functions and
 B(tension) yields the character result tension.

 Any suggestions would be greatly appreciated,

 Philip









 This message should be regarded as confidential. If you have received this 
 email in error please notify the sender and destroy it immediately.
 Statements of intent shall only become binding when confirmed in hard copy by 
 an authorised signatory.  The contents of this email may relate to dealings 
 with other companies within the Detica Group plc group of companies.

 Detica Limited is registered in England under No: 1337451.

 Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.



[[alternative HTML version deleted]]

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


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


Re: [R] Cochran-Armitage

2008-12-12 Thread Peter Dalgaard
Chuck Cleland wrote:
 On 12/12/2008 3:29 AM, robert-mcfad...@o2.pl wrote:
 Hello,
 Which package allows to use Cochrana-Armitage trend test? I tried to search 
 for but I found only package coin in which there is no explicit function.
 
   But there is this example in coin:
 
 ### Cochran-Armitage trend test for proportions
 ### Lung tumors in female mice exposed to 1,2-dichloroethane
 ### Encyclopedia of Biostatistics (Armitage  Colton, 1998),
 ### Chapter Trend Test for Counts and Proportions, page 4578, Table 2
 lungtumor - data.frame(dose = rep(c(0, 1, 2), c(40, 50, 48)),
 tumor = c(rep(c(0, 1), c(38, 2)),
   rep(c(0, 1), c(43, 7)),
   rep(c(0, 1), c(33, 15
 table(lungtumor$dose, lungtumor$tumor)
 
 ### Cochran-Armitage test (permutation equivalent to correlation
 ### between dose and tumor), cf. Table 2 for results
 independence_test(tumor ~ dose, data = lungtumor, teststat = quad)
 
   See the following:
 
 http://finzi.psych.upenn.edu/R/library/coin/html/ContingencyTests.html


Also prop.trend.test().

There seems to be a subtle difference, though:

 independence_test(tumor ~ dose, data = lungtumor, teststat = quad)

Asymptotic General Independence Test

data:  tumor by dose
chi-squared = 10.6381, df = 1, p-value = 0.001108


 tt - table(lungtumor$dose, lungtumor$tumor)
 prop.trend.test(tt[,2],rowSums(tt))

Chi-squared Test for Trend in Proportions

data:  tt[, 2] out of rowSums(tt) ,
 using scores: 1 2 3
X-squared = 10.7157, df = 1, p-value = 0.001062


Anyone have a guess at what the difference is? (Just curious.)

-pd


 
   There also is an implementation in the GeneticsBase package
 (Bioconductor).
 
 Best,
 RobMac 

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


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

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


[R] Functions in R like lincom and nlcom of Stata

2008-12-12 Thread Marc Marí Dell'Olmo
Hello all,

Does anyone know if there exists any function in R that resembles the
lincom and nlcom of STATA?. These functions computes point estimates,
standard errors, significance levels, confidence intervals, etc. for linear
and non linear combinations of previous estimated parameters. Down here
you've got links to descriptions of the functions of STATA

nlcom:

http://www.stata.com/help.cgi?nlcom

lincom:

http://www.stata.com/help.cgi?lincom
Thank you,

Marc

[[alternative HTML version deleted]]

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


Re: [R] The end of Matlab

2008-12-12 Thread Claudia Beleites
Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
 How about:

 x[, -seq(to=ncol(x), length=n)]
Doing it is not my problem. I just agree with Mike in that I would like if I 
could do shorter than: 

x[, 1 : (ncol(x) - n)] 

which I btw prefer to your solution.

Also, I don't have a problem writing generalized versions of head and tail to 
work along other/more dimensions. Or a combined function, taking first and last 
arguments. 

Still, they would not be as convenient to use as matlab's:
3 : end - 4
which btw. also does not need parentheses.

I guess the general problem is that there is only one thing with integers that 
can easily be (ab)used as a flag: the negative sign. 

But there are (at least) 2 possibly useful special ways of indexing: 
- exclusion (as in R)
- using -n for end - n (as in perl)

Now we enjoy having a shortcut for exclusion (at least I do), but still feel 
that marking from the end would be useful.

As no other signs (in the sense of flag) are available for integers, we won't 
be able to stop typing somewhat more in R.

Wacek:
 x[3:]
 instead of
 x[3:length(x)]
 x[3:end]
I don't think that would help: 
what to use for end - 3 within the convention that negative values mean 
exclusion?




--- now I start dreaming ---

However, it is possible to define new binary operators (operators are great for 
lazy typing...).

Let's say %:% should be a new operator to generate proper indexing sequences 
to be used inside [ :
e.g. an.array [ 1:3, -2 %:% -5, ...]

If we now find an.array which is x inside [ (and also inside [[) - which is 
possible but maybe a bit fiddly

and if we can also find out which of the indices is actually evaluated (which I 
don't know how to do)

then we could use something* as a flag for from the end and calculate the 
proper sequence.

something* could e.g. be 
either an attribute to the operators (convenient if we can define an unary 
operator that allows setting it, e.g. § 3 [§ is the easy-to-type sign on my 
keyboard that is not yet used...])

or i (the imaginary one) if there is no other convenient unary operator e.g. 
3i

= 
easy part of the solution:
make.index - function (x, along.dim = 1, from, to){
if (is.null (dim (x)))
   dim - length (x)
else 
  dim - dim (x)[along.dim]

if (is.complex (from)){
from - dim - from # 0i means end
## warning if re (from) != 0 ?
}
if (is.complex (to)){
to - dim - to # 0i means end
## warning if re (to) != 0 ?
}
   
from : to
}

%:% - function (e1, e2)  ## using a new operator does not mess up :
make.index (x = find.x (), along.dim = find.dim (), e1, e2)

now, the heavy part are the still missing find.x () and find.dim () functions...

I'm not sure whether this would be worth the work, but maybe someone is around 
who just knows how to do this.


Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] setting the R_Libs gives warning message from Rgui.exe

2008-12-12 Thread Uwe Ligges



Daren Tan wrote:
Hi, 
 
I keep getting the error message and a pop-up window for selecting CRAN mirror server from Rgui.exe after setting the R_Libs
 
Warning in install.packages(necessary[!installed], dep = T) :

  argument 'lib' is missing: using 'D:/Program Files/R/R-2.8.0.libs'


This is a warning that R chooses the first library in the current list, 
and this is obviously the one you intended, isn't it?



--- Please select a CRAN mirror for use in this session ---
Error in contrib.url(repos, type) : 


This is the more interesting error. What is the whole message?
You may have chosen a non-working mirror or your internet connectrion is 
broken, or ...or... or

...


Uwe Ligges



 
I set the command for Rgui.exe to be 
D:\Program Files\R\R-2.8.0\bin\Rgui.exe --no-restore --no-save --max-mem-size  2000MB R_LIBS=D:/Program Files/R/R-2.8.0.libs
 

sessionInfo()
R version 2.8.0 (2008-10-20) 
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] stats graphics  grDevices datasets  utils methods   base 
other attached packages:

[1] qvalue_1.1
loaded via a namespace (and not attached):
[1] tools_2.8.0


 
_

[[elided Hotmail spam]]

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


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


[R] Fwd: Re: The end of Matlab (sorry, I messed up a sentence)

2008-12-12 Thread Claudia Beleites
--  Weitergeleitete Nachricht  --

Betreff: Re: [R] The end of Matlab
Datum: Freitag 12 Dezember 2008
Von: Claudia Beleites cbelei...@units.it
An: r-help@r-project.org

Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
 How about:

 x[, -seq(to=ncol(x), length=n)]
Doing it is not my problem. I just agree with Mike in that I would like if I 
could do shorter than: 

x[, 1 : (ncol(x) - n)] 

which I btw prefer to your solution.

Also, I don't have a problem writing generalized versions of head and tail to 
work along other/more dimensions. Or a combined function, taking head-n and 
tail-n arguments. 

Still, they would not be as convenient to use as matlab's:
3 : end - 4
which btw. also does not need parentheses.

I guess the general problem is that there is only one thing with integers that 
can easily be (ab)used as a flag: the negative sign. 

But there are (at least) 2 possibly useful special ways of indexing: 
- exclusion (as in R)
- using -n for end - n (as in perl)

Now we enjoy having a shortcut for exclusion (at least I do), but still feel 
that marking from the end would be useful.

As no other signs (in the sense of flag) are available for integers, we won't 
be able to stop typing somewhat more in R.

Wacek:
 x[3:]
 instead of
 x[3:length(x)]
 x[3:end]
I don't think that would help: 
what to use for end - 3 within the convention that negative values mean 
exclusion?




--- now I start dreaming ---

However, it is possible to define new binary operators (operators are great for 
lazy typing...).

Let's say %:% should be a new operator to generate proper indexing sequences 
to be used inside [ :
e.g. an.array [ 1:3, -2 %:% -5, ...]

If we now find an.array which is x inside [ (and also inside [[) - which is 
possible but maybe a bit fiddly

and if we can also find out which of the indices is actually evaluated (which I 
don't know how to do)

then we could use something* as a flag for from the end and calculate the 
proper sequence.

something* could e.g. be 
either an attribute to the operators (convenient if we can define an unary 
operator that allows setting it, e.g. § 3 [§ is the easy-to-type sign on my 
keyboard that is not yet used...])

or i (the imaginary one) if there is no other convenient unary operator e.g. 
3i

= 
easy part of the solution:
make.index - function (x, along.dim = 1, from, to){
if (is.null (dim (x)))
   dim - length (x)
else 
  dim - dim (x)[along.dim]

if (is.complex (from)){
from - dim - from # 0i means end
## warning if re (from) != 0 ?
}
if (is.complex (to)){
to - dim - to # 0i means end
## warning if re (to) != 0 ?
}
   
from : to
}

%:% - function (e1, e2)  ## using a new operator does not mess up :
make.index (x = find.x (), along.dim = find.dim (), e1, e2)

now, the heavy part are the still missing find.x () and find.dim () functions...

I'm not sure whether this would be worth the work, but maybe someone is around 
who just knows how to do this.


Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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

---
-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


[R] Error message when starting TINN-R

2008-12-12 Thread Richardson, Patrick
When R starts I get the following error message

Warning message:
In grep(paste([{]TclEval , topic, [}], sep = ), tclvalue(.Tcl(dde 
services TclEval {})), :
argument 'useBytes = TRUE' will be ignored

Has anyone else run into this issue and is there any way to can fix this?

Thanks,

Patrick



This email message, including any attachments, is for th...{{dropped:9}}

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


Re: [R] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk
Claudia Beleites wrote:
 Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
   
 How about:

 x[, -seq(to=ncol(x), length=n)]
 
 Doing it is not my problem. I just agree with Mike in that I would like if I 
 could do shorter than: 

 x[, 1 : (ncol(x) - n)] 

 which I btw prefer to your solution.

 Also, I don't have a problem writing generalized versions of head and tail to 
 work along other/more dimensions. Or a combined function, taking first and 
 last 
 arguments. 

 Still, they would not be as convenient to use as matlab's:
 3 : end - 4
 which btw. also does not need parentheses.

 I guess the general problem is that there is only one thing with integers 
 that 
 can easily be (ab)used as a flag: the negative sign. 

 But there are (at least) 2 possibly useful special ways of indexing: 
 - exclusion (as in R)
 - using -n for end - n (as in perl)

 Now we enjoy having a shortcut for exclusion (at least I do), but still feel 
 that marking from the end would be useful.

 As no other signs (in the sense of flag) are available for integers, we won't 
 be able to stop typing somewhat more in R.

 Wacek:
   
 x[3:]
 instead of
 x[3:length(x)]
 x[3:end]
 
 I don't think that would help: 
 what to use for end - 3 within the convention that negative values mean 
 exclusion?


   

might seem tricky, but not impossible:

x[-2]
# could mean 'all except for 2nd', as it is now

x[1:-2]
# could mean 'from start to the 2nd backwards from the end'

since r disallows mixing positive and negative indexing, the above would
not be ambiguous.  worse with

x[-3:-1]

which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
to the 1st from the end', and so would be ambiguous.  in this context,
indeed, having explicit 'end' could help avoid the ambiguity.


vQ

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

2008-12-12 Thread Richardson, Patrick
I have asked the maintainer for a fix and didn't get a reply, which is why I 
posted to the list to see if there were any other ideas.

Sorry to bother. . . with my warning message.

Patrick


-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sent: Friday, December 12, 2008 9:34 AM
To: Richardson, Patrick
Cc: 'r-help@r-project.org'
Subject: Re: [R] Error message when starting TINN-R

And the *Error* message was (that was a warning)?

The warning comes from some contributed code, probably in Tinn-R.  Please
find out where it is and ask the maintainer for a fix.  But it looks
harmless enough.

On Fri, 12 Dec 2008, Richardson, Patrick wrote:

 When R starts I get the following error message

 Warning message:
 In grep(paste([{]TclEval , topic, [}], sep = ), tclvalue(.Tcl(dde 
 services TclEval {})), :
 argument 'useBytes = TRUE' will be ignored

 Has anyone else run into this issue and is there any way to can fix this?

 Thanks,

 Patrick



 This email message, including any attachments, is for ...{{dropped:27}}

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


Re: [R] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 8:25 AM, hadley wickham wrote:

From which you might conclude that I don't like the design of subset, and
you'd be right.  However, I don't think this is a counterexample to my
general rule.  In the subset function, the select argument is treated as an
unevaluated expression, and then there are rules about what to do with it.
 (I.e. try to look up name `a` in the data frame, if that fails, ...)

For the requested behaviour to similarly fall within the general rule, we'd
have to treat all indices to all kinds of things (vectors, matrices,
dataframes, etc.) as unevaluated expressions, with special handling for the
particular symbol `end`.


Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions. 


Ummm, doesn't that require changes to *both* indexing and seq?


This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].


I agree:  it would be a nice addition, but a fair bit of work.  I think 
it would be quite doable for the indexable things in the base packages, 
but there are a lot of contributed packages that define [ methods, and 
those methods would all need to be modified too.


(Just to be clear, when I say doable, I'm thinking that your iterators 
return functions that compute subsets of index ranges.  For example, 
evens() might be implemented as


evens - function() {
  result - function(indices) {
indices[indices %% 2 == 0]
  }
  class(result) - iterator
  return(result)
}

and then `[` in v[evens()] would recognize that it had been passed an 
iterator, and would pass 1:length(v) to the iterator to get the subset 
of even indices.  Is that what you had in mind?)


Duncan

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


Re: [R] assign()ing within apply

2008-12-12 Thread Thompson, David (MNR)
Any tips?
 
DaveT.
-Original Message-
From: Thompson, David (MNR) 
Sent: December 9, 2008 04:03 PM
To: 'r-help@r-project.org'
Subject: assign()ing within apply

Hello,

I'm trying to convert a character column in several dataframes 
to lower case.

###
#
# Sample data and 'spp' column summaries:
# dput(ban.ovs.1993[sample(row.names(ban.ovs.1993), 20), 1:4])
ban.ovs.93 - structure(list(oplt = c(43L, 43L, 38L, 26L, 35L, 
8L, 39L, 1L, 
34L, 50L, 10L, 29L, 31L, 24L, 18L, 12L, 27L, 49L, 28L, 51L), 
rplt = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
NA_integer_), tree = c(427L, 410L, 639L, 494L, 649L, 166L, 
735L, 163L, 120L, 755L, 612L, 174L, 129L, 331L, 269L, 152L, 
552L, 227L, 243L, 96L), spp = c(MH, MST, MH, HE, 
BE, MH, MH, MH, MH, Or, IW, Or, MH, MH, 
BY, MH, MH, BE, MH, MR)), .Names = c(oplt, 
rplt, tree, spp), row.names = c(4587L, 4570L, 3947L, 2761L, 
3653L, 652L, 4136L, 64L, 3567L, 5318L, 838L, 3091L, 3366L, 2423L, 
1775L, 1061L, 2893L, 5161L, 2967L, 5395L), class = data.frame)

# dput(pem.ovs.1994[sample(row.names(pem.ovs.1994), 20), 1:4])
pem.ovs.94 - structure(list(oplt = c(8L, 17L, 36L, 9L, 31L, 
11L, 35L, 51L, 
51L, 49L, 40L, 1L, 9L, 17L, 4L, 42L, 6L, 3L, 39L, 25L), tree = c(531L, 
557L, 546L, 261L, 592L, 134L, 695L, 933L, 945L, 114L, 34L, 54L, 
549L, 574L, 193L, 96L, 70L, 4L, 546L, 789L), spp = c(MH, MH, 
MH, BF, BF, MH, IW, OR, OR, BF, MH, IW, OR, 
MH, SM, BE, BE, BE, OR, OR), oaz = c(38L, 205L, 
140L, 277L, 329L, 209L, 222L, 24L, 67L, 187L, 156L, 181L, 174L, 
248L, 42L, 279L, 273L, 357L, 160L, 183L)), .Names = c(oplt, 
tree, spp, oaz), row.names = c(1204L, 2943L, 5790L, 1616L, 
5063L, 2013L, 5691L, 8188L, 8200L, 7822L, 6302L, 54L, 1698L, 
2960L, 421L, 6690L, 775L, 245L, 6205L, 4121L), class = data.frame)

# count per spp
invisible(lapply(ls(pat='ovs'), function(y) { cat(y, \n)  ; 
print(summary.factor(get(y)[,'spp'])) ; cat(\n) } ) )
ban.ovs.93 
BE  BY  HE  IW  MH  MR MST  Or 
 2   1   1   1  11   1   1   2 

pem.ovs.94 
BE BF IW MH OR SM 
 3  3  2  6  5  1 
#
###

I have tried variants on the following and cannot remember how 
to have the result assign()ed back to the original dataframes.
lapply(ls(pat='ovs'), function(y) { assign(paste(y, 
[,'spp'], sep=), tolower(get(y)[,'spp'])) } )

I *do* get the expected results:
[[1]]
 [1] mh  mst mh  he  be  mh  mh  mh  mh  
or  iw  or  mh  mh  by  mh  mh  be  mh  mr 

[[2]]
 [1] mh mh mh bf bf mh iw or or bf mh 
iw or mh sm be be be or or

, I just can't remember how to get them back into the original 
dataframe objects. Suggestions?

Thanx, DaveT.
*
Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
david.john.thomp...@ontario.ca
http://ontario.ca/ofri
*

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


Re: [R] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk

 Wacek:
   
 
 x[3:]
 instead of
 x[3:length(x)]
 x[3:end]
 
   
 I don't think that would help: 
 what to use for end - 3 within the convention that negative values mean 
 exclusion?


   
 

 might seem tricky, but not impossible:

 x[-2]
 # could mean 'all except for 2nd', as it is now

 x[1:-2]
 # could mean 'from start to the 2nd backwards from the end'

 since r disallows mixing positive and negative indexing, the above would
 not be ambiguous.  worse with

 x[-3:-1]

 which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
 to the 1st from the end', and so would be ambiguous.  in this context,
 indeed, having explicit 'end' could help avoid the ambiguity.

   

on the other hand, another possible solution would be to have ':' mean,
inside range selection expressions, not the usual sequence generation,
but rather specification of start and end indices:

x[1:2]
# from 1st to 2nd, inclusive

x[seq(1,2)]
# same as above

x[c(1,2)]
# same as above

x[1:-2]
# from 1st to 2nd from the end, not x[c(1,0,-1,-2)]

x[seq(1,-2)]
# no way, mixed indices

x[-2:-1]
# from 2nd to 1st, both from the end, not x[c(-2,-1)]

x[length(x) + -1:0]
# same as above

x[seq(-2,-1)]
# except for 2nd and 1st

x[c(-2,-1)]
# same as above

x[2:]
# from 2nd up

x[seq(2, max(2, length(x)))]
# same as above (would not be without max)

x[:3]
# up to 3rd

x[seq(1,3)]
# same as above

x[:-3]
# up to 3rd from the end

x[seq(1, length(x)-2)]
# same as above

with additional specifications for the behaviour in case of invalid
indices and decreasing indices:

x[2:1]
# from the 2nd to the 1st, in reverse order
# or nothing, invalid indexing

which can be easily done with the unambiguous x[seq(2,1)] or x[c(2,1)]

this is daydreaming, of course, because such modifications would break
much old code, and the benefit may not outweigh the effort.

vQ

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


Re: [R] Please help me in Converting this from C# to R [C1]

2008-12-12 Thread Taoufik NADIFI
Please, can you tell me if you know how can i use the library Igraph in C# 
?

Thanks
Nadifi Taoufik
*
This message and any attachments (the message) are con...{{dropped:15}}

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


[R] How-To capture and handle errors with R

2008-12-12 Thread mauede
The following error occurs every now and then by calling a function of wmTSA 
package:

Error in `row.names-.data.frame`(`*tmp*`, value = c(1, 0)) : 
  invalid 'row.names' length

I would greatly appreciate some guidelines about how to catch such an error 
upon its occurrence and have it handled by my own routine 
rather than letting R stop the currently run script.
I had a look a the R on-line documentation about errors handler and also ran 
some provided examples that confused my mind.
The error is in textual form. I do not know whether I have to pass the whole 
message to the handler.
When such an exception occurs the execution control is not transferred to my 
routine.
I would like to see a working example.

Thank you so much,
Maura 


Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e 
tutti i telefonini TIM!
Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer

[[alternative HTML version deleted]]

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


Re: [R] Row order in plot

2008-12-12 Thread qroberts

Thanks very much for the replies.

Both suggestions worked perfectly.

That's one more step towards understanding R.

Thanks again.


-- 
View this message in context: 
http://www.nabble.com/Row-order-in-plot-tp20962774p20974800.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] preprocessCore

2008-12-12 Thread irene . vicari


Bonjour!
Je suis en train de faire un projet utilisant Affymatrix mais j'ai un problème à
télécharger un package depuis R: une fois que je télécharge le package et je
demande de faire rma ca sort l'erreur suivante et je n'ai aucune idée de
comment je pourrais faire.

 library(preprocessCore)
 plac.rma - rma(plac.new)
Background correcting
Normalizing
Calculating Expression
Errore in rma(plac.new) :
  function 'R_subColSummarize_medianpolish_log' not provided by package
'preprocessCore'

Est-ce que vous avez un conseil à me donner? J'ai un projet à finir et je suis
complètement bloquée :(

Merci d'avance,
Irene Vicari

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

2008-12-12 Thread mauede
Is there any way to handle errors retuened by R functions ... something like 
the exception handling in C++ ?

Thank you so much,
Maura 

Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e 
tutti i telefonini TIM!
Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer

[[alternative HTML version deleted]]

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


Re: [R] How to generate a prediction equation for a stratified survival model that was fitted by cph() in Design package

2008-12-12 Thread Yu, Changhong
Dear Dr. Harrell,

Thanks for response so quickly. Here is example code to illustrate the
problem.

 n - 1000
 set.seed(731)
 age - 50 + 12*rnorm(n)
 label(age) - Age
 sex - factor(sample(c('Male','Female'), n,
+   rep=TRUE, prob=c(.6, .4)))
 cens - 15*runif(n)
 h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
 dt - -log(runif(n))/h
 label(dt) - 'Follow-up Time'
 e - ifelse(dt = cens,1,0)
 dt - pmin(dt, cens)
 units(dt) - Year
 dat - data.frame(dt,e,age,sex)
 dd - datadist(dat)
 options(datadist='dd')
 f1 - cph( Surv(dt,e) ~ rcs(age,4) + sex, data=dat,x=TRUE, y=TRUE,
surv=TRUE)
 f2 - cph( Surv(dt,e)~ age + strat(sex), data=dat, x=TRUE,
y=TRUE,surv=TRUE)
 Function(f1) # works well
function(age = 48.800654,sex = Male) {0.28612987-0.017321951*
age+0.00012586581*pmax(age-29.600456,0)^3-0.00046285671*pmax(age-44.2731
98,0)^3+0.00042111763*pmax(age-53.769262,0)^3-8.4126731e-05*pmax(age-69.
855597,0)^3-0.64448916*(sex==Male) }
environment: 0x02c2aef4
 Function(f2)
Error in Nam[[i]] : subscript out of bounds

I am using Windows R ( version 2.6.0 2007-10-03).

Best regards,

Changhong Yu

-Original Message-
From: Frank E Harrell Jr [mailto:f.harr...@vanderbilt.edu] 
Sent: Thursday, December 11, 2008 6:58 PM
To: Yu, Changhong
Cc: r-help@r-project.org
Subject: Re: [R] How to generate a prediction equation for a stratified
survival model that was fitted by cph() in Design package

Yu, Changhong wrote:
 Dear all,
 
 I used cph() function from Frank harrell's Design package to create a
 survival model, then used functions 'Function' and 'sascode' to
generate
 prediction equation based on the saved survival model. But it failed.
I
 included a stratified variable in the model. If I removed the
 stratification, they were working well. Does that mean that function
 'Function' doesn't accept a stratified model?

It is supposed to work for that case.  Please send trivial example code 
with data defined in the code that replicates the problem you are 
seeing, and I'll debug.

Frank

 
 Any thoughts on this will be appreciated. Thanks.
 
 
 Changhong
 
 ===
 
 P Please consider the environment before printing this e-mail
 
 Cleveland Clinic is ranked one of the top hospitals
 in America by U.S. News  World Report (2008).  
 Visit us online at http://www.clevelandclinic.org for
 a complete listing of our services, staff and
 locations.
 
 
 Confidentiality Note:  This message is intended for
use\...{{dropped:13}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


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



P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News  World Report (2008).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}

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


Re: [R] setting the R_Libs gives warning message from Rgui.exe

2008-12-12 Thread Daren Tan

I have managed to get rid the two warning messages simply by uninstalling and 
installing again R. Very likely that I disrupted the installation of a large 
package. 

 Date: Fri, 12 Dec 2008 15:07:38 +0100
 From: lig...@statistik.tu-dortmund.de
 To: dare...@hotmail.com
 CC: r-h...@stat.math.ethz.ch
 Subject: Re: [R] setting the R_Libs gives warning message from Rgui.exe
 
 
 
 Daren Tan wrote:
 Hi, 
 
 I keep getting the error message and a pop-up window for selecting CRAN 
 mirror server from Rgui.exe after setting the R_Libs
 
 Warning in install.packages(necessary[!installed], dep = T) :
 argument 'lib' is missing: using 'D:/Program Files/R/R-2.8.0.libs'
 
 This is a warning that R chooses the first library in the current list, 
 and this is obviously the one you intended, isn't it?
 
 --- Please select a CRAN mirror for use in this session ---
 Error in contrib.url(repos, type) : 
 
 This is the more interesting error. What is the whole message?
 You may have chosen a non-working mirror or your internet connectrion is 
 broken, or ...or... or
 ...
 
 
 Uwe Ligges
 
 
 
 
 I set the command for Rgui.exe to be 
 D:\Program Files\R\R-2.8.0\bin\Rgui.exe --no-restore --no-save 
 --max-mem-size 2000MB R_LIBS=D:/Program Files/R/R-2.8.0.libs
 
 sessionInfo()
 R version 2.8.0 (2008-10-20) 
 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] stats graphics grDevices datasets utils methods base 
 other attached packages:
 [1] qvalue_1.1
 loaded via a namespace (and not attached):
 [1] tools_2.8.0
 
 
 
 _
 [[elided Hotmail spam]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] DSC 2009: Now open for registration and abstract submission

2008-12-12 Thread Peter Dalgaard
Re. Workshop on Directions in Statistical Computing, Copenhagen 13-14
July 2009.

http://www.r-project.org/dsc-2009

The web interface for registration and submission of abstracts is now open.

(The site is still under construction in a number of respects. In
particular, we haven't negotiated discounts with any of the hotels yet.)


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

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


Re: [R] Eror handling with R

2008-12-12 Thread Sarah Goslee
Is try() what you're looking for?

Sarah

On Fri, Dec 12, 2008 at 5:43 AM,  mau...@alice.it wrote:
 Is there any way to handle errors retuened by R functions ... something like 
 the exception handling in C++ ?

 Thank you so much,
 Maura

 Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e 
 tutti i telefonini TIM!
 Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer



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

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


Re: [R] The end of Matlab

2008-12-12 Thread Gabor Grothendieck
Here is how to emulate matlab end in R in the case of matrices.

Rather than redefine the matrix class (which would be a bit intrusive) we
just define a subclass of matrix called matrix2.  Note in the examples that
matrix2 survives some operations such as + but not others such as crossprod
so in those one would have to coerce back to matrix2 using as.matrix2.


as.matrix2 - function(x, ...) UseMethod(as.matrix2)

as.matrix2.default - function(x, ...) {
   do.call(structure, list(x, ...,
   class = c(matrix2, setdiff(class(x), matrix2
}

matrix2 - function(data, ...) as.matrix2(matrix(data, ...))

[.matrix2 - function(x, i, j, ...) {
i - if (missing(i)) TRUE
else eval.parent(do.call(substitute, list(substitute(i), list(end = 
nrow(x)
j - if (missing(j)) TRUE
else eval.parent(do.call(substitute, list(substitute(j), list(end = 
ncol(x)
.subset(x, i, j, ...)
}


 # test
 m - matrix2(1:12, 3, 4)
 # matrix2 survives the + operation
 class(m+2)
[1] matrix2 matrix

 # but not crossprod
 class(crossprod(m))
[1] matrix

 # coercing back
 as.matrix2(crossprod(m))
 [,1] [,2] [,3] [,4]
[1,]   14   32   50   68
[2,]   32   77  122  167
[3,]   50  122  194  266
[4,]   68  167  266  365
attr(,class)
[1] matrix2 matrix

 # example of using end
 m[2:end, 2:end]
 [,1] [,2] [,3]
[1,]58   11
[2,]69   12



On Thu, Dec 11, 2008 at 9:45 PM, Mike Rowe mwr...@gmail.com wrote:
 Greetings!

 I come to R by way of Matlab.  One feature in Matlab I miss is its
 end keyword.  When you put end inside an indexing expression, it
 is interpreted as the length of the variable along the dimension being
 indexed.  For example, if the same feature were implemented in R:

 my.vector[5:end]

 would be equivalent to:

 my.vector[5:length(my.vector)]

 or:

 this.matrix[3:end,end]

 would be equivalent to:

 this.matrix[3:nrow(this.matrix),ncol(this.matrix)]   # or
 this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]

 As you can see, the R version requires more typing, and I am a lousy
 typist.

 With this in mind, I wanted to try to implement something like this in
 R.  It seems like that in order to be able to do this, I would have to
 be able to access the parse tree of the expression currently being
 evaluated by the interpreter from within my End function-- is this
 possible?  Since the [ and [[ operators are primitive I can't see
 their arguments via the call stack functions...

 Anyone got a workaround?  Would anybody else like to see this feature
 added to R?

 Thanks,
 Mike

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


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


[R] character count

2008-12-12 Thread Ista Zahn
Dear list,
I have a variable that consists of typed responses. I wish to compute
a variable equal to the number of characters in the original variable.
For example:

 x - c(convert this to 32 because it has 32 characters, this one has 22 
 characters, 12 characters)

[Some magic function here]

 x
[1] 32 22 12

Any ideas?

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


Re: [R] The end of Matlab

2008-12-12 Thread Claudia Beleites
I just realized that my idea of doing something without going into the 
extraction functions itself won't work 
:-( it was a nice dream, though.

The reason is that there is no general way to find out what the needed length 
is: At least I'm just writing a class where 2 kinds of columns are involved. I 
don't give a dim attribute, though. But I could, and then: how to know how it 
should be interpreted?

 on the other hand, another possible solution would be to have ':' mean,
 inside range selection expressions, not the usual sequence generation,
 but rather specification of start and end indices:
...
 this is daydreaming, of course, because such modifications would break
 much old code,
nothing would break if some other sign instead of : would be used. Maybe 
something like end...

 and the benefit may not outweigh the effort.
This might be true in any case.

If I only think of how many lines of nrow, ncol, length  Co I could have 
written instead of posting wrong proposals

Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] character count

2008-12-12 Thread Claudia Beleites

nchar (c(convert this to 47 because it has 47 characters, this one has 26 
characters, 13 characters))

HTH Claudia
-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk
Claudia Beleites wrote:
 Wacek:
   
 x[3:]
 instead of
 x[3:length(x)]
 x[3:end]
 
 I don't think that would help:
 what to use for end - 3 within the convention that negative values mean
 exclusion?
   
 might seem tricky, but not impossible:

 x[-2]
 # could mean 'all except for 2nd', as it is now

 x[1:-2]
 # could mean 'from start to the 2nd backwards from the end'
 
 I know you get thus far. You might even think to decide whether exclusion or 
 'from the end' is meant from ascending ./. descending order of the sequence, 
 but this messes around with returning the reverse order.

   

that's a design issue.  one simple solution is to have this sort of
indexing return always in ascending order.  thus,

x = 1:5
x[1:-1]
# 1 2 3 4 5
x[5:-5]
# NULL rather than 5 4 3 2 1 -- as in matlab or python

x[seq(5,1)]
# 5 4 3 2 1

that is, the ':'-based indexing can be made not to mess with the order. 
for reversing the order, why not use:

x[5:-1:1]
# 5 4 3 2 1

x[-3:-1:-5]
# 3 2 1 rather than x[c(-3,-4,-5)], which would be 1 2


 since r disallows mixing positive and negative indexing, the above would
 not be ambiguous.  worse with

 x[-3:-1]

 which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
 to the 1st from the end', and so would be ambiguous.  in this context,
 indeed, having explicit 'end' could help avoid the ambiguity.
 
 that's the problem.
 also: how would 'except from the 5th last to the 3rd last' be expressed?
   

for exclusions you'd need to use negative indices anyway:

x[seq(-5,-3)]

now, neither x[-5:-3] nor x[-3:-5] would do the job they do now, but the
above is not particularly longer, while selecting the
5th-to3rd-from-the-end columns is simply x[-5:-3] (which could be made
to fail on out-of-range indices) instead of something like x[length(x) -
4:2] (which will silently do the wrong thing if length(x)  4, and thus
requires extra care).

this is a rather loose idea, and unrealistic in the context of r, but i
do not see much problem with it on the conceptual level.

vQ

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


[R] Odp: character count

2008-12-12 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:

 Dear list,
 I have a variable that consists of typed responses. I wish to compute
 a variable equal to the number of characters in the original variable.
 For example:
 
  x - c(convert this to 32 because it has 32 characters, this one 
has 22 
 characters, 12 characters)
 
 [Some magic function here]

If you consider space as a character then

 nchar(x)

gives you the result.

If not so such construction can do it

 unlist(lapply(lapply(strsplit(x,  ), paste, collapse=), nchar))

Regards
Petr

 
  x
 [1] 32 22 12
 
 Any ideas?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Odp: character count

2008-12-12 Thread Gabor Grothendieck
On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL petr.pi...@precheza.cz wrote:
 Hi


 r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:

 Dear list,
 I have a variable that consists of typed responses. I wish to compute
 a variable equal to the number of characters in the original variable.
 For example:

  x - c(convert this to 32 because it has 32 characters, this one
 has 22
 characters, 12 characters)

 [Some magic function here]

 If you consider space as a character then

  nchar(x)

 gives you the result.

 If not so such construction can do it

  unlist(lapply(lapply(strsplit(x,  ), paste, collapse=), nchar))


or perhaps:

x - abc def
nchar(gsub( , , x)) # 6

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


Re: [R] Odp: character count

2008-12-12 Thread Henrique Dallazuanna
Or :

 nchar(gsub([[:space:]], , x))

On Fri, Dec 12, 2008 at 2:00 PM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi


 r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:

  Dear list,
  I have a variable that consists of typed responses. I wish to compute
  a variable equal to the number of characters in the original variable.
  For example:
 
   x - c(convert this to 32 because it has 32 characters, this one
 has 22
  characters, 12 characters)
 
  [Some magic function here]

 If you consider space as a character then

  nchar(x)

 gives you the result.

 If not so such construction can do it

  unlist(lapply(lapply(strsplit(x,  ), paste, collapse=), nchar))

 Regards
 Petr

 
   x
  [1] 32 22 12
 
  Any ideas?
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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




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

[[alternative HTML version deleted]]

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


Re: [R] character count

2008-12-12 Thread Ista Zahn
Thanks to everyone who responded. This turns out to be amazingly easy.
To count characters including spaces:
nchar(x)
To count characters excluding spaces:
nchar(gsub( *,,x))

Thanks!

On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL petr.pi...@precheza.cz wrote:
 Hi


 r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:

 Dear list,
 I have a variable that consists of typed responses. I wish to compute
 a variable equal to the number of characters in the original variable.
 For example:

  x - c(convert this to 32 because it has 32 characters, this one
 has 22
 characters, 12 characters)

 [Some magic function here]

 If you consider space as a character then

  nchar(x)

 gives you the result.

 If not so such construction can do it

  unlist(lapply(lapply(strsplit(x,  ), paste, collapse=), nchar))

 Regards
 Petr


  x
 [1] 32 22 12

 Any ideas?

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



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


[R] What packages have impute method ?

2008-12-12 Thread Daren Tan

Besides the impute package, are there others that have alternative impute 
approaches ? I hope to compare their performances. 
 
Thanks

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Functions in R like lincom and nlcom of Stata

2008-12-12 Thread Marc Marí Dell'Olmo
Hello all,

Does anyone know if there exists any function in R that resembles the
lincom and nlcom of STATA?. These functions computes point
estimates, standard errors, significance levels, confidence intervals,
etc. for linear and non linear combinations of previous estimated
parameters. Down here you've got links to descriptions of the
functions of STATA

nlcom:
http://www.stata.com/help.cgi?nlcom
lincom:
http://www.stata.com/help.cgi?lincom

Thank you,
Marc

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


[R] mixed model nested ANOVA

2008-12-12 Thread Sebpe De Smedt
Hi,


I'm working on leaf characteristics of trees. Each tree is characterised by
about 10 leaf traits.
The trees were sampled at 9 different locations (about 20 to 30
trees/location, NOT balanced), grouped in 3 different climatic zones
(Sahelian, Soudanian and Guinean) (NOT balanced).
Further, each tree is characterised by some degree of human pressure
(mutilation degree), in total 4 different degrees were defined (NOT
balanced).

In the dryer zones, the trees are under a much higher human pressure than in
the more humid climatic zones, zone and mutilation degree are thus
strongly correlated.

I want to know how zones (fixed effects, climate interests me) and
locations (nested in zones, random effects, location doesn't interests
me) are influencing the leaf traits (say for example SLA). Further, also
human pressure is affecting leaf traits so I want to characterise the
influence of mutilation degree (fixed effects) on SLA.

I found some interesting information, but still, I am not be able to analyse
the data properly. I think I have to use the function lme() or lme().

Can anyone tell me which function and command I have to use? And how I can
produce an ANOVA table?


Thanks in advance,
Sebpe De Smedt

[[alternative HTML version deleted]]

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


Re: [R] character count

2008-12-12 Thread Gabor Grothendieck
On Fri, Dec 12, 2008 at 11:05 AM, Ista Zahn iz...@psych.rochester.edu wrote:
 Thanks to everyone who responded. This turns out to be amazingly easy.
 To count characters including spaces:
 nchar(x)
 To count characters excluding spaces:
 nchar(gsub( *,,x))

The * is unnecessary.


 Thanks!

 On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL petr.pi...@precheza.cz wrote:
 Hi


 r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:

 Dear list,
 I have a variable that consists of typed responses. I wish to compute
 a variable equal to the number of characters in the original variable.
 For example:

  x - c(convert this to 32 because it has 32 characters, this one
 has 22
 characters, 12 characters)

 [Some magic function here]

 If you consider space as a character then

  nchar(x)

 gives you the result.

 If not so such construction can do it

  unlist(lapply(lapply(strsplit(x,  ), paste, collapse=), nchar))

 Regards
 Petr


  x
 [1] 32 22 12

 Any ideas?

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



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


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


Re: [R] converting multiple columns from POSIX* to Date

2008-12-12 Thread Farrel Buchinsky
Something strange. The lapply only processed the first row and then wrote
that value to every row of the original dataframe. It is as if the lapply is
indeed processing every item on the list, namely each column, but the ifelse
or the as.Date is getting messed up. Not only is it only processing the
first row but it is also returning the value as numbers rather than dates. I
am now playing around with Hadley Wickham's plyr package. So far looking
good but still need to work out a few things.
Farrel Buchinsky
GrandCentral Tel: (412) 567-7870



On Wed, Dec 10, 2008 at 19:08, Marc Schwartz marc_schwa...@comcast.netwrote:

 Use inherits() then rather than class():

  DF[] - lapply(DF, function(x) ifelse(inherits(x, POSIXt),
as.Date(x), x))

 That should hopefully work better than my first attempt.

 HTH,

 Marc Schwartz

 on 12/10/2008 05:47 PM Farrel Buchinsky wrote:
  I will try that but I am somewhat skeptical since when I go
  class(date.of.birth) I get not just one word but two:  POSIXt
  POSIXct. Will that not mess up the logical test
 
  When I tried the following:
  lapply(as.list(dataframename),class)==POSIXt
  every item was false
 
  Farrel Buchinsky
  GrandCentral Tel: (412) 567-7870
 
 
 
 
 
  Dear Farrel,
  Determine the class of each column and apply as.Date() just to those
 which
  class is POSIX. For more details see ?class. Here is an example assuming
  that you're data is named mydata:
  apply(mydata, 2, function(x) ifelse( class(x)==POSIXt |
   class(x)==POSIXlt , as.Date(x) , x ) )
 
  HTH,
 
  Jorge
 
 
 
  On Wed, Dec 10, 2008 at 6:26 PM, Farrel Buchinsky fjb...@gmail.com
 wrote:
  converting a POSIX class variable to a date class is easy.
  dates-as.Date(x) #where X is of class POSIX
  How does one do that to all columns in a data frame that are of POSIX
  class and leave all the other columns (integers, factors) as is.
 
  Feel free to reply with just one or two buzzwords that I could then
  search for to find how to do it.
 
  Farrel Buchinsky
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

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


Re: [R] The end of Matlab

2008-12-12 Thread Greg Snow
Just to muddy the waters a bit further.  Currently we can do things like:

 pascal.tri - numeric(0)
 class(pascal.tri) - 'pasctri'

 `[.pasctri` - function(x, ...) {
+ dots - list(...)
+ n - dots[[1]]
+ row - choose(n, 0:n)
+ if(length(dots)  1) {
+ row - row[ dots[[2]] ]
+ }
+ row
+ }

 pascal.tri[4]
[1] 1 4 6 4 1
 pascal.tri[4,2]
[1] 4

Now whether that is clever or abusive, I'm not sure (probably not clever).

But what would we expect:

 pascal.tri[end]

to return?

Also if we can access the last element of a vector as:

 x[end]

(which I am not opposed to, just don't know if it is worth the effort) then how 
long will it be before someone wants to be able to do:

 x[end+1] - new.value

and put that in a loop, which would lead to very poor programming practice (but 
so easy it would tempt many).

Just my $0.015 worth,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Wacek Kusnierczyk
 Sent: Friday, December 12, 2008 8:57 AM
 To: claudia.belei...@gmx.de
 Cc: R help
 Subject: Re: [R] The end of Matlab

 Claudia Beleites wrote:
  Wacek:
 
  x[3:]
  instead of
  x[3:length(x)]
  x[3:end]
 
  I don't think that would help:
  what to use for end - 3 within the convention that negative values
 mean
  exclusion?
 
  might seem tricky, but not impossible:
 
  x[-2]
  # could mean 'all except for 2nd', as it is now
 
  x[1:-2]
  # could mean 'from start to the 2nd backwards from the end'
 
  I know you get thus far. You might even think to decide whether
 exclusion or
  'from the end' is meant from ascending ./. descending order of the
 sequence,
  but this messes around with returning the reverse order.
 
 

 that's a design issue.  one simple solution is to have this sort of
 indexing return always in ascending order.  thus,

 x = 1:5
 x[1:-1]
 # 1 2 3 4 5
 x[5:-5]
 # NULL rather than 5 4 3 2 1 -- as in matlab or python

 x[seq(5,1)]
 # 5 4 3 2 1

 that is, the ':'-based indexing can be made not to mess with the order.
 for reversing the order, why not use:

 x[5:-1:1]
 # 5 4 3 2 1

 x[-3:-1:-5]
 # 3 2 1 rather than x[c(-3,-4,-5)], which would be 1 2


  since r disallows mixing positive and negative indexing, the above
 would
  not be ambiguous.  worse with
 
  x[-3:-1]
 
  which could mean both 'except for 3rd, 2nd, and 1st' and 'from the
 3rd
  to the 1st from the end', and so would be ambiguous.  in this
 context,
  indeed, having explicit 'end' could help avoid the ambiguity.
 
  that's the problem.
  also: how would 'except from the 5th last to the 3rd last' be
 expressed?
 

 for exclusions you'd need to use negative indices anyway:

 x[seq(-5,-3)]

 now, neither x[-5:-3] nor x[-3:-5] would do the job they do now, but
 the
 above is not particularly longer, while selecting the
 5th-to3rd-from-the-end columns is simply x[-5:-3] (which could be made
 to fail on out-of-range indices) instead of something like x[length(x)
 -
 4:2] (which will silently do the wrong thing if length(x)  4, and thus
 requires extra care).

 this is a rather loose idea, and unrealistic in the context of r, but i
 do not see much problem with it on the conceptual level.

 vQ

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

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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 On 12/12/2008 8:25 AM, hadley wickham wrote:

 From which you might conclude that I don't like the design of subset, and
 you'd be right.  However, I don't think this is a counterexample to my
 general rule.  In the subset function, the select argument is treated as
 an
 unevaluated expression, and then there are rules about what to do with
 it.
  (I.e. try to look up name `a` in the data frame, if that fails, ...)

 For the requested behaviour to similarly fall within the general rule,
 we'd
 have to treat all indices to all kinds of things (vectors, matrices,
 dataframes, etc.) as unevaluated expressions, with special handling for
 the
 particular symbol `end`.

 Except you wouldn't have to necessarily change indexing - you could
 change seq instead.  Then 5:end could produce some kind of special
 data structure (maybe an iterator) that was recognised by the various
 indexing functions.

 Ummm, doesn't that require changes to *both* indexing and seq?

Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
expression.

 This would still be a lot of work for not a lot
 of payoff, but it would be a logically consistent way of adding this
 behaviour to indexing, and the basic work would make it possible to
 develop other sorts of indexing, eg df[evens(), ], or df[last(5),
 last(3)].

 I agree:  it would be a nice addition, but a fair bit of work.  I think it
 would be quite doable for the indexable things in the base packages, but
 there are a lot of contributed packages that define [ methods, and those
 methods would all need to be modified too.

That's true, although I suspect many contributed [.methods eventually
delegate to base methods and might work without further modification.

 (Just to be clear, when I say doable, I'm thinking that your iterators
 return functions that compute subsets of index ranges.  For example, evens()
 might be implemented as

 evens - function() {
  result - function(indices) {
indices[indices %% 2 == 0]
  }
  class(result) - iterator
  return(result)
 }

 and then `[` in v[evens()] would recognize that it had been passed an
 iterator, and would pass 1:length(v) to the iterator to get the subset of
 even indices.  Is that what you had in mind?)

Yes, that's exactly what I was thinking, although you'd have to put
some thought into the conventions - would it be better to pass in the
length of the vector instead of a vector of indices?  Should all
iterators return logical vectors?  That way you could do x[evens() 
last(5)] to get the even indices out of the last 5, as opposed to
x[evens()][last(5)] which would return the last 5 even indices.

You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement.  first(n) could also be useful, selecting the first
min(n, length(vector)) observations.   An iterator version of rev()
would also be handy.

Maybe selector would be a better name than iterator though, as these
don't have the same feel as iterators in other languages.

Hadley

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

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


Re: [R] The end of Matlab

2008-12-12 Thread Vitalie Spinu

On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham h.wick...@gmail.com wrote:


You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement.  first(n) could also be useful, selecting the first
min(n, length(vector)) observations.   An iterator version of rev()
would also be handy.

Maybe selector would be a better name than iterator though, as these
don't have the same feel as iterators in other languages.


That is really something!! Real high level language!!
Selectors could depend on named variables in data frame as well:

mtcars[sel(cyl3)last(5)]
mtcars[sel(cyl3)boot(80%)]

or may be just 


mtcars[cyl3last(20)]

or this is already too far?


VS.

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


[R] How to mimic select.list using RGtk2/gWidgetsRGtk2?

2008-12-12 Thread ronggui
I want to write a function mimic the function of select.list(), here
is my preliminary version.

select - function(x,multiple=TRUE,...){
ans-new.env()
g - gwindow(title=title,wid=200,heigh=500)
x1-ggroup(FALSE,con=g)
x2-gtable(x,multiple=multiple,con=x1,expand=TRUE)
gbutton(OK,con=x1,handler=function(h,...){
value - svalue(x2)
if (length(value)==0) value=
assign(selected,value,env=h$action$env)
dispose(x1)
},action=list(env=ans))
ans
}

However, it doesn't behave as what I want.  What I want is that: for
{select(c(a,b)); foo()}, foo() only runs after I have clicked the
OK button of select(). Any hints?

Thanks.
-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate, City University of Hong Kong
Website: http://ronggui.huang.googlepages.com/
RQDA project: http://rqda.r-forge.r-project.org/

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


Re: [R] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 11:38 AM, hadley wickham wrote:

On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 12/12/2008 8:25 AM, hadley wickham wrote:


From which you might conclude that I don't like the design of subset, and
you'd be right.  However, I don't think this is a counterexample to my
general rule.  In the subset function, the select argument is treated as
an
unevaluated expression, and then there are rules about what to do with
it.
 (I.e. try to look up name `a` in the data frame, if that fails, ...)

For the requested behaviour to similarly fall within the general rule,
we'd
have to treat all indices to all kinds of things (vectors, matrices,
dataframes, etc.) as unevaluated expressions, with special handling for
the
particular symbol `end`.


Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions.


Ummm, doesn't that require changes to *both* indexing and seq?


Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
expression.


This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].


I agree:  it would be a nice addition, but a fair bit of work.  I think it
would be quite doable for the indexable things in the base packages, but
there are a lot of contributed packages that define [ methods, and those
methods would all need to be modified too.


That's true, although I suspect many contributed [.methods eventually
delegate to base methods and might work without further modification.


(Just to be clear, when I say doable, I'm thinking that your iterators
return functions that compute subsets of index ranges.  For example, evens()
might be implemented as

evens - function() {
 result - function(indices) {
   indices[indices %% 2 == 0]
 }
 class(result) - iterator
 return(result)
}

and then `[` in v[evens()] would recognize that it had been passed an
iterator, and would pass 1:length(v) to the iterator to get the subset of
even indices.  Is that what you had in mind?)


Yes, that's exactly what I was thinking, although you'd have to put
some thought into the conventions - would it be better to pass in the
length of the vector instead of a vector of indices?  Should all
iterators return logical vectors?  That way you could do x[evens() 
last(5)] to get the even indices out of the last 5, as opposed to
x[evens()][last(5)] which would return the last 5 even indices.


Actually, I don't think so.  evens()  last(5) would fail to evaluate, 
because you're trying to do a logical combination of two functions, not 
of two logical vectors.  Or are we going to extend the logical operators 
to work on iterators/selectors too?


Duncan Murdoch


You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement.  first(n) could also be useful, selecting the first
min(n, length(vector)) observations.   An iterator version of rev()
would also be handy.

Maybe selector would be a better name than iterator though, as these
don't have the same feel as iterators in other languages.

Hadley



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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 On 12/12/2008 11:38 AM, hadley wickham wrote:

 On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch murd...@stats.uwo.ca
 wrote:

 On 12/12/2008 8:25 AM, hadley wickham wrote:

 From which you might conclude that I don't like the design of subset,
 and
 you'd be right.  However, I don't think this is a counterexample to my
 general rule.  In the subset function, the select argument is treated
 as
 an
 unevaluated expression, and then there are rules about what to do with
 it.
  (I.e. try to look up name `a` in the data frame, if that fails, ...)

 For the requested behaviour to similarly fall within the general rule,
 we'd
 have to treat all indices to all kinds of things (vectors, matrices,
 dataframes, etc.) as unevaluated expressions, with special handling for
 the
 particular symbol `end`.

 Except you wouldn't have to necessarily change indexing - you could
 change seq instead.  Then 5:end could produce some kind of special
 data structure (maybe an iterator) that was recognised by the various
 indexing functions.

 Ummm, doesn't that require changes to *both* indexing and seq?

 Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
 expression.

 This would still be a lot of work for not a lot
 of payoff, but it would be a logically consistent way of adding this
 behaviour to indexing, and the basic work would make it possible to
 develop other sorts of indexing, eg df[evens(), ], or df[last(5),
 last(3)].

 I agree:  it would be a nice addition, but a fair bit of work.  I think
 it
 would be quite doable for the indexable things in the base packages, but
 there are a lot of contributed packages that define [ methods, and those
 methods would all need to be modified too.

 That's true, although I suspect many contributed [.methods eventually
 delegate to base methods and might work without further modification.

 (Just to be clear, when I say doable, I'm thinking that your iterators
 return functions that compute subsets of index ranges.  For example,
 evens()
 might be implemented as

 evens - function() {
  result - function(indices) {
   indices[indices %% 2 == 0]
  }
  class(result) - iterator
  return(result)
 }

 and then `[` in v[evens()] would recognize that it had been passed an
 iterator, and would pass 1:length(v) to the iterator to get the subset of
 even indices.  Is that what you had in mind?)

 Yes, that's exactly what I was thinking, although you'd have to put
 some thought into the conventions - would it be better to pass in the
 length of the vector instead of a vector of indices?  Should all
 iterators return logical vectors?  That way you could do x[evens() 
 last(5)] to get the even indices out of the last 5, as opposed to
 x[evens()][last(5)] which would return the last 5 even indices.

 Actually, I don't think so.  evens()  last(5) would fail to evaluate,
 because you're trying to do a logical combination of two functions, not of
 two logical vectors.  Or are we going to extend the logical operators to
 work on iterators/selectors too?

Oh yes, that's a good point.  But wouldn't the following do the job?

.selector - function(a, b) {
  function(n) a(n)  b(n)
}

or

.selector - function(a, b) {
  function(n) intersect(a(n), b(n))
}

depending on whether selectors return logical or numeric vectors.
Writing functions for | and ! would be similarly easy.  Or am I
missing something?

Hadley

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

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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 11:11 AM, Vitalie Spinu vitosm...@rambler.ru wrote:
 On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham h.wick...@gmail.com
 wrote:

 You could also imagine similar iterators for random sampling, like
 samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
 with replacement.  first(n) could also be useful, selecting the first
 min(n, length(vector)) observations.   An iterator version of rev()
 would also be handy.

 Maybe selector would be a better name than iterator though, as these
 don't have the same feel as iterators in other languages.

 That is really something!! Real high level language!!
 Selectors could depend on named variables in data frame as well:

 mtcars[sel(cyl3)last(5)]
 mtcars[sel(cyl3)boot(80%)]

 or may be just
 mtcars[cyl3last(20)]

 or this is already too far?

This would be a considerable extension because then the selector would
need to know about all other variables in the dataset, and you'd need
someway of combining selectors with logical vectors.  So it would be a
huge increase in complexity for not much gain, given that with just
the interface we have described you could do:

mtcars[mtcars$cyl  3, ][last(20), ]
# or
subset(mtcars, cyl  3)[last(20), ]

The main idea of selectors is that they would be independent of the
data structure that they are being used with.

Hadley

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

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


Re: [R] spatial AR and ARIMA

2008-12-12 Thread Roger Bivand
Erin Hodgess erinm.hodgess at gmail.com writes:

 
 Dear R People:
 
 Are there functions for spatial AR and ARIMA models in R, please?

Would looking at the Spatial task view on your CRAN mirror help? If by AR 
you mean simultaneous or conditional autoregressive models using spatial 
weights (or moving average, but not SAR and SMA at the same time), see 
spautolm() in spdep. Note that with corSpatial(), you can fit a selection of
relevant mixed effects models using nlme and similar packages - is this what 
you are looking for?

Roger Bivand 

 
 Thanks,
 Sincerely,
 Erin


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


Re: [R] The end of Matlab

2008-12-12 Thread Gabor Grothendieck
On Fri, Dec 12, 2008 at 12:11 PM, Vitalie Spinu vitosm...@rambler.ru wrote:
 On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham h.wick...@gmail.com
 wrote:

 You could also imagine similar iterators for random sampling, like
 samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
 with replacement.  first(n) could also be useful, selecting the first
 min(n, length(vector)) observations.   An iterator version of rev()
 would also be handy.

 Maybe selector would be a better name than iterator though, as these
 don't have the same feel as iterators in other languages.

 That is really something!! Real high level language!!
 Selectors could depend on named variables in data frame as well:

 mtcars[sel(cyl3)last(5)]
 mtcars[sel(cyl3)boot(80%)]

 or may be just
 mtcars[cyl3last(20)]


You can do this (and quite a bit more) in data.table:

 library(data.table)
 mtcars.dt - as.data.table(mtcars)
 tail(mtcars.dt[cyl  5], 4)
  mpg cyl  disp  hp dratwt qsec vs am gear carb
[1,] 27.3   4  79.0  66 4.08 1.935 18.9  1  141
[2,] 26.0   4 120.3  91 4.43 2.140 16.7  0  152
[3,] 30.4   4  95.1 113 3.77 1.513 16.9  1  152
[4,] 21.4   4 121.0 109 4.11 2.780 18.6  1  142

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


Re: [R] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 12:23 PM, hadley wickham wrote:

On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 12/12/2008 11:38 AM, hadley wickham wrote:


On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch murd...@stats.uwo.ca
wrote:


On 12/12/2008 8:25 AM, hadley wickham wrote:


From which you might conclude that I don't like the design of subset,
and
you'd be right.  However, I don't think this is a counterexample to my
general rule.  In the subset function, the select argument is treated
as
an
unevaluated expression, and then there are rules about what to do with
it.
 (I.e. try to look up name `a` in the data frame, if that fails, ...)

For the requested behaviour to similarly fall within the general rule,
we'd
have to treat all indices to all kinds of things (vectors, matrices,
dataframes, etc.) as unevaluated expressions, with special handling for
the
particular symbol `end`.


Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions.


Ummm, doesn't that require changes to *both* indexing and seq?


Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
expression.


This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].


I agree:  it would be a nice addition, but a fair bit of work.  I think
it
would be quite doable for the indexable things in the base packages, but
there are a lot of contributed packages that define [ methods, and those
methods would all need to be modified too.


That's true, although I suspect many contributed [.methods eventually
delegate to base methods and might work without further modification.


(Just to be clear, when I say doable, I'm thinking that your iterators
return functions that compute subsets of index ranges.  For example,
evens()
might be implemented as

evens - function() {
 result - function(indices) {
  indices[indices %% 2 == 0]
 }
 class(result) - iterator
 return(result)
}

and then `[` in v[evens()] would recognize that it had been passed an
iterator, and would pass 1:length(v) to the iterator to get the subset of
even indices.  Is that what you had in mind?)


Yes, that's exactly what I was thinking, although you'd have to put
some thought into the conventions - would it be better to pass in the
length of the vector instead of a vector of indices?  Should all
iterators return logical vectors?  That way you could do x[evens() 
last(5)] to get the even indices out of the last 5, as opposed to
x[evens()][last(5)] which would return the last 5 even indices.


Actually, I don't think so.  evens()  last(5) would fail to evaluate,
because you're trying to do a logical combination of two functions, not of
two logical vectors.  Or are we going to extend the logical operators to
work on iterators/selectors too?


Oh yes, that's a good point.  But wouldn't the following do the job?

.selector - function(a, b) {
  function(n) a(n)  b(n)
}

or

.selector - function(a, b) {
  function(n) intersect(a(n), b(n))
}

depending on whether selectors return logical or numeric vectors.
Writing functions for | and ! would be similarly easy.  Or am I
missing something?


No, I think those definitions would be fine, but I'd be concerned about 
speed issues if we start messing with primitives.


While we're at it, we might as well do the same sort of thing for :, and 
define a selector named end, and then 3:end would give a selector from 3 
to the end, which brings us back to the original question.  So it's not 
nearly as intrusive as I thought it would be.


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Make installed packages available to new R version

2008-12-12 Thread Roy Robertson
After installing a new version of R, how do I make the packages that I 
have already installed and use on the old version available to the new 
version?


Thank you,

Roy Robertson

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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
 Oh yes, that's a good point.  But wouldn't the following do the job?

 .selector - function(a, b) {
  function(n) a(n)  b(n)
 }

 or

 .selector - function(a, b) {
  function(n) intersect(a(n), b(n))
 }

 depending on whether selectors return logical or numeric vectors.
 Writing functions for | and ! would be similarly easy.  Or am I
 missing something?

 No, I think those definitions would be fine, but I'd be concerned about
 speed issues if we start messing with primitives.

Speed or expressiveness: pick one? ;)  People could always use the
regular subsetting mechanisms if they want the best speed - any
changes to support selectors wouldn't affect the speed of the other
methods of subsetting, would they?

 While we're at it, we might as well do the same sort of thing for :, and
 define a selector named end, and then 3:end would give a selector from 3 to
 the end, which brings us back to the original question.  So it's not nearly
 as intrusive as I thought it would be.

3:end() do you mean?  Or do you mean extending seq so that it uses
unevaluted input?

Hadley


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

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


Re: [R] Make installed packages available to new R version

2008-12-12 Thread Vitalie Spinu

Have a look at this 
http://thread.gmane.org/gmane.comp.lang.r.general/87014/focus=133050
it is safer to have all you packages reinstalled once you have updated R.

HTH.


On Fri, 12 Dec 2008 18:47:33 +0100, Roy Robertson jroyrobert...@comcast.net 
wrote:

After installing a new version of R, how do I make the packages that I  
have already installed and use on the old version available to the new  
version?


Thank you,

Roy Robertson

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

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


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


Re: [R] candisc plotting

2008-12-12 Thread Pete Shepard
Dear Michael,


You haven't told us what your data is, and we can only surmise -- not very
helpful for you and annoying for those who try to help.

Apologies, I am brand new to R and this mailing list. Will try to be more
concise.

Here is my data a NEW verion of my data:

  Curvature Diameter   Quality
1  2.95 6.63Passed
2  2.53 7.79Passed
3  3.57 5.65Passed
4  3.16 5.47Passed
5  2.58 4.46 NotPassed
6  2.16 6.22 NotPassed
7  3.27 3.52 NotPassed

What I am trying to get from the candisc method is a 1 dimensional
scatterplot that separates my two groups Passed and NotPassed

On this data I do a do.mod - lm(cbind(Diameter, Curvature) ~ Quality,
data=do)

do.mod produces

Coefficients:
   Diameter  Curvature
(Intercept)4.73332.6700
QualityPassed  1.65170.3825

I then run the candisc method: do.can - candisc(do.mod, data=do)

this produces:

Canonical Discriminant Analysis for Quality:

   CanRsq Eigenvalue Difference Percent Cumulative
1 0.91354 10.566100100

Test of H0: The canonical correlations in the
current row and all that follow are zero

  LR test stat approx F num Df den Df   Pr( F)
10.086   52.831  1  5 0.0007706 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

What I think I would like to plot is the discriminant function of each
sample 1-7.

Here is an example of what I am trying to do with candisc.

http://people.revoledu.com/kardi/tutorial/LDA/Numerical%20Example.html

Thanks










On Thu, Dec 11, 2008 at 3:36 PM, Michael Friendly frien...@yorku.ca wrote:

 Dear Pete,

 You haven't told us what your data is, and we can only surmise -- not very
 helpful for you and annoying for those who try to help.

 Pete Shepard wrote:

 Hello,

 I have a file with two dependent variables (three and five) and one
 independent variable. I do  i.mod - lm(cbind(three, five) ~ species,
 data=i.txt) and get the following output:


 Coefficients:
 three   five
 (Intercept)   9.949   9.586
 species  -1.166  -1.156

 From this, it seems that species is numeric variable, not a factor.
 If so, canonical discriminant analysis in not appropriate, so
 all following bets are off.

 That's likely why you end up with only one canonical dimension.


  I do a i.can-candisc(i.mod,data=i):

 Is data=i the same as data=i.txt?


 and get the following output:

 Canonical Discriminant Analysis for species:

CanRsq Eigenvalue Difference Percent Cumulative
 1 0.0965060.10681100100

 Test of H0: The canonical correlations in the
 current row and all that follow are zero
 LR test stat approx F num Df den Df   Pr( F)
 10.903   63.875  1598 6.859e-15 ***
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

 this is different than the output I get with SAS:

 What was your SAS code? Was the data the same?


 Eigenvalue Difference Proportion Cumulative  Ratio F Value
 Num DF Den DF Pr  F

   1 0.10681. 1. 0.90349416
 31.88  2597 .0001




 I am also wondering how to plot the can1*can1 like it is done in SAS.

 proc plot;
plot can1*can1=species;
format species spechar.;
title2 'Plot of Constits_vs_cassettes';
  run;

  If you want to compare plots for canonical analysis in SAS and R,
 see my macros, canplot and hecan at
 http://www.math.yorku.ca/SCS/sasmac/

 But in general, if all you have is 1 canonical dimension, a dotplot or
 boxplot of the canonical scores would be more useful than a scatterplot
 plot of can1 * can1.

 The plot method for candisc objects in the candisc package has some
 code to handle the 1 can-D case.

 hope this helps
 -Michael

 Thanks

[[alternative HTML version deleted]]

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



 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.
 York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
 Toronto, ONT  M3J 1P3 CANADA



[[alternative HTML version deleted]]

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


Re: [R] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 1:06 PM, hadley wickham wrote:

Oh yes, that's a good point.  But wouldn't the following do the job?

.selector - function(a, b) {
 function(n) a(n)  b(n)
}

or

.selector - function(a, b) {
 function(n) intersect(a(n), b(n))
}

depending on whether selectors return logical or numeric vectors.
Writing functions for | and ! would be similarly easy.  Or am I
missing something?


No, I think those definitions would be fine, but I'd be concerned about
speed issues if we start messing with primitives.


Speed or expressiveness: pick one? ;)  People could always use the
regular subsetting mechanisms if they want the best speed - any
changes to support selectors wouldn't affect the speed of the other
methods of subsetting, would they?


While we're at it, we might as well do the same sort of thing for :, and
define a selector named end, and then 3:end would give a selector from 3 to
the end, which brings us back to the original question.  So it's not nearly
as intrusive as I thought it would be.


3:end() do you mean?  Or do you mean extending seq so that it uses
unevaluted input?


My end would be the output of your end().  If there are no args and no 
local context, I don't see the need for it to be a function call.  It 
would just be defined as something like


end - structure( function(n) c(rep(FALSE, n-1), TRUE), class=selector)

I'm not sure what the definition of : should be if one of the args is a 
selector.


Duncan

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


Re: [R] The end of Matlab

2008-12-12 Thread Claudia Beleites
 evens()  last(5)
wouldn't x[evens()][last(5)] do the  already?

or is different, though.

Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] Make installed packages available to new R version

2008-12-12 Thread Mike Prager
Roy Robertson jroyrobert...@comcast.net wrote:

 After installing a new version of R, how do I make the packages that I 
 have already installed and use on the old version available to the new 
 version?

Here is my solution. It has worked over many releases of R,
though it will probably require one initial re-installation of
packages.

Set environment variable R_LIBS to some permanent directory
before installing a version of R. (That is, NOT a directory
under the tree of your current R version.) When you subsequently
install packages, they will go into that location and won't need
re-installation with each new version of R. 

It's still necessary to run update.packages() periodically --
such as after installing a new R version -- to keep the
installed packages current.

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

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


Re: [R] The end of Matlab

2008-12-12 Thread Greg Snow
That depends on what you want evens()  last(5) to mean.  Does that mean the 
last 5 evens (returning 5 values) or the values in the last 5 that are also 
even items (returning either 2 or 3 values depending on if the structure has an 
odd or even number of elements).  It could be interpreted either way.  Your 
subset below does the first, the other examples do the 2nd.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Claudia Beleites
 Sent: Friday, December 12, 2008 11:38 AM
 To: r-help@r-project.org
 Subject: Re: [R] The end of Matlab

  evens()  last(5)
 wouldn't x[evens()][last(5)] do the  already?

 or is different, though.

 Claudia

 --
 Claudia Beleites
 Dipartimento dei Materiali e delle Risorse Naturali
 Università degli Studi di Trieste
 Via Alfonso Valerio 6/a
 I-34127 Trieste

 phone: +39 (0 40) 5 58-34 47
 email: cbelei...@units.it

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

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

2008-12-12 Thread Fernando Bizuet
Hello,

I am trying to do a loop with dates, but when I try to use the index is not
a date.

   Fcorte -  as.Date('2008/11/30',format = %Y/%m/%d)
   fini - Fcorte + 1
   ffin - seq(fini,by='months',length=2)[2] - 1

   for (i in seq(fini,to = ffin, by='days'))
print (weekdays(i))  # i doesn't a date

How can I do a loop with dates and get the index of each date? are there a
method to convert the index i to date?


Thanks in advance.

[[alternative HTML version deleted]]

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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
 My end would be the output of your end().  If there are no args and no local
 context, I don't see the need for it to be a function call.  It would just
 be defined as something like

 end - structure( function(n) c(rep(FALSE, n-1), TRUE), class=selector)

Oh, I see what you mean.

 I'm not sure what the definition of : should be if one of the args is a
 selector.

Alternatively you could use !first(2), and only use end/last when you
want to select the last n observations.  Of course !first(2) would be
the equivalent to -(1:2) so there's not much savings there.

Hadley

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

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


Re: [R] loop with dates

2008-12-12 Thread Henrique Dallazuanna
Try this:

weekdays(seq(fini,to = ffin, by='days'))

or in a loop:

sapply(as.character(seq(fini,to = ffin, by='days')),
  function(d)weekdays(as.Date(d)))

On Fri, Dec 12, 2008 at 4:55 PM, Fernando Bizuet fbiz...@gmail.com wrote:

 Hello,

 I am trying to do a loop with dates, but when I try to use the index is not
 a date.

   Fcorte -  as.Date('2008/11/30',format = %Y/%m/%d)
   fini - Fcorte + 1
   ffin - seq(fini,by='months',length=2)[2] - 1

   for (i in seq(fini,to = ffin, by='days'))
print (weekdays(i))  # i doesn't a date

 How can I do a loop with dates and get the index of each date? are there a
 method to convert the index i to date?


 Thanks in advance.

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


Re: [R] loop with dates

2008-12-12 Thread Gabor Grothendieck
Try iterating over the index rather than the value of
each component:

s - seq(fini,to = ffin, by='days')
for (i in seq_along(s)) print(s[[i]])


On Fri, Dec 12, 2008 at 1:55 PM, Fernando Bizuet fbiz...@gmail.com wrote:
 Hello,

 I am trying to do a loop with dates, but when I try to use the index is not
 a date.

   Fcorte -  as.Date('2008/11/30',format = %Y/%m/%d)
   fini - Fcorte + 1
   ffin - seq(fini,by='months',length=2)[2] - 1

   for (i in seq(fini,to = ffin, by='days'))
print (weekdays(i))  # i doesn't a date

 How can I do a loop with dates and get the index of each date? are there a
 method to convert the index i to date?


 Thanks in advance.

[[alternative HTML version deleted]]

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


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


Re: [R] Odp: character count

2008-12-12 Thread Petr PIKAL
Ok, I knew somebody come with regex solution. My regex skills are limited 
so I do not use it very often.

Regards
Petr

r-help-boun...@r-project.org napsal dne 12.12.2008 17:03:38:

 On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL petr.pi...@precheza.cz 
wrote:
  Hi
 
 
  r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:
 
  Dear list,
  I have a variable that consists of typed responses. I wish to compute
  a variable equal to the number of characters in the original 
variable.
  For example:
 
   x - c(convert this to 32 because it has 32 characters, this one
  has 22
  characters, 12 characters)
 
  [Some magic function here]
 
  If you consider space as a character then
 
   nchar(x)
 
  gives you the result.
 
  If not so such construction can do it
 
   unlist(lapply(lapply(strsplit(x,  ), paste, collapse=), nchar))
 
 
 or perhaps:
 
 x - abc def
 nchar(gsub( , , x)) # 6
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] prevalence ratio and confidence intervals

2008-12-12 Thread Roberta Pereira Niquini
Hi everybody,

I would like to estimate prevalence ratio and confidence intervals. 

I tried to do a log-binomial regression, but there was a failure of 
convergence.
Now, I would like to learn how to do a poisson regression with robust 
variance.
I am trying to estimate coefficients with poisson regression and then get 
standard errors that are adjusted for heteroskedasticity. 

glm22- svyglm(y~x1+x2+x3+offset(log(x4)), data = banco,  family = poisson, 
design= design_tarv)

# Y has a binomial distribution (0/1)
# X1, X2, X3 e X4 are categorical variables.
#I am using the library(survey) because it is an analysis of Complex Sample 
Survey Data .

summary(glm22)

Call:
svyglm(y~x1+x2+x3+ offset(log(x4)),data = banco, family = poisson, design = 
design_tarv)

Survey design:
svydesign(ids = ~conglomerado, strata = ~estrato, data = banco, 
weights = ~peso)

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) -5.612240.07223 -77.699   2e-16 ***
x1   0.338470.07428   4.557 0.000155 ***
x2   0.177450.07059   2.514 0.019765 *  
x3   0.335080.09447   3.547 0.001808 ** 
x4   0.243820.08808   2.768 0.011217 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

(Dispersion parameter for poisson family taken to be 0.7535822)

Number of Fisher Scoring iterations: 5

# Using family=quasipoisson, I found the same values.


library(sandwich)

vcovHAC(glm22)

 (Intercept)x1   x2   x3x4
(Intercept)1.060857e-12-1.306035e-13-5.139155e-13 -9.788354e-13 -3.428080e-13
x1 -1.306035e-13  7.237868e-13   -3.263182e-13  -1.620593e-13  1.704392e-13
x2 -5.139155e-13  -3.263182e-13  1.250564e-12   7.207572e-13   -9.350062e-13
x3 -9.788354e-13  -1.620593e-13  7.207572e-13   1.707176e-12   -2.244859e-13
x4 -3.428080e-13   1.704392e-13   -9.350062e-13  -2.244859e-13   2.031640e-12

sqrt(diag(vcovHAC(glm22)))

 (Intercept)   x1x2x3 x4
1.029979e-06 8.507566e-07 1.118286e-06 1.306589e-06 1.425356e-06 


I think these standards errors are very small. 

Is this the correct form to do poisson regression with robust variance?

Thank you for the help, 
Roberta.

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


Re: [R] Make installed packages available to new R version

2008-12-12 Thread Prof Brian Ripley

You have not told us your OS (despite the posting guide).

For Windows this is covered in the rw-FAQ.  Similar advice would apply on 
a Unix-alike.


For Mac OS X, see the recent archives of the R-sig-mac list. E.g. the 
strangely titled threads (look in a threaded view) around


https://stat.ethz.ch/pipermail/r-sig-mac/2008-November/005565.html

(probably using the Package Installer).

On Fri, 12 Dec 2008, Roy Robertson wrote:

After installing a new version of R, how do I make the packages that I have 
already installed and use on the old version available to the new version?


Thank you,

Roy Robertson

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



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

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


Re: [R] loop with dates

2008-12-12 Thread Jagat.K.Sheth
 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Fernando Bizuet
 Sent: Friday, December 12, 2008 12:55 PM
 To: r-help@r-project.org
 Subject: [R] loop with dates
 
 Hello,
 
 I am trying to do a loop with dates, but when I try to use 
 the index is not
 a date.

See ?for. That help page mentions the following which can clarify what
to expect 

... The variable 'var' has the same type as 'seq' ...

Small illustration,

fac  - gl(5,1,labels=letters[1:5])
fac
[1] a b c d e
Levels: a b c d e

typeof(fac)
[1] integer

for(i in fac) print(i)
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5


 
Fcorte -  as.Date('2008/11/30',format = %Y/%m/%d)
fini - Fcorte + 1
ffin - seq(fini,by='months',length=2)[2] - 1
 
for (i in seq(fini,to = ffin, by='days'))
 print (weekdays(i))  # i doesn't a date

typeof(ffin)
[1] double

As your index is no longer of class 'Date', you will get
Error in UseMethod(weekdays) : no applicable method for weekdays

 
 How can I do a loop with dates and get the index of each 
 date? are there a
 method to convert the index i to date?

Here's one way 
dd - seq(fini,to = ffin, by='days')
for (i in seq_along(dd)) print(dd[i])

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

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


Re: [R] assign()ing within apply

2008-12-12 Thread Thompson, David (MNR)
Thanks Jorge,
 
I am aware of the method you suggest, however, it's not quite what I was
asking for.
I was attempting to do this change on 56 dataframes, so I attempted to
do so with a list of all rather than each individually.
 
Thanks, DaveT.




From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] 
Sent: December 12, 2008 11:11 AM
To: Thompson, David (MNR)
Subject: Re: [R] assign()ing within apply



Dear David, 

Try this:

ban.ovs.93[,'spp']-tolower(ban.ovs.93[,'spp'])
ban.ovs.93

pem.ovs.94[,'spp']-tolower(pem.ovs.94[,'spp'])
pem.ovs.94


HTH,

Jorge



On Fri, Dec 12, 2008 at 9:51 AM, Thompson, David (MNR)
david.john.thomp...@ontario.ca wrote:


Any tips?

DaveT.

-Original Message-
From: Thompson, David (MNR)
Sent: December 9, 2008 04:03 PM
To: 'r-help@r-project.org'
Subject: assign()ing within apply

Hello,

I'm trying to convert a character column in several
dataframes
to lower case.

###
#
# Sample data and 'spp' column summaries:
# dput(ban.ovs.1993[sample(row.names(ban.ovs.1993),
20), 1:4])
ban.ovs.93 - structure(list(oplt = c(43L, 43L, 38L,
26L, 35L,
8L, 39L, 1L,
34L, 50L, 10L, 29L, 31L, 24L, 18L, 12L, 27L, 49L, 28L,
51L),
rplt = c(NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
NA_integer_), tree = c(427L, 410L, 639L, 494L,
649L, 166L,
735L, 163L, 120L, 755L, 612L, 174L, 129L, 331L,
269L, 152L,
552L, 227L, 243L, 96L), spp = c(MH, MST, MH,
HE,
BE, MH, MH, MH, MH, Or, IW, Or,
MH, MH,
BY, MH, MH, BE, MH, MR)), .Names =
c(oplt,
rplt, tree, spp), row.names = c(4587L, 4570L,
3947L, 2761L,
3653L, 652L, 4136L, 64L, 3567L, 5318L, 838L, 3091L,
3366L, 2423L,
1775L, 1061L, 2893L, 5161L, 2967L, 5395L), class =
data.frame)

# dput(pem.ovs.1994[sample(row.names(pem.ovs.1994),
20), 1:4])
pem.ovs.94 - structure(list(oplt = c(8L, 17L, 36L, 9L,
31L,
11L, 35L, 51L,
51L, 49L, 40L, 1L, 9L, 17L, 4L, 42L, 6L, 3L, 39L, 25L),
tree = c(531L,
557L, 546L, 261L, 592L, 134L, 695L, 933L, 945L, 114L,
34L, 54L,
549L, 574L, 193L, 96L, 70L, 4L, 546L, 789L), spp =
c(MH, MH,
MH, BF, BF, MH, IW, OR, OR, BF, MH,
IW, OR,
MH, SM, BE, BE, BE, OR, OR), oaz = c(38L,
205L,
140L, 277L, 329L, 209L, 222L, 24L, 67L, 187L, 156L,
181L, 174L,
248L, 42L, 279L, 273L, 357L, 160L, 183L)), .Names =
c(oplt,
tree, spp, oaz), row.names = c(1204L, 2943L,
5790L, 1616L,
5063L, 2013L, 5691L, 8188L, 8200L, 7822L, 6302L, 54L,
1698L,
2960L, 421L, 6690L, 775L, 245L, 6205L, 4121L), class =
data.frame)

# count per spp
invisible(lapply(ls(pat='ovs'), function(y) { cat(y,
\n)  ;
print(summary.factor(get(y)[,'spp'])) ; cat(\n) } ) )
ban.ovs.93
BE  BY  HE  IW  MH  MR MST  Or
 2   1   1   1  11   1   1   2

pem.ovs.94
BE BF IW MH OR SM
 3  3  2  6  5  1
#
###

I have tried variants on the following and cannot
remember how
to have the result assign()ed back to the original
dataframes.
lapply(ls(pat='ovs'), function(y) { assign(paste(y,
[,'spp'], sep=), tolower(get(y)[,'spp'])) } )

I *do* get the expected results:
[[1]]
 [1] mh  mst mh  he  be  mh  mh  mh
mh
or  iw  or  mh  mh  by  mh  mh  be
mh  mr

[[2]]
 [1] mh mh mh bf bf mh iw or or bf
mh
iw or mh sm be be be or or

, I just can't remember how to get them back into the
original
dataframe objects. Suggestions?

Thanx, DaveT.
*
Silviculture Data Analyst
   

[R] ANNOUNCE: 2009 John M. Chambers Statistical Software Award

2008-12-12 Thread J.R. Lockwood
John M. Chambers Statistical Software Award - 2009
Statistical Computing Section
American Statistical Association

The Statistical Computing Section of the American Statistical
Association announces the competition for the John M.  Chambers
Statistical Software Award. In 1998 the Association for Computing
Machinery presented its Software System Award to John Chambers for the
design and development of S. Dr. Chambers generously donated his award
to the Statistical Computing Section to endow an annual prize for
statistical software written by an undergraduate or graduate student.
The prize carries with it a cash award of $1000, plus a substantial
allowance for travel to the annual Joint Statistical Meetings where
the award will be presented.

Teams of up to 3 people can participate in the competition, with the
cash award being split among team members. The travel allowance will
be given to just one individual in the team, who will be presented the
award at JSM.  To be eligible, the team must have designed and
implemented a piece of statistical software.  The individual within
the team indicated to receive the travel allowance must have begun the
development while a student, and must either currently be a student,
or have completed all requirements for her/his last degree after
January 1, 2007.  To apply for the award, teams must provide the
following materials:

   Current CV's of all team members.

   A letter from a faculty mentor at the academic institution of the
   individual indicated to receive the travel award.  The letter
   should confirm that the individual had substantial participation in
   the development of the software, certify her/his student status
   when the software began to be developed (and either the current
   student status or the date of degree completion), and briefly
   discuss the importance of the software to statistical practice.

   A brief, one to two page description of the software, summarizing
   what it does, how it does it, and why it is an important
   contribution.  If the team member competing for the travel
   allowance has continued developing the software after finishing
   her/his studies, the description should indicate what was developed
   when the individual was a student and what has been added since.

   Access to the software by the award committee for their use on
   inputs of their choosing.  Access to the software can consist of an
   executable file, Web-based access, macro code, or other appropriate
   form.  Access should be accompanied by enough information to allow
   the judges to effectively use and evaluate the software (including
   its design considerations.)  This information can be provided in a
   variety of ways, including but not limited to a user manual (paper
   or electronic), a paper, a URL, online help to the system, and
   source code.  In particular, the entrant must be prepared to
   provide complete source code for inspection by the committee if
   requested.

All materials must be in English.  We prefer that electronic text be
submitted in Postscript or PDF.  The entries will be judged on a
variety of dimensions, including the importance and relevance for
statistical practice of the tasks performed by the software, ease of
use, clarity of description, elegance and availability for use by the
statistical community. Preference will be given to those entries that
are grounded in software design rather than calculation.  The decision
of the award committee is final.

All application materials must be received by 5:00pm EST, Monday,
February 23, 2009 at the address below.  The winner will be announced
in May and the award will be given at the 2009 Joint Statistical
Meetings.

Information on the competition can also be accessed on the website of
the Statistical Computing Section (www.statcomputing.org or see the
ASA website, www.amstat.org for a pointer), including the names and
contributions of previous winners.  Inquiries and application
materials should be emailed or mailed to:

Chambers Software Award
c/o J.R. Lockwood
The RAND Corporation
4570 Fifth Avenue, Suite 600
Pittsburgh, PA 15213
lockw...@rand.org

__

This email message is for the sole use of the intended r...{{dropped:6}}

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


Re: [R] The end of Matlab

2008-12-12 Thread Vitalie Spinu

On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham h.wick...@gmail.com wrote:



or may be just
mtcars[cyl3last(20)]

or this is already too far?


This would be a considerable extension because then the selector would
need to know about all other variables in the dataset, and you'd need
someway of combining selectors with logical vectors. 



If selector returns a logical vector then I really don't see where is the problem. Probably I am mistaken but 
implementing mtcars[cyl3] is not such a big deal. Just an operator `[.` start searching for cyl 
from inside the x frame and not from parent.frame as it does now. It is just like putting 
with inside '[', or not?

When started with R I was really disappointed that such a natural and intuitive 
subsetting  is not allowed, but instead lengthy and ackward 
mtcars[mtcars$syl3] is required.

R is an interactive language for 99% of the users and features like that(and 
selectors indeed) would make a tremendous difference.

Regards,
SV.

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


Re: [R] mixed model nested ANOVA

2008-12-12 Thread Andrew Robinson
Hi Sebpe,

the analysis of the data that you describe could be a complex and
lengthy process, in which decisions that you are confronted by are
affected by previous decisions that you have made.  I recommend
obtaining the assistance of a statistician, preferably a local one
whose door you can knock on.  If you are unable to do so then I
suggest that you borrow/buy a copy of the Pinheiro and Bates book,
which documents lme() and its friends, and study it carefully,
especially the worked examples.

Good luck!

Andrew

On Fri, Dec 12, 2008 at 03:13:06PM +, Sebpe De Smedt wrote:
 Hi,
 
 
 I'm working on leaf characteristics of trees. Each tree is characterised by
 about 10 leaf traits.
 The trees were sampled at 9 different locations (about 20 to 30
 trees/location, NOT balanced), grouped in 3 different climatic zones
 (Sahelian, Soudanian and Guinean) (NOT balanced).
 Further, each tree is characterised by some degree of human pressure
 (mutilation degree), in total 4 different degrees were defined (NOT
 balanced).
 
 In the dryer zones, the trees are under a much higher human pressure than in
 the more humid climatic zones, zone and mutilation degree are thus
 strongly correlated.
 
 I want to know how zones (fixed effects, climate interests me) and
 locations (nested in zones, random effects, location doesn't interests
 me) are influencing the leaf traits (say for example SLA). Further, also
 human pressure is affecting leaf traits so I want to characterise the
 influence of mutilation degree (fixed effects) on SLA.
 
 I found some interesting information, but still, I am not be able to analyse
 the data properly. I think I have to use the function lme() or lme().
 
 Can anyone tell me which function and command I have to use? And how I can
 produce an ANOVA table?
 
 
 Thanks in advance,
 Sebpe De Smedt
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


[R] Avoiding multiple outputs using RODBC package

2008-12-12 Thread Brigid Mooney
I am using R as a data manipulation tool for a SQL database.  So in some of
my R scripts I use the RODBC package to retreive data, then run analysis,
and use the sqlSave function in the RODBC package to store the results in a
database.

There are two problems I want to avoid, and they are highly related: (1)
having R rerun analysis which has already been done and saved into output
database table, and (2) ending up with more than one identical row in
my output database table.

-
The analysis I am running allows the user to input a large number of
variables, for example:
date, version, a, b, c, d, e, f, g, ...

After R completes its analysis, I write the results to a database table in
the format:
Value, date, version, a, b, c, d, e, f, g, ...

where Value is the result of the R analysis, and the rest of the columns are
the criteria that was used to get that value.
--

Can anyone think of a way to address these problems?  The only thing I can
think of so far is to run an sqlQuery to get a table of all the variable
combinations that are saved at the start, and then simply avoid computing
and re-outputing those results.  However, my results database table
currently has over 200K rows (and will grow very quickly as I keep going
with this project), so I think that would not be the most expeditious answer
as I think just the SQL query to download 200K rows x 10+ columns is going
to be time consuming in and of itself.

I know this is kindof a weird problem, and am open to all sorts of ideas...

Thanks!

[[alternative HTML version deleted]]

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


[R] Help with a permutation test

2008-12-12 Thread Grant Gillis
Hello List and thanks in advance for all of your help,


I am trying implement a permutation test of a multinomial logistic
regression ('multinom' within the nnet package).  In the end I want to
compare the parameter estimate from my data to the distribution of
randomized parameter estimates.

I have figured out how to permute my dependent variable (MNNUM) x number of
times, apply multinomial logistic regression, to each permutation, and save
the results in a list.  Where I am stuck is figuring out how to take the
mean and SD of the coefficients from my list of regressions.  I know that
the coefficients are stored in the $wts slot of the model.

Below is what I have so far.  I am sure there are nicer ways to do this and
if you feel so inclined please suggest them.



#this is a function to permute the MNNUM column once
rand- function(DF){
new.DF-DF
new.DF$MNNUM-sample(new.DF$MNNUM)
new.DF

}

#this function does one model I am interested in.

modeltree-function(DF){
MLM.plot - multinom(MN_fact  ~ Canpy  + mean_dbh  + num_beechoak  +
num_class5  + prop_hard , data=hfdata, trace=FALSE)
MLM.plot
}

# this replicates the 'rand' function and applies a model

resamp.funct-function(DF,funct, n){
list-replicate(n,rand(DF), simplify = FALSE)
sapply(list, funct, simplify = FALSE)
}


#So if I paste below:

l-resamp.funct(hfdata, modeltree, 3)

# I get


 l-resamp.funct(hfdata, modltree, 3)

 l
[[1]]
Call:
multinom(formula = MN_fact ~ Canpy + mean_dbh + num_beechoak +
num_class5 + prop_hard, data = hfdata, trace = FALSE)

Coefficients:
 (Intercept)   Canpymean_dbh num_beechoak num_class5
prop_hard
none -11.1845028 0.063880939  0.08440340   -0.7050239 -0.0998379
6.894522
sabrinus -10.6848488 0.055157318  0.19276777   -0.6441996  0.1219245
3.325704
volans-0.2481854 0.004410597 -0.02710102   -0.1061700 -0.1858376
2.495856

Residual Deviance: 163.7211
AIC: 199.7211

[[2]]
Call:
multinom(formula = MN_fact ~ Canpy + mean_dbh + num_beechoak +
num_class5 + prop_hard, data = hfdata, trace = FALSE)

Coefficients:
 (Intercept)   Canpymean_dbh num_beechoak num_class5
prop_hard
none -11.1845028 0.063880939  0.08440340   -0.7050239 -0.0998379
6.894522
sabrinus -10.6848488 0.055157318  0.19276777   -0.6441996  0.1219245
3.325704
volans-0.2481854 0.004410597 -0.02710102   -0.1061700 -0.1858376
2.495856

Residual Deviance: 163.7211
AIC: 199.7211

[[3]]
Call:
multinom(formula = MN_fact ~ Canpy + mean_dbh + num_beechoak +
num_class5 + prop_hard, data = hfdata, trace = FALSE)

Coefficients:
 (Intercept)   Canpymean_dbh num_beechoak num_class5
prop_hard
none -11.1845028 0.063880939  0.08440340   -0.7050239 -0.0998379
6.894522
sabrinus -10.6848488 0.055157318  0.19276777   -0.6441996  0.1219245
3.325704
volans-0.2481854 0.004410597 -0.02710102   -0.1061700 -0.1858376
2.495856

Residual Deviance: 163.7211
AIC: 199.7211

[[alternative HTML version deleted]]

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


Re: [R] character count

2008-12-12 Thread Carlos Cuartas
Hi Ista,
one way could be:

ncharacters-unlist(lapply(x,function(x)nchar(gsub(' ','',x
ncharacters




From: Ista Zahn iz...@psych.rochester.edu
To: r-help@r-project.org
Sent: Friday, December 12, 2008 10:31:10 AM
Subject: [R] character count

Dear list,
I have a variable that consists of typed responses. I wish to compute
a variable equal to the number of characters in the original variable.
For example:

 x - c(convert this to 32 because it has 32 characters, this one has 22 
 characters, 12 characters)

[Some magic function here]

 x
[1] 32 22 12

Any ideas?

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



  
[[alternative HTML version deleted]]

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


[R] Trellis margins settings so that they are like a base graphic with no figure region when printed to png file?

2008-12-12 Thread Mark Heckmann
  
Dear R-experts,

I want to produce a very small png file (35 x 18 px) that contains a
histogram without a figure region or margins, only the pure heights. 
In the base graphic this was easy:

  png(filename = hist.png, res = 72, width=35, height=18)
par(mar=c(0,0,0,0), oma=c(0,0,0,0))
hist(rnorm(100), main=)
  dev.off()

Now I want a grid graphics output as I need the graphic as an object.
I tried several trellis.par settings but I was not able to figure it out
(PROBLEM (1)).
Up to now it looks like this:

myHistogram - histogram(rnorm(100), xlab=, ylab=, 
 par.settings=list(
axis.line=list(col=transparent),
 
xlab.text=list(col=transparent),
 
ylab.text=list(col=transparent),
 
axis.text=list(col=transparent)   )
)

This looks acceptable although I would like smaller margins, that is to say
no margins at all.

PROBLEM (2) now is, that when it is printed to the png file, the graphic
almost consist of margins only. The main part of the plot shrinks to some
tiny points.

I don't know how to change the settings, so I that I get the same as in the
base system.

Does anyone know?

TIA
Mark

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


[R] How can we predict differences in a slope, given that the random component was significant?

2008-12-12 Thread Sachi Ito
Dear R users,

Using R lme function, I found that both fixed and random effects of variable
A on variable B are significant.  Now, I'd like to analyze what variables
are predicting differences in the slope.  In other words, I'd like to know
what variables (e.g., variable C) are predicting individual differences in
the effects of A on B.  I have many data points for A and B for each
individual, whereas I have only one data point for C.
I'd appreciate if anyone could answer the question.

Thank you for your attention.

[[alternative HTML version deleted]]

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


[R] aggregate and median

2008-12-12 Thread t . raff
Hello R-experts,

I have a simple question: how do I aggregate data using the median
function with na.rm = TRUE, i.e.

aggregate(x, list(x$y, x$z), FUN = '')

I have tried 'median(x, na.rm = TRUE)' but that doesn't help.

Any suggestions are very much appreciated,


Thorsten

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


Re: [R] aggregate and median

2008-12-12 Thread jim holtman
aggregate(x, list(x$y, x$a), FUN=median, na.rm=TRUE)

On Fri, Dec 12, 2008 at 2:13 PM,  t.r...@med2.uni-kiel.de wrote:
 Hello R-experts,

 I have a simple question: how do I aggregate data using the median
 function with na.rm = TRUE, i.e.

 aggregate(x, list(x$y, x$z), FUN = '')

 I have tried 'median(x, na.rm = TRUE)' but that doesn't help.

 Any suggestions are very much appreciated,


 Thorsten

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




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

What is the problem that you are trying to solve?

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


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 3:08 PM, Vitalie Spinu vitosm...@rambler.ru wrote:
 On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham h.wick...@gmail.com
 wrote:


 or may be just
 mtcars[cyl3last(20)]

 or this is already too far?

 This would be a considerable extension because then the selector would
 need to know about all other variables in the dataset, and you'd need
 someway of combining selectors with logical vectors.

 If selector returns a logical vector then I really don't see where is the
 problem. Probably I am mistaken but implementing mtcars[cyl3] is not such a
 big deal. Just an operator `[.` start searching for cyl from inside the
 x frame and not from parent.frame as it does now. It is just like putting
 with inside '[', or not?

And that's a big change to the current behaviour!

I think there are a few good reasons why this shouldn't be the default:

 * You could no longer do: cyl - 4;  mtcars[mtcars$cyl == cyl, ]
(which is very useful when writing function)

 * If you want that behaviour, then just use subset

 * It only makes sense for variables of data frames, not for all the
other types of subsets

 * Generally it's better to be explicit than not

 When started with R I was really disappointed that such a natural and
 intuitive subsetting  is not allowed, but instead lengthy and ackward
 mtcars[mtcars$syl3] is required.

 R is an interactive language for 99% of the users and features like that(and
 selectors indeed) would make a tremendous difference.

 Regards,
 SV.




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

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


Re: [R] [Rd] gregexpr - match overlap mishandled (PR#13391)

2008-12-12 Thread Wacek Kusnierczyk
Greg Snow wrote:
 Where do you get should and expect from?  All the regular expression 
 tools that I am familiar with only match non-overlapping patterns unless you 
 do extra to specify otherwise.  One of the standard references for regular 
 expressions if you really want to understand what is going on is Mastering 
 Regular Expressions by Jeffrey Friedl.  You should really read through that 
 book before passing judgment on the correctness of an implementation.

 If you want the overlaps, you need to come up with a regular expression that 
 will match without consuming all of the string.  Here is one way to do it 
 with your example:

   gregexpr(1122(?=1122), paste(rep(1122, 10), collapse=), perl=TRUE)
 [[1]]
 [1]  1  5  9 13 17 21 25 29 33
 attr(,match.length)
 [1] 4 4 4 4 4 4 4 4 4

   

another option would be to move the anchor backwards after each match,
but i'm not sure if the problem really needs it and if it could be done
from within r.

greg (and another person who answered this post earlier):
while your frustration is understandable, i think reid (and possibly
other users as well) would benefit from a brief explanation instead of
your emotional reactions.  you ought to be more patient and less
arrogant with newbies who will often think there is a bug in r when
there isn't.

reid:
when matching is performed, there is a pointer moved through the
string.  in global matching, after a match is found the pointer is just
behind the matched substring, and further matching proceeds from there. 
for example example, suppose you match aaa (the string) with aa (the
pattern) globally.  after the first successful match, the position
pointer is *behind the second a* in the string, and no further match can
be found from there.in this context, 'global' does not mean that all
possible matches are found, rather that matching is performed iteratively.

the above is probably a solution to your problem, though the matches
have length 4, not 8.  in perl, you could manually move back the anchor
after each match, e.g.:

$string = 1122 x 10;
$n = length($string)/2;
@matches = ();
$string =~ /11221122(??{push @matches [$-[0], $]; pos($s) -= $n})/g;

now @matches has 9 elements, each a ref to an array with the starting
position and the content (of length 8) of the respective match:
@matches = ([0, 11221122], [4, 11221122], ...)

not sure if you can do this within r.  not sure if you'll ever need it. 
for more complex cases when you need overlapping matches and you need
their content, greg's solution might not do, but in general that's the
solution.

vQ

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


Re: [R] mixed exponential distribution

2008-12-12 Thread David Winsemius


On Dec 10, 2008, at 10:36 AM, Fazekas, Jacob wrote:


Good morning,

Is there anyway to do Mixed Exponential Distribution in R?




require(fortunes)
fortune(109)



I am trying
to load some lag-weighted empirical survival distribution into R and  
run

a mixed exponential on that data.


You might want see whether the worked examples on pp 12-13 are helpful:
http://cran.r-project.org/web/packages/actuar/vignettes/risk.pdf

The actuar package implements much of the classic Loss Models tome.

--
David Winsemius, MD, MPH
Heritage Labs





Thanks,
Jacob Fazekas
Jacob Fazekas
Assistant Actuary
Auto-Owners Insurance Company
517-703-2543
fazekas.ja...@aoins.com

[[alternative HTML version deleted]]

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


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