Re: [Rd] [R] put R on a web server

2006-07-17 Thread Elio Mineo
A link to some R web server projects was achievable from the web page 
http://www.r-project.org/other-projects.html. The Url of this page was 
the following:
http://franklin.imgen.bcm.tmc.edu/R.web.servers/
but now this link seems down.
Bye,
Elio


Gabor Grothendieck wrote:

>Would be useful to have this list added to www.r-project.org web site or CRAN
>or failing that to the wiki.  Sorry if its already there but I googled for the
>first URL and www.r-project.org and it came up blank.
>
>On 7/16/06, Jean lobry <[EMAIL PROTECTED]> wrote:
>  
>
>>>Has anyone put R on a web server any time, recently, please?
>>>  
>>>
>>It depends on what you mean by "recently".
>>
>>R 2.3.1 and 1054 packages at http://kryton.cc.unt.edu/cgi-bin/R/Rprog
>>R 2.3.1 and 1046 packages at http://www.unt.edu/rss/Rinterface.htm
>>R 2.3.1 and 499  packages at http://pbil.univ-lyon1.fr/Rweb/
>>R 2.3.0 and 85   packages at http://rweb.stat.umn.edu/Rweb/
>>R 2.2.1 and 359  packages at http://actin.ucd.ie/Rweb/
>>R 2.2.0 and 25   packages at http://www.digitalhermit.com/math/Rweb.html
>>R 2.2.0 and 25   packages at http://r.nakama.ne.jp/Rweb-jp/
>>R 2.1.0 and 25   packages at http://dssm.unipa.it/R-php/
>>R 2.1.0 and 25   packages at
>>http://homeworld.rutgers.edu/Rweb/Rweb.general.html
>>R 2.0.1 and 526  packages at http://www.ms.uky.edu/~statweb/
>>R 1.9.1 and 35   packages at http://origin.scic.ulst.ac.uk/Rweb/
>>R 1.9.0 and 106  packages at http://hermes.sdu.dk/cgi-bin/go/
>>R 1.9.0 and 48   packages at http://claree.univ-lille1.fr/Rweb/
>>R 1.8.1 and 30   packages at http://www.er.uqam.ca/nobel/r17165/Rweb/Rweb.html
>>R 1.8.1 and 30   packages at http://bayes.math.montana.edu/Rweb/
>>R 1.7.0 and 49   packages at http://bic.uams.edu/Rweb/
>>R 1.6.1 and 28   packages at
>>http://user.cs.tu-berlin.de/~ulfi/cgi-bin/r-online/r-online.cgi
>>R 1.5.0 and 32   packages at http://www.nku.edu/~longa/Rweb/
>>R 1.3.0 and 11   packages at http://genome1.beatson.gla.ac.uk/Rweb/
>>
>>--
>>Jean R. Lobry([EMAIL PROTECTED])
>>Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
>>43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
>>allo  : +33 472 43 12 87 fax: +33 472 43 13 88
>>http://pbil.univ-lyon1.fr/members/lobry/
>>
>>__
>>R-help@stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>
>>
>
>__
>R-devel@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-devel
>
>  
>

-- 
--
Angelo M. Mineo
Dipartimento di Scienze Statistiche e Matematiche "S. Vianelli"
Università degli Studi di Palermo
Viale delle Scienze
90128 Palermo
url: http://dssm.unipa.it/elio

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Re : [R] Date Format

2006-07-17 Thread pierre clauss
Thank you very much for all your responses that help me a lot
Pierre.


- Message d'origine 
De : Martyn Plummer <[EMAIL PROTECTED]>
À : Peter Dalgaard <[EMAIL PROTECTED]>
Cc : Gabor Grothendieck <[EMAIL PROTECTED]>; r-devel@r-project.org; pierre 
clauss <[EMAIL PROTECTED]>
Envoyé le : Mercredi, 12 Juillet 2006, 11h10mn 39s
Objet : Re: [Rd] [R] Date Format


On Tue, 2006-07-11 at 20:05 +0200, Peter Dalgaard wrote:
> Martyn Plummer <[EMAIL PROTECTED]> writes:
> 
> > I moved this to R-devel because I am wondering why the base package does
> > not allow you to convert from numeric to Date. Could we not have
> > something like this?
> > 
> > as.Date.numeric <- function(x, epoch="1970-01-01", ...) {
> >if (!is.character(epoch) || length(epoch) != 1)
> >   stop("invalid epoch")
> >as.Date(epoch, ...) + x
> > }
> 
> We could, but you might as well do it explicitly. There's something to
> be said for not confusing the concept of dates with a particular
> implementation, which is effectively what happens if you can convert
> them to and from numeric too seamlessly.

Currently you can easily convert one way, but not the other. I just find
that a bit odd.

Pierre's problem was that his Date objects were converted internally by
some function.  His first instinct, to use as.Date to convert them back,
was, I think, correct. But that doesn't work. So now we say "You have to
understand how Date objects are implemented to get your dates back"? I
don't know about that.

> I'm more perplexed by the failure of adding difftimes to dates:
> 
> > as.Date("2006-1-1") + (as.Date("2006-1-1") - as.Date("2006-1-2"))
> [1] "2005-12-31"
> Warning message:
> Incompatible methods ("+.Date", "Ops.difftime") for "+"
> 
> and if you have a difftime in non-days units, you'll  actually get a
> wrong result:
> 
> > D1 <- as.Date("2006-1-1")
> > D2 <- as.Date("2006-1-2")
> > difftime(D2,D1,units="hours")
> Time difference of 24 hours
> > dd <- difftime(D2,D1,units="hours")
> > D1+dd
> [1] "2006-01-25"
> Warning message:
> Incompatible methods ("+.Date", "Ops.difftime") for "+"

[I raised this problem earlier in private discussions with Peter]

It certainly is perplexing. There is code in "+.Date" that correctly
handles the case where the second argument is a difftime. But it will
never get called! I wonder if it ever worked.

The warning is coming from DispatchGroup (in eval.c). When it finds
different methods for two arguments of a binary group generic, it gives
up and the default method is called - in this case R_binary in
arithmetic.c - which is why the results depends on the implementation of
the difftime object.

I guessed that this was a limitation of S3 generics, and I suppose I was
right.  To allow mixing arguments of two classes, you would need code in
Ops.foo to handle objects of class bar *and* vice versa.  It's a bad
idea to have two separate bits of code to do the same job, so I can't
fault the logic of forbidding this, but it does leave us with some
usability problems.

While we are on the topic, is there no function to convert a difftime
object from one time scale to another? I found a couple of private
functions, but nothing public.

Martyn



> > On Tue, 2006-07-11 at 12:58 -0400, Gabor Grothendieck wrote:
> > > Try this:
> > > 
> > > library(zoo)
> > > as.Date(11328)
> > > 
> > > See the Help Desk article in R News 4/1 for more on dates.
> > > 
> > > 
> > > On 7/11/06, pierre clauss <[EMAIL PROTECTED]> wrote:
> > > > Hi everybody,
> > > > I need your precious help for, I think, a simple request, but I do not 
> > > > manage to solve this.
> > > >
> > > > When I use a "table" function with dates in the rows, the rows are 
> > > > coerced to number after the table function.
> > > >
> > > > So I need to transform the row names into date format. But I do not 
> > > > manage.
> > > >
> > > > Therefore, for an example, I manage to write this :
> > > >
> > > > datetest<-"06/01/2001"
> > > > datetest<-as.Date(datetest,"%d/%m/%Y")
> > > > datetest<-as.numeric(datetest)
> > > >
> > > > to get 11328.
> > > >
> > > > But I do not obtain the inverse tranformation :
> > > >
> > > > datetest<-as.Date(datetest,"%d/%m/%Y")
> > > >
> > > > How do we get this please ?
> > > >
> > > > Thanks a lot for your solution.
> > > > Pierre.
> > > >
> > > >
> > 
> > ---
> > This message and its attachments are strictly confidential. ...{{dropped}}
> > 
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> > 
> 

---
This message and its attachments are strictly confidential. ...{{dropped}}

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] multiplying multidimensional arrays (was: Re: [R] Manipulation involving arrays)

2006-07-17 Thread RAVI VARADHAN
Dear Gabor,

Thank you very much for your solution.  It speeded calculations by a factor of 
two.  

Now to your recommendation about making this solution a basic operation.  I 
completely agree with your suggestion. That is exactly what I would have hoped 
for.  In fact, my first try was to do:

Tbar <- tarray %*% t(wt)

Since tarray is (3,3,mcsamp) and wt is (n,mcsamp), I figured that the result 
would be a (3,3,n) array that would sum over mcsamp, as in the case of 2-dim 
array multiplication.  But obviously that didn't work as "non-conformable".  
Your simple trick of forcing the 3-dim array to a 2-dim matrix using 
matrix(tarray, 3*3) is quite clever.

Thanks again for your help.

Best,
Ravi.

- Original Message -
From: Gabor Grothendieck <[EMAIL PROTECTED]>
Date: Sunday, July 16, 2006 10:29 pm
Subject: multiplying multidimensional arrays (was: Re: [R] Manipulation 
involving arrays)

> I am moving this to r-devel.
> 
> The problem and solution below posted on r-help could have been
> a bit slicker if %*% worked with multidimensional arrays multiplying
> them so that if the first arg is a multidimensional array it is 
> mulitpliedalong the last dimension (and first dimension for the 
> second arg).
> Then one could have written:
> 
> Tbar <- tarray %*% t(wt) / rep(wti, each = 9)
> 
> which is a bit nicer than what had to be done, see below, given 
> that %*% only
> works with matrices.
> 
> I suggest that %*% be so extended to multidimensional arrays.  Note
> that this is upwardly compatible and all existing cases would continue
> to work unchanged.
> 
> On 7/16/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > The double loop is the same as:
> >
> >  Tbar[] <- matrix(tarray, 9) %*% t(wt) / rep(wti, each = 9)
> >
> >
> > On 7/16/06, RAVI VARADHAN <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > I have the following piece of code that is part of a larger 
> function.  This piece is the most time consuming part of the 
> function, and I would like to make this a bit more efficient.  
> Could anyone suggest a way to do this faster?
> > >
> > > In particular, I would like to replace the nested "for" loop 
> with a faster construct.  I tried things like "kronecker" and 
> "outer" combined with apply, but couldn't get it to work.
> > >
> > >
> > > Here is a sample code:
> > >
> > >  ##
> > >  n <- 120
> > >  sigerr <- 5
> > >  covmat <- diag(c(8,6,3.5))
> > >  mu <- c(105,12,10)
> > >  mcsamp <- 1
> > >
> > >  Tbar <- array(0, dim=c(3,3,n))
> > >
> > >  # theta is a mcsamp x 3 matrix
> > >  theta <- mvrnorm(mcsamp, mu = mu, Sigma = covmat)
> > >
> > >  wt <- matrix(runif(n*mcsamp),n,mcsamp)
> > >  wti <- apply(wt,1,sum)
> > >
> > >  tarray <- 
> array(apply(theta,1,function(x)outer(x,x)),dim=c(3,3,mcsamp))> >
> > >  for (i in 1:n) {
> > >  for (k in 1:mcsamp) {
> > >  Tbar[,,i] <- Tbar[,,i] + wt[i,k] * tarray[,,k]
> > >  }
> > >  Tbar[,,i] <- Tbar[,,i] / wti[i]
> > >  }
> > >
> >
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Patch to allow negative argument in head() and tail()

2006-07-17 Thread Vincent Goulet
Dear developeRs (and other abuseRs ;-),

I would like to contribute a patch against functions head() and tail() of 
package utils to allow for a negative 'n' argument. This allows to extract 
all but the first/last 'n' elements/rows/lines of an object, similar to 
the "drop" operator of APL. [1]

I put the patched head.R and head.Rd files, along with diff files in

http://vgoulet.act.ulaval.ca/pub/R/

The differences were obtained against today's version of r-devel (more 
specifically revision 30277 of head.R and revision 30915 of head.Rd).

Some comments:

- The current version of head() and tail() will accept a vector of length > 1 
for argument 'n' but will silently use the smallest value. This became 
awkward to reproduce in my versions and did not seem interesting anyway. 
Instead, I added an error message if length(n)  > 1.

- I used the word "scalar" in the aforementioned error message to mean a 
vector of length 1. Perhaps is this not the correct R terminology?

- I added a 'addrownums = TRUE' argument to head() used when n < 0, similar to 
tail() with n > 0. This required to write separate methods for 
classes 'data.frame' and 'matrix'.

- The 'function' methods are not modified.

- In the man page, the 'function' method was not documented in the usage 
section. Done now.

- I don't think the patch would break any existing code, except code using the 
(undocumented) "feature" mentioned in my first remark, above.

I hope you will find my (albeit small) contribution useful.

Best regards,

-
[1] See previous messages to r-devel by myself 

and Bill Venables 


-- 
  Vincent Goulet, Associate Professor
  École d'actuariat
  Université Laval, Québec 
  [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R as shell script

2006-07-17 Thread Juha Vierinen

Hi Jeffrey!

Great work with rinterp! I had barely read into the R embedded API and
somebody implements exactly what I need. Thank you! I played around
with it a bit and I was able to access stdin() without any
modifications, I have added a stdin example to the wiki. I hope this
can be considered for inclusion to the R distribution.

I took a quick stab at adding making a copy of argc and argv to the R
script, but those macros look quite scary, so I might be doing many
more mistakes than I am aware of (hint: malloc). Now command line
arguments are also passed, and the following also works:

args.r:
#!/usr/bin/rinterp

cat("n args: ")
cat(argc)
cat("\n")
for (i in 1:argc)
{
 cat(sprintf("arg %d = %s\n",i,argv[i]))
}
-


./args.r a b c

n args: 4
arg 1 = ./args.r
arg 2 = a
arg 3 = b
arg 4 = c

The attachment contains the new rinterp.c

juha

On 7/14/06, Jeffrey Horner <[EMAIL PROTECTED]> wrote:

Juha Vierinen wrote:
> Hi,
>
> I am considering if I should invest in learning R. Based on the
> language definition and introductory documents, it seems nice. But now
> I am faced with a problem: I want to be able to run R programs easily
> from the unix shell, and write scripts that can automatically select R
> as the interpreter:
>
> #!/usr/bin/R
> cat("Hello world.\n")
>
> This of course doesn't work, because /usr/bin/R is a shell script.
>
> I have been able to create a binary wrapper that calls R with the
> correct arguments, which is documented here:
>
> http://kavaro.fi/mediawiki/index.php/Using_R_from_the_shell
>
> This still lacks eg. standard input (but I have no idea how I can
> implement it in R) and full command line argument passing (can be
> done), but am I on the right track, or is there already something that
> does what I need?

If you search the mailing list archives:

http://tolstoy.newcastle.edu.au/R/

you can find entries like the following (searching on "bang"):

http://tolstoy.newcastle.edu.au/R/devel/05/01/1910.html

which implements similar functionality. But I thought this would be a
fun little (distracting) project, so I created an R wiki page:

http://wiki.r-project.org/rwiki/doku.php?id=developers:rinterp

with source code describing how to solve this problem by embedding R
within your C program. Here's the main function:

/* rinterp: shebang support for R
  *
  * Usage:
  *
  * From the command line:
  * $ rinterp filename
  *
  * In a file:
  * 
  * #!/path/to/rinterp
  * cat("hello world\n");
  * 
  */
int main(int argc, char **argv){

 /* R embedded arguments */
 char *R_argv[] = {"RINTERP", "--gui=none", "--slave", "--silent",
"--vanilla","--no-readline"};
 int R_argc = sizeof(R_argv)/sizeof(R_argv[0]);

 struct stat sbuf;

 /* Setenv R_HOME: insert or replace into environment.
  * The RHOME macro is defined during configure
  */
 if (setenv("R_HOME",RHOME,1) != 0){
 perror("ERROR: couldn't set/replace R_HOME");
 exit(1);
 }

 /* Assume last argument is the file we want to source.
  * Ignore other args for now.
  */
 if (argc > 1) {/* don't try and source rinterp binary */
 if (stat(argv[argc-1],&sbuf) != 0){
 perror(argv[argc-1]);
 exit(1);
 }
 } else {
 fprintf(stderr,"Usage: rinterp filename\n");
 exit(1);
 }

 /* Initialize R interpreter */
 Rf_initEmbeddedR(R_argc, R_argv);

 /* Now call R function source(filename) */
 call_fun1str("source",argv[argc-1]);

 exit(0);
}

Feel free to logon to the R wiki and contribute to the page. I think it
would be interesting to solve this once and for all.

Cheers!
--
Jeffrey Horner   Computer Systems Analyst School of Medicine
615-322-8606 Department of Biostatistics   Vanderbilt University

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel