Re: [R] loading igraph package on Solaris

2008-01-09 Thread Prof Brian Ripley
On Tue, 8 Jan 2008, Peter McMahan wrote:

> Hello,
> I'm having trouble getting the igraph package to load on Solaris. I
> can get igraph to compile and install from a local directory without
> issues using simply "R CMD INSTALL igraph", however "library(igraph)"
> from within R gives the following errors:
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
> unable to load shared library '/home/mcmahan/R/i386-pc-
> solaris2.10-library/2.5/igraph/libs/igraph.so':
>   ld.so.1: R: fatal: relocation error: file /home/mcmahan/R/i386-pc-
> solaris2.10-library/2.5/igraph/libs/igraph.so: symbol __1cDstdEcerr_:
> referenced symbol not found
> Error : .onLoad failed in 'loadNamespace' for 'igraph'
> Error: package/namespace load failed for 'igraph'
>
> At the suggestion of the igraph help list, I've tried adding "-lCstd"
> to src/Makevars.in after the "[EMAIL PROTECTED]@" and recompliling,
> but no luck.

You say you are using gcc, but that would be relevant to the Sun C++ 
compiler (see the R-admin manual, which also says that configure adds it 
where needed).  So which C++ compiler is this?  The symptoms do look as if 
you are mixing incompatible C and C++ compilers.

I don't have anything like as old components as you have, but igraph 
contains C++ errors and will not compile under the SunStudio 12 C++ 
compiler (reported to the maintainer a long time ago).  It did work for me 
just now using gcc/g++ 4.2.1 and R 2.6.1 patched.

> Any ideas? My system info is:
> SunOS 5.10 i386  Generic_120012-14 09-19-2007
> gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
> R version 2.5.1 (2007-06-27)
> igraph version 0.4.5 (with a few changes to compile on Solaris)

Since no changes are needed to compile under gcc, this suggests you are 
not using gcc's C++ compiler.

> thanks,
> Peter

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

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


Re: [R] loading igraph package on Solaris

2008-01-09 Thread Gabor Csardi
On Wed, Jan 09, 2008 at 08:03:59AM +, Prof Brian Ripley wrote:
[...]
> 
> You say you are using gcc, but that would be relevant to the Sun C++ 
> compiler (see the R-admin manual, which also says that configure adds it 
> where needed).  So which C++ compiler is this?  The symptoms do look as if 
> you are mixing incompatible C and C++ compilers.
> 
> I don't have anything like as old components as you have, but igraph 
> contains C++ errors and will not compile under the SunStudio 12 C++ 
> compiler (reported to the maintainer a long time ago).  It did work for me 
> just now using gcc/g++ 4.2.1 and R 2.6.1 patched.

Brian, indeed, i made the fixes you sent me, but it seems that only 
in the development branch of igraph not in the one which is on CRAN.
Anyway, i'll fix them in both. Thanks again.

Peter, here are the changes you need to make to the source if compiling
with the Sun Studio compiler:
http://code.google.com/p/igraph/issues/detail?id=1
(although it seems that the easiest is compiling with gcc/g++).

Gabor

> > Any ideas? My system info is:
> > SunOS 5.10 i386  Generic_120012-14 09-19-2007
> > gcc (GCC) 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
> > R version 2.5.1 (2007-06-27)
> > igraph version 0.4.5 (with a few changes to compile on Solaris)
> 
> Since no changes are needed to compile under gcc, this suggests you are 
> not using gcc's C++ compiler.
> 
> > thanks,
> > Peter
> 
> -- 
> Brian D. Ripley,  [EMAIL PROTECTED]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <[EMAIL PROTECTED]>MTA RMKI, ELTE TTK

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

2008-01-09 Thread Jonas Malmros
Dear Mr. Rowlingson, Rizopoulos, Jaworski, and Ripley

Thank you for your help with the polynomial.

Regards,
Jonas

On Jan 7, 2008 5:18 PM, Barry Rowlingson <[EMAIL PROTECTED]> wrote:
> Dimitris Rizopoulos wrote:
> > try this:
> >
> > y <- c(15.51, 12.44, 31.5, 21.5, 17.89, 27.09, 15.02, 13.43, 18.18,
> > 11.32)
> > x <- seq(3.75, 6, 0.25)
> > coef(lm(y ~ x + I(x^2) + I(x^3)))
>
> Or use the 'poly' function:
>
>  > coef(lm(x~poly(y,3)))
>  (Intercept) poly(y, 3)1 poly(y, 3)2 poly(y, 3)3
>   4.875  -0.6233293   0.0312415  -0.6464533
>
>  But hmmm those aren't the same coefficients?
>
>  Because you need to use 'raw=TRUE' if you really want to fit the raw
> powers rather than orthogonal polynomials (which are better behaved than
> fitting the raw powers):
>
>  > coef(lm(y~poly(x,3,raw=TRUE)))
> (Intercept) poly(x, 3, raw = TRUE)1 poly(x, 3, raw = TRUE)2
> -774.258364  472.172611  -91.633939
> poly(x, 3, raw = TRUE)3
>5.800653
>
> And there's your coefficients. See help(poly) for more.
>
> Barry
>



-- 
Jonas Malmros
Stockholm University
Stockholm, Sweden

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] choose the intercept from glm and lm

2008-01-09 Thread Knut Krueger
Chuck Cleland schrieb:
>> Regards Knut
>
>   Here is one way:
>
> outcome <- relevel(outcome, ref="2")
>
> ?relevel
>
Thank you very much.

Knut

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


[R] memory problems (not me. my pc!)

2008-01-09 Thread Sara Mouro
Dear R users,

I have got an error message related with memory size, but I could not  
understand if and how to solve it.
Could you please help me?

I was using the source quickPCNM-761.R, for a space matrix with 12572  
rows (with X and Y (UTM) coordinates), and an Y matrix containing  
response data, with 10 variables (with lots of zero values).

When I run:
  resPCNM<-quickPCNM(dados1,coordXY)

I got:
Error: cannot allocate vector of size 602.9 Mb
In addition: Warning messages:
1: In vector("double", length) :
   Reached total allocation of 254Mb: see help(memory.size)
2: In vector("double", length) :
   Reached total allocation of 254Mb: see help(memory.size)
3: In vector("double", length) :
   Reached total allocation of 254Mb: see help(memory.size)
4: In vector("double", length) :
   Reached total allocation of 254Mb: see help(memory.size)

Afterwards I have used memory.size as follows:

 > memory.size()
[1] 14.10536
 > memory.size(TRUE)
[1] 19.1875
 > round(memory.limit(), 2)
[1] 254.98


How could I solve this problem?
With another (i.e. with more memory) PC?
How much memory do I nedd? 602.9?


Best regards,
Sara Mouro
PS- I have also used the option range=TRUE, and thus I think the  
memory problems have nothing to do with the (high) UTM values.
PS2- I hope the zero values in response variables are not a problem  
for PCNM analysis?!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can R solve this optimization problem?

2008-01-09 Thread Paul Smith
On Jan 8, 2008 2:58 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > Thanks again, Gabor. Apparently, something is missing in your
> > approach, as I tried to apply it to the original problem (without sin)
> > and the result seems not being correct::
> >
> > f <- function(z) {
> >  a <- sum(-(999:1)*z)
> >  return(a)
> > }
> >
> > result <- optim(rep(0,999), f,
> > NULL,lower=rep(-1/1000,999),upper=rep(1/1000,999),method="L-BFGS-B")
> > b <- result$par
> >
> > x <- 0
> >
> > for (i in 1:999) {
> >  x[i+1] <- b[i] + x[i]
> > }
> >
> > The vector x contains the solution, but it does not correspond to the
> > analytical solution. The analytical solution is
> >
> > x(t) = t, if t <= 1/2 and
> >
> > x(t) = 1 - t, if t >= 1/2.
> >
> > Am I missing something?
> >
>
> No, but I was -- the x[n] = 0 constraint.  Add it through
> a penalty term and try this:
>
> theta <- 1000
> n <- 100
> x <-  rep(1/n, n)
> f <- function(x) sum(n:1 * x) - theta * sum(x)^2
> optim(x, f, lower = rep(-1, n), upper = rep(1, n), method = "L-BFGS-B",
>   control = list(maxit = 1000, fnscale = -1, lmm = 25))
> plot(cumsum(res$par))

Thanks, Gabor. Inspired by your code, I have written the following:

theta <- 5000
n <- 1000
x <-  rep(1/n, n)
f <- function(x) sum(n:1 * x) - theta * sum(x)^2
res <- optim(x, f, lower = rep(-1/n, n), upper = rep(1/n, n), method =
"L-BFGS-B",control = list(maxit = 2000, fnscale = -1))

b <- res$par

x <- 0

for (i in 1:n) {
  x[i+1] <- b[i] + x[i]
}

plot(seq(0,1,by=1/n),x,type="l")

to solve the same problem. It works fine unless one replaces

theta <- 5000

by

theta <- 1e100

According to a book that I consulted meanwhile, the larger the value
of theta the better the solution should be. Why does not it happen
with my example? Any clues?

Paul

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Constrained minimization solver for nonlinear programming

2008-01-09 Thread Paul Smith
On Jan 9, 2008 4:01 AM, tom soyer <[EMAIL PROTECTED]> wrote:
> I noticed that R has a few bound-constrained nonlinear min and max solvers,
> such as optim, nlm, etc. But I could not find a constrained min and max
> solver that is not LP. Does this mean R do not have this capability? It is
> hard to believe that R may not be as advanced as Excel in certain areas...
> Maybe it's there but I missed it? Does anyone know?

Do you mean optimization solvers for nonlinear problems with equality
constraints? If so, you can use optim and friends with penalties to
incorporate equality constraints.

Paul

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

2008-01-09 Thread Matthias Wendel
 

-Ursprüngliche Nachricht-
Von: Matthias Wendel [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 9. Januar 2008 13:06
An: '[EMAIL PROTECTED]'
Cc: 'Gabor Grothendieck'
Betreff: AW: [R] subsetting

 
Thank you, Gabor, for this clarificaton. This is very helpful für me.
Matthias
-Ursprüngliche Nachricht-
Von: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 4. Januar 2008 20:05
An: Matthias Wendel
Cc: r-help@r-project.org
Betreff: Re: [R] subsetting

Here are three ways:

1. Define inner inside outer:

outer <- function() { s <- 1; inner <- function() s; inner() }
outer() # 1

2.  Use parent.frame:

inner <- function() parent.frame()$s
outer <- function() { s <- 1; inner() }
outer() # 1

3. Pass s explicitly:

inner <- function(s) s
outer <- function() { s <- 1; inner(s) }
outer() # 1



On Jan 4, 2008 1:36 PM, Matthias Wendel <[EMAIL PROTECTED]> wrote:
>
> I'm using R Version 2.6.1 under Windows XP.
>
> > search()
>  [1] ".GlobalEnv""s" "s" 
> "package:cairoDevice"
>  [5] "package:datasets"  "package:foreign"   "package:graphics"  
> "package:grDevices"
>  [9] "package:gWidgetsrJava" "package:gWidgets"  "package:Hmisc" 
> "package:JGR"
> [13] "package:JavaGD""package:rJava" "package:stats" 
> "package:utils"
> [17] "package:methods"   "Autoloads" "package:base"
>
> The Problem: I'm using a function which is constructing a subset of a 
> dataframe. This dataframe is used in another function. The structure is like 
> this:
>
> > inner = function (){
> + print('inner:')
> + print(s)
> + }
> > outer = function(){
> + t = data.frame(list(X=1:10, Y=LETTERS[1:10])) s = t[t[,'X'] < 5, ]
> + print('outer:')
> + print(t[, 'Y'])
> + inner()
> + }
> > outer()
>
> And the response in the R-Console is:
>
> [1] "outer:"
>  [1] A B C D E F G H I J
> Levels: A B C D E F G H I J
> [1] "inner:"
> Fehler in print(s) : objekt "s" nicht gefunden (Error in print(s) : 
> object "s" not found)
>
> How can I make s reachable in inner?
>
> Regards,
> Matthias
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] labels to values

2008-01-09 Thread Matthias Wendel
I couldn't find out how the following to solve:
There is a column in a data.frame:

> d[, 'Y6']
  [1]  6  3  8 11  8  9  6  8  3  5 10 15 NA  9  8  3  8 16  6  6 NA 10  5  2  
7  7  6 16  7 15  7 10 12  8  7 12 12 16  7  6  8  8
15  6  [45] NA  8 99  7 12  8  9 16  7 16  8  7  7  1 15 12  8  7 10  7  8  7  
8  9  8  6  6  8  6 16 11  5 11 11  1 11  3  7  7 10
10 10  6 11  [89] 16 NA  1  3  2 10 99 10  3  3  9  7 16 99 16  1 10  2 13 13 
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 NA 10 16
16 NA  6 10  5 11 [133] 11  1  1  1  1 16  1 16  1  1  1  1  6  6  6 16  8 16 
16 16 16  5  6 10 99 11 11 10  6  6  1  1  6  1 11 11
16  9 11 16  6  8  8 16 [177] 16  8  6 16 16 12 12 12 12 12 12 12 16  9 16 15 
12 12 15 10 16 15  4  1  2 14  4  4  2  5 NA  1  5  5
7  9  5 12 12 NA 16 12 12 12 [221] 12 12 12 12 12 12 99 NA 12 12 NA  1 16  1  7 
11  5  6  7  1 13  6  8 16  2  1  5 16 16  9  8  8
8  7 16  8  8  2  8  5  4  6 14  5 [265] 14  8  8 14  4  4  8 14  8 14  6  2  3 
14  3 16  5 15 15 15 15 15 15 15 15 15 15 15 13 13
13 13 13 13 13 13 13 13 13 13 13 15  6 NA [309] 12  3  9  9 NA 10 16
attr(,"value.labels")
  Verwaltung Servicegesellschaft Waldfriede (SKW)   
 Kurzzeitpflege Waldfriede 
  16   15   
14 
   Sozialstation  Krankenpflegeschule   
   Med. Technischer Dienst 
  13   12   
11 
   Pflege OP  Funktionsdienst   
Pflege Gynäkologie 
  109   
 8 
Pflege ChirurgiePflege Innere   
 Ärzte Anästhesie, Röntgen 
   76   
 5 
   Ärzte Gynäkologie  Ärzte Chirurgie   
  Ärzte Innere 
   43   
 2 
Patientenberatung/-betreuung 
   1 

I'd like to have the column with the value.labels as values. How do I do that?
Thanks,
Matthias

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

2008-01-09 Thread Ido M. Tamir
Hi,

I directed somebody to install R (2.6.1) on his OSX computer,
following instructions from http://cran.r-project.org/bin/macosx.
She can run R from the console.
But plot(1:10) doesn't produce any output or open a window (as I am
used to from linux).

More importantly:
Rscript is not in the path (minor problem ln -s is hopefully doable). I tried 
to put a hardcoded path to Rscript into the shebang line but this fails. And 
when I try to invoke it directly:

>-bash: ./Rscript: cannot execute binary file

On linux this works.

I would like to send her some Rscripts, but how can we make them
run on her system?



thank you very much,
ido



imaclab3:/Library/Frameworks/R.framework/Resources/bin ru$ ls -l 

total 1008
-rwxrwxr-x   1 root  admin    1654 Nov 26 17:36 BATCH
-rwxrwxr-x   1 root  admin    2188 Nov 26 17:36 COMPILE
-rwxrwxr-x   1 root  admin   34391 Nov 26 17:36 INSTALL
-rwxrwxr-x   1 root  admin    1593 Nov 26 17:36 LINK
-rwxrwxr-x   1 root  admin    7210 Nov 26 17:37 R
-rwxrwxr-x   1 root  admin    7210 Nov 26 17:37 R.orig
-rw-rw-r--   1 root  admin     655 Nov 26 17:37 R.rej
-rwxrwxr-x   1 root  admin    2244 Nov 26 17:36 REMOVE
-rwxrwxr-x   1 root  admin     928 Nov 26 17:36 Rcmd
-rwxrwxr-x   1 root  admin    9523 Nov 26 17:36 Rd2dvi
-rwxrwxr-x   1 root  admin     842 Nov 26 17:36 Rd2txt
-rwxrwxr-x   1 root  admin    3237 Nov 26 17:36 Rdconv
-rwxrwxr-x   1 root  admin    1320 Nov 26 17:36 Rdiff
-rwxrwxr-x   1 root  admin    2854 Nov 26 17:36 Rprof
-rwxrwxr-x   1 root  admin   18084 Nov 26 17:36 Rscript
-rwxrwxr-x   1 root  admin    4656 Nov 26 17:36 SHLIB
-rwxrwxr-x   1 root  admin   16129 Nov 26 17:36 Sd2Rd
-rwxrwxr-x   1 root  admin     730 Nov 26 17:36 Stangle
-rwxrwxr-x   1 root  admin     726 Nov 26 17:36 Sweave
-rwxrwxr-x   1 root  admin   21715 Nov 26 17:36 build
-rwxrwxr-x   1 root  admin   78570 Nov 26 17:36 check
-rwxrwxr-x   1 root  admin    6927 Nov 26 17:36 config
drwxrwxr-x   4 root  admin     136 Nov 26 17:36 exec
-rwxrwxr-x   1 root  admin    3613 Nov 26 17:36 f77_f2c
-rwxrwxr-x   1 root  admin   10720 Nov 26 17:36 javareconf
-rwxrwxr-x   1 root  admin  215101 Nov 26 17:36 libtool
-rwxrwxr-x   1 root  admin    3495 Nov 26 17:36 mkinstalldirs
-rwxrwxr-x   1 root  admin     413 Nov 26 17:36 pager

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Constrained minimization solver for nonlinear programming

2008-01-09 Thread tom soyer
Thanks Paul. yes, with equality constraints. What are "friends"? I read the
document for optim, but still could not figure out how to do this. Do you
just set the lower bound equal to the upper bound?

Also, is it possible to ask R to search for a solution based on a target
value instead of min and max? Is there a function like that in R?

Thanks!

On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
>
> On Jan 9, 2008 4:01 AM, tom soyer <[EMAIL PROTECTED]> wrote:
> > I noticed that R has a few bound-constrained nonlinear min and max
> solvers,
> > such as optim, nlm, etc. But I could not find a constrained min and max
> > solver that is not LP. Does this mean R do not have this capability? It
> is
> > hard to believe that R may not be as advanced as Excel in certain
> areas...
> > Maybe it's there but I missed it? Does anyone know?
>
> Do you mean optimization solvers for nonlinear problems with equality
> constraints? If so, you can use optim and friends with penalties to
> incorporate equality constraints.
>
> Paul
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Tom

[[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] Constrained minimization solver for nonlinear programming

2008-01-09 Thread Paul Smith
On Jan 9, 2008 1:14 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> Thanks Paul. yes, with equality constraints. What are "friends"? I read the
> document for optim, but still could not figure out how to do this. Do you
> just set the lower bound equal to the upper bound?

constrOptim is a friend of optim. See ?constrOptim.

Could you please provide a concrete example of an optimization problem
that you would like R solving it?

> Also, is it possible to ask R to search for a solution based on a target
> value instead of min and max? Is there a function like that in R?

Could you please provide a concrete example?

Paul



> On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > On Jan 9, 2008 4:01 AM, tom soyer <[EMAIL PROTECTED]> wrote:
> > > I noticed that R has a few bound-constrained nonlinear min and max
> solvers,
> > > such as optim, nlm, etc. But I could not find a constrained min and max
> > > solver that is not LP. Does this mean R do not have this capability? It
> is
> > > hard to believe that R may not be as advanced as Excel in certain
> areas...
> > > Maybe it's there but I missed it? Does anyone know?
> >
> > Do you mean optimization solvers for nonlinear problems with equality
> > constraints? If so, you can use optim and friends with penalties to
> > incorporate equality constraints.
> >
> > Paul
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Tom

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


Re: [R] Plotting labeled impulses: label collision

2008-01-09 Thread Johannes Graumann
Jim,

I finally got back to this implementation of mine and dude, this function is 
amazing! Thank you so much!

Joh

On Saturday 05 January 2008 11:42:30 Jim Lemon wrote:
> Johannes Graumann wrote:
> > Dear all,
> >
> > As you can see from the attachment I'm using R to automatically annotate
> > peptide fragmentation mass spectra, which are represented by impulse
> > plots. I'd like to poll you on approaches of how to deal as generally as
> > possible with the two biggest annotation issues I run into:
> > 1) very close annotated masses (impulses) with similar y-axis dimensions
> > - resulting in overlapping labels
> > 2) very close annotated masses with widely differing y-axis dimensions -
> > resulting in the label for the smaller one partially overplotting the
> > impulse of the larger one
> >
> > Both cases can be seen in the appended png: for 1) see x of aprox. 1100,
> > for 2) x of aprox. 575
> >
> > If one does this manually one would write the labels somewhere where
> > there's plenty of space and then connect them with lines to the
> > impulses/masses they actually represent ...
> >
> > Any insight in how to make this pretty(er) automatically is highly
> > appreciated.
>
> Hi Joh,
> I would have loved to say that you could do this with the prettyR
> package, but I'll have to settle for plotrix. I realized that the
> spread.labels function would almost do what you want. With a minor
> change, as in the function below, I think it might get you there.
>
> spread.labels<-function (x,y,labels=NULL,spready=NA,
>   offsets,bg="white",border=FALSE,between=FALSE,
>   linecol=par("fg"),...) {
>
>   if(missing(x))
>stop("Usage: spread.labels(x,y,labels,...)")
>   ny<-length(y)
>   if(between) {
>if(length(linecol)==1) linecol<-rep(linecol,2)
>nlabels<-length(labels)
>newy<-seq(y[1],y[ny],length=nlabels)
># put the labels in the middle
>labelx<-rep(mean(x),nlabels)
># do the left lines
>segments(x[1:nlabels],y[1:nlabels],
> labelx-strwidth(labels)/2,newy,col=linecol[1])
># now the right lines
>segments(x[(nlabels+1):ny],y[(nlabels+1):ny],
> labelx+strwidth(labels)/2,newy,col=linecol[2])
>boxed.labels(labelx,newy,labels,bg=bg,
> border=border,...)
>   }
>   else {
>if(is.na(spready))
> spready<-diff(range(x))if(spready) {
> sort.index<-sort.list(y)
> x<-x[sort.index]
> y<-y[sort.index]
> newy<-seq(y[1],y[ny],length=length(labels))
> if(missing(offsets)) {
>  offset<-diff(par("usr")[1:2])/4
>  offsets<-rep(c(offset, -offset), ny/2 + 1)[1:ny]
> }
> segments(x+offsets,newy,x,y)
> boxed.labels(x+offsets,newy,labels[sort.index],
>  bg=bg,border=border,...)
>}
>else {
> sort.index<-sort.list(x)
> x<-x[sort.index]
> y<-y[sort.index]
> nx<-length(x)
> newx <- seq(x[1],x[nx],length=length(labels))
> if(missing(offsets)) {
>  offset<-diff(par("usr")[3:4])/4
>  offsets<-rep(c(offset,-offset),nx/2+1)[1:nx]
> }
> segments(newx,y+offsets,x,y)
> boxed.labels(newx,y+offsets,labels[sort.index],
>  bg=bg,border=border,...)
>}
>   }
> }
>
> Try calling it like this:
>
> spread.labels(x=,y=,
>   labels=,spready=FALSE,
>   offsets=rep(1,),
>   srt=90)
>
> By passing different offsets you may be able to fix some of the really
> bad crowding on the labels.
>
> Jim




signature.asc
Description: This is a digitally signed message part.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can R solve this optimization problem?

2008-01-09 Thread Gabor Grothendieck
If its too large the the primary portion of the objective basically
just looks like roundoff error.  By the way there is also rdonlp2
which can handle constraints.  Not on CRAN -- try google.

On Jan 9, 2008 6:45 AM, Paul Smith <[EMAIL PROTECTED]> wrote:
>
> On Jan 8, 2008 2:58 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > > Thanks again, Gabor. Apparently, something is missing in your
> > > approach, as I tried to apply it to the original problem (without sin)
> > > and the result seems not being correct::
> > >
> > > f <- function(z) {
> > >  a <- sum(-(999:1)*z)
> > >  return(a)
> > > }
> > >
> > > result <- optim(rep(0,999), f,
> > > NULL,lower=rep(-1/1000,999),upper=rep(1/1000,999),method="L-BFGS-B")
> > > b <- result$par
> > >
> > > x <- 0
> > >
> > > for (i in 1:999) {
> > >  x[i+1] <- b[i] + x[i]
> > > }
> > >
> > > The vector x contains the solution, but it does not correspond to the
> > > analytical solution. The analytical solution is
> > >
> > > x(t) = t, if t <= 1/2 and
> > >
> > > x(t) = 1 - t, if t >= 1/2.
> > >
> > > Am I missing something?
> > >
> >
> > No, but I was -- the x[n] = 0 constraint.  Add it through
> > a penalty term and try this:
> >
> > theta <- 1000
> > n <- 100
> > x <-  rep(1/n, n)
> > f <- function(x) sum(n:1 * x) - theta * sum(x)^2
> > optim(x, f, lower = rep(-1, n), upper = rep(1, n), method = "L-BFGS-B",
> >   control = list(maxit = 1000, fnscale = -1, lmm = 25))
> > plot(cumsum(res$par))
>
> Thanks, Gabor. Inspired by your code, I have written the following:
>
> theta <- 5000
> n <- 1000
> x <-  rep(1/n, n)
> f <- function(x) sum(n:1 * x) - theta * sum(x)^2
> res <- optim(x, f, lower = rep(-1/n, n), upper = rep(1/n, n), method =
> "L-BFGS-B",control = list(maxit = 2000, fnscale = -1))
>
> b <- res$par
>
> x <- 0
>
> for (i in 1:n) {
>  x[i+1] <- b[i] + x[i]
> }
>
> plot(seq(0,1,by=1/n),x,type="l")
>
> to solve the same problem. It works fine unless one replaces
>
> theta <- 5000
>
> by
>
> theta <- 1e100
>
> According to a book that I consulted meanwhile, the larger the value
> of theta the better the solution should be. Why does not it happen
> with my example? Any clues?
>
> Paul
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Rscript on OSX

2008-01-09 Thread Andrew Beckerman
Ido -

R for OSX generally runs via an application, called R.app, which your  
colleague could find in their applications directory.  It can run  
scripts and has a rather nice script editor associated with it.

You can run R as you would in linux using X11.app, found in  
Applications->Utilities on OSX.  R is not designed to run from  
Terminal.app (actually, terminal does not do graphics well for R).
X11 provides the behaviour that you would be used to in Linux etc.

BTW - there is a R-Mac-help group as well for macintosh specific  
issues - [EMAIL PROTECTED]

Andrew

-
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/
--


On 9 Jan 2008, at 13:22, Ido M. Tamir wrote:

> Hi,
>
> I directed somebody to install R (2.6.1) on his OSX computer,
> following instructions from http://cran.r-project.org/bin/macosx.
> She can run R from the console.
> But plot(1:10) doesn't produce any output or open a window (as I am
> used to from linux).
>
> More importantly:
> Rscript is not in the path (minor problem ln -s is hopefully  
> doable). I tried
> to put a hardcoded path to Rscript into the shebang line but this  
> fails. And
> when I try to invoke it directly:
>
>> -bash: ./Rscript: cannot execute binary file
>
> On linux this works.
>
> I would like to send her some Rscripts, but how can we make them
> run on her system?
>
>
>
> thank you very much,
> ido
>
>
>
> imaclab3:/Library/Frameworks/R.framework/Resources/bin ru$ ls -l
>
> total 1008
> -rwxrwxr-x   1 root  admin1654 Nov 26 17:36 BATCH
> -rwxrwxr-x   1 root  admin2188 Nov 26 17:36 COMPILE
> -rwxrwxr-x   1 root  admin   34391 Nov 26 17:36 INSTALL
> -rwxrwxr-x   1 root  admin1593 Nov 26 17:36 LINK
> -rwxrwxr-x   1 root  admin7210 Nov 26 17:37 R
> -rwxrwxr-x   1 root  admin7210 Nov 26 17:37 R.orig
> -rw-rw-r--   1 root  admin 655 Nov 26 17:37 R.rej
> -rwxrwxr-x   1 root  admin2244 Nov 26 17:36 REMOVE
> -rwxrwxr-x   1 root  admin 928 Nov 26 17:36 Rcmd
> -rwxrwxr-x   1 root  admin9523 Nov 26 17:36 Rd2dvi
> -rwxrwxr-x   1 root  admin 842 Nov 26 17:36 Rd2txt
> -rwxrwxr-x   1 root  admin3237 Nov 26 17:36 Rdconv
> -rwxrwxr-x   1 root  admin1320 Nov 26 17:36 Rdiff
> -rwxrwxr-x   1 root  admin2854 Nov 26 17:36 Rprof
> -rwxrwxr-x   1 root  admin   18084 Nov 26 17:36 Rscript
> -rwxrwxr-x   1 root  admin4656 Nov 26 17:36 SHLIB
> -rwxrwxr-x   1 root  admin   16129 Nov 26 17:36 Sd2Rd
> -rwxrwxr-x   1 root  admin 730 Nov 26 17:36 Stangle
> -rwxrwxr-x   1 root  admin 726 Nov 26 17:36 Sweave
> -rwxrwxr-x   1 root  admin   21715 Nov 26 17:36 build
> -rwxrwxr-x   1 root  admin   78570 Nov 26 17:36 check
> -rwxrwxr-x   1 root  admin6927 Nov 26 17:36 config
> drwxrwxr-x   4 root  admin 136 Nov 26 17:36 exec
> -rwxrwxr-x   1 root  admin3613 Nov 26 17:36 f77_f2c
> -rwxrwxr-x   1 root  admin   10720 Nov 26 17:36 javareconf
> -rwxrwxr-x   1 root  admin  215101 Nov 26 17:36 libtool
> -rwxrwxr-x   1 root  admin3495 Nov 26 17:36 mkinstalldirs
> -rwxrwxr-x   1 root  admin 413 Nov 26 17:36 pager
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Constrained minimization solver for nonlinear programming

2008-01-09 Thread tom soyer
Thanks Paul. I thought constrOptim does not do equality. I will check again.

A concrete example for finding a solution based on a target value instead of
min or max would be something like this: let's say I am trying exponential
smoothing on a time series and would like to find a solution for the
smoothing constant that instead of minimizes the root mean square error
(RMSE), it targets a particular value of RMSE. Is this possible in R?


On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
>
> On Jan 9, 2008 1:14 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> > Thanks Paul. yes, with equality constraints. What are "friends"? I read
> the
> > document for optim, but still could not figure out how to do this. Do
> you
> > just set the lower bound equal to the upper bound?
>
> constrOptim is a friend of optim. See ?constrOptim.
>
> Could you please provide a concrete example of an optimization problem
> that you would like R solving it?
>
> > Also, is it possible to ask R to search for a solution based on a target
> > value instead of min and max? Is there a function like that in R?
>
> Could you please provide a concrete example?
>
> Paul
>
>
>
> > On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > > On Jan 9, 2008 4:01 AM, tom soyer <[EMAIL PROTECTED]> wrote:
> > > > I noticed that R has a few bound-constrained nonlinear min and max
> > solvers,
> > > > such as optim, nlm, etc. But I could not find a constrained min and
> max
> > > > solver that is not LP. Does this mean R do not have this capability?
> It
> > is
> > > > hard to believe that R may not be as advanced as Excel in certain
> > areas...
> > > > Maybe it's there but I missed it? Does anyone know?
> > >
> > > Do you mean optimization solvers for nonlinear problems with equality
> > > constraints? If so, you can use optim and friends with penalties to
> > > incorporate equality constraints.
> > >
> > > Paul
> > >
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> >
> >
> > --
> > Tom
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Tom

[[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] Two dependent variables in formula

2008-01-09 Thread Alberto Murta
On Wednesday 09 January 2008 1:57 pm, Carla Rebelo wrote:
> Hello,
>
>  I' m trying to change the formula in the rpart function. The
> format of a general formula is Answer ~ expression, where Answer is
> the dependent variable and expression is set of terms containing the
> independent variables and separated by operators. I want the response
> of the formula is more than one dependent variable. It is possible?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.

You should take a look at package 'mvpart': 

http://cran.r-project.org/src/contrib/Descriptions/mvpart.html

-- 
 Alberto G. Murta
IPIMAR - National Institute of Fisheries and Marine Research
Avenida de Brasilia s/n; 1449-006 - Lisboa; Portugal
Tel: +351 213027000; Fax: +351 21 3015948; email: [EMAIL PROTECTED]

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

2008-01-09 Thread jiho
On 2008-January-09  , at 15:01 , Andrew Beckerman wrote:
> R is not designed to run from
> Terminal.app (actually, terminal does not do graphics well for R).


Actually it can, provided that you:
- install the package CarbonEL which allows you to plot to quartz  
windows from outside R.app (with minor quirks but that's still very  
nice to have)
- set the default plotting device to X11 in your .Rprofile and:
. do nothing if you are on leopard (since X11 should start  
automatically)
. if you are on previous versions, add
export DISPLAY=:0.0
to you shell startup script (.profile, .bashrc whatever) so that the  
display variable is defined. You'll have to start X11 manually but  
once it is started, you should be able to run X11 apps directly from  
Terminal.app

Hope that helps.

JiHO
---
http://jo.irisson.free.fr/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 need arguments pro-S-PLUS and against SAS...

2008-01-09 Thread Neil Shephard

You might find this article useful

Kellie B. Keeling and Robert J. Pavur, A comparative study of the
reliability of
nine statistical software packages,
Computational Statistics & Data Analysis, Volume 51, Issue 8, 1 May 2007,
Pages
3811-3831.
(http://www.sciencedirect.com/science/article/B6V8V-4JHMGWJ-1/2/77a29a95c2071997f13fcca7267711d1)
 




Alberto Monteiro wrote:
> 
> I need arguments pro-S-PLUS and against SAS for a meeting I will 
> have next week. S-Plus is (90 - 99)% compatible with R, so using 
> S-Plus will make things much easier for everyone. But I can't use
> this argument. What other arguments could I use?
> 
> Alberto Monteiro
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/I-need-arguments-pro-S-PLUS-and-against-SAS...-tp14621011p14713230.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] as.date - german date format

2008-01-09 Thread Uwe Ligges


Konga wrote:
> Hi,
> 
> I have a data.frame with the following variable:
> $  xx  :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3 3
> 
> now I´d like use "as.date" on it - if I comprehend the instructions on
> http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
> it should work like this:
> 
> as.date(xx, "%d.%m.%Y") - but it doesn´t...

At least as.Date() works for me for *one* of your factor labels:

as.Date(factor("01.02.2006"), "%d.%m.%Y")
[1] "2006-02-01"

So, please read the posting guide before posting and learn that you 
should tell us:

What is the error message? Which R version is this? What are all the 
labels (in order to reproduce your error)?

in order to get better help.

Uwe Ligges



> the survival Package ist loaded - is there a problem with the german format?
> Or did I understand something wrong?
> 
> Much better than tranforming the format from to data would be to import it
> in the right format.
> Is there a parameter for read.csv to get it as a date from the beginning?
> 
> 
> 
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Penalized L1 regression error in lasso2 package

2008-01-09 Thread Miguel Ratón Almansa
Hi everbody,

I need to apply lasso regression using the function l1ce from the lasso2 
package:

fr <- l1ce( fitness_T ~ ., data = dr, absolute.t=TRUE, standardize=FALSE );

Where fitness_T is my response, "." represents all the terms of my 
dataframe dr. This function fails when I use a lot of variables (around 
200-300 terms) in the dataframe. Is there any constraint about this? 
This is the error message I get:

Error en l1ce(fitness_T ~ ., data = dr, absolute.t = TRUE, standardize = 
FALSE) :
  Oops, something went wrong in .C("lasso",..): -1

Sometimes I get the same error when I introduce dataframes like the 
following (with only 30 terms):

  X1  X2   X3  X4   
X5 X6  X7  X8
1  0.7320944 0.4567412 0.44856288 0.05964432 0.05954413 0.6156447 
0.7659501 0.573173534
2  0.7773032 0.3449025 0.04422306 0.50439358 0.39123515 0.8047629 
0.4401352 0.064500660
3  0.7773032 0.3449025 0.04422306 0.50439358 0.39123515 0.8047629 
0.4401352 0.064500660
4  0.5768691 0.4639482 0.25751515 0.33793192 0.01037575 0.1798244 
0.5707092 0.735116023
5  0.9802398 0.5033950 0.48795317 0.97431465 0.51465128 0.2914794 
0.6774021 0.602885327
6  0.9802398 0.5033950 0.48795317 0.97431465 0.51465128 0.2914794 
0.6774021 0.602885327
7  0.9802398 0.5033950 0.48795317 0.97431465 0.51465128 0.2914794 
0.6774021 0.602885327
8  0.8252928 0.4653600 0.85582162 0.53349585 0.81383935 0.8111897 
0.5070405 0.006989377
9  0.8252928 0.4653600 0.85582162 0.53349585 0.81383935 0.8111897 
0.5070405 0.006989377
10 0.4685068 0.6208291 0.20864631 0.81919070 0.88421721 0.4488032 
0.3170425 0.268553276

...

  X25  X26 X27 X28  
   X29  X30 fitness_T
1  0.51582545 0.2883907 0.004668415 0.50093324 0.5488026 0.36071348 
-30911635603
2  0.50049201 0.5951309 0.388231982 0.87264326 0.7180451 0.09474729 
-30592911895
3  0.50049201 0.5951309 0.388231982 0.87264326 0.7180451 0.09474729 
-30592911895
4  0.4840 0.5687469 0.945986723 0.04843440 0.3921170 0.68509765 
-23433191157
5  0.74335685 0.6656366 0.295069967 0.65278954 0.8403278 0.01226897  
-8358708674
6  0.74335685 0.6656366 0.295069967 0.65278954 0.8403278 0.01226897  
-8358708674
7  0.74335685 0.6656366 0.295069967 0.65278954 0.8403278 0.01226897  
-8358708674
8  0.55207468 0.5004715 0.396061154 0.78939996 0.9649179 0.10526002  
12377155187
9  0.55207468 0.5004715 0.396061154 0.78939996 0.9649179 0.10526002  
12377155187
10 0.01548059 0.5422345 0.408542004 0.05060681 0.8768663 0.49197307 
115852466198

I get the same error. Is there any constraint about the values that can 
take the response in the formula of l1ce?

Can somebody help me?

Thank you for your help,
Miguel Ratón Almansa

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

2008-01-09 Thread Konga

Hi,

I have a data.frame with the following variable:
$  xx  :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3 3

now I´d like use "as.date" on it - if I comprehend the instructions on
http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
it should work like this:

as.date(xx, "%d.%m.%Y") - but it doesn´t...

the survival Package ist loaded - is there a problem with the german format?
Or did I understand something wrong?

Much better than tranforming the format from to data would be to import it
in the right format.
Is there a parameter for read.csv to get it as a date from the beginning?




-- 
View this message in context: 
http://www.nabble.com/as.date---german-date-format-tp14712654p14712654.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] Two dependent variables in formula

2008-01-09 Thread Carla Rebelo
Hello,

 I' m trying to change the formula in the rpart function. The  
format of a general formula is Answer ~ expression, where Answer is  
the dependent variable and expression is set of terms containing the  
independent variables and separated by operators. I want the response  
of the formula is more than one dependent variable. It is possible?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] close connection, closeAllConnections()

2008-01-09 Thread mel
close connection, closeAllConnections()

Hello,

For windows2000 and windowsXP, R.2.6.1
I have a little problem with the following lines

 > socketConnection('127.0.0.1', port=7496, server=F, blocking=F, 
open='wb', encoding='');
description  class   mode 
text opened   can read
"->127.0.0.1:7496"   "socket"   "wb" 
"binary"   "opened"  "yes"
  can write
  "yes"
 > showConnections(all=TRUE)
   descriptionclass  mode text isopen   can read can write
0 "stdin""terminal" "r"  "text"   "opened" "yes""no"
1 "stdout"   "terminal" "w"  "text"   "opened" "no" "yes"
2 "stderr"   "terminal" "w"  "text"   "opened" "no" "yes"
3 "->127.0.0.1:7496" "socket"   "wb" "binary" "opened" "yes""yes"
 > closeAllConnections()
Erreur dans close.socket(getConnection(set[i])) : invalid 'socket'
argument

with the previous R version,
calling closeAllConnections() did nicely close connection #3
... but now, this works no more.

I'm missing something and would be very thankful for any
infos/pointer about this little worry.
(I believe some changes were planned with the connection functions
in R.2.6.1, could it be that ?)
Thanks
Vincent

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

2008-01-09 Thread Abi Ghanem josephine
Hi,
I am encountering a problem in reading a file,
the file looks like that:
T  3  0   --   -- --T --   -- -- 18.98
   3  1  6.75 4.3939  --   -- -- 18.58
   3  2  6.90 4.9043  --   -- -- 18.63
   3  3  7.07 5.3948  --   -- -- 18.78
G  4  0  7.41 5.5447G --   -- -- 18.90
   4  1  7.44 5.993010.93 5.3023 18.95
   4  2  7.27 6.052311.16 5.7419 18.96
   4  3  7.27 5.542711.58 5.9518 18.97
the first an the 7th column contains only T and G
my problem is i want to have the 4th column as a vector : 6.75, 6.90, 
7.07, 7.41, 7.44, 7.27, 7.27.

when i do a simple read.delim(data, sep="", header=FALSE), i get this

T  3 0---- -- T ----  -- 18.98
3  1  6.75  4.3939 ---- -- 18.58
3  2  6.90  4.9043 ---- -- 18.63
3  3  7.07  5.3948 ---- -- 18.78
G  4 0  7.41  5.54 47 G ----  -- 18.90
4  1  7.44  5.9930  10.93  5.30 23 18.95
4  2  7.27  6.0523  11.16  5.74 19 18.96
4  3  7.27  5.5427  11.58  5.95 18 18.97

with the first line containing T, 3, 3, 3, G, 4, 4, 4 so the values are 
shifted in the 1st and 5th row


i tried to change sep="" to sep="\t", but than i don't get a matrix
i just get a one column file.
"  T  3  0   --   -- --T --   -- -- 18.98"
" 3  1  6.75 4.3939  --   -- -- 18.58"
" 3  2  6.90 4.9043  --   -- -- 18.63"
" 3  3  7.07 5.3948  --   -- -- 18.78"
"  G  4  0  7.41 5.5447G --   -- -- 18.90"
" 4  1  7.44 5.993010.93 5.3023 18.95"
" 4  2  7.27 6.052311.16 5.7419 18.96"
" 4  3  7.27 5.542711.58 5.9518 18.97"

My question is there is a way to read the file either with skipping the 
first column and the 7th,
Or how can i get to have a vector with the 4th column.

Thanks for the help,
Josephine

-- 


Josephine ABI GHANEM
IBPC, UPR 9080
13, rue P. et M. Curie,
75005 Paris, FRANCE

email: [EMAIL PROTECTED]
tel: 01 58 41 51 67
  06 28 07 25 71

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Gustaf Rydevik
Hi all,

Reading the wikipedia page on R, I stumbled across the following:
http://fluff.info/blog/arch/0172.htm

It does seem interesting that the C execution is that much slower from
R than from a native C program. Could any of the more technically
knowledgeable people explain why this is so?

The author also have some thought-provoking opinions on R being
no-good and that you should write everything in C instead (mainly
because R is slow and too good at graphics, encouraging data
snooping). See  http://fluff.info/blog/arch/0041.htm
 While I don't agree (granted, I can't really write C), it was
interesting to read something from a very different perspective than
I'm used to.

Best regards,

Gustaf

_
Department of Epidemiology,
Swedish Institute for Infectious Disease Control
work email: gustaf.rydevik at smi dot ki dot se
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Two dependent variables in formula

2008-01-09 Thread Gavin Simpson
On Wed, 2008-01-09 at 13:57 +, Carla Rebelo wrote:
> Hello,
> 
>  I' m trying to change the formula in the rpart function. The  
> format of a general formula is Answer ~ expression, where Answer is  
> the dependent variable and expression is set of terms containing the  
> independent variables and separated by operators. I want the response  
> of the formula is more than one dependent variable. It is possible?

Try one or both the packages mvpart or party. mvpart replaces all of
rpart when you load it and provides handling for multivariate responses.
party provides an alternative implementation based on conditional
inference trees.

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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

2008-01-09 Thread Konga


Uwe Ligges-3 wrote:
> 
> 
> 
> Konga wrote:
>> Hi,
>> 
>> I have a data.frame with the following variable:
>> $  xx  :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3
>> 3
>> 
>> now I´d like use "as.date" on it - if I comprehend the instructions on
>> http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
>> it should work like this:
>> 
>> as.date(xx, "%d.%m.%Y") - but it doesn´t...
> 
> What is the error message? 
> - Fehler in as.date(mydata$xx, "%d.%m.%Y") : 
>   Cannot coerce to date format
> 
> Which R version is this? 
> -2.6.0
> 
> What are all the 
> labels (in order to reproduce your error)?
> - The data.frame has 1500 objects - do you want me to print them all? Even
> the 66 different levels of the factor would be a little bit much, I think.
> But I printed them once, they all have the same format.
> 
> 
> 
> 
> 
> 
> in order to get better help.
> 
> Uwe Ligges
> 
> 
> 
>> the survival Package ist loaded - is there a problem with the german
>> format?
>> Or did I understand something wrong?
>> 
>> Much better than tranforming the format from to data would be to import
>> it
>> in the right format.
>> Is there a parameter for read.csv to get it as a date from the beginning?
>> 
>> 
>> 
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/as.date---german-date-format-tp14712654p14714199.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] An "R is slow"-article

2008-01-09 Thread Armstrong, Whit
fisher.test seems to use the .C calling convention in a couple of
different places.

for example:

tmp <- .C("fisher_sim", as.integer(nr), as.integer(nc), 
as.integer(sr), as.integer(sc), as.integer(n), 
as.integer(B), integer(nr * nc), double(n + 1), 
integer(nc), results = double(B), PACKAGE =
"stats")$results


perhaps some R experts on the list can tell us whether there is
significant overhead to .C vs .Call.

Does .C really duplicate its arguments?  What does RObjToCPtr do?


(line 1682.. in dotcode.c)

/* Convert the arguments for use in foreign */
/* function calls.  Note that we copy twice */
/* once here, on the way into the call, and */
/* once below on the way out. */
cargs = (void**)R_alloc(nargs, sizeof(void*));
nargs = 0;
for(pargs = args ; pargs != R_NilValue; pargs = CDR(pargs)) {
#ifdef THROW_REGISTRATION_TYPE_ERROR
if(checkTypes &&
   !comparePrimitiveTypes(checkTypes[nargs], CAR(pargs), dup)) {
/* We can loop over all the arguments and report all the

   erroneous ones, but then we would also want to avoid

   the conversions.  Also, in the future, we may just

   attempt to coerce the value to the appropriate

   type. This is why we pass the checkTypes[nargs] value

   to RObjToCPtr(). We just have to sort out the ability

   to return the correct value which is complicated by

   dup, etc. */
errorcall(call, _("Wrong type for argument %d in call to
%s"),
  nargs+1, symName);
}
#endif
cargs[nargs] = RObjToCPtr(CAR(pargs), naok, dup, nargs + 1,
  which, symName, argConverters + nargs,
  checkTypes ? checkTypes[nargs] : 0,
  encname);
#ifdef R_MEMORY_PROFILING
if (TRACE(CAR(pargs)) && dup)
memtrace_report(CAR(pargs), cargs[nargs]);
#endif
nargs++;
}

Thanks,
Whit


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Gustaf Rydevik
> Sent: Wednesday, January 09, 2008 10:25 AM
> To: r-help@r-project.org
> Subject: [R] An "R is slow"-article
> 
> Hi all,
> 
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
> 
> It does seem interesting that the C execution is that much 
> slower from R than from a native C program. Could any of the 
> more technically knowledgeable people explain why this is so?
> 
> The author also have some thought-provoking opinions on R 
> being no-good and that you should write everything in C 
> instead (mainly because R is slow and too good at graphics, 
> encouraging data snooping). See  
> http://fluff.info/blog/arch/0041.htm
>  While I don't agree (granted, I can't really write C), it 
> was interesting to read something from a very different 
> perspective than I'm used to.
> 
> Best regards,
> 
> Gustaf
> 
> _
> Department of Epidemiology,
> Swedish Institute for Infectious Disease Control work email: 
> gustaf.rydevik at smi dot ki dot se skype:gustaf_rydevik
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 




This e-mail message is intended only for the named recipient(s) above. It may 
contain confidential information. If you are not the intended recipient you are 
hereby notified that any dissemination, distribution or copying of this e-mail 
and any attachment(s) is strictly prohibited. If you have received this e-mail 
in error, please immediately notify the sender by replying to this e-mail and 
delete the message and any attachment(s) from your system. Thank you.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Barry Rowlingson
Gustaf Rydevik wrote:
> Hi all,
> 
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
> 
> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?

  I don't think it is. He's comparing some C code with calling 
fisher.test() from R, which he claims does 'nothing but call C code over 
and over'. Wrong. It checks its arguments in R, it checks for multiple 
arguments, it does all sorts of goodness before finally calling 
.C("fexact"). And then it does even more things. Confidence intervals, 
odds ratios, p-values and so on.

  He needs to re-run his tests but instead of calling fisher.test() he 
should prepare the data and call .C("fexact",...) directly.

> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/0041.htm

  And of course C is good at buffer overflows and memory leaks and 
spending ages compiling when you really just want to do fisher.test(foo) 
and have done with it.

  He says: "I used to have a simulation written in R calling compiled C 
that took overnight to process 100 agents, but now that it's all in C 
simulations with 9,000 agents run in forty minutes. Don't risk it--learn 
to do statistical computing in C today!". Fine, but I imagine his R code 
was created much quicker than the C code. R is quicker to write, and 
once you have established that your code is running too slow for you, 
then you optimise. By that point you've hopefully debugged your 
algorithm and spotted all the nasty traps that would have tied you up in 
the C debugger for a week. You then rewrite in pure C for speed, and you 
of course have a set of test cases generated from R to verify your C is 
doing the same as your R. Win win.

  He claims to be an economist but clearly doesn't recognise the economy 
of rapid development...

Barry

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

2008-01-09 Thread David Bickel
Is there any automatic mechanism for extracting a likelihood or test
statistic distribution (PDF or CDF) from an object of class "htest" or
from another object of a general class encoding a hypothesis test
result?

I would like to have a function that takes "x", an object of class
"htest", as its only argument and that returns the likelihood or test
statistic distribution that was used to compute the p-value. It seems
the only way to write such a function is to manually assign each test
its statistic's distribution, e.g., like this:

FUN <- if(names(x$statistic) == "t")
  dt
else if(names(x$statistic) == "X-squared")
  dchisq
# etc.

Is there a general S3 or S4 class other than "htest" that would better
accommodate such extraction of distributions or likelihoods? I would
also appreciate any suggestions for strategies or contributed packages
that may facilitate automation. For example, would the "distrTEst"
package help?

David

__
David R. Bickel
Ottawa Institute of Systems Biology
http://www.oisb.ca/members.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Duncan Murdoch
On 1/9/2008 10:25 AM, Gustaf Rydevik wrote:
> Hi all,
> 
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
> 
> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?

That conclusion isn't supported by his test. The main source of the 
difference is interpreting the loop:

test_ct <- 1
x   <- matrix(c(300, 860, 240, 380), nrow=2)
for (i in 1:test_ct)
 {fisher.test(x)}

If he wanted to show that R makes C go slower, he should have put 
together an example that spent most of its time in C, without returning 
to R 1 times.  For example, make the entries in that table 1000 
times larger, and do the test just once:

 > x   <- matrix(c(30, 86, 24, 38), nrow=2)
 > fisher.test(x)

This takes about 20 seconds on my PC, and I'd guess it would take about 
the same amount of time in this author's pure C implementation.

My own experience is that R is about 100 times slower than pure C, and 
usually it doesn't matter.  In cases where it does, I'll  move the 
calculations into C.

If I followed Blair's advice and did everything in C, then development 
would take much longer, the code would be much buggier (even his example 
has bugs, and he admits it!!) and all those cases where R is fast enough 
would just never get done.

Duncan Murdoch

> 
> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/0041.htm
>  While I don't agree (granted, I can't really write C), it was
> interesting to read something from a very different perspective than
> I'm used to.
> 
> Best regards,
> 
> Gustaf
> 
> _
> Department of Epidemiology,
> Swedish Institute for Infectious Disease Control
> work email: gustaf.rydevik at smi dot ki dot se
> skype:gustaf_rydevik
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Constrained minimization solver for nonlinear programming

2008-01-09 Thread Paul Smith
On Jan 9, 2008 2:13 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> Thanks Paul. I thought constrOptim does not do equality. I will check again.

Indeed, constrOptim does not do equality constraints, but, trough
penalties, one can add them.

> A concrete example for finding a solution based on a target value instead of
> min or max would be something like this: let's say I am trying exponential
> smoothing on a time series and would like to find a solution for the
> smoothing constant that instead of minimizes the root mean square error
> (RMSE), it targets a particular value of RMSE. Is this possible in R?

Yes, Tom, R can do that for you. Apply the exponential smoothing. At
the end, you get the RMSE as an expression depending on alpha (the
smoothing parameter). Then use

uniroot

to solve the following equation

RMSE == "your desired value for RMSE".

Please, notice that this is not an optimization problem.

Paul


>
>
>
> On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > On Jan 9, 2008 1:14 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> > > Thanks Paul. yes, with equality constraints. What are "friends"? I read
> the
> > > document for optim, but still could not figure out how to do this. Do
> you
> > > just set the lower bound equal to the upper bound?
> >
> > constrOptim is a friend of optim. See ?constrOptim.
> >
> > Could you please provide a concrete example of an optimization problem
> > that you would like R solving it?
> >
> > > Also, is it possible to ask R to search for a solution based on a target
> > > value instead of min and max? Is there a function like that in R?
> >
> > Could you please provide a concrete example?
> >
> > Paul
> >
> >
> >
> > > On 1/9/08, Paul Smith <[EMAIL PROTECTED] > wrote:
> > > >
> > > >
> > > >
> > > > On Jan 9, 2008 4:01 AM, tom soyer <[EMAIL PROTECTED]> wrote:
> > > > > I noticed that R has a few bound-constrained nonlinear min and max
> > > solvers,
> > > > > such as optim, nlm, etc. But I could not find a constrained min and
> max
> > > > > solver that is not LP. Does this mean R do not have this capability?
> It
> > > is
> > > > > hard to believe that R may not be as advanced as Excel in certain
> > > areas...
> > > > > Maybe it's there but I missed it? Does anyone know?
> > > >
> > > > Do you mean optimization solvers for nonlinear problems with equality
> > > > constraints? If so, you can use optim and friends with penalties to
> > > > incorporate equality constraints.
> > > >
> > > > Paul
> > > >
> > > >
> > > > __
> > > > R-help@r-project.org mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.
> > > >
> > >
> > >
> > >
> > > --
> > > Tom
> >
> > __
> >
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Tom

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


[R] Need help on distance matrix

2008-01-09 Thread Lassana TOURE
Hi

I have a data like this.

79

77.51

79.64

84.08

71.6

90.22

91.46

89.49

94.51

97.45

97.99

97.86

69.88

77.44

72.44

74.21

72.54

78.27

82.03

78.62

80.4

85.97

86.22

84.04

I try to do a distance matrix. I get error if I run the following program:

D2 <- matrix(0,n,n)

for (i1 in 1:n)

for (i2 in 1:n)

D2[i1,i2] <- (X[i1,1]-X[i2,1])^2 + (X[i1,2]-X[i2,2])^2 

 

I need help

thanks

 

 

  _  

I am using the free version of SPAMfighter for private users.
It has removed 337 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter   for free now!


[[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] Ransac implementation

2008-01-09 Thread Ralf Goertz
Hi,

is there an R-implementation of the RANSAC-algorithm?

Thanks,

Ralf

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


Re: [R] An "R is slow"-article

2008-01-09 Thread Peter Dalgaard
Gustaf Rydevik wrote:
> Hi all,
>
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
>
> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?
>
>   
Well, if you are obsessed with speed, R can be the wrong tool. This is
an ingrained aspect of the language itself; if you are interested,
consult some of Luke Tierney's writings about the difficulties of
writing an R compiler. To some extent, it is a tradeoff for flexibility
and expressiveness.

The example is somewhat misleading. The C execution time is probably the
same, but it is drowned out by the administrative overhead of
fisher.test (a 2x2 Fisher test is really not a very complex operation
when cell counts are in the hundreds.)

> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/0041.htm
>  While I don't agree (granted, I can't really write C), it was
> interesting to read something from a very different perspective than
> I'm used to.
>   
The idea that you really shouldn't look at data before testing
statistical hypotheses is not without merit, but taken to the extreme,
it tends to become ridiculous. You end up in a situation where you
either can't do anything or you don't know what you are doing. It is
related to the discussions about randomized trials versus observational
studies. The former are in many ways stronger, but sometimes
unavailable, and they tend to be using a very big hammer to whack in a
single nail.


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Paul Gilbert

Gustaf Rydevik wrote:
> Hi all,
> 
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
> 
There are certainly situations where one would want to consider faster 
solutions than interpreted languages but, having been through these 
arguments a few times over the years, here are a few things you might 
consider:

1/ How much is your time worth, how much does the computer time cost, 
and how much does a faster computer cost when you start writing your code?

2/ How much is your time worth, how much does the computer time cost, 
and how much does a faster computer cost when you finish writing your code?

3/ If you tweak the code, or use someone else's private tweaks, how much 
do you trust the results relative to more widely used and tested versions?

4/ You should do speed comparisons with something resembling your real 
problem.

5/ If you want to make R look really bad use a loop that gobbles lots of 
memory, so your machine starts to swap. (This is my guess of part of the 
problem with the "script".)

6/ If you want your code to be really fast, don't do any error checking. 
(This also avoids the enormous amount of time you waste when you find 
errors.)

> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?
> 
> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C 

People used to say assembler, that's progress.

Paul Gilbert

instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/0041.htm
>  While I don't agree (granted, I can't really write C), it was
> interesting to read something from a very different perspective than
> I'm used to.
> 
> Best regards,
> 
> Gustaf
> 
> _
> Department of Epidemiology,
> Swedish Institute for Infectious Disease Control
> work email: gustaf.rydevik at smi dot ki dot se
> skype:gustaf_rydevik
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


La version française suit le texte anglais.



This email may contain privileged and/or confidential in...{{dropped:26}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Marc Schwartz
Barry Rowlingson wrote:
> Gustaf Rydevik wrote:
>> Hi all,
>>
>> Reading the wikipedia page on R, I stumbled across the following:
>> http://fluff.info/blog/arch/0172.htm
>>
>> It does seem interesting that the C execution is that much slower from
>> R than from a native C program. Could any of the more technically
>> knowledgeable people explain why this is so?
> 
>   I don't think it is. He's comparing some C code with calling 
> fisher.test() from R, which he claims does 'nothing but call C code over 
> and over'. Wrong. It checks its arguments in R, it checks for multiple 
> arguments, it does all sorts of goodness before finally calling 
> .C("fexact"). And then it does even more things. Confidence intervals, 
> odds ratios, p-values and so on.
> 
>   He needs to re-run his tests but instead of calling fisher.test() he 
> should prepare the data and call .C("fexact",...) directly.
> 
>> The author also have some thought-provoking opinions on R being
>> no-good and that you should write everything in C instead (mainly
>> because R is slow and too good at graphics, encouraging data
>> snooping). See  http://fluff.info/blog/arch/0041.htm
> 
>   And of course C is good at buffer overflows and memory leaks and 
> spending ages compiling when you really just want to do fisher.test(foo) 
> and have done with it.
> 
>   He says: "I used to have a simulation written in R calling compiled C 
> that took overnight to process 100 agents, but now that it's all in C 
> simulations with 9,000 agents run in forty minutes. Don't risk it--learn 
> to do statistical computing in C today!". Fine, but I imagine his R code 
> was created much quicker than the C code. R is quicker to write, and 
> once you have established that your code is running too slow for you, 
> then you optimise. By that point you've hopefully debugged your 
> algorithm and spotted all the nasty traps that would have tied you up in 
> the C debugger for a week. You then rewrite in pure C for speed, and you 
> of course have a set of test cases generated from R to verify your C is 
> doing the same as your R. Win win.
> 
>   He claims to be an economist but clearly doesn't recognise the economy 
> of rapid development...
> 
> Barry

If support list activity is any surrogate measure of the success of his
arguments, that there are 7 subscribers and only 2 posts (both by the
same person and without a reply from the application author) on the
Apophenia e-mail lists at:

  https://sourceforge.net/mail/?group_id=130901

one would hypothesize that he has been less than persuasive...

What color is the sky in his world?

;-)

Regards,

Marc Schwartz

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

2008-01-09 Thread Gabor Grothendieck
You could create an S3 generic that does it.  That is not initially
any less work than the if statement but if you add new distribution
no existing code need be modified.  Just add a new method for each
distribution to be supported:

getDistr <- function(x) {
.Class <- names(x$value$statistic)
NextMethod("getDistr")
}

# initial list of distributions supported
getDistr.t <- function(x) dt
"getDistr.X-squared" <- function(x) dchisq

# test the two distributions

example(t.test)
getDistr(.Last.value)

example(prop.test)
getDistr(.Last.value)


On Jan 9, 2008 10:46 AM, David Bickel <[EMAIL PROTECTED]> wrote:
> Is there any automatic mechanism for extracting a likelihood or test
> statistic distribution (PDF or CDF) from an object of class "htest" or
> from another object of a general class encoding a hypothesis test
> result?
>
> I would like to have a function that takes "x", an object of class
> "htest", as its only argument and that returns the likelihood or test
> statistic distribution that was used to compute the p-value. It seems
> the only way to write such a function is to manually assign each test
> its statistic's distribution, e.g., like this:
>
> FUN <- if(names(x$statistic) == "t")
>  dt
> else if(names(x$statistic) == "X-squared")
>  dchisq
> # etc.
>
> Is there a general S3 or S4 class other than "htest" that would better
> accommodate such extraction of distributions or likelihoods? I would
> also appreciate any suggestions for strategies or contributed packages
> that may facilitate automation. For example, would the "distrTEst"
> package help?
>
> David
>
> __
> David R. Bickel
> Ottawa Institute of Systems Biology
> http://www.oisb.ca/members.htm
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Jeffrey Horner
I hazard to say that the author of that blog post isn't using the time 
he saved from writing his analyses in C very efficiently. I wonder how 
long it took him to write it in C in the first place, even to setup the 
testing of C against R, or to write the blog post.

He didn't say.

Jeff

Armstrong, Whit wrote on 01/09/2008 09:49 AM:
> fisher.test seems to use the .C calling convention in a couple of
> different places.
> 
> for example:
> 
> tmp <- .C("fisher_sim", as.integer(nr), as.integer(nc), 
> as.integer(sr), as.integer(sc), as.integer(n), 
> as.integer(B), integer(nr * nc), double(n + 1), 
> integer(nc), results = double(B), PACKAGE =
> "stats")$results
> 
> 
> perhaps some R experts on the list can tell us whether there is
> significant overhead to .C vs .Call.
> 
> Does .C really duplicate its arguments?  What does RObjToCPtr do?
> 
> 
> (line 1682.. in dotcode.c)
> 
> /* Convert the arguments for use in foreign */
> /* function calls.  Note that we copy twice */
> /* once here, on the way into the call, and */
> /* once below on the way out. */
> cargs = (void**)R_alloc(nargs, sizeof(void*));
> nargs = 0;
> for(pargs = args ; pargs != R_NilValue; pargs = CDR(pargs)) {
> #ifdef THROW_REGISTRATION_TYPE_ERROR
> if(checkTypes &&
>!comparePrimitiveTypes(checkTypes[nargs], CAR(pargs), dup)) {
> /* We can loop over all the arguments and report all the
> 
>erroneous ones, but then we would also want to avoid
> 
>the conversions.  Also, in the future, we may just
> 
>attempt to coerce the value to the appropriate
> 
>type. This is why we pass the checkTypes[nargs] value
> 
>to RObjToCPtr(). We just have to sort out the ability
> 
>to return the correct value which is complicated by
> 
>dup, etc. */
> errorcall(call, _("Wrong type for argument %d in call to
> %s"),
>   nargs+1, symName);
> }
> #endif
> cargs[nargs] = RObjToCPtr(CAR(pargs), naok, dup, nargs + 1,
>   which, symName, argConverters + nargs,
>   checkTypes ? checkTypes[nargs] : 0,
>   encname);
> #ifdef R_MEMORY_PROFILING
> if (TRACE(CAR(pargs)) && dup)
> memtrace_report(CAR(pargs), cargs[nargs]);
> #endif
> nargs++;
> }
> 
> Thanks,
> Whit
> 
> 
>> -Original Message-
>> From: [EMAIL PROTECTED] 
>> [mailto:[EMAIL PROTECTED] On Behalf Of Gustaf Rydevik
>> Sent: Wednesday, January 09, 2008 10:25 AM
>> To: r-help@r-project.org
>> Subject: [R] An "R is slow"-article
>>
>> Hi all,
>>
>> Reading the wikipedia page on R, I stumbled across the following:
>> http://fluff.info/blog/arch/0172.htm
>>
>> It does seem interesting that the C execution is that much 
>> slower from R than from a native C program. Could any of the 
>> more technically knowledgeable people explain why this is so?
>>
>> The author also have some thought-provoking opinions on R 
>> being no-good and that you should write everything in C 
>> instead (mainly because R is slow and too good at graphics, 
>> encouraging data snooping). See  
>> http://fluff.info/blog/arch/0041.htm
>>  While I don't agree (granted, I can't really write C), it 
>> was interesting to read something from a very different 
>> perspective than I'm used to.
>>
>> Best regards,
>>
>> Gustaf
>>
>> _
>> Department of Epidemiology,
>> Swedish Institute for Infectious Disease Control work email: 
>> gustaf.rydevik at smi dot ki dot se skype:gustaf_rydevik
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> 
> This e-mail message is intended only for the named recipient(s) above. It may 
> contain confidential information. If you are not the intended recipient you 
> are hereby notified that any dissemination, distribution or copying of this 
> e-mail and any attachment(s) is strictly prohibited. If you have received 
> this e-mail in error, please immediately notify the sender by replying to 
> this e-mail and delete the message and any attachment(s) from your system. 
> Thank you.
> 
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner

__
R-help@r-pr

Re: [R] labels to values

2008-01-09 Thread Henrique Dallazuanna
If I understand your question, you can do:

x1 <- as.factor(d[,'Y6'])
levels(x1)[levels(x1) %in% attributes(x)[1]] <-
c(names(unlist(lapply(levels(x1),
function(z)which(z==attributes(x)[[1]])

On 09/01/2008, Matthias Wendel <[EMAIL PROTECTED]> wrote:
> I couldn't find out how the following to solve:
> There is a column in a data.frame:
>
> > d[, 'Y6']
>   [1]  6  3  8 11  8  9  6  8  3  5 10 15 NA  9  8  3  8 16  6  6 NA 10  5  2 
>  7  7  6 16  7 15  7 10 12  8  7 12 12 16  7  6  8  8
> 15  6  [45] NA  8 99  7 12  8  9 16  7 16  8  7  7  1 15 12  8  7 10  7  8  7 
>  8  9  8  6  6  8  6 16 11  5 11 11  1 11  3  7  7 10
> 10 10  6 11  [89] 16 NA  1  3  2 10 99 10  3  3  9  7 16 99 16  1 10  2 13 13 
> 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 NA 10 16
> 16 NA  6 10  5 11 [133] 11  1  1  1  1 16  1 16  1  1  1  1  6  6  6 16  8 16 
> 16 16 16  5  6 10 99 11 11 10  6  6  1  1  6  1 11 11
> 16  9 11 16  6  8  8 16 [177] 16  8  6 16 16 12 12 12 12 12 12 12 16  9 16 15 
> 12 12 15 10 16 15  4  1  2 14  4  4  2  5 NA  1  5  5
> 7  9  5 12 12 NA 16 12 12 12 [221] 12 12 12 12 12 12 99 NA 12 12 NA  1 16  1  
> 7 11  5  6  7  1 13  6  8 16  2  1  5 16 16  9  8  8
> 8  7 16  8  8  2  8  5  4  6 14  5 [265] 14  8  8 14  4  4  8 14  8 14  6  2  
> 3 14  3 16  5 15 15 15 15 15 15 15 15 15 15 15 13 13
> 13 13 13 13 13 13 13 13 13 13 13 15  6 NA [309] 12  3  9  9 NA 10 16
> attr(,"value.labels")
>   Verwaltung Servicegesellschaft Waldfriede (SKW) 
>Kurzzeitpflege Waldfriede
>   16   15 
>   14
>Sozialstation  Krankenpflegeschule 
>  Med. Technischer Dienst
>   13   12 
>   11
>Pflege OP  Funktionsdienst 
>   Pflege Gynäkologie
>   109 
>8
> Pflege ChirurgiePflege Innere 
>Ärzte Anästhesie, Röntgen
>76 
>5
>Ärzte Gynäkologie  Ärzte Chirurgie 
> Ärzte Innere
>43 
>2
> Patientenberatung/-betreuung
>1
>
> I'd like to have the column with the value.labels as values. How do I do that?
> Thanks,
> Matthias
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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

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

2008-01-09 Thread Tom Backer Johnsen
I have just recieved "The R book" by Michael Crawley, and I am deeply 
impressed. Really.  Chapter 2, "Essentials of the R language" taught 
me a lot.  More than 900 pages of concentrated Information.  Recommended!

Tom
-- 
++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Alberto Monteiro
[article: http://fluff.info/blog/arch/0172.htm ]

Duncan Murdoch wrote:
> 
> If I followed Blair's advice and did everything in C, then 
> development would take much longer, the code would be much buggier 
> (even his example has bugs, and he admits it!!) and all those cases 
> where R is fast enough would just never get done.
> 
I was particularly horrified by this comment:

  The reader well-versed with Apophenia will notice that there is
  a memory leak, because apop_test_fisher_exact returns an apop_data
  struct that never gets freed. But 10,000 lost matrices didn't affect
  the speed of the program at all. The lesson from this is that the
  details of memory management that R is handling for you are not
  such a big deal on a modern PC anyway. 

So, he does a C code that _doesn't_ check if there is memory before
allocating things, then _doesn't_ free memory when it finishes, and
naively says that C is 50 times faster than R?

Alberto Monteiro

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

2008-01-09 Thread Peter Dalgaard
David Bickel wrote:
> Is there any automatic mechanism for extracting a likelihood or test
> statistic distribution (PDF or CDF) from an object of class "htest" or
> from another object of a general class encoding a hypothesis test
> result?
>
> I would like to have a function that takes "x", an object of class
> "htest", as its only argument and that returns the likelihood or test
> statistic distribution that was used to compute the p-value. It seems
> the only way to write such a function is to manually assign each test
> its statistic's distribution, e.g., like this:
>
> FUN <- if(names(x$statistic) == "t")
>   dt
> else if(names(x$statistic) == "X-squared")
>   dchisq
> # etc.
>
>   
Just take the p-value itself as the test statistic and use dunif.

I think doing this may also show you that you have a conceptual problem
(What would you do with the likelihood?)

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Robin Hankin
Hello Gustaf, List.

Thanks Gustaf for your post!


well I am working pretty intensively with fisher.test() right now, as
some of you will know.

The comparison is not fair:  R's fisher.test() does a whole
bunch of error checking and testing for the size of the
input matrix and assessing of other arguments, and
puts together a nice little list of class "htest".

The C routine does none of this.


The clincher is that fisher.test() as called gives an estimate
for the odds ratio using uniroot() to numerically solve an
equation in terms of the hypergeometric probability
distribution.  This takes a lo time, but
one doesn't notice it in a standard R session.


Sorry, but the time comparison is simply not worth reporting.







On 9 Jan 2008, at 15:25, Gustaf Rydevik wrote:

> Hi all,
>
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/0172.htm
>
> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?
>
> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/0041.htm
> While I don't agree (granted, I can't really write C), it was
> interesting to read something from a very different perspective than
> I'm used to.
>
> Best regards,
>
> Gustaf
>
> _
> Department of Epidemiology,
> Swedish Institute for Infectious Disease Control
> work email: gustaf.rydevik at smi dot ki dot se
> skype:gustaf_rydevik
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 Hankin
Uncertainty Analyst and Neutral Theorist,
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

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


Re: [R] plotting help needed

2008-01-09 Thread bartjoosen

maybe this is what you want:
plot(all~c(1:2),type="b",col="blue",xlim=c(1,4),ylim=c(20,150),pch=c("a","b"),yaxt="none")
 
lines(all2~c(2:3),type="o",col="yellow",pch=c("d","e")) 

for some manuals, look at the contributed documents section at the R
homepage


Bart


ran2 wrote:
> 
> Dear all,
> 
> i need some help with plotting.
> 
> the specific problem is the following:
> 
> #FYI
> a=100
> b=95
> d=94.5
> e=70
> 
> all=c(a,b)
> all2=c(d,e)
> plot(all,type="b",col="blue",xlim=c(1,4),ylim=c(20,150))
> lines(all2,type="o",col="yellow")
> 
> 
> this does work so far, but ...
> i´d like to have 4 intersects, just named by characters.. no scale  
> please.
> the second problem is, i am trying to start the second vector where  
> the first vector stops (same point on the x-axis - y is different ;) )
> 
> admittedly all this sounds quite basic, but i couldnt get a long with  
> it for  a while. if somebody knows a good manual about graphics in R,  
> i´d be happy if you let me know.
> 
> thanks in advance !
> 
> matthias 
>   [[alternative HTML version deleted]]
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/plotting-help-needed-tp14697049p14707893.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] use "save.image" inside a function?

2008-01-09 Thread Hua Li
Hi, All 

I'm trying to save the workspace as a Check Point for
possible future come back. The "save.image" function
works if the whole coding is in a main function:

rm(list=ls())
t = 1
t = t+1
print(paste("before",t))
# [1] "before 2"
save.image("tt.RData")
 
t = t+1
print(paste("after",t))
# [1] "after 3"
 
load("tt.RData")
print(paste("check",t))
# [1] "check 2"

As you can see, the value right before I save the
workspace is restored.

However, if I run the saving inside a function, it
seems that it restores to the vale outside the
function rather than the one before the save command:

rm(list=ls())
test.fcn <- function(t=1){
 t = t+1
 print(paste("before",t))
 save.image("tt.RData")

 t = t+1
 print(paste("after",t))
 
 load("tt.RData")
 print(paste("check",t))
 
}
   
t = 1
test.fcn(t=t)
# [1] "before 2"
# [1] "after 3"
# [1] "check 1"

So it restores the value before the program enters the
function (t=1), though what I really want is the value
inside the function(t=2).

Is there anything wrong with the way I use the
"save.image" function? Or is there other command I can
use to reach my goal?

Thanks a lot!

Hua



  

Never miss a thing.  Make Yahoo your home page.

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


Re: [R] use "save.image" inside a function?

2008-01-09 Thread Prof Brian Ripley
save.image() saves the global workspace: it does not save the environments 
of executing functions.  If you want to save the latter, use the 'envir' 
argument of save().

On Tue, 8 Jan 2008, Hua Li wrote:

> Hi, All
>
> I'm trying to save the workspace as a Check Point for
> possible future come back. The "save.image" function
> works if the whole coding is in a main function:
>
> rm(list=ls())
> t = 1
> t = t+1
> print(paste("before",t))
> # [1] "before 2"
> save.image("tt.RData")
>
> t = t+1
> print(paste("after",t))
> # [1] "after 3"
>
> load("tt.RData")
> print(paste("check",t))
> # [1] "check 2"
>
> As you can see, the value right before I save the
> workspace is restored.
>
> However, if I run the saving inside a function, it
> seems that it restores to the vale outside the
> function rather than the one before the save command:
>
> rm(list=ls())
> test.fcn <- function(t=1){
> t = t+1
> print(paste("before",t))
> save.image("tt.RData")
>
> t = t+1
> print(paste("after",t))
>
> load("tt.RData")
> print(paste("check",t))
>
> }
>
> t = 1
> test.fcn(t=t)
> # [1] "before 2"
> # [1] "after 3"
> # [1] "check 1"
>
> So it restores the value before the program enters the
> function (t=1), though what I really want is the value
> inside the function(t=2).
>
> Is there anything wrong with the way I use the
> "save.image" function? Or is there other command I can
> use to reach my goal?
>
> Thanks a lot!
>
> Hua
>
>
>
>  
> 
> Never miss a thing.  Make Yahoo your home page.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

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


[R] R help

2008-01-09 Thread Sitadri_Bagchi
Is there a number I can call to get started with R?  I have some really 
basic questions that won't take more than 10 minutes.

Sitadri




This e-mail, including attachments, is intended for the person(s) or company 
named and may contain confidential and/or legally privileged information. 
Unauthorized disclosure, copying or use of this information may be unlawful and 
is prohibited. If you are not the intended recipient, please delete this 
message and notify the sender.
All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic 
Message Repository. If you do not wish the retention of potentially private 
e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail 
account for any private, non-business related communications.
[[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] R help

2008-01-09 Thread Gustaf Rydevik
On Jan 9, 2008 5:47 PM,  <[EMAIL PROTECTED]> wrote:
> Is there a number I can call to get started with R?  I have some really
> basic questions that won't take more than 10 minutes.
>
> Sitadri
>

Try and write your questions down to this mailing list, and you're
bound to get answers,

/Gustaf

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Constrained minimization solver for nonlinear programming

2008-01-09 Thread tom soyer
Thanks Paul. I will try it.

On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
>
> On Jan 9, 2008 2:13 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> > Thanks Paul. I thought constrOptim does not do equality. I will check
> again.
>
> Indeed, constrOptim does not do equality constraints, but, trough
> penalties, one can add them.
>
> > A concrete example for finding a solution based on a target value
> instead of
> > min or max would be something like this: let's say I am trying
> exponential
> > smoothing on a time series and would like to find a solution for the
> > smoothing constant that instead of minimizes the root mean square error
> > (RMSE), it targets a particular value of RMSE. Is this possible in R?
>
> Yes, Tom, R can do that for you. Apply the exponential smoothing. At
> the end, you get the RMSE as an expression depending on alpha (the
> smoothing parameter). Then use
>
> uniroot
>
> to solve the following equation
>
> RMSE == "your desired value for RMSE".
>
> Please, notice that this is not an optimization problem.
>
> Paul
>
>
> >
> >
> >
> > On 1/9/08, Paul Smith <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > > On Jan 9, 2008 1:14 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> > > > Thanks Paul. yes, with equality constraints. What are "friends"? I
> read
> > the
> > > > document for optim, but still could not figure out how to do this.
> Do
> > you
> > > > just set the lower bound equal to the upper bound?
> > >
> > > constrOptim is a friend of optim. See ?constrOptim.
> > >
> > > Could you please provide a concrete example of an optimization problem
> > > that you would like R solving it?
> > >
> > > > Also, is it possible to ask R to search for a solution based on a
> target
> > > > value instead of min and max? Is there a function like that in R?
> > >
> > > Could you please provide a concrete example?
> > >
> > > Paul
> > >
> > >
> > >
> > > > On 1/9/08, Paul Smith <[EMAIL PROTECTED] > wrote:
> > > > >
> > > > >
> > > > >
> > > > > On Jan 9, 2008 4:01 AM, tom soyer <[EMAIL PROTECTED]> wrote:
> > > > > > I noticed that R has a few bound-constrained nonlinear min and
> max
> > > > solvers,
> > > > > > such as optim, nlm, etc. But I could not find a constrained min
> and
> > max
> > > > > > solver that is not LP. Does this mean R do not have this
> capability?
> > It
> > > > is
> > > > > > hard to believe that R may not be as advanced as Excel in
> certain
> > > > areas...
> > > > > > Maybe it's there but I missed it? Does anyone know?
> > > > >
> > > > > Do you mean optimization solvers for nonlinear problems with
> equality
> > > > > constraints? If so, you can use optim and friends with penalties
> to
> > > > > incorporate equality constraints.
> > > > >
> > > > > Paul
> > > > >
> > > > >
> > > > > __
> > > > > R-help@r-project.org mailing list
> > > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > > PLEASE do read the posting guide
> > > > http://www.R-project.org/posting-guide.html
> > > > > and provide commented, minimal, self-contained, reproducible code.
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Tom
> > >
> > > __
> > >
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> >
> >
> > --
> > Tom
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Tom

[[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] as.date - german date format

2008-01-09 Thread Uwe Ligges


Konga wrote:
> 
> Uwe Ligges-3 wrote:
>>
>>
>> Konga wrote:
>>> Hi,
>>>
>>> I have a data.frame with the following variable:
>>> $  xx  :Factor w/ 66 levels "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3
>>> 3
>>>
>>> now I´d like use "as.date" on it - if I comprehend the instructions on
>>> http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
>>> it should work like this:
>>>
>>> as.date(xx, "%d.%m.%Y") - but it doesn´t...
>> What is the error message? 
>> - Fehler in as.date(mydata$xx, "%d.%m.%Y") : 
>>   Cannot coerce to date format

I see, so this is really as.data() from the survival package.

>> Which R version is this? 
>> -2.6.0
>>
>> What are all the 
>> labels (in order to reproduce your error)?
>> - The data.frame has 1500 objects - do you want me to print them all? Even
>> the 66 different levels of the factor would be a little bit much, I think.
>> But I printed them once, they all have the same format.

The data.frame has 1500 rows but the factor just 66 labels. You could 
have made it available from some web server.

Anyway, you could try

   as.date(format(as.Date(mydata$xx, "%d.%m.%Y"), "%m/%d/%Y"))

instead (discussion open for better ideas!).


Uwe Ligges


>>
>>
>> in order to get better help.
>>
>> Uwe Ligges
>>
>>
>>
>>> the survival Package ist loaded - is there a problem with the german
>>> format?
>>> Or did I understand something wrong?
>>>
>>> Much better than tranforming the format from to data would be to import
>>> it
>>> in the right format.
>>> Is there a parameter for read.csv to get it as a date from the beginning?
>>>
>>>
>>>
>>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] R help

2008-01-09 Thread Gabor Grothendieck
On Jan 9, 2008 11:57 AM, Gustaf Rydevik <[EMAIL PROTECTED]> wrote:
> On Jan 9, 2008 5:47 PM,  <[EMAIL PROTECTED]> wrote:
> > Is there a number I can call to get started with R?  I have some really
> > basic questions that won't take more than 10 minutes.
> >
> > Sitadri
> >
>
> Try and write your questions down to this mailing list, and you're
> bound to get answers,

But read the posting guide (at the bottom of every message first).

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

2008-01-09 Thread Gabor Grothendieck
Read in lines using readLines, delete all T and G characters
and reread using read.table:

Lines.raw <- "T  3 0---- -- T ----  -- 18.98
3  1  6.75  4.3939 ---- -- 18.58
3  2  6.90  4.9043 ---- -- 18.63
3  3  7.07  5.3948 ---- -- 18.78
G  4 0  7.41  5.54 47 G ----  -- 18.90
4  1  7.44  5.9930  10.93  5.30 23 18.95
4  2  7.27  6.0523  11.16  5.74 19 18.96
4  3  7.27  5.5427  11.58  5.95 18 18.97
"
# in reality next line would be Lines <- readLines("myfile.dat")
Lines <- readLines(textConnection(Lines.raw))
DF <- read.table(textConnection(gsub("[TG]", "", Lines)), na.strings = "--")



On Jan 9, 2008 10:18 AM, Abi Ghanem josephine
<[EMAIL PROTECTED]> wrote:
> Hi,
> I am encountering a problem in reading a file,
> the file looks like that:
> T  3  0   --   -- --T --   -- -- 18.98
>   3  1  6.75 4.3939  --   -- -- 18.58
>   3  2  6.90 4.9043  --   -- -- 18.63
>   3  3  7.07 5.3948  --   -- -- 18.78
> G  4  0  7.41 5.5447G --   -- -- 18.90
>   4  1  7.44 5.993010.93 5.3023 18.95
>   4  2  7.27 6.052311.16 5.7419 18.96
>   4  3  7.27 5.542711.58 5.9518 18.97
> the first an the 7th column contains only T and G
> my problem is i want to have the 4th column as a vector : 6.75, 6.90,
> 7.07, 7.41, 7.44, 7.27, 7.27.
>
> when i do a simple read.delim(data, sep="", header=FALSE), i get this
>
> T  3 0---- -- T ----  -- 18.98
> 3  1  6.75  4.3939 ---- -- 18.58
> 3  2  6.90  4.9043 ---- -- 18.63
> 3  3  7.07  5.3948 ---- -- 18.78
> G  4 0  7.41  5.54 47 G ----  -- 18.90
> 4  1  7.44  5.9930  10.93  5.30 23 18.95
> 4  2  7.27  6.0523  11.16  5.74 19 18.96
> 4  3  7.27  5.5427  11.58  5.95 18 18.97
>
> with the first line containing T, 3, 3, 3, G, 4, 4, 4 so the values are
> shifted in the 1st and 5th row
>
>
> i tried to change sep="" to sep="\t", but than i don't get a matrix
> i just get a one column file.
> "  T  3  0   --   -- --T --   -- -- 18.98"
> " 3  1  6.75 4.3939  --   -- -- 18.58"
> " 3  2  6.90 4.9043  --   -- -- 18.63"
> " 3  3  7.07 5.3948  --   -- -- 18.78"
> "  G  4  0  7.41 5.5447G --   -- -- 18.90"
> " 4  1  7.44 5.993010.93 5.3023 18.95"
> " 4  2  7.27 6.052311.16 5.7419 18.96"
> " 4  3  7.27 5.542711.58 5.9518 18.97"
>
> My question is there is a way to read the file either with skipping the
> first column and the 7th,
> Or how can i get to have a vector with the 4th column.
>
> Thanks for the help,
> Josephine
>
> --
>
>
> Josephine ABI GHANEM
> IBPC, UPR 9080
> 13, rue P. et M. Curie,
> 75005 Paris, FRANCE
>
> email: [EMAIL PROTECTED]
> tel: 01 58 41 51 67
>  06 28 07 25 71
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Distance matrix from a binary data frame

2008-01-09 Thread Marc
Hi,

I am trying to calculate a distance matrix on a binary data frame using 
dist.binary() {ade4}. This is the code I run and the error I get:

 > sjlc.dist <- dist.binary(as.data.frame(data), method=2) #D = (a+d) / 
(a+b+c+d)
Error in if (any(df < 0)) stop("non negative value expected in df") :
  missing value where TRUE/FALSE needed

I don't know if the problem are the missing values in my data. If so how 
can I handle them?

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.


Re: [R] as.date - german date format

2008-01-09 Thread John Kane
"Functions to convert between character
representations and objects of class "Date"
representing calendar dates."

 $  xx  :Factor w/ 66 levels

try as.character(xx)


--- Konga <[EMAIL PROTECTED]> wrote:

> 
> Hi,
> 
> I have a data.frame with the following variable:
> $  xx  :Factor w/ 66 levels
> "01.02.2006","01.03.2006",..: 3 3 3 3 3 3 3 3 3
> 
> now I´d like use "as.date" on it - if I comprehend
> the instructions on
>
http://finzi.psych.upenn.edu/R/library/base/html/format.Date.html
> it should work like this:
> 
> as.date(xx, "%d.%m.%Y") - but it doesn´t...
> 
> the survival Package ist loaded - is there a problem
> with the german format?
> Or did I understand something wrong?
> 
> Much better than tranforming the format from to data
> would be to import it
> in the right format.
> Is there a parameter for read.csv to get it as a
> date from the beginning?
> 
> 
> 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/as.date---german-date-format-tp14712654p14712654.html
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

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


[R] formating ftable

2008-01-09 Thread Monica Pisica

Hi all,
 
I am using ftable and xtabs to get total counts of species per location per 
hight category (understory, midstory and overstory). i can save the data in 
almost the format i would like it to be - but not quite. Here it is an example 
of what i get:
 
x - is a dataframe with the following columns: LocationID, Species, 
PercentCover, Category
where Category tells if the Species belongs to understory, midstory or 
overstory 
 
y1 <- ftable(xtabs(PercentCover ~ LocationID + Species + Category, data=x))y2 
<- format(y1, quote = FALSE, sep = “,”)write.table(y2, “test1.csv”, row.names = 
FALSE, col.names = FALSE, sep = “,”)If i read the test1.csv it will look like 
that: Category  
  Midstory Overstory   Understory
LocationID Species
Loc1   A
   0 0 10
   B
   10   20   0
   C
   55   0 10
   ….   
  …   …   …
Loc2   A
   0 0 0
   B
   5 60   0
   C
   35   0 25
   …
  …   …   …
What i would like: (1) eliminate the column (Category) because it is empty 
anyway (i suppose i can create a new data.frame from y2 in which i skip column 
"Category"); (2) have LocationID, Species, Midstory, Overstory, and Understory 
on the same row; (3) have the column LocationIDfilled in between Loc1 and Loc2 
with Loc1 and not an empty string, and so on for each location.Any suggestions 
will be very greatly appreciated, thanks,Monica

_


GLM_CPC_VideoChat_distantfamily_012008
[[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] An "R is slow"-article

2008-01-09 Thread Philippe Grosjean
Jeffrey Horner wrote:
> I hazard to say that the author of that blog post isn't using the time 
> he saved from writing his analyses in C very efficiently. I wonder how 
> long it took him to write it in C in the first place, even to setup the 
> testing of C against R, or to write the blog post.
> 
> He didn't say.
> 
> Jeff

Yes, he did: he said he took the C code out of the fisher.test() R 
function and just did a little bit of tweaking. So, it did not took too 
long to reuse existing C code someone else wrote and debugged, for 
sure... But, as you suggest, what about writing it from scratch in C or 
R, that is the real question, of course!

Philippe

> Armstrong, Whit wrote on 01/09/2008 09:49 AM:
>> fisher.test seems to use the .C calling convention in a couple of
>> different places.
>>
>> for example:
>>
>> tmp <- .C("fisher_sim", as.integer(nr), as.integer(nc), 
>> as.integer(sr), as.integer(sc), as.integer(n), 
>> as.integer(B), integer(nr * nc), double(n + 1), 
>> integer(nc), results = double(B), PACKAGE =
>> "stats")$results
>>
>>
>> perhaps some R experts on the list can tell us whether there is
>> significant overhead to .C vs .Call.
>>
>> Does .C really duplicate its arguments?  What does RObjToCPtr do?
>>
>>
>> (line 1682.. in dotcode.c)
>>
>> /* Convert the arguments for use in foreign */
>> /* function calls.  Note that we copy twice */
>> /* once here, on the way into the call, and */
>> /* once below on the way out. */
>> cargs = (void**)R_alloc(nargs, sizeof(void*));
>> nargs = 0;
>> for(pargs = args ; pargs != R_NilValue; pargs = CDR(pargs)) {
>> #ifdef THROW_REGISTRATION_TYPE_ERROR
>> if(checkTypes &&
>>!comparePrimitiveTypes(checkTypes[nargs], CAR(pargs), dup)) {
>> /* We can loop over all the arguments and report all the
>>
>>erroneous ones, but then we would also want to avoid
>>
>>the conversions.  Also, in the future, we may just
>>
>>attempt to coerce the value to the appropriate
>>
>>type. This is why we pass the checkTypes[nargs] value
>>
>>to RObjToCPtr(). We just have to sort out the ability
>>
>>to return the correct value which is complicated by
>>
>>dup, etc. */
>> errorcall(call, _("Wrong type for argument %d in call to
>> %s"),
>>   nargs+1, symName);
>> }
>> #endif
>> cargs[nargs] = RObjToCPtr(CAR(pargs), naok, dup, nargs + 1,
>>   which, symName, argConverters + nargs,
>>   checkTypes ? checkTypes[nargs] : 0,
>>   encname);
>> #ifdef R_MEMORY_PROFILING
>> if (TRACE(CAR(pargs)) && dup)
>> memtrace_report(CAR(pargs), cargs[nargs]);
>> #endif
>> nargs++;
>> }
>>
>> Thanks,
>> Whit
>>
>>
>>> -Original Message-
>>> From: [EMAIL PROTECTED] 
>>> [mailto:[EMAIL PROTECTED] On Behalf Of Gustaf Rydevik
>>> Sent: Wednesday, January 09, 2008 10:25 AM
>>> To: r-help@r-project.org
>>> Subject: [R] An "R is slow"-article
>>>
>>> Hi all,
>>>
>>> Reading the wikipedia page on R, I stumbled across the following:
>>> http://fluff.info/blog/arch/0172.htm
>>>
>>> It does seem interesting that the C execution is that much 
>>> slower from R than from a native C program. Could any of the 
>>> more technically knowledgeable people explain why this is so?
>>>
>>> The author also have some thought-provoking opinions on R 
>>> being no-good and that you should write everything in C 
>>> instead (mainly because R is slow and too good at graphics, 
>>> encouraging data snooping). See  
>>> http://fluff.info/blog/arch/0041.htm
>>>  While I don't agree (granted, I can't really write C), it 
>>> was interesting to read something from a very different 
>>> perspective than I'm used to.
>>>
>>> Best regards,
>>>
>>> Gustaf
>>>
>>> _
>>> Department of Epidemiology,
>>> Swedish Institute for Infectious Disease Control work email: 
>>> gustaf.rydevik at smi dot ki dot se skype:gustaf_rydevik
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide 
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> This e-mail message is intended only for the named recipient(s) above. It 
>> may contain confidential information. If you are not the intended recipient 
>> you are hereby notified that any dissemination, distribution or copying of 
>> this e-mail and any attachment(s) is strictly prohibited. If you have 
>> received this e-mail in error, please immediately notify the sender by 
>> replying to this e-mail and delete the message and any attachment(s) from 
>> your system. Thank you.
>>
>>
>>
>> -

[R] January 2008 ez Lake & Pond Newsletter

2008-01-09 Thread Great Lakes Bio Systems
Having trouble viewing this message?  Please click
http://www.glb-enzymes.com/cms/index.php?option=com_sm2emailmarketing&task=showarchivemessage&id=27&Itemid=169
.

++Benefits of Aeration in the Lake & Pond Environment

Aeration is one of the most powerful tools for maintaining the
overall health of aquatic environments, including maintaining
water clarity, reducing organic sludge build-up, and supplying high
levels of dissolved oxygen levels for fish & beneficial
bacteria populations alike.  Read more about the benefits of using
aeration with natural technologies at:
http://www.glb-enzymes.com/cms/content/view/175/191/

++See us at the 2008 Northeast Aquatic Plant Management (NEAPMS) Show

See the latest innovations in enzyme, bacteria, & aeration technology
for the Lake & Pond industry at the 2008 Northeast Aquatic
Plant Management Show January 15 - 16, 2008 at the Grand Summit
Resort at Mount Snow in West Dover, Vermont USA.

Planning to go to the show? Stop at our booth and leave a business
card for a chance to win a $50 Visa gift card! Schedule a
meeting with a Great Lakes Bio Systems/MixAir Tech Representative by
clicking here:
http://www.glb-enzymes.com/cms/content/view/148/167/


Do you have a specific issue that you'd like to solve? Complete our
ez Lake & Pond Questionnaire to see if we can help:
http://www.glb-enzymes.com/cms/content/view/147/156/ .

++ez Lake & Pond: A Complete Line of Eco-Friendly Products

Are you or your customers seeking an environmentally friendly
alternative to using chemicals in a natural pond? Are your
customers aware of the alternatives?

ez Lake & Pond Products offer innovative and extremely effective
natural solutions using natural enzymes, bacteria, trace
minerals to solve common pond problems such as sludge (muck), algae,
and water clarity issues. For more information about the
complete ez Lake & Pond product line, visit
http://www.ez-lakeandpond.com.

++MixAir Technologies: The Revolution in Aeration

MixAir Technologies, a sister company to Great Lakes Bio Systems,
manufactures energy efficient fine bubble aeration systems for
the Lake & Pond environment. MixAir Tech diffusers are available in a
variety of designs to accomodate numerous types of
installations. Read more about MixAir Technologies at
http://www.mixairtech.com .

++About Us

Located just outside Milwaukee, WI, Great Lakes Bio Systems
manufactures the most concentrated, non-bacterial broad-spectrum
enzyme products available today.  All formulations are made from
natural ingredients and are readily biodegradable. For more
information on the full ez product line, visit us at
http://www.ez-lakeandpond.com.

To ensure receipt of our e-mails, please add [EMAIL PROTECTED] to
your address book.

++Unsubscribe

This e-mail was sent to: [EMAIL PROTECTED]  We are a
reputable manufacturer of natural technologies. Though we'd hate to
lose you, we
immediately honor all requests to unsubscribe from our list.  Click
here to unsubscribe
http://www.glb-enzymes.com/cms/index.php?option=com_sm2emailmarketing&task=unsubscribe&[EMAIL
 PROTECTED]&code=74432ee7464834f03303a295942b9ab5,
visit our website
http://www.glb-enzymes.com/cms/content/view/138/134/, or you may
contact us at the address below.

Receiving this email from a friend? Sign up for a copy of your own at
http://www.glb-enzymes.com/cms/content/view/138/148/

++Links:

All Lake & Pond Products:
http://www.glb-enzymes.com/cms/content/view/47/75/

Technology: http://www.glb-enzymes.com/cms/content/view/42/99/

Case Studies: http://www.glb-enzymes.com/cms/content/view/70/143/

Login:
http://www.glb-enzymes.com/cms/component/option,com_login/Itemid,147/

Contact Us: http://www.glb-enzymes.com/cms/content/view/60/149/

++Product Lines:

Aquaculture: http://www.ez-aquaculture.com

Cleaners: http://www.ez-cleaners.com

Industrial: http://www.ez-industrial.com

Lake & Pond: http://www.ez-lakeandpond.com

Pool & Spa: http://www.ez-poolandspa.com

(c) 2007 Great Lakes Bio Systems, Inc.

13916 Leetsbir Rd Sturtevant, WI 53177

(262) 884-9377 [EMAIL PROTECTED]

No portion of this newsletter may be reproduced without permission.

[Newsletter ends]


[[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] labels to values

2008-01-09 Thread John Kane
There probably is an easier way but you put the
value.labels and corresponding numbers into a
data.frame, stick d[,'Y6] into  a data frame and merge
the two. Then just add or replace d[,Y6] in the
original data.frame.
Example
# Set up basic data
aa <- 1:15   
bb <- letters[1:15]
# Apply attribute to aa
attr(aa, "value.labels")  <- bb ; aa
# mock dataset 
cc <- data.frame(hhh= sample(aa, 25, replace=TRUE));
cc

# attrubutes and corresponding numberic values
x <- data.frame(jjj=aa, labs=attr(aa,'value.labels'))
;x

# merge 
merge(cc, x, by.x="hhh", by.y="jjj" )

--- Matthias Wendel <[EMAIL PROTECTED]> wrote:

> I couldn't find out how the following to solve:
> There is a column in a data.frame:
> 
> > d[, 'Y6']
>   [1]  6  3  8 11  8  9  6  8  3  5 10 15 NA  9  8 
> 3  8 16  6  6 NA 10  5  2  7  7  6 16  7 15  7 10 12
>  8  7 12 12 16  7  6  8  8
> 15  6  [45] NA  8 99  7 12  8  9 16  7 16  8  7  7 
> 1 15 12  8  7 10  7  8  7  8  9  8  6  6  8  6 16 11
>  5 11 11  1 11  3  7  7 10
> 10 10  6 11  [89] 16 NA  1  3  2 10 99 10  3  3  9 
> 7 16 99 16  1 10  2 13 13 13 13 13 13 13 13 13 13 13
> 13 13 13 13 13 13 NA 10 16
> 16 NA  6 10  5 11 [133] 11  1  1  1  1 16  1 16  1 
> 1  1  1  6  6  6 16  8 16 16 16 16  5  6 10 99 11 11
> 10  6  6  1  1  6  1 11 11
> 16  9 11 16  6  8  8 16 [177] 16  8  6 16 16 12 12
> 12 12 12 12 12 16  9 16 15 12 12 15 10 16 15  4  1 
> 2 14  4  4  2  5 NA  1  5  5
> 7  9  5 12 12 NA 16 12 12 12 [221] 12 12 12 12 12 12
> 99 NA 12 12 NA  1 16  1  7 11  5  6  7  1 13  6  8
> 16  2  1  5 16 16  9  8  8
> 8  7 16  8  8  2  8  5  4  6 14  5 [265] 14  8  8 14
>  4  4  8 14  8 14  6  2  3 14  3 16  5 15 15 15 15
> 15 15 15 15 15 15 15 13 13
> 13 13 13 13 13 13 13 13 13 13 13 15  6 NA [309] 12 
> 3  9  9 NA 10 16
> attr(,"value.labels")
>   Verwaltung
> Servicegesellschaft Waldfriede (SKW)   
> Kurzzeitpflege Waldfriede 
>   16
>   15
>   14 
>Sozialstation
>  Krankenpflegeschule  Med. Technischer
> Dienst 
>   13
>   12
>   11 
>Pflege OP
>  Funktionsdienst   Pflege
> Gynäkologie 
>   10
>9
>8 
> Pflege Chirurgie
>Pflege InnereÄrzte Anästhesie,
> Röntgen 
>7
>6
>5 
>Ärzte Gynäkologie
>  Ärzte Chirurgie Ärzte
> Innere 
>4
>3
>2 
> Patientenberatung/-betreuung 
>1 
> 
> I'd like to have the column with the value.labels as
> values. How do I do that?
> Thanks,
> Matthias
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] An "R is slow"-article

2008-01-09 Thread Michael A. Miller
> "Paul" == Paul Gilbert <[EMAIL PROTECTED]> writes:

> Gustaf Rydevik wrote:

>> The author also have some thought-provoking opinions on R
>> being no-good and that you should write everything in C

> People used to say assembler, that's progress.

>From the FORTRAN Preliminary Report, IBM, November 1954:

  "FORTRAN should virtually eliminate coding and debugging."

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


Re: [R] R help

2008-01-09 Thread John Kane

--- [EMAIL PROTECTED] wrote:

> Is there a number I can call to get started with R? 
> I have some really 
> basic questions that won't take more than 10
> minutes.
> 
> Sitadri

Probably not unless you know an R-user personally or
there's someone at your firm or institution whom you
can corner. :)

There's no problem about asking really basic questions
here although it is a good idea to read some of the
documentation first. It helps make the questions sound
intelligent.

In fact, it is probably better to post the questions
as it allows you to clearify your thinking and it
ususallly is easier to respond to the questions when
one has code right in front of one. 

Whenever possible give a little example of what you're
doing (as requested in the posting guide).   A line of
code is worth 1000 words of description (to
paraphrase) 

I found a very basic but very useful tutorial at
http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html .  

A handy place to find a lot of basic information is in
the R FAQ 7—access from the main R page. Section 7
can often explain some of R's endearing quirks.

Also have a look at the Books and Contributed
documentation links on the main R page.  There is a
lot of excellent information there, including several
short documents that address the new user.

The "Introduction to R" is very useful but I must say
that I started to find it useful after reading some of
the other materials on the site. 




  Looking for the perfect gift? Give the gift of Flickr!

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

2008-01-09 Thread Sitadri_Bagchi
 Folks, Two simple questions :

(1) I have a data set (call it data.xls) in a folder in my hard drive. How 
do I perform a simple regression between two variables from that data set? 
 After I click on 'R', what exactly do I type in?

(2) Where do I get to see the complete library of packages offered by R? 
In particular, I am interested in quantile regression and logistic 
regression.

Thanks.

Sitadri




This e-mail, including attachments, is intended for the person(s) or company 
named and may contain confidential and/or legally privileged information. 
Unauthorized disclosure, copying or use of this information may be unlawful and 
is prohibited. If you are not the intended recipient, please delete this 
message and notify the sender.
All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic 
Message Repository. If you do not wish the retention of potentially private 
e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail 
account for any private, non-business related communications.
[[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] (no subject)

2008-01-09 Thread Sitadri_Bagchi
On 1/9/2008 4:28 PM, [EMAIL PROTECTED] wrote:
> I have a couple of simple questions. 
> 
> (a) Suppose that I have an Excel dataset stored in a file called 
> dataset.xls located in some folder in my hard drive.  Suppose that it 
has 
> two columns called  X  and  Y  of equal length.  After I click on R and 
> have the page that says 'type help() for...', how do I instruct to 
perform 
> a simple linear regression of  Y  on  X?  Can you give me a step-by-step 

> procedure?
> 
> (b) What do I type in to view a full listing of the packages offered by 
R? 
>  In particular, I am interested in logistic regression and quantile 
> regression.
> 
> One of the problems I am having is to figure out how to access the data 
> set.
> 
> Thanks.
> 
> Sitadri
> 




This e-mail, including attachments, is intended for the person(s) or company 
named and may contain confidential and/or legally privileged information. 
Unauthorized disclosure, copying or use of this information may be unlawful and 
is prohibited. If you are not the intended recipient, please delete this 
message and notify the sender.
All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic 
Message Repository. If you do not wish the retention of potentially private 
e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail 
account for any private, non-business related communications.
[[alternative HTML version deleted]]

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


Re: [R] help with R

2008-01-09 Thread Wensui Liu
1) there are many ways to read data from excel into R, such as rodbc package.
2) check cran, or do a r search.

On Jan 9, 2008 4:35 PM,  <[EMAIL PROTECTED]> wrote:
>  Folks, Two simple questions :
>
> (1) I have a data set (call it data.xls) in a folder in my hard drive. How
> do I perform a simple regression between two variables from that data set?
>  After I click on 'R', what exactly do I type in?
>
> (2) Where do I get to see the complete library of packages offered by R?
> In particular, I am interested in quantile regression and logistic
> regression.
>
> Thanks.
>
>Sitadri
>
>
>
>
> This e-mail, including attachments, is intended for the person(s) or company 
> named and may contain confidential and/or legally privileged information. 
> Unauthorized disclosure, copying or use of this information may be unlawful 
> and is prohibited. If you are not the intended recipient, please delete this 
> message and notify the sender.
> All incoming and outgoing e-mail messages are stored in the Swiss Re 
> Electronic Message Repository. If you do not wish the retention of 
> potentially private e-mails by Swiss Re, we strongly advise you not to use 
> the Swiss Re e-mail account for any private, non-business related 
> communications.
>[[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.
>



-- 
===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question about putting multiple plots on the same page

2008-01-09 Thread FD
Hi,

I met a problem when trying to put multiple plots on the same page. I have a
plotting function (e.g., myfunction()) that contains the lines of par(),
layout(). Now I want to try four types of parameter combinations and  put
these four figures on the same page. I tried par(mfrow or mfcol) and layout
but no go. It seems split.screen is the right choice for me. But I always
got the error message "Error in plot.new() : figure margins too large".  I
don't really want to change the margin settings in myfunction() since it
involves lots of modifications.  Are there any easier ways to split window
and also automatically adjust the margins (and other plotting settings)?
Thanks a lot.

FD

[[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] Course*** R/S-Plus Advanced Programming ****by XLSolutions Corp

2008-01-09 Thread [EMAIL PROTECTED]

   Happy New Year
   Our *** San Francisco *** R/Splus Advanced Programming is scheduled for
   January 24-25,
   2008
   Please email for earlybird rates: Payments due after the class.
   R/Splus Advanced Programming Course Outline:
   Day 1
   - Overview of R/S fundamentals: Syntax and Semantics
   - Class and Inheritance
   - Concepts, Construction and good use of Language Objects
   - Coercion and Efficiency
   - Object-oriented Programming in R and S-Plus
   - Taking advantage of fast objects and fast functions
   - Advanced Manipulation tools: Parse, Deparse, Substitute, etc.
   - How to fully take advantage of Vectorization
   - Generic and Method Functions
   - Search path, Databases and Frames Visibility (S-plus)
   Day 2
   - Working with Large Objects
   - Handling Properly Recursion and Iterative Calculations
   - Managing loops; For (S-Plus) and for() loops
   - Consequences of Lazy Evaluation
   - Efficient Code Practices for Large Computations
   - Memory Management and Resource Monitoring
   - Writing R and S-plus Functions to call Compiled Code
   - Writing and Debugging Compiled Code for S-plus and R system
   - Connecting R to External Data Sources
   - Macros in R
   - Understanding the Structure of Model fitting Functions in R and
   S-plus
   - Designing and Packaging Efficiently a new model Function
   Payment due AFTER the class
   Email us for group discounts.
   Email Sue Turner: [EMAIL PROTECTED]
   Phone: 206-686-1578
   Visit us: [2]www.xlsolutions-corp.com/courselist.htm
   Please let us know if you and your colleagues are interested in this
   class to take advantage of group discount.
   Register now to secure your seat!
   Cheers,
   Elvis Miller, PhD
   Manager Training.
   XLSolutions C orporation
   206 686 1578
   [3]www.xlsolutions-corp.com

References

   1. file://localhost/tmp/tmpxwgWPu.html#Compose
   2. http://www.xlsolutions-corp.com/courselist.htm
   3. http://www.xlsolutions-corp.com/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help with R

2008-01-09 Thread Roland Rau
Hi,

please have a look at the posting guide (link is at the bottom of your 
message). Most (if not all) of your problems should be solved if you 
follow the advice given there.
Anyway, please have a look below:

[EMAIL PROTECTED] wrote:
>  Folks, Two simple questions :
> 
> (1) I have a data set (call it data.xls) in a folder in my hard drive. How 
> do I perform a simple regression between two variables from that data set? 
>  After I click on 'R', what exactly do I type in?

1.1 getting excel data into R
- please read the manual R Data Import/Export shipped with your R 
distribution or browse online, for example, at 
http://cran.r-project.org/doc/manuals/R-data.html in particular 
http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets
- I prefer to use rather CSV files which can be easily read by R using 
read.table()
1.2 simple regression
- function lm() is your friend
- furthermore have a look at "An Introduction to R", in particular 
Section 11.2 
http://cran.r-project.org/doc/manuals/R-intro.html#Linear-models

Maybe this code gets you started (not tested, modify according to your 
application):
mydata <- read.table("C:\\mypath\\tomyfile\\data.csv", header=TRUE, sep=",")
mymodel1 <- lm(mydata$Y ~ mydata$X)
mymodel1
summary(mymodel1)



> 
> (2) Where do I get to see the complete library of packages offered by R? 
One possibility is http://stat.ethz.ch/CRAN/src/contrib/PACKAGES.html


> In particular, I am interested in quantile regression and logistic 
> regression.
- There is a package called quantreg written by Roger Koenker.
- Logistic regression: check the function glm()

Hope this helps you to get started,
Roland



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

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


Re: [R] help with R

2008-01-09 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote:
>  Folks, Two simple questions :
>
> (1) I have a data set (call it data.xls) in a folder in my hard drive. How 
> do I perform a simple regression between two variables from that data set? 
>  After I click on 'R', what exactly do I type in?
>
>   
Ideally, you shouldn't really start from there (because transfer of data 
between different applications is not for beginners --  it is better to 
have your data in a text file with a well-defined format), but let's try:

a) Open the spreadsheet. Make sure that the 1st element of each column 
has the name of the variable. Let us assume that the 2 relevant ones are 
called "x" and "y".  Highlight the relevant region and copy to clipboard.

b) In R type

mydata <- read.delim2("clipboard")
names(y)
plot(y~x, data=mydata)
summary(lm(y~x, data=mydata))

This assumes that you are using a German locale (comma is decimal 
separator), otherwise use read.delim("clipboard").


> (2) Where do I get to see the complete library of packages offered by R? 
> In particular, I am interested in quantile regression and logistic 
> regression.
>
> Thanks.
>
> Sitadri
>
>   


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

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

2008-01-09 Thread AndyZon

Hi,

I have a huge number of categorical variables, say at least 1, and I put
them into a matrix, each column is one variable. The question is: how can I
make all of the pairwise cross tabulation tables efficiently? The
straightforward solution is to use for-loops by looping two indexes on the
table() function, but it was just too slow. Is there a more efficient way to
do that? Any guidance will be greatly appreciated.

Andy 
-- 
View this message in context: 
http://www.nabble.com/pairwise-cross-tabulation-tables-tp14723520p14723520.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] help with R

2008-01-09 Thread John Sorkin
Sitadri,
What operating system are you using? Have you loaded R onto you computer? If 
not I suggest you do so. You can than enter the command
?lm
which will give you information about lm command, the command used to perform 
linear regresssion. I would also suggest that you go to
http://cran.r-project.org/doc/manuals/R-intro.html
and do some reading of the introduction document. Once you have done this you 
should be able to get started using R and will be able to ask a question that 
we can more easily answer.
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
>>> <[EMAIL PROTECTED]> 01/09/08 4:35 PM >>>
 Folks, Two simple questions :

(1) I have a data set (call it data.xls) in a folder in my hard drive. How 
do I perform a simple regression between two variables from that data set? 
 After I click on 'R', what exactly do I type in?

(2) Where do I get to see the complete library of packages offered by R? 
In particular, I am interested in quantile regression and logistic 
regression.

Thanks.

Sitadri




This e-mail, including attachments, is intended for the person(s) or company 
named and may contain confidential and/or legally privileged information. 
Unauthorized disclosure, copying or use of this information may be unlawful and 
is prohibited. If you are not the intended recipient, please delete this 
message and notify the sender.
All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic 
Message Repository. If you do not wish the retention of potentially private 
e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail 
account for any private, non-business related communications.
[[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.

Confidentiality Statement:
This email message, including any attachments, is for th...{{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.


[R] Subsetting Method [ Revisited

2008-01-09 Thread Gregory Wall

Hello Everyone:

As usual, thanks in advance for any help. 

I was hoping to get some more advice on this question:

I'm trying to write a subsetting routine for an S3 object I've created --
lets call it myObject. 

myObject has a few attributes basically of type string and numerics. Its
atomic value is just a vector of ints.

I want to write my own subsetting routine to subset myObject in an
unconventional way.

So my method looks like this:

"[.myObject" <- function( obj, i, j, ...){

. parameter checking and calculations

print("Test")

}

If I call this method in an R session I get the following results:

obj <- "an instance of a myObject"

obj[]

OUTPUT:
Test
Test

Error: index of length zero.

I'm not sure how to prevent it from printing twice. I don't understand why
"print.default() is returning what it was asked to print, which then gets
printed again automatically" as was mentioned in a previous thread. 

Does the solution involve creating a child class as mentioned here:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77057.html

I'm having a difficult time following the execution steps for this R code:

obj[] 

Again, thanks very much for any suggestions.

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


Re: [R] help with R

2008-01-09 Thread John Sorkin
Sitadri,
I would also look at
http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html
a site that was pointed out in a recent posting to the listserve by John Kane.

John

Sitadri,
What operating system are you using? Have you loaded R onto you computer? If 
not I suggest you do so. You can than enter the command
?lm
which will give you information about lm command, the command used to perform 
linear regresssion. I would also suggest that you go to
http://cran.r-project.org/doc/manuals/R-intro.html
and do some reading of the introduction document. Once you have done this you 
should be able to get started using R and will be able to ask a question that 
we can more easily answer.
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
>>> <[EMAIL PROTECTED]> 01/09/08 4:35 PM >>>
 Folks, Two simple questions :

(1) I have a data set (call it data.xls) in a folder in my hard drive. How 
do I perform a simple regression between two variables from that data set? 
 After I click on 'R', what exactly do I type in?

(2) Where do I get to see the complete library of packages offered by R? 
In particular, I am interested in quantile regression and logistic 
regression.

Thanks.

Sitadri




This e-mail, including attachments, is intended for the person(s) or company 
named and may contain confidential and/or legally privileged information. 
Unauthorized disclosure, copying or use of this information may be unlawful and 
is prohibited. If you are not the intended recipient, please delete this 
message and notify the sender.
All incoming and outgoing e-mail messages are stored in the Swiss Re Electronic 
Message Repository. If you do not wish the retention of potentially private 
e-mails by Swiss Re, we strongly advise you not to use the Swiss Re e-mail 
account for any private, non-business related communications.
[[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.

Confidentiality Statement:
This email message, including any attachments, is for th...{{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.


[R] general linear hypothesis glht() to work with lme()

2008-01-09 Thread array chip
Hi,

I am trying to test some contrasts, using glht() in
multcomp package on fixed effects in a linear mixed
model fitted with lme() in nlme package. The command I
used is:

   ## a simple randomized block design, 
   ## type is fixed effect
   ## batch is random effect
   ## model with interaction
dat.lme<-lme(info.index~type, random=~1|batch/type,
data=dat)
glht(dat.lme, linfct = mcp(type =c("b+t-2*m=0")))

The lme model fit is ok, but I got an error message
with glht():
Error in eval(expr, envir, enclos) : object
"info.index" not found
Error in factor_contrasts(model) : no 'model.matrix'
method for 'model' found!

according to help page of glht(), it should work with
linear mixed model, what is the problem here?

Thanks



  

Be a better friend, newshound, and

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question about putting multiple plots on the same page

2008-01-09 Thread jim holtman
You need to provide commented, minimal, self-contained, reproducible
code.  The following code works fine for me:

> par(mfrow=c(2,2))
> plot(0)
> plot(1)
> plot(2)
> plot(3)
>

But I have no idea of how you are trying to use it, what operating
system you have, what type of device you are going out to, what your
margins are, etc.

On Jan 9, 2008 4:52 PM, FD <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I met a problem when trying to put multiple plots on the same page. I have a
> plotting function (e.g., myfunction()) that contains the lines of par(),
> layout(). Now I want to try four types of parameter combinations and  put
> these four figures on the same page. I tried par(mfrow or mfcol) and layout
> but no go. It seems split.screen is the right choice for me. But I always
> got the error message "Error in plot.new() : figure margins too large".  I
> don't really want to change the margin settings in myfunction() since it
> involves lots of modifications.  Are there any easier ways to split window
> and also automatically adjust the margins (and other plotting settings)?
> Thanks a lot.
>
> FD
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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

2008-01-09 Thread Charles C. Berry
On Wed, 9 Jan 2008, AndyZon wrote:

>
> Hi,
>
> I have a huge number of categorical variables, say at least 1, and I put
> them into a matrix, each column is one variable. The question is: how can I
> make all of the pairwise cross tabulation tables efficiently? The
> straightforward solution is to use for-loops by looping two indexes on the
> table() function, but it was just too slow. Is there a more efficient way to
> do that? Any guidance will be greatly appreciated.

The totals are merely the crossproducts of a suitably constructed binary 
(zero-one) matrix is used to encode the categories. See '?contr.treatment' 
if you cannot grok 'suitably constructed'.

If the categories are all dichotomies coded as 0:1, you can use

res <- crossprod( dat )

to find the totals for the (1,1) cells

If you need the full tables, you can get them from the marginal totals 
using

diag( res )

to get the number in each '1' margin and

nrow(dat)

to get the table total from which the numbers in each '0' margin by 
subtracting the corresponding '1' margin.

With dichotomous variables, dat has 1 columns and you will only need 
1^2 integers or about 0.75 Gigabytes to store the 'res'. And it takes 
about 20 seconds to run 1000 rows on my MacBook. Of course, 'res' has a 
redundant triangle

This approach generalizes to any number of categories:

To extend this to more than two categories, you will need to do for each 
such column what model.matrix(~factor( dat[,i] ) ) does by default
( using 'contr.treatment' ) - construct zero-one codes for all but one 
(reference) category.

Note that with 1 trichotomies, you will have a result with

1^2 * ( 3-1 )^2

integers needing about 3 Gigabytes, and so on.

HTH,

Chuck

p.s. Why on Earth are you doing this


>
> Andy
> -- 
> View this message in context: 
> http://www.nabble.com/pairwise-cross-tabulation-tables-tp14723520p14723520.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.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2008-01-09 Thread Steven McKinney

print("Test") appears to be the last
line of your "[.myObject" function,
so its value will be returned by the function.  
This may not be what you want.

Presumably you want some subset of
the input object returned, so put that
below the 
print("Test")
line.

You could use the invisible() function
to wrap the print, or put it after
while you are developing and debugging your
extractor function.

Try

print("Test")
invisible()

or

invisible(print("Test"))

if these need to be at the end of your extractor.



Steven McKinney


-Original Message-
From: [EMAIL PROTECTED] on behalf of Gregory Wall
Sent: Wed 1/9/2008 3:59 PM
To: r-help@r-project.org
Subject: [R] Subsetting Method [ Revisited
 

Hello Everyone:

As usual, thanks in advance for any help. 

I was hoping to get some more advice on this question:

I'm trying to write a subsetting routine for an S3 object I've created --
lets call it myObject. 

myObject has a few attributes basically of type string and numerics. Its
atomic value is just a vector of ints.

I want to write my own subsetting routine to subset myObject in an
unconventional way.

So my method looks like this:

"[.myObject" <- function( obj, i, j, ...){

. parameter checking and calculations

print("Test")

}

If I call this method in an R session I get the following results:

obj <- "an instance of a myObject"

obj[]

OUTPUT:
Test
Test

Error: index of length zero.

I'm not sure how to prevent it from printing twice. I don't understand why
"print.default() is returning what it was asked to print, which then gets
printed again automatically" as was mentioned in a previous thread. 

Does the solution involve creating a child class as mentioned here:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77057.html

I'm having a difficult time following the execution steps for this R code:

obj[] 

Again, thanks very much for any suggestions.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] question on how to extract values from atomic vector

2008-01-09 Thread Jack Luo
Dear List,

I have an atomic vector named "Results"

Results
[1] 1 1 1
attr(,"prob")
[1] 0.667 1.000 1.000
Levels: 0 1

when I type

attributes(Results)
$levels
[1] "0" "1"

$class
[1] "factor"

$prob
[1] 0.667 1.000 1.000

However, when I type
Results$prob

It has the following warning message:

NULL
Warning message:
In Results$prob : $ operator is invalid for atomic vectors, returning NULL

I've been doing some search and seems that this question was asked by
someone before and I can not seem to find a solution to extract the value
from the atomic vector, could somebody help me with this?

Thanks a lot!

Jack

[[alternative HTML version deleted]]

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


[R] how can i add a package that i want to use permanent

2008-01-09 Thread 文波胡
I want use a package(lattice) in R to do some work
but everytime when i open R program  ,this package is not loaded,
so  everytime  i have to load it ,
who can tell me  how to load this package permanent

thanks!!!
-- 
ºúÎIJ¨
TEL:15918732631
E-MAIL:[EMAIL PROTECTED]
[EMAIL PROTECTED]

[[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] question on how to extract values from atomic vector

2008-01-09 Thread jim holtman
There are a couple of ways of getting the values:

> x <- cbind(a=1:3, pi=pi) # simple matrix w/ dimnames
> attributes(x)
$dim
[1] 3 2

$dimnames
$dimnames[[1]]
NULL

$dimnames[[2]]
[1] "a"  "pi"


> attributes(x)$dim
[1] 3 2
> attr(x, 'dim')
[1] 3 2
>

So in your case,

attr(Results, 'prob')

or

attributes(Results)$prob



On Jan 9, 2008 10:12 PM, Jack Luo <[EMAIL PROTECTED]> wrote:
> Dear List,
>
> I have an atomic vector named "Results"
>
> Results
> [1] 1 1 1
> attr(,"prob")
> [1] 0.667 1.000 1.000
> Levels: 0 1
>
> when I type
>
> attributes(Results)
> $levels
> [1] "0" "1"
>
> $class
> [1] "factor"
>
> $prob
> [1] 0.667 1.000 1.000
>
> However, when I type
> Results$prob
>
> It has the following warning message:
>
> NULL
> Warning message:
> In Results$prob : $ operator is invalid for atomic vectors, returning NULL
>
> I've been doing some search and seems that this question was asked by
> someone before and I can not seem to find a solution to extract the value
> from the atomic vector, could somebody help me with this?
>
> Thanks a lot!
>
> Jack
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 can i add a package that i want to use permanent

2008-01-09 Thread jim holtman
?Startup

On Jan 9, 2008 10:28 PM, 文波胡 <[EMAIL PROTECTED]> wrote:
> I want use a package(lattice) in R to do some work
> but everytime when i open R program  ,this package is not loaded,
> so  everytime  i have to load it ,
> who can tell me  how to load this package permanent
>
> thanks!!!
> --
> ºúÎIJ¨
> TEL:15918732631
> E-MAIL:[EMAIL PROTECTED]
>[EMAIL PROTECTED]
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



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

What is the problem you are trying to solve?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question about putting multiple plots on the same page

2008-01-09 Thread FD
Jim:

Thanks for your response. Here is an example I took from graphics gallery (
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=2 ). Now I
want to place 4 plots into the same page (e.g., one for swiss, one for usa,
and so on) by running the author's function plotacpclust() 4 times. I tried
par(mfrow=c(2,2) or layout(matrix(1,2,3,4), 2, 2) but none of them works.
When I used split.screen(), I always got the error message "Error in
plot.new() : figure margins too large".  Any ideas?

Thanks.

FD


On 1/9/08, jim holtman <[EMAIL PROTECTED]> wrote:
>
> You need to provide commented, minimal, self-contained, reproducible
> code.  The following code works fine for me:
>
> > par(mfrow=c(2,2))
> > plot(0)
> > plot(1)
> > plot(2)
> > plot(3)
> >
>
> But I have no idea of how you are trying to use it, what operating
> system you have, what type of device you are going out to, what your
> margins are, etc.
>
> On Jan 9, 2008 4:52 PM, FD <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I met a problem when trying to put multiple plots on the same page. I
> have a
> > plotting function (e.g., myfunction()) that contains the lines of par(),
> > layout(). Now I want to try four types of parameter combinations
> and  put
> > these four figures on the same page. I tried par(mfrow or mfcol) and
> layout
> > but no go. It seems split.screen is the right choice for me. But I
> always
> > got the error message "Error in plot.new() : figure margins too
> large".  I
> > don't really want to change the margin settings in myfunction() since it
> > involves lots of modifications.  Are there any easier ways to split
> window
> > and also automatically adjust the margins (and other plotting settings)?
> > Thanks a lot.
> >
> > FD
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve?
>

[[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] diff in a dataframe

2008-01-09 Thread Vishal Belsare
I have a dataframe say:

date   price_g   price_s
 0.340.56
 0.360.76
   .  .
   .  .
   .  .

and so on. say, 1000 rows.

Is it possible to add two columns to this dataframe, by computing say
diff(log(price_g) and diff(log(price_s)) ?

The elements in the first row of these columns cannot be computed, but
can I coerce this to happen and assign a missing value there? It would
be really great if I could do that, because in this case I don't have
to re-index my transformed series to the dates again in a new
dataframe.

Thanks in anticipation.


Vishal Belsare

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

2008-01-09 Thread Konga


Thanks a lot, it works!

Now I have to find out why - but I think I can/should do it on my own ;o)


-- 
View this message in context: 
http://www.nabble.com/as.date---german-date-format-tp14712654p14728914.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.