[R] Error RODBC: Random termination of R

2008-02-15 Thread Ulrich Leopold
Dear list,

I get random terminations of R-2.6.2 when using RODBC-1.2_3 and a remote
PostgreSQL-8.2.6 database, unixodbc-2.2.11-16,
odbc-postgresql-1:08.01.0200-2.1 on Ubuntu Linux 7.10.

The exact messages can be seen below. It seems that there is some memory
corruption going on. But it seems random to me and can neither be related to
addPK=T/F or fast=T/F. It happens for all possible combinations. Besides I do
not really understand what these messages mean.

Any idea to what it might be related exactly?

Thanks in advance,
Ulrich Leopold

Session details:

>sessionInfo()
R version 2.6.2 (2008-02-08)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] RODBC_1.2-3

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17

> library(RODBC)
> channel = odbcConnect("crtedb", uid = "uleopold")
> channel
RODB Connection 1
Details:
  case=tolower
  DSN=crtedb
  DATABASE=valid
  SERVER=10.3.1.91
  PORT=5432
  SSLMODE=prefer
  UID=uleopold
  PWD=**
  ReadOnly=Yes
  FakeOidIndex=No
  ShowOidColumn=No
  RowVersioning=No
  ShowSystemTables=No
  ConnSettings=
  Fetch=100
  Socket=8192
  UnknownSizes=0
  MaxVarcharSize=254
  MaxLongVarcharSize=8190
  Debug=0
  CommLog=0
  Optimizer=1
  Ksqo=1
  UseDeclareFetch=0
  TextAsLongVarchar=1
  UnknownsAsLongVarchar=0
  BoolsAsChar=1
  Parse=0
  CancelAsFreeStmt=0
  ExtraSysTablePrefixes=dd_

  LFConversion=0
  UpdatableCursors=0
  DisallowPremature=0
  TrueIsMinus1=0
  BI=0
  ByteaAsLongVarBinary=0
  UseServerSidePrepare=0
  LowerCaseIdentifier=0

> sqlDrop(channel, "clx_test")
character(0)
> sqlSave(channel, clx_test, varTypes=varspec, addPK=TRUE, fast=TRUE) >
odbcClose(channel)
*** glibc detected *** /usr/lib/R/bin/exec/R: corrupted double-linked list:
0x082dd498 ***
=== Backtrace: =
/lib/tls/i686/cmov/libc.so.6[0xb7b8c3f9]
/lib/tls/i686/cmov/libc.so.6[0xb7b8db6e]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7b91800]
/usr/lib/R/lib/libR.so(R_chk_free+0x21)[0xb7d687c1]
/usr/local/lib/R/site-library/RODBC/libs/RODBC.so[0xb742db8d]
/usr/local/lib/R/site-library/RODBC/libs/RODBC.so(RODBCClose+0x2a)[0xb742dd5a]
/usr/lib/R/lib/libR.so[0xb7d13ea2]
/usr/lib/R/lib/libR.so(Rf_eval+0x707)[0xb7d406a7]
/usr/lib/R/lib/libR.so[0xb7d43037]
/usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4]
/usr/lib/R/lib/libR.so[0xb7d41967]
/usr/lib/R/lib/libR.so(Rf_eval+0x444)[0xb7d403e4]
/usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0xb7d439b7]
/usr/lib/R/lib/libR.so(Rf_eval+0x2e2)[0xb7d40282]
/usr/lib/R/lib/libR.so(Rf_ReplIteration+0x19b)[0xb7d6632b]
/usr/lib/R/lib/libR.so(run_Rmainloop+0x107)[0xb7d666f7]
/usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0xb7d6674c]
/usr/lib/R/bin/exec/R(main+0x46)[0x8048776]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7b3a050]
/usr/lib/R/bin/exec/R[0x8048691]
=== Memory map: 
08048000-08049000 r-xp  08:03 422045 /usr/lib/R/bin/exec/R
08049000-0804a000 rw-p  08:03 422045 /usr/lib/R/bin/exec/R
0804a000-09941000 rw-p 0804a000 00:00 0  [heap]
a770-a7721000 rw-p a770 00:00 0
a7721000-a780 ---p a7721000 00:00 0
a78ef000-a793e000 r-xp  08:03 259109 /usr/lib/libgcrypt.so.11.2.3
a793e000-a794 rw-p 0004e000 08:03 259109 /usr/lib/libgcrypt.so.11.2.3
a794-a7943000 r-xp  08:03 259082
/usr/lib/libgpg-error.so.0.3.0 a7943000-a7944000 rw-p 2000 08:03 259082   
 /usr/lib/libgpg-error.so.0.3.0 a7944000-a7953000 r-xp  08:03 266851  
  /usr/lib/libtasn1.so.3.0.9 a7953000-a7954000 rw-p e000 08:03 266851
/usr/lib/libtasn1.so.3.0.9 a7954000-a79be000 r-xp  08:03 730108
/usr/lib/libgnutls.so.13.3.0 a79be000-a79c4000 rw-p 0006a000 08:03 730108
/usr/lib/libgnutls.so.13.3.0 a79c4000-a79da000 r-xp  08:03 732700
/usr/lib/libsasl2.so.2.0.22 a79da000-a79db000 rw-p 00015000 08:03 732700
/usr/lib/libsasl2.so.2.0.22 a79db000-a79e6000 r-xp  08:03 732704
/usr/lib/liblber.so.2.0.130 a79e6000-a79e7000 rw-p b000 08:03 732704
/usr/lib/liblber.so.2.0.130 a79e7000-a79f6000 r-xp  08:03 712558
/lib/tls/i686/cmov/libresolv-2.6.1.so
a79f6000-a79f8000 rw-p f000 08:03 712558
/lib/tls/i686/cmov/libresolv-2.6.1.so
a79f8000-a79fa000 rw-p a79f8000 00:00 0
a79fa000-a7a01000 r-xp  08:03 259121
/usr/lib/libkrb5support.so.0.1 a7a01000-a7a02000 rw-p 6000 08:03 259121   
 /usr/lib/libkrb5support.so.0.1 a7a02000-a7a26000 r-xp  08:03 259108  
  /usr/lib/libk5crypto.so.3.1 a7a26000-a7a27000 rw-p 00024000 08:03 259108
/usr/lib/libk5crypto.so.3.1 a7a27000-a7a5b000 r-xp  08:03 732705
/usr/lib/libldap_r.so.2.0.130 a7a5b000-a7a5c000 rw-p 00034000 08:03 732705
/usr/lib/libld

[R] Wavelets density estimation

2008-02-15 Thread excalibur

Hello,
i have a set of data X_1,...,X_n of an unknown density function f.

I want to estimate the density function f with wavelets.

Can I do this with the package wavethresh ? How ?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Wavelets-density-estimation-tp15496157p15496157.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to estimate the parameters of differential equations from data

2008-02-15 Thread Jannik Vindeloev
Hello list

I have a theoretical differential equation model (two coupled differential
equations) describing the acidification of dairy cultures in milk:

dX/dt = f(H, param)*X
dH/dt = g(param)*dX/dt

pH = -log10(H)

I also have actual data of the same.

I would like to estimate the parameters of the theoretical model from real
data, but don't know how to go about it in R (I'm fairly new to R). Is
there an R-package for this purpose?

Any help from the list is highly appreciated.

Thank you

Jannik Vindeløv, Ph.D.
Project Manager
Dairy Culture Development
Innovation

P.O. Box 64
Arpajon
Cedex
F-91292
France

Phone: +33 (0)1 6988 3636
Direct Phone: +33 (0)1 6988 3629
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with heatmap.2

2008-02-15 Thread Ng Stanley
Hi,

> temp1[1:6,]
_XXX BB_XXX C_XXX D_XXX  E_XXX SkHep1_XXX
500.75285 0.30630  0.56330  0.45755  0.496650.74685
630.35930-0.22725  0.04725  0.53955  0.563900.51170
69   -1.57515-1.67610 -1.61695 -1.11685 -0.00085   -1.89155
910.84640 0.43595  0.62350  0.46645  0.094301.03985
136   0.42050 0.42340  0.61730  0.13950 -0.576000.82470
137   0.40290 0.35105  0.52040  0.00340  0.152350.35650

> heatmap.2(temp1[1:6,])
Error in heatmap.2(temp1[1:6, ]) : `x' must be a numeric matrix

What causes the error, and how to resolve ?

[[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 on using try() to catch an error

2008-02-15 Thread Prof Brian Ripley
Neither of reduced_model not full_model will ever be NULL.  If this 
fails, they inherit from class "try-error".  See ?try.

So you want

inherits(reduced_model, "try-error") || inherits(full_model, "try-error")


On Thu, 14 Feb 2008, Juliet Hannah wrote:

> Dear R Users,
>
> I have the following glm, which I am running several times in a loop
> (I am not including the full code):
>
> reduced_model <- NULL;
> full_model <- NULL;
> reduced_model <- try(glm.fit(X4,n,family=poisson(link="log")))
> full_model <- try(glm.fit(X5,n,family=poisson(link="log")));
>
> On some occasions, an error is produced, which is why I have attempted
> to work around this with try().
>
> I then have the following statement, which checks if full_model or
> reduced_model are still NULL.
>
> if (is.null(reduced_model) || is.null(full_model)) p <- NA else p <-
> pchisq(reduced_model$deviance - full_model$deviance,
> reduced_model$df.residual - full_model$df.residual, lower.tail=
> FALSE);
>
> This is not solving my problem meaning my program still stops and
> gives me the following error:
>
> Error in ifelse(y == 0, 1, y/mu) : dim<- : dims [product 9] do not
> match the length of object [18]
> Error in pmatrix[perm, ] <- apply(pairs.subset, 1, getLRTp2) :
>nothing to replace with
>
>
> Can you help me figure out what I have done incorrectly?
>
> Thanks for your time,
>
> Juliet
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] How to estimate the parameters of differential equations fromdata

2008-02-15 Thread Frede Aakmann Tøgersen


Try the odesolve package or the nlmeODE package which builds on odesolve.


Best regards

Frede Aakmann Tøgersen
Scientist


UNIVERSITY OF AARHUS
Faculty of Agricultural Sciences
Dept. of Genetics and Biotechnology
Blichers Allé 20, P.O. BOX 50
DK-8830 Tjele

Phone:   +45 8999 1900
Direct:  +45 8999 1878

E-mail:  [EMAIL PROTECTED]
Web:   http://www.agrsci.org

This email may contain information that is confidential.
Any use or publication of this email without written permission from Faculty of 
Agricultural Sciences is not allowed.
If you are not the intended recipient, please notify Faculty of Agricultural 
Sciences immediately and delete this email.

 

> -Oprindelig meddelelse-
> Fra: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] På vegne af Jannik Vindeloev
> Sendt: 15. februar 2008 09:34
> Til: r-help@r-project.org
> Emne: [R] How to estimate the parameters of differential 
> equations fromdata
> 
> Hello list
> 
> I have a theoretical differential equation model (two coupled 
> differential
> equations) describing the acidification of dairy cultures in milk:
> 
> dX/dt = f(H, param)*X
> dH/dt = g(param)*dX/dt
> 
> pH = -log10(H)
> 
> I also have actual data of the same.
> 
> I would like to estimate the parameters of the theoretical 
> model from real data, but don't know how to go about it in R 
> (I'm fairly new to R). Is there an R-package for this purpose?
> 
> Any help from the list is highly appreciated.
> 
> Thank you
> 
> Jannik Vindeløv, Ph.D.
> Project Manager
> Dairy Culture Development
> Innovation
> 
> P.O. Box 64
> Arpajon
> Cedex
> F-91292
> France
> 
> Phone: +33 (0)1 6988 3636
> Direct Phone: +33 (0)1 6988 3629
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] finding source for a function

2008-02-15 Thread Uwe Ligges
Or just read the article

  Ligges, U. (2006): R Help Desk: Accessing the Sources. R News 6 (4), 
43-45. http://cran.r-project.org/doc/Rnews/

which was written particularly for answering this kind of questions.

Best,
Uwe Ligges


Gabor Csardi wrote:
> RSiteSearch is your friend. E.g.:
> 
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/63365.html
> 
> and then click on 'Next in thread a couple of times
> 
> Gabor
> 
> On Thu, Feb 14, 2008 at 03:23:30PM -0600, Edna Bell wrote:
>> Dear R Gurus:
>>
>> How do you get source for functions which say "UseMethod" when you
>> type in their names, please?
>>
>> I've tried getAnywhere and getMethods...I thought that might produce them.
>>
>> Thanks in advance.
>>
>> Sincerely,
>> Edna
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] storing ggplot objects as components of a vector

2008-02-15 Thread Gallego Liberman, Matias
Hi.
 
I have a lot of plots that i need to store as components of a vector.
Here you have an example
 
> DF<-data.frame(A=rnorm(12),B=c(1:12),C=rep(c(1:4),each=3))
> Q<-c()
> length(Q)<-3
> PAC<-geom_point(mapping=aes(x=A,y=B),data=DF[DF$C==1,])
> P<-ggplot()+PAC
> P #generates the plot
> Q[1]<-P
Warning message:
In Q[1] <- P :
  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo
> Q[1]
[[1]]
NULL
 
 
I guess the problem is the class of Q[1]. 
if so, what class should I coerce Q to for the sentence: > Q[1] to generate the 
plot as > P does?
 
thanks in advance

[[alternative HTML version deleted]]

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


Re: [R] problem with heatmap.2

2008-02-15 Thread Uwe Ligges


Ng Stanley wrote:
> Hi,
> 
>> temp1[1:6,]
> _XXX BB_XXX C_XXX D_XXX  E_XXX SkHep1_XXX
> 500.75285 0.30630  0.56330  0.45755  0.496650.74685
> 630.35930-0.22725  0.04725  0.53955  0.563900.51170
> 69   -1.57515-1.67610 -1.61695 -1.11685 -0.00085   -1.89155
> 910.84640 0.43595  0.62350  0.46645  0.094301.03985
> 136   0.42050 0.42340  0.61730  0.13950 -0.576000.82470
> 137   0.40290 0.35105  0.52040  0.00340  0.152350.35650
> 
>> heatmap.2(temp1[1:6,])
> Error in heatmap.2(temp1[1:6, ]) : `x' must be a numeric matrix
> 
> What causes the error, and how to resolve ?


Type

  str(temp1)

and find that either the matrix is not numeric or (what I highly 
suspect) that temp1 is a data.frame rather than a matrix.

Best,
Uwe Ligges




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

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


Re: [R] data manipulation for plotting

2008-02-15 Thread Jim Lemon
[EMAIL PROTECTED] wrote:
>Hi,
> 
>i'd like to plot some data that I have with the value on the x axis and 
> freq
>on the y axis.
> 
>So, I need to calculate the freq a value is seen within my data vector
> 
>for example, say i have a vector of data
> 
>data=c(1,1,1,4,5,5,6)
> 
>I want
> 
>values<-c(1,4,5,6)
> 
>freq<-c(3,1,2,1)
> 
>in order to enable me to plot this. Sorry, i'm new to R. What is standard
>procedure here for plotting the data vector?
> 
>  
Here's one way:

rich.dat<-c(1,1,1,4,5,5,6)
library(plotrix)
library(prettyR)
barp(freq(rich.dat)[[1]],names.arg=unique(rich.dat))

Jim

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


Re: [R] lm, coefficient 'not defined because of singularities'? What does this mean?

2008-02-15 Thread Martin Waller
Ah yes - you're right, and its also a tiny number (10^-18)

Thanks...

Martin

Patrick Burns wrote:
> I think it is saying that there is only one (unique)
> number in 'x1'.  If that is right, then you could do:
>
> lm(y1 ~ x1 - 1)
>
> Patrick Burns
> [EMAIL PROTECTED]
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S User")
>
> Martin Waller wrote:
>
>> Hello,
>>
>> I'm doing an lm(y1~x1), no NAs in them, both of length 283.
>>
>> I get out however and 'NA' for the estimate of x1 and summary gives:
>>
>> Residuals:
>> Min1QMedian3QMax
>> -0.1998309 -0.0447269 -0.0006252  0.0390933  0.3141687
>>
>> Coefficients: (1 not defined because of singularities)
>> Estimate Std. Error t value Pr(>|t|)
>> (Intercept) -0.021291   0.003994   -5.331 2.01e-07 ***
>> x1  NANA   NA   NA
>> ---
>> Signif. codes: 0 .***. 0.001 .**. 0.01 .*. 0.05 '.' 0.1 ' ' 1
>>
>> Residual standard error: 0.06719 on 282 degrees of freedom
>>
>>
>> I don't understand why x1 can't be defined because of singularities - 
>> is it trying to tell me something about the data and what can I do 
>> about it?
>>
>> Thanks for any help,
>>
>> Martin
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] storing ggplot objects as components of a vector

2008-02-15 Thread Uwe Ligges


Gallego Liberman, Matias wrote:
> Hi.
>  
> I have a lot of plots that i need to store as components of a vector.
> Here you have an example
>  
>> DF<-data.frame(A=rnorm(12),B=c(1:12),C=rep(c(1:4),each=3))
>> Q<-c()
>> length(Q)<-3

You need a list, hence replace the last two lines by:

Q <- vector(mode="list", length=2)


>> PAC<-geom_point(mapping=aes(x=A,y=B),data=DF[DF$C==1,])
>> P<-ggplot()+PAC
>> P #generates the plot
>> Q[1]<-P

and here replace last line by:

Q[[1]]<-P

Best,
Uwe Ligges


> Warning message:
> In Q[1] <- P :
>   número de items para para sustituir no es un múltiplo de la longitud del 
> reemplazo
>> Q[1]
> [[1]]
> NULL
>  
>  
> I guess the problem is the class of Q[1]. 
> if so, what class should I coerce Q to for the sentence: > Q[1] to generate 
> the plot as > P does?
>  
> thanks in advance
> 
>   [[alternative HTML version deleted]]
> 
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Latent class analysis

2008-02-15 Thread Tom Backer Johnsen
Which package(s) contain something on latent class analysis?

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] storing ggplot objects as components of a vector

2008-02-15 Thread ONKELINX, Thierry
You'll need to store it in a list rather than a vector.

library(ggplot2)
DF<-data.frame(A=rnorm(12),B=c(1:12),C=rep(c(1:4),each=3))
Q <- list()
PAC<-geom_point(mapping=aes(x=A,y=B),data=DF[DF$C==1,])
P<-ggplot()+PAC
Q[[length(Q) + 1]] <- P
Q[[1]]

You could shorten this into

library(ggplot2)
DF<-data.frame(A=rnorm(12),B=c(1:12),C=rep(c(1:4),each=3))
Q <- list()
Q[[length(Q) + 1]] <- ggplot(DF[DF$C==1,], aes(x=A,y=B)) + geom_point()
Q[[1]] 

HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully 
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of 
uncertainties, a surgery of suppositions. ~M.J.Moroney

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Gallego Liberman, Matias
Verzonden: vrijdag 15 februari 2008 10:09
Aan: r-help@r-project.org
Onderwerp: [R] storing ggplot objects as components of a vector

Hi.

I have a lot of plots that i need to store as components of a vector.
Here you have an example

> DF<-data.frame(A=rnorm(12),B=c(1:12),C=rep(c(1:4),each=3))
> Q<-c()
> length(Q)<-3
> PAC<-geom_point(mapping=aes(x=A,y=B),data=DF[DF$C==1,])
> P<-ggplot()+PAC
> P #generates the plot
> Q[1]<-P
Warning message:
In Q[1] <- P :
  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo
> Q[1]
[[1]]
NULL


I guess the problem is the class of Q[1]. 
if so, what class should I coerce Q to for the sentence: > Q[1] to generate the 
plot as > P does?

thanks in advance

[[alternative HTML version deleted]]

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


Re: [R] Latent class analysis

2008-02-15 Thread Dimitris Rizopoulos
check function lca() in package 'e1071'.

Best,
Dimitris


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

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


- Original Message - 
From: "Tom Backer Johnsen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 15, 2008 10:32 AM
Subject: [R] Latent class analysis


> Which package(s) contain something on latent class analysis?
>
> 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.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.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] question about calling winbugs in R

2008-02-15 Thread Xin
Dear All:

  Do you have any experience on calling winbugs in R enviorment? I uploaded 
R2winbgus, pktools, BRugs, ect. in order to call winbugs. In the end, I try to 
use bugs(). The error message still displays that bugs() can not find.

  Do you have any similar issue? If so, could you give your advice?

  Many Thanks!

  Xin
[[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] For Subset or Reshaping the Table

2008-02-15 Thread Henrique Dallazuanna
Try this:

cbind(Row=rownames(x), stack(x)[,2:1])[cbind(Row=rownames(x),
stack(x)[,2:1])[,3]>3,]

On 14/02/2008, dinesh kumar <[EMAIL PROTECTED]> wrote:
> Hi  R users
>  I am a new user in the field of R.
>  I want to subset or reshape a data.frame.
>  For example I have a matrix like
>
>A  B  C  D  E  F  G
>  a  1  2  3   4  5   6  7
>  b  4  6  8   9  5   5  6
>  c  3  4  4   4  3   3  6
>  d  1  2  4   6  8   8  9
>  e  5  6  7   8  9   2  3
>
>  I want to reshape the matrix in this format
>
>  Row  Col  Value
>  a   D 4
>  a   E 5
>  a   F 6
>  ..  ..
>  e   E 9
>
>  I want only the  pair which pass a threshold for example >3.
>
>  Please help me.
>
>  Dinesh
>
>
>
>
>
>  --
>  Dinesh Kumar Barupal
>  Research Associate
>  Metabolomics Fiehn Lab
>  UCD Genome Center
>  451 East Health Science Drive
>  GBSF Builidng
>  University of California
>  DAVIS
>  95616
>  http://fiehnlab.ucdavis.edu/staff/kumar
>
> [[alternative HTML version deleted]]
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>


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

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

2008-02-15 Thread Abderrahim Oulhaj
your r2 model  corresponds to method = "Laplace".

r4=lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="Laplace") is 
equivalent to r2.

Bests,

Abderrahim


- Original Message - 
From: "Daniel Malter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 15, 2008 12:50 AM
Subject: [R] LMER


> Hi,
>
> I run the following models:
>
> 1a. lmer(Y~X+(1|Subject),family=binomial(link="logit")) and
> 1b. lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
>
> Why does 1b produce results different from 1a? The reason why I am asking 
> is
> that the help states that "PQL" is the default of GLMMs
>
> and
>
> 2. gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
>
> The interesting thing about the example below is, that gamm is also 
> supposed
> to fit by "PQL". Interestingly, however, the GAMM fit yields about the
> coefficient estimates of 1b. But the significance values of 1a. Any 
> insight
> would be greatly appreciated.
>
>
> library(lme4)
> library(mgcv)
>
> Y=c(0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1)
> X=c(1,2,3,4,3,1,0,0,2,3,3,2,4,3,2,1,1,3,4,2,3)
> Subject=as.factor(c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7))
> cbind(Y,X,Subject)
>
> r1=lmer(Y~X+(1|Subject),family=binomial(link="logit"))
> summary(r1)
>
> r2=lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
> summary(r2)
>
> r3=gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
> summary(r3$gam)
>
>
>
> -
> cuncta stricte discussurus
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] Help, Statistics Question. Testing for equality of frequncies of an event

2008-02-15 Thread si.fu
Hi All,

I have a basic statistics question you might be able to help.

I have some data collected within a single population (say of chronic illness) 
over a period of time (number under observation is constant, say 100 subjects). 

The question is how could I test whether the frequency of an event (say 
hospital admission) over one period is no different to other.

My data looks like this

Week No of Events (hospital admissions)
123
226
346
423
545
658
734

The hypothesis : The frequency of events (hospital admissions) during the 
period covering weeks 3 and 4 is not different to any other weeks.

Many Thanks for your help.

RA

-
Email sent from www.virginmedia.com/email
Virus-checked using McAfee(R) Software and scanned for spam

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


Re: [R] question about calling winbugs in R

2008-02-15 Thread Uwe Ligges


Xin wrote:
> Dear All:
> 
>   Do you have any experience on calling winbugs in R enviorment? I uploaded 

So you installed them, I assume?


> R2winbgus, pktools, BRugs, ect. in order to call winbugs. In the end, I try 
> to use bugs(). The error message still displays that bugs() can not find.

What is the exact error message and what did you type exactly?

If bugs() is not found, you may have forgotten to load the package, if 
WinBUGS was not found, you might have misspecified the path to WinBUGS.

Note that R2WinBUGS is per se intended to be a WinBUGS interface while 
BRugs is intended for the more modern OpenBUGS.

Uwe Ligges


> 
>   Do you have any similar issue? If so, could you give your advice?
> 
>   Many Thanks!
> 
>   Xin
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Latent class analysis

2008-02-15 Thread Ingmar Visser
and also check packages: flexmix, polca, depmix and a few others ...

On 15 Feb 2008, at 11:01, Dimitris Rizopoulos wrote:

> check function lca() in package 'e1071'.
>
> Best,
> Dimitris
>
> 
> Dimitris Rizopoulos
> Ph.D. Student
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
>
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/(0)16/336899
> Fax: +32/(0)16/337015
> Web: http://med.kuleuven.be/biostat/
>  http://www.student.kuleuven.be/~m0390867/dimitris.htm
>
>
> - Original Message -
> From: "Tom Backer Johnsen" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 15, 2008 10:32 AM
> Subject: [R] Latent class analysis
>
>
>> Which package(s) contain something on latent class analysis?
>>
>> 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.
>>
>
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.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.

Ingmar Visser
Department of Psychology, University of Amsterdam
Roetersstraat 15
1018 WB Amsterdam
The Netherlands
t: +31-20-5256723



[[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] Poisson-lognormal probability calculations

2008-02-15 Thread k . jewell
Hi,

just for the record, although I don't think it's relevant (!)
-
> sessionInfo()
R version 2.6.0 (2007-10-03)
i386-pc-mingw32

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

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

other attached packages:
[1] VGAM_0.7-5 xlsReadWrite_1.3.2


I'm having some problems with a Poisson-lognormal density (mass?) function.

VGAM has the dpolono function, but that doesn't work for x-values over 170,
and I need to go to *much* bigger numbers. It fails first because of gamma
overflow, then because of non-finite integrand.
-
> VGAM::dpolono(170)
[1] 4.808781e-09
> VGAM::dpolono(171)
[1] 0
Warning message:
In VGAM::dpolono(171) : value out of range in 'gammafn'
> VGAM::dpolono(172)
[1] 0
Warning message:
In VGAM::dpolono(172) : value out of range in 'gammafn'
> VGAM::dpolono(173)
[1] 0
Warning message:
In VGAM::dpolono(173) : value out of range in 'gammafn'
> VGAM::dpolono(174)
Error in integrate(f = integrand, lower = -Inf, upper = Inf, x = x[i],  :
  non-finite function value
-

I tidied up a little (to my eyes only, no offence intended to the estimable
authors of VGAM) and avoided the gamma overflow by using logs - OK so far,
it agrees almost perfectly with VGAM::dpolono for x up to 170, and now
extends the range up to 173 (wow!!).
-
dApolono <-
function (x, meanlog = 0, sdlog = 1, ...) {
require(stats)
integrand <- function(t, x, meanlog, sdlog)
exp(-t+x*log(t)-log(sdlog*t*sqrt(2*pi))-0.5*((log(t)-meanlog)/sdlog)^2)
mapply(function(x, meanlog, sdlog, ...){
   temp <- try(
 integrate(f = integrand, lower = 0, upper = Inf, x = x, meanlog =
meanlog, sdlog = sdlog, ...)
  )
 ifelse(inherits(temp, "try-error"), NA,
exp(log(temp$value)-lgamma(x+1)))
  }
  , x, meanlog, sdlog, ...
   )
   }
plot(log(dApolono(0:173)))
dApolono(174)
-

Addressing the non-finite integrand, I noticed that the gamma(x+1) divisor
was outside the integrand so that as x gets bigger the integrand gets
bigger, only to be finally divided by an increasing gamma(x+1). I reasoned
that putting the divisor inside the integral might incur a substantial
performance hit, but would keep the integrand at reasonable values.

--
dApolono <-
function (x, meanlog = 0, sdlog = 1, ...) {
require(stats)
integrand <- function(t, x, meanlog, sdlog)
exp(-t+x*log(t)-log(sdlog*t*sqrt(2*pi))-0.5*((log(t)-meanlog)/sdlog)^2-lgamm
a(x+1))
mapply(function(x, meanlog, sdlog, ...){
   temp <- try(
 integrate(f = integrand, lower = 0, upper = Inf, x = x, meanlog =
meanlog, sdlog = sdlog, ...)
  )
 ifelse(inherits(temp, "try-error"), NA, temp$value)
  }
  , x, meanlog, sdlog, ...
   )
   }
plot(log(dApolono(0:173)))
dApolono(174)
dApolono(1E3)
-

This avoids the non-finite integrand and gives me answers at much higher x,
but now at least some of the answers are wrong (not to say silly), even in
the range where the other versions worked. I've tried other variations
including changing the variable of integration to log(t) and integrating
dpois()*dlnorm(), but I can't fix it; if the factorial (=gamma) is inside
the integrand I get silly answers, if it's outside I get non-finite
integrand.

I'm tearing my hair. Can anyone suggest where I may be going wrong? Any
suggestions at all will be appreciated.

Thanks in advance,

Keith Jewell
mailto:[EMAIL PROTECTED] telephone (direct) +44 (0)1386 842055




_
The information in this document and attachments is given after the exercise of 
all reasonable care and skill in its compilation, preparation and issue, but is 
provided without liability in its application or use.  It may contain 
privileged information that is exempt from disclosure by law and may be 
confidential.  If you are not the intended recipient you must not copy, 
distribute or take any action in reliance on it.  If you have received this 
document in error please notify us and delete this message from your system 
immediately.

Campden & Chorleywood Food Research Association Group;
Campden & Chorleywood Food Research Association (company limited by 
guarantee),registered number 510618);
CCFRA Group Services Ltd. (registered number 3841905); and
CCFRA Technology Ltd  (registered number 3836922),
all registered in England and Wales with the registered office at Station Road, 
Chipping C

Re: [R] Latent class analysis

2008-02-15 Thread Tom Backer Johnsen
Thanks!

Ingmar Visser wrote:
> and also check packages: flexmix, polca, depmix and a few others ...
> 
> On 15 Feb 2008, at 11:01, Dimitris Rizopoulos wrote:
> 
>> check function lca() in package 'e1071'.
>>
>> Best,
>> Dimitris
>>
>> 
>> Dimitris Rizopoulos
>> Ph.D. Student
>> Biostatistical Centre
>> School of Public Health
>> Catholic University of Leuven
>>
>> Address: Kapucijnenvoer 35, Leuven, Belgium
>> Tel: +32/(0)16/336899
>> Fax: +32/(0)16/337015
>> Web: http://med.kuleuven.be/biostat/
>>  http://www.student.kuleuven.be/~m0390867/dimitris.htm
>>
>>
>> - Original Message -
>> From: "Tom Backer Johnsen" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Friday, February 15, 2008 10:32 AM
>> Subject: [R] Latent class analysis
>>
>>
>>> Which package(s) contain something on latent class analysis?
>>>
>>> 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.
>>>
>>
>>
>> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.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.
> 
> Ingmar Visser
> Department of Psychology, University of Amsterdam
> Roetersstraat 15
> 1018 WB Amsterdam
> The Netherlands
> t: +31-20-5256723
> 
> 
> 


-- 
++
| 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] setting color ranges

2008-02-15 Thread Jim Lemon
samsr wrote:
> Hi,
> 
>  I need to plot a matrix using image() such that negative values are easily
> distinguishable from posittive values, while also maintaining a gradation in
> color with magnitude. How can I set ranges for colors in order to achieve
> this. Thanks.
> 
Hi Sam,

This will give you red colors for the negative values, green for positive.

x<-matrix(rnorm(100),nrow=10)
cellcol<-matrix(rep("#00",100),nrow=10)
library(plotrix)
cellcol[x<0]<-color.scale(x[x<0],c(1,0.8),c(0,0.5),0)
cellcol[x>0]<-color.scale(x[x>0],0,c(0.7,0.8),c(0.5,0))
image(z=x,col=cellcol)

Jim

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


[R] GAUSS (Aptech) & R

2008-02-15 Thread Naji Nassar

Hi



Is there a correspondance between R commands and other software commands
(GAUSS mainly).. I'd like to translate some Gauss into R..


Thanks for your help
Naji

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

2008-02-15 Thread Douglas Bates
Could you send us the output of sessionInfo() please so we can see
which version of the lme4 package you are using?  In recent versions,
especially the development version available as

install.packages("lme4", repos = "http://r-forge.r-project.org";)

the PQL algorithm is no longer used.  The Laplace approximation is now
the default.  The adaptive Gauss-Hermite quadrature (AGQ)
approximation may be offered in the future.

If the documentation indicates that PQL is the default then that is a
documentation error.  With the currently available implementation of
the direct optimization of the Laplace approximation to the
log-likelihood for the model there is no purpose in offering PQL.

On Thu, Feb 14, 2008 at 6:50 PM, Daniel Malter <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I run the following models:
>
>  1a. lmer(Y~X+(1|Subject),family=binomial(link="logit")) and
>  1b. lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
>
>  Why does 1b produce results different from 1a? The reason why I am asking is
>  that the help states that "PQL" is the default of GLMMs
>
>  and
>
>  2. gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
>
>  The interesting thing about the example below is, that gamm is also supposed
>  to fit by "PQL". Interestingly, however, the GAMM fit yields about the
>  coefficient estimates of 1b. But the significance values of 1a. Any insight
>  would be greatly appreciated.
>
>
>  library(lme4)
>  library(mgcv)
>
>  Y=c(0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1)
>  X=c(1,2,3,4,3,1,0,0,2,3,3,2,4,3,2,1,1,3,4,2,3)
>  Subject=as.factor(c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7))
>  cbind(Y,X,Subject)
>
>  r1=lmer(Y~X+(1|Subject),family=binomial(link="logit"))
>  summary(r1)
>
>  r2=lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
>  summary(r2)
>
>  r3=gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
>  summary(r3$gam)
>
>
>
>  -
>  cuncta stricte discussurus
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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] Controling width of boxes in boxplots

2008-02-15 Thread Marcin Kozak
Hi,

I want to add boxplots to a scatterplot:

plot(x,y, xlim=c(80,120),ylim=c(80,120))
boxplot(y,add=TRUE,at=118)
boxplot(x,add=TRUE,at=118,horizontal=TRUE)

How can I control the width of the boxes (say, I'd like them to be of
width 3 in the variables' scales). I've tried the "width" parameter
but failed.

Thanks in advance,
Marcin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-02-15 Thread Susann Fält
Hello,

I am trying to set up the oneChannelGUI in R to analyse exon arrays but I
can not start up the package.

 

I receive the error message “ Tcl/Tk Extensions not found”

I have followed the suggestion: “If you don't know how to set environment
variables in Windows, one way

to make sure that R can find the Tcl/Tk extensions Tktable2.8 and bwidget1.6
(Tktable2.9 and bwidget1.8 are used in my installation) is to copy them from
your ActiveTcl installation e.g. in C:\Tcl\lib into

the Tcl subdirectory of your R installation.”

 

It still doesn’t work so could you please give me som further instructions
how I should proceed.

 

Thank You!

 

Best wishes,

 

Susann Fält, Phd


[[alternative HTML version deleted]]

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


[R] help on loop function

2008-02-15 Thread mohamed nur anisah
Dear lists,
   
  Anysuggestion on how to write a loop function which has nx2 matrix as an 
input, where each of the row represents an interval. the function should return 
a mx2 matrix containing the no matched interval of x?? i've tried my own 
function but it's only applies for 2x2 matrix. 
   
  Here is my code:
   
  overlap<-function(x,y){
m=length(x)
n=length(y)
 for(i in 1:m){
  for(j in 1:n){
   if(x[i]>=y[j]) print(TRUE)
   else print(FALSE)
 }
   } 
  }
   
  Many thanks!! 
   
  Cheers,
  Anisah

   
-

[[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] Error with stop()

2008-02-15 Thread jgarcia
Hello;
I've used stop() previously without any problem.
Now, I'm using a condition and getting an error when stop() is called.

Mi condition is:

if(dim(r.temp)[1] != (length(jul.names)+6)) stop("buffered data not
available")


An the R' response is:

> source("my_program.R")
Error in eval.with.vis(expr, envir, enclos) :
  buffered data not available
>

Can you help me with this?

Best regards,
Javier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Controling width of boxes in boxplots

2008-02-15 Thread Henrique Dallazuanna
Try this:

x <- sample(5, 100, rep=T)
y <- rnorm(100)

plot(x,y, xlim=c(min(x)-.5, max(x)), ylim=c(min(y), max(y)+1))
boxplot(y, pars=list(boxwex=0.3), at=min(x)-.5, add=T)
boxplot(x, pars=list(boxwex=0.3), at=max(y)+1, add=T, horizontal=T)


On 15/02/2008, Marcin Kozak <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I want to add boxplots to a scatterplot:
>
>  plot(x,y, xlim=c(80,120),ylim=c(80,120))
>  boxplot(y,add=TRUE,at=118)
>  boxplot(x,add=TRUE,at=118,horizontal=TRUE)
>
>  How can I control the width of the boxes (say, I'd like them to be of
>  width 3 in the variables' scales). I've tried the "width" parameter
>  but failed.
>
>  Thanks in advance,
>  Marcin
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] For Subset or Reshaping the Table

2008-02-15 Thread hadley wickham
On Thu, Feb 14, 2008 at 7:53 PM, dinesh kumar <[EMAIL PROTECTED]> wrote:
> Hi  R users
>  I am a new user in the field of R.
>  I want to subset or reshape a data.frame.
>  For example I have a matrix like
>
>A  B  C  D  E  F  G
>  a  1  2  3   4  5   6  7
>  b  4  6  8   9  5   5  6
>  c  3  4  4   4  3   3  6
>  d  1  2  4   6  8   8  9
>  e  5  6  7   8  9   2  3
>
>  I want to reshape the matrix in this format
>
>  Row  Col  Value
>  a   D 4
>  a   E 5
>  a   F 6
>  ..  ..
>  e   E 9
>
>  I want only the  pair which pass a threshold for example >3.

library(reshape)
molten <- melt(mymatrix)
subset(molten, value > 3)

You can learn more about the reshape package at http://had.co.nz/reshape

Hadley


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

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


[R] No response for help

2008-02-15 Thread G Ilhamto
Dear R admin,

I sent so many emails but none was posted.
What happened?

Thanks
Ilham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] write output in a custom format

2008-02-15 Thread Charilaos Skiadas
Perhaps I am missing the obvious, but can't you simply write a small  
function that, given each particle "object", returns a string with  
the required output format (probably a couple of "paste" calls with  
sep and collapse set), and then use sapply and this function on the  
list of particles to create one long character vector, and simply  
write that out in one go? If you wanted to avoid a loop, then that  
means you have enough memory to store all the data, so you should  
have enough memory for this character vector as well.

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On Feb 15, 2008, at 7:57 AM, baptiste Auguié wrote:

> Fair point! I guess I'll see how long it takes with a pure R
> solution, and maybe then try some optimization if needed.
>
>
> Thanks again,
>
> baptiste
>
>
> On 14 Feb 2008, at 21:27, jim holtman wrote:
>
>> There is nothing wrong with a loop for handling this case.  Most of
>> your time is probably going to be spent writing out the files.  If  
>> you
>> don't want 'for' loops, you can use 'lapply', but I am not sure what
>> type of "performance" improvement you will see.  You are having to
>> make decisions on each particle on how to write it. You can also use
>> awk/perl as you indicated, but you would have to write the data out
>> for those programs.  You might take a test run and see.  I would  
>> guess
>> that by the time you format it for awk and then run awk, you could
>> have done the whole thing in R.  But it is your choice and there are
>> plenty of tools to choose from.
>>
>> On 2/14/08, baptiste Auguié <[EMAIL PROTECTED]> wrote:
>>> Thanks for the input! It does work fine, however I'll have to do
>>> another loop to repeat this whole process quite a few times (10^3,
>>> 10^4 particles maybe), so I was hoping for a solution without loop.
>>> Maybe I could reshape all the values into a big array, dump it to a
>>> file and replace some values using system(awk...). I just don't
>>> really know how to format the data, having different number of  
>>> values
>>> for some lines. Would that be a sensible thing to do?
>>>
>>> thanks,
>>>
>>> baptiste
>>>
>>>
>>>
>>>
>>> On 14 Feb 2008, at 16:49, jim holtman wrote:
>>>
 Here is a start.  You basically have to interate through your
 data and
 use 'cat' to write it out:

 particle <- list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c
 (0,1,0,1)))
 output <- file("/tempxx.txt", "w")
 cat(particle$dose, "\n", file=output, sep=" ")
 for (i in 1:nrow(particle$pos)){
 cat(particle$pos$x[i], particle$pos$y[i], "\n", file=output,
 sep=" ")
 }
 cat("#\n", file=output, sep=" ")
 close(output)

 Here is what the file looks like:

 1 100 0
 0 0
 1 1
 0 0
 1 1
 #


 On 2/14/08, baptiste Auguié <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
> I need to create a text file in the following format,
>
>> 1 100.0 0
>>  0 0
>>  1 1
>>  0 0
>>  1 1
>> #
>> 1 100.0 0
>>  0 0
>>  0 1
>>  1 0
>>  1 1
> ...
>
> where # is part of the format and not a R comment.
>
> Each block (delimited by #) consists of a first line with three
> values, call it dose, and a list of (x,y) coordinates which are a
> matrix or data.frame,
>
>
>> particle <- list(dose=c(1,100.0,0),pos=data.frame(x=c 
>> (0,1,0,1),y=c
>> (0,1,0,1)))
>>
>> print(particle)
>
>
>
> I'd like to establish a connection to a file and append to it a
> "particle" block in the format above, or even write the whole
> file at
> once.
>
> Because different lines have a different number of elements, I
> couldn't get write.table to work in this case, and my attempts at
> sink
> (), dump(), writeLines(), writeChar() all turn into really dirty
> solutions. I have this feeling I'm overlooking a simple solution.
>
> Any help welcome,
>
>
> baptiste
>
> _
>
> Baptiste Auguié
>
> Physics Department
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
>
> Phone: +44 1392 264187
>
> http://newton.ex.ac.uk/research/emag
> http://projects.ex.ac.uk/atto
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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?
>>>
>>> _
>>>
>>> Baptiste Auguié
>>>
>>> Physics Department
>>> University of Exeter
>>> Stocker Road,
>>> Exeter, Devon,
>>> EX4 4QL, UK
>>>
>>> Phone: +44 1392 264187

Re: [R] Analysis with spatstat and Kcross() requires to much memory

2008-02-15 Thread Roger Bivand
Rainer M Krug  gmail.com> writes:

> 
> Hi
> 
> I am running analysis with Kcross from the package spatstat and I am getting
> a message that R can  not allocate enough memory for a vector of 900MB.
> R seems to be running towards the 2GB limit per process.
> 
> The dataset is not to big (ca 3000 points) but the mask for the points is
> extremely irregular (a buffer around roads which have been sampled) and I
> can do trhe analysis if I use a rectangular mask covering the whole area
> (which is obviously not correct).

Rainer,

Would it be possible for you to rasterise the road buffer (I'm assuming that it
is a vector buffer), so that the window is an image mask rather than a polygon
window? My assumption would be that as.im() would get you there, but you'd need
to watch the dimyx= argument.

It is also usually helpful to look at traceback() after such a failure, so that
you can see at which point in Kcross things fell apart - that is, which internal
function was being used. Then you can concentrate on finding a way of solving
that specific problem.

Roger

> 
> My question is: is there a way of splitting the dataset or changing the mask
> son that I can do the analysis, as I don't want to move to a 64bit computer
> (if not necessary).
> 
> Thanks,
> 
> Rainer
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] write output in a custom format

2008-02-15 Thread baptiste Auguié
Fair point! I guess I'll see how long it takes with a pure R  
solution, and maybe then try some optimization if needed.


Thanks again,

baptiste


On 14 Feb 2008, at 21:27, jim holtman wrote:

> There is nothing wrong with a loop for handling this case.  Most of
> your time is probably going to be spent writing out the files.  If you
> don't want 'for' loops, you can use 'lapply', but I am not sure what
> type of "performance" improvement you will see.  You are having to
> make decisions on each particle on how to write it. You can also use
> awk/perl as you indicated, but you would have to write the data out
> for those programs.  You might take a test run and see.  I would guess
> that by the time you format it for awk and then run awk, you could
> have done the whole thing in R.  But it is your choice and there are
> plenty of tools to choose from.
>
> On 2/14/08, baptiste Auguié <[EMAIL PROTECTED]> wrote:
>> Thanks for the input! It does work fine, however I'll have to do
>> another loop to repeat this whole process quite a few times (10^3,
>> 10^4 particles maybe), so I was hoping for a solution without loop.
>> Maybe I could reshape all the values into a big array, dump it to a
>> file and replace some values using system(awk...). I just don't
>> really know how to format the data, having different number of values
>> for some lines. Would that be a sensible thing to do?
>>
>> thanks,
>>
>> baptiste
>>
>>
>>
>>
>> On 14 Feb 2008, at 16:49, jim holtman wrote:
>>
>>> Here is a start.  You basically have to interate through your  
>>> data and
>>> use 'cat' to write it out:
>>>
>>> particle <- list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c
>>> (0,1,0,1)))
>>> output <- file("/tempxx.txt", "w")
>>> cat(particle$dose, "\n", file=output, sep=" ")
>>> for (i in 1:nrow(particle$pos)){
>>> cat(particle$pos$x[i], particle$pos$y[i], "\n", file=output,
>>> sep=" ")
>>> }
>>> cat("#\n", file=output, sep=" ")
>>> close(output)
>>>
>>> Here is what the file looks like:
>>>
>>> 1 100 0
>>> 0 0
>>> 1 1
>>> 0 0
>>> 1 1
>>> #
>>>
>>>
>>> On 2/14/08, baptiste Auguié <[EMAIL PROTECTED]> wrote:
 Hi,


 I need to create a text file in the following format,

> 1 100.0 0
>  0 0
>  1 1
>  0 0
>  1 1
> #
> 1 100.0 0
>  0 0
>  0 1
>  1 0
>  1 1
 ...

 where # is part of the format and not a R comment.

 Each block (delimited by #) consists of a first line with three
 values, call it dose, and a list of (x,y) coordinates which are a
 matrix or data.frame,


> particle <- list(dose=c(1,100.0,0),pos=data.frame(x=c(0,1,0,1),y=c
> (0,1,0,1)))
>
> print(particle)



 I'd like to establish a connection to a file and append to it a
 "particle" block in the format above, or even write the whole  
 file at
 once.

 Because different lines have a different number of elements, I
 couldn't get write.table to work in this case, and my attempts at
 sink
 (), dump(), writeLines(), writeChar() all turn into really dirty
 solutions. I have this feeling I'm overlooking a simple solution.

 Any help welcome,


 baptiste

 _

 Baptiste Auguié

 Physics Department
 University of Exeter
 Stocker Road,
 Exeter, Devon,
 EX4 4QL, UK

 Phone: +44 1392 264187

 http://newton.ex.ac.uk/research/emag
 http://projects.ex.ac.uk/atto

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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?
>>
>> _
>>
>> Baptiste Auguié
>>
>> Physics Department
>> University of Exeter
>> Stocker Road,
>> Exeter, Devon,
>> EX4 4QL, UK
>>
>> Phone: +44 1392 264187
>>
>> http://newton.ex.ac.uk/research/emag
>> http://projects.ex.ac.uk/atto
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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?

_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the pos

[R] lmer in package of lme4

2008-02-15 Thread WANG
Dear Sir/madam,

I use lmer to extract model in your package of lme4. It seems works
well. But the problem is when I use anova/summary the extracted model,
no p-value is shown at all. In previous version(nlme), I mainly use
p-value to judge which term is significant or not, and then make a
decision to keep this term or not. Does it means that sth wrong with my
installation of package/R? or you use other value to judge the
significance of terms?

Many thanks for your help in advance!

Best wishes,

Ping.

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

2008-02-15 Thread G Ilhamto
Hi R help,

I run my data in nnet with skip layer, factor response (with 0 & 1
values) and explicitly put softmax=T to compare the result of the
default nnet with no softmax specification. I assume this should give
me the same result. I got the result the default one, but not the
softmax version and I got the error message that I did not quite
understand.

test6.nn.skipT.softm.Yfac <- nnet(Yfac~ X1 +.. +X8, skip=T, size=0,
softmax=T, data = train.set)

Error in nnet.default(x, y, w, entropy = TRUE, ...) : no weights to fit

In addition: Warning messages:
1: In if (softmax) { :  the condition has length > 1 and only the
first element will be used
2: In if (skip) net <- add.net(net, seq(1, net$n[1]), seq(1 + net$n[1] +  :
  the condition has length > 1 and only the first element will be used

When I specify the weights (0.1 just for a try)
test6.nn.skipT.softm.Yfac <- nnet(Yfac~ X1 +.. +X8, skip=T, size=0,
weights= 0.1, softmax=T, data = train.set)

I got another error message:
Error in model.frame.default(formula = Yfac ~ HusYEduc + AgeRespd +
muslimat +  :
variable lengths differ (found for '(weights)')
-

Q: Does softmax apply to two-category response?
 What is softmax require?

Thank you,
Ilham

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

2008-02-15 Thread G Ilhamto
Hi R help,

I run my data in nnet with skip layer, factor response (with 0 & 1
values) and explicitly put softmax=T to compare the result of the
default nnet with no softmax specification. I assume this should give
me the same result. I got the result the default one, but not the
softmax version and I got the error message that I did not quite
understand.

test6.nn.skipT.softm.Yfac <- nnet(Yfac~ X1 +.. +X8, skip=T, size=0,
softmax=T, data = train.set)

Error in nnet.default(x, y, w, entropy = TRUE, ...) : no weights to fit

In addition: Warning messages:
1: In if (softmax) { :  the condition has length > 1 and only the
first element will be used
2: In if (skip) net <- add.net(net, seq(1, net$n[1]), seq(1 + net$n[1] +  :
 the condition has length > 1 and only the first element will be used

When I specify the weights (0.1 just for a try)
test6.nn.skipT.softm.Yfac <- nnet(Yfac~ X1 +.. +X8, skip=T, size=0,
weights= 0.1, softmax=T, data = train.set)

I got another error message:
Error in model.frame.default(formula = Yfac ~ HusYEduc + AgeRespd +
muslimat +  :
variable lengths differ (found for '(weights)')
-

Q: Does softmax apply to two-category response?
What is softmax require?

Thank you,
Ilham

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

2008-02-15 Thread Dieter Vanderelst
Hi List,

I have a problem plotting data using the lineplot.CI command in the sciplot 
package.

I want to plot the data of 2 experimental cases using different lines (traces). 
Time is on the X-axis. The tricky thing is that the data collection in the 
second case started later than for the first case. This is to say: the first n 
data points for the second case are missing.

So far so good. However, when I plot the data using lineplot.CI, the standard 
error bars are not aligned correctly with the markers.

I know that this might be difficult to imagine. Here you can find an example: 
http://i254.photobucket.com/albums/hh115/MarkerMe/example.png

So, has anybody experienced this problem and solved it before? I think I could 
try padding the data of the second case with zeros to eliminate the missing 
data. But I hope there is a better solution.

Regards,
Dieter

Dieter Vanderelst
dieter dot vanderelst at emailengine dot org

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


[R] function similar to str_replace() in php.

2008-02-15 Thread Dong-hyun Oh
Dear expeRt,

I would like to know whether a function similar to str_replace() in  
php exists in R.

Looking forward to hearing from you.

Best,



=
Center of Excellence for Science and Innovation Studies,
Royal Institute of Technology
Drottning Kristinas väg 30
100 44 Stockholm, Sweden
e-mail: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
Office: +46 8 790 67 93
Fax: +46 8 790 95 17
Cell phone: +46 73 563 45 22
=

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


Re: [R] function similar to str_replace() in php.

2008-02-15 Thread Gabor Csardi
I don't know php very well, but perhaps you need 

?sub

Gabor

On Fri, Feb 15, 2008 at 03:54:19PM +0100, Dong-hyun Oh wrote:
> Dear expeRt,
> 
> I would like to know whether a function similar to str_replace() in  
> php exists in R.
> 
> Looking forward to hearing from you.
> 
> Best,
> 
> 
> 
> =
> Center of Excellence for Science and Innovation Studies,
> Royal Institute of Technology
> Drottning Kristinas väg 30
> 100 44 Stockholm, Sweden
> e-mail: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
> Office: +46 8 790 67 93
> Fax: +46 8 790 95 17
> Cell phone: +46 73 563 45 22
> =
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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


Re: [R] LMER

2008-02-15 Thread Daniel Malter
Thanks for your replies. My real problem is that, for my real data, I get
basically the same results from r2 and r3 (so to speak), but the coefficient
estimates and significance levels for r1 are very different from those of r2
and r3. And therefore, I do not know which of the results to trust and which
not (if any).

The session info follows:

R version 2.6.0 (2007-10-03) 
i386-pc-mingw32 

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

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

other attached packages:
[1] nlme_3.1-86   mgcv_1.3-29   lme4_0.99875-9Matrix_0.999375-3
lattice_0.16-5   

loaded via a namespace (and not attached):
[1] grid_2.6.0

Cheers,
Daniel


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Douglas
Bates
Gesendet: Friday, February 15, 2008 7:29 AM
An: Daniel Malter
Cc: [EMAIL PROTECTED]
Betreff: Re: [R] LMER

Could you send us the output of sessionInfo() please so we can see which
version of the lme4 package you are using?  In recent versions, especially
the development version available as

install.packages("lme4", repos = "http://r-forge.r-project.org";)

the PQL algorithm is no longer used.  The Laplace approximation is now the
default.  The adaptive Gauss-Hermite quadrature (AGQ) approximation may be
offered in the future.

If the documentation indicates that PQL is the default then that is a
documentation error.  With the currently available implementation of the
direct optimization of the Laplace approximation to the log-likelihood for
the model there is no purpose in offering PQL.

On Thu, Feb 14, 2008 at 6:50 PM, Daniel Malter <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  I run the following models:
>
>  1a. lmer(Y~X+(1|Subject),family=binomial(link="logit")) and  1b. 
> lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
>
>  Why does 1b produce results different from 1a? The reason why I am 
> asking is  that the help states that "PQL" is the default of GLMMs
>
>  and
>
>  2. gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
>
>  The interesting thing about the example below is, that gamm is also 
> supposed  to fit by "PQL". Interestingly, however, the GAMM fit yields 
> about the  coefficient estimates of 1b. But the significance values of 
> 1a. Any insight  would be greatly appreciated.
>
>
>  library(lme4)
>  library(mgcv)
>
>  Y=c(0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1)
>  X=c(1,2,3,4,3,1,0,0,2,3,3,2,4,3,2,1,1,3,4,2,3)
>  Subject=as.factor(c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7))
>  cbind(Y,X,Subject)
>
>  r1=lmer(Y~X+(1|Subject),family=binomial(link="logit"))
>  summary(r1)
>
>  r2=lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
>  summary(r2)
>
>  r3=gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
>  summary(r3$gam)
>
>
>
>  -
>  cuncta stricte discussurus
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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] Controling width of boxes in boxplots

2008-02-15 Thread John Kane
Have a look at boxwex in boxplot. Something like
boxplot(y,add=TRUE,at=118, boxwex=3)
may give you what you want.

--- Marcin Kozak <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I want to add boxplots to a scatterplot:
> 
> plot(x,y, xlim=c(80,120),ylim=c(80,120))
> boxplot(y,add=TRUE,at=118)
> boxplot(x,add=TRUE,at=118,horizontal=TRUE)
> 
> How can I control the width of the boxes (say, I'd
> like them to be of
> width 3 in the variables' scales). I've tried the
> "width" parameter
> but failed.
> 
> Thanks in advance,
> Marcin
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



  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.


Re: [R] Softmax in nnet

2008-02-15 Thread Prof Brian Ripley
Looks like you meant to use 'TRUE' not 'T'.  The latter is probably a 
variable you defined of length > 1.

Double-posting at least halves your chances of getting help, so please 
stop doing it.

On Fri, 15 Feb 2008, G Ilhamto wrote:

> Hi R help,
>
> I run my data in nnet with skip layer, factor response (with 0 & 1
> values) and explicitly put softmax=T to compare the result of the
> default nnet with no softmax specification. I assume this should give
> me the same result. I got the result the default one, but not the
> softmax version and I got the error message that I did not quite
> understand.
>
> test6.nn.skipT.softm.Yfac <- nnet(Yfac~ X1 +.. +X8, skip=T, size=0,
> softmax=T, data = train.set)
>
> Error in nnet.default(x, y, w, entropy = TRUE, ...) : no weights to fit
>
> In addition: Warning messages:
> 1: In if (softmax) { :  the condition has length > 1 and only the
> first element will be used
> 2: In if (skip) net <- add.net(net, seq(1, net$n[1]), seq(1 + net$n[1] +  :
>  the condition has length > 1 and only the first element will be used
>
> When I specify the weights (0.1 just for a try)
> test6.nn.skipT.softm.Yfac <- nnet(Yfac~ X1 +.. +X8, skip=T, size=0,
> weights= 0.1, softmax=T, data = train.set)
>
> I got another error message:
> Error in model.frame.default(formula = Yfac ~ HusYEduc + AgeRespd +
> muslimat +  :
> variable lengths differ (found for '(weights)')
> -
>
> Q: Does softmax apply to two-category response?
> What is softmax require?
>
> Thank you,
> Ilham
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] anyone know how to plot histograma and line in the same graph

2008-02-15 Thread Henrique Dallazuanna
Try this:

hist(x[,1], ylim=c(0,max(x[,2])))
lines(x[,2], col="blue", lty=2)


On 15/02/2008, Xin <[EMAIL PROTECTED]> wrote:
> Dear:
>
>I have two series data, which are:
>   p1-obs p1-exp
>   13 13
>   20 23.296
>   22 18.139
>   19 14.972
>   10 12.576
>   16 10.658
>   8 9.0794
>   4 7.7625
>   3 6.6536
>   5 5.7141
>   7 4.9146
>   4 4.2321
>   0 3.648
>   4 3.1471
>   4 2.7168
>   2 2.3468
>   4 2.0283
>   2 1.7537
>   2 1.517
>   5 1.3127
>   1 1.1362
>
>
>  And I want to plot one of series by historgram and the other by line.
>
>  such as the attachment.
>
>
>  Thanks
>
>
>  Xin
>
> __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] lmer in package of lme4

2008-02-15 Thread jebyrnes

Rather than go over all of this again, see here

http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests

-- 
View this message in context: 
http://www.nabble.com/lmer-in-package-of-lme4-tp15501802p15502440.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] lmer in package of lme4

2008-02-15 Thread Ben Bolker
WANG  newcastle.ac.uk> writes:

> I use lmer to extract model in your package of lme4. It seems works
> well. But the problem is when I use anova/summary the extracted model,
> no p-value is shown at all. In previous version(nlme), I mainly use
> p-value to judge which term is significant or not, and then make a
> decision to keep this term or not. Does it means that sth wrong with my
> installation of package/R? or you use other value to judge the
> significance of terms?

   As it turns out, assessing the significance of fixed-effects terms
in a mixed model is potentially a huge problem.  Essentially, Doug
Bates no longer feels that the simple denominator-degrees-of-freedom 
approach that was used in nlme is reliable.

http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests&s=bates%20mixed

   After reading all of this (and checking out mcmcsamp in the lme4 package),
you may need to turn to [EMAIL PROTECTED] for further assistance ...

  good luck,
Ben Bolker

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

2008-02-15 Thread Manuel Morales
On Fri, 2008-02-15 at 15:18 +0100, Dieter Vanderelst wrote:
> Hi List,
> 
> I have a problem plotting data using the lineplot.CI command in the sciplot 
> package.
> 
> I want to plot the data of 2 experimental cases using different lines 
> (traces). Time is on the X-axis. The tricky thing is that the data collection 
> in the second case started later than for the first case. This is to say: the 
> first n data points for the second case are missing.
> 
> So far so good. However, when I plot the data using lineplot.CI, the standard 
> error bars are not aligned correctly with the markers.
> 
> I know that this might be difficult to imagine. Here you can find an example: 
> http://i254.photobucket.com/albums/hh115/MarkerMe/example.png
> 
> So, has anybody experienced this problem and solved it before? I think I 
> could try padding the data of the second case with zeros to eliminate the 
> missing data. But I hope there is a better solution.

I wrote this function to plot data from factorial designs. The current
version therefore fails for designs where data are not present in all
levels of the variables, as is the case for your example. I'll take
another look at this and see if there's an easy way to change this.

Manuel

> Regards,
> Dieter
> 
> Dieter Vanderelst
> dieter dot vanderelst at emailengine dot org
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
http://mutualism.williams.edu
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lineplot.CI problem

2008-02-15 Thread hadley wickham
On Fri, Feb 15, 2008 at 8:18 AM, Dieter Vanderelst
<[EMAIL PROTECTED]> wrote:
> Hi List,
>
>  I have a problem plotting data using the lineplot.CI command in the sciplot 
> package.
>
>  I want to plot the data of 2 experimental cases using different lines 
> (traces). Time is on the X-axis. The tricky thing is that the data collection 
> in the second case started later than for the first case. This is to say: the 
> first n data points for the second case are missing.
>
>  So far so good. However, when I plot the data using lineplot.CI, the 
> standard error bars are not aligned correctly with the markers.
>
>  I know that this might be difficult to imagine. Here you can find an 
> example: http://i254.photobucket.com/albums/hh115/MarkerMe/example.png
>
>  So, has anybody experienced this problem and solved it before? I think I 
> could try padding the data of the second case with zeros to eliminate the 
> missing data. But I hope there is a better solution.


If you post a reproducible example (i.e. some sample data), I'm sure
you would get contributions describing how to do what you want in base
graphics, lattice graphics and with ggplot2.

Hadley

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

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


Re: [R] contingency table

2008-02-15 Thread John Kane
Have a look at 
length(iris$Species)
length(prev)
--- Carla Rebelo <[EMAIL PROTECTED]> wrote:

> Hello!
> 
> May you help me? I'm trying to do a contingency
> table using this
> 
>  > data(iris)
>  > library(rpart)
>  > modelo <- rpart(Species ~., iris)
>  > prev <- predict(modelo, iris)
> 
> Finally the contingency table
>  > table(iris$Species, prev)
> But an error occurs:
> Error in table(iris$Species, prev) :
>   all arguments must have the same length
> 
> And I do not understand why, may you help me?
> 
> 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.
>

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

2008-02-15 Thread John Kane
Place the command library(newpackage) in your Rprofile
is one way.

--- Stefano Sofia <[EMAIL PROTECTED]>
wrote:

> I am using R Version 2.3.1 (2006-06-01) in Linux
> with Ubuntu 7.4.
> 
> I installed a new package with 
> 
> R CMD INSTALL -l /usr/lib/R/library
> newpackage.tar.gz
> 
> Each time I run R I need to load this new package
> typing library(newpackage).
> My question is: how can I automatically load this
> new package once for ever?
> I read the manual but I have not been able to find
> the solution to that.
> 
> thank you
> Stefano
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

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


Re: [R] Help, Statistics Question. Testing for equality of frequncies of an event

2008-02-15 Thread David Winsemius
<[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]
orld.com: 

> Hi All,
> 
> I have a basic statistics question you might be able to help.
> 
> I have some data collected within a single population (say of
> chronic illness) over a period of time (number under observation is
> constant, say 100 subjects). 
> 
> The question is how could I test whether the frequency of an event
> (say hospital admission) over one period is no different to other. 
> 
> My data looks like this
> 
> Week No of Events (hospital admissions)
> 123
> 226
> 346
> 423
> 545
> 658
> 734
> 
> The hypothesis : The frequency of events (hospital admissions)
> during the period covering weeks 3 and 4 is not different to any
> other weeks. 


?glm

With family = poisson

-- 
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Transfer Crosstable to Word-Document (2. attempt)

2008-02-15 Thread ukoenig
# Dear list,
# I am an R-beginner and
# spent the last days looking for a method to insert tables produced
# with R into a word document. I thought about SPPS:  copy a table from
# an SPO-file and paste it into a word document
# (if needed do some formatting with that table).
# Annother idea was, to produce a TEX-file,
# insert it and make it a word-table.

# I found the following libraries, which seemed to be promising:
# xtable
# prettyR
# R2HTML
# Hmisc
# SciViews / svViews



###
## My example: a crosstable (made with CrossTable from lib gmodels 
###

library(gmodels)
library(xtable)
library(svViews)

# Data for crosstabulation
set.seed(1)
n <- 200
sex <- sample(c("f","m"),n,T)
state <- sample(c("AL","AK","CA"),n,T)

#Create crosstab
ct <- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
ct #display crosstab on screen

#Trie to produce a html file
xtable(ct) #Error message: No method!
methods(xtable)



#Try to create a rich formatted table and insert it into Word
#with svViws, but only a little part of crosstab it inserted

docdir <- "r:\\r"
WordOpen(file.path(docdir, "cross.doc"))
viewfile <- view(ct, type = "summary", browse = FALSE)
WordGoto("ctview")
WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
WordActivate(async = TRUE)


#How could I create the latex-code for the crosstable?
w <- latex(ct) #would that work?

# I could not test this, because I didn´t install Miktex yet
# (I will do this soon)

Can someone help me?

Thanks in advance
Udo


--
Udo Koenig
Clinic for child and adolescent psychiatry
University of Marburg / Germany

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] OT: installing the XML package - xmlOutputBufferCreateBuffer problem

2008-02-15 Thread Benilton Carvalho

Hi,

first of, my apologies for the possibly off-topic message regarding a  
problem when installing the XML package (I meant to post at omegahat- 
help, but  I get 404 at http://www.omegahat.org/mailman/listinfo)


When installing the XML package using:

install.packages("XML")

everything seems to go fine... but then I try to load the package and  
I get:


> library(XML)
Error in dyn.load(file, ...) :
  unable to load shared library '/microarray/bin/R-devel/library/XML/ 
libs/XML.so':
  /microarray/bin/R-devel/library/XML/libs/XML.so: undefined symbol:  
xmlOutputBufferCreateBuffer

Error : .onLoad failed in 'loadNamespace' for 'XML'
Error: package/namespace load failed for 'XML'

Suggestions?

thanks a lot,

b

> sessionInfo()
R version 2.7.0 Under development (unstable) (2007-10-10 r43139)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.iso885915;LC_NUMERIC=C;LC_TIME=en_US.iso885915;LC_COLLATE=en_US.iso885915;LC_MONETARY=en_US.iso885915;LC_MESSAGES=en_US.iso885915;LC_PAPER=en_US.iso885915;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.iso885915;LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] tcltk_2.7.0 tools_2.7.0

$ xml2-config --version
2.6.23

$ uname -a
Linux compute-0-35.local 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT  
2006 x86_64 x86_64 x86_64 GNU/Linux



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

2008-02-15 Thread Marc Belisle
Howdee,

*** I know that the lmList() function exists, yet I don't want to use it.
***

Would anyone be kind enough to tell how I can apply the function lm() to
each level of a given factor so to obtain the intercept and slope for each
factor level within a matrix?

For instance, suppose a dataframe containing 3 variables: id, x and y.

I want to compute the function lm() for each level contained in id, as
lmList would do...

Thanks for your time,

Marc

===
Marc Bélisle
Professeur adjoint
Chaire de recherche du Canada en écologie spatiale et en écologie du paysage
Département de biologie
Université de Sherbrooke
2500 Boul. de l'Université
Sherbrooke, Québec
J1K 2R1 Canada

Tél: +1-819-821-8000 poste 61313
Fax: +1-819-821-8049
Courriél: [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.


[R] Transfer Crosstable to Word-Document

2008-02-15 Thread ukoenig
# Dear list,
# I am an R-beginner and
# spent the last days looking for a method to insert tables produced
# with R into a word document. I thought about SPPS:  copy a table from
# an SPO-file and paste it into a word document
# (if needed do some formatting with that table).
# Annother idea was, to produce a TEX-file,
# insert it and make it a word-table.

# I found the following libraries, which seemed to be promising:
# xtable
# prettyR
# R2HTML
# Hmisc
# SciViews / svViews



###
## My example: a crosstable (made with CrossTable from lib gmodels 
###

library(gmodels)
library(xtable)
library(svViews)

# Data for crosstabulation
set.seed(1)
n <- 200
sex <- sample(c("f","m"),n,T)
state <- sample(c("AL","AK","CA"),n,T)

#Create crosstab
ct <- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
ct #display crosstab on screen

#Trie to produce a html file
xtable(ct) #Error message: No method!
methods(xtable)



#Try to create a rich formatted table and insert it into Word
#with svViws, but only a little part of crosstab it inserted

docdir <- "r:\\r"
WordOpen(file.path(docdir, "cross.doc"))
viewfile <- view(ct, type = "summary", browse = FALSE)
WordGoto("ctview")
WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
WordActivate(async = TRUE)


#How could I create the latex-code for the crosstable?
w <- latex(ct) #would that work?

# I could not test this, because I didn´t install Miktex yet
# (I will do this soon)

Can someone help me?

Thanks in advance
Udo


--
Udo Koenig
Clinic for child and adolescent psychiatry
University of Marburg / Germany

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

2008-02-15 Thread markleeds
>From: mohamed nur anisah <[EMAIL PROTECTED]>
>Date: 2008/02/15 Fri AM 07:13:15 CST
>To: r-help@r-project.org
>Subject: [R] help on loop function

a similar ( if not identical ? ) question was asked a few days ago and the 
answer is at the link below.

http://article.gmane.org/gmane.comp.lang.r.general/106129


>Dear lists,
>   
>  Anysuggestion on how to write a loop function which has nx2 matrix as an 
> input, where each of the row represents an interval. the function should 
> return a mx2 matrix containing the no matched interval of x?? i've tried my 
> own function but it's only applies for 2x2 matrix. 
>   
>  Here is my code:
>   
>  overlap<-function(x,y){
>m=length(x)
>n=length(y)
> for(i in 1:m){
>  for(j in 1:n){
>   if(x[i]>=y[j]) print(TRUE)
>   else print(FALSE)
> }
>   } 
>  }
>   
>  Many thanks!! 
>   
>  Cheers,
>  Anisah
>
>   
>-
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Transfer Crosstable to Word-Document

2008-02-15 Thread Gabor Grothendieck
Here are 2 ways:

1. Display it on the screen and hit the PrintScreen button.
Then paste that into Word and use Word's image editor
to crop it and expand or shrink it appropriately.

2. Run this in R:

capture.output(CrossTable(...whatever...), file = "clipboard")

Paste the clipboard into Word and change the font of the
pasted text to Courier or other fixed space font and change its
size too if need be.

On Fri, Feb 15, 2008 at 10:30 AM,  <[EMAIL PROTECTED]> wrote:
> # Dear list,
> # I am an R-beginner and
> # spent the last days looking for a method to insert tables produced
> # with R into a word document. I thought about SPPS:  copy a table from
> # an SPO-file and paste it into a word document
> # (if needed do some formatting with that table).
> # Annother idea was, to produce a TEX-file,
> # insert it and make it a word-table.
>
> # I found the following libraries, which seemed to be promising:
> # xtable
> # prettyR
> # R2HTML
> # Hmisc
> # SciViews / svViews
>
>
>
> ###
> ## My example: a crosstable (made with CrossTable from lib gmodels 
> ###
>
> library(gmodels)
> library(xtable)
> library(svViews)
>
> # Data for crosstabulation
> set.seed(1)
> n <- 200
> sex <- sample(c("f","m"),n,T)
> state <- sample(c("AL","AK","CA"),n,T)
>
> #Create crosstab
> ct <- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
> ct #display crosstab on screen
>
> #Trie to produce a html file
> xtable(ct) #Error message: No method!
> methods(xtable)
>
>
>
> #Try to create a rich formatted table and insert it into Word
> #with svViws, but only a little part of crosstab it inserted
>
> docdir <- "r:\\r"
> WordOpen(file.path(docdir, "cross.doc"))
> viewfile <- view(ct, type = "summary", browse = FALSE)
> WordGoto("ctview")
> WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
> WordActivate(async = TRUE)
>
>
> #How could I create the latex-code for the crosstable?
> w <- latex(ct) #would that work?
>
> # I could not test this, because I didn´t install Miktex yet
> # (I will do this soon)
>
> Can someone help me?
>
> Thanks in advance
> Udo
>
>
> --
> Udo Koenig
> Clinic for child and adolescent psychiatry
> University of Marburg / Germany
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Extract from matrix

2008-02-15 Thread _Fede_

Hi all.

I have certain problem with the extraction of data from matrices. I know how
extract elements from a matrix, but what I would like to do is to extract a
concrete number, not an element. For example if I have this matrix X:

 [,1] [,2] [,3] [,4]
[1,]3   13   23   33
[2,]9   19   29   39
[3,]   10   20   30   40

I can do X[-2] or X[2] in order to eliminate the element of the matrix or to
extract it, respectively.

But, what I need is to extract or to eliminate a value of the matrix. For
example the 29.

Can I do this? How?

Thanks for the help.
-- 
View this message in context: 
http://www.nabble.com/Extract-from-matrix-tp15502655p15502655.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] Behaviour of integrate (was 'Poisson-lognormal probability calcul ations')

2008-02-15 Thread k . jewell
Hi again,

Adding further information to my own query, this function gets to the core
of the problem, which I think lies in the behaviour of 'integrate'.
-
function (x, meanlog = 0, sdlog = 1, ...) {
require(stats)
integrand <- function(t, x, meanlog, sdlog) dpois(x,t)*dlnorm(t,
meanlog, sdlog)
mapply(function(x, meanlog, sdlog, ...)
#(1/gamma(x+1))*
 integrate(function(t, x, meanlog, sdlog)
#   gamma(x+1)*
  integrand(t, x, meanlog, sdlog),
  lower = 0, upper = Inf, x = x, meanlog = meanlog, sdlog =
sdlog, ...)$value,
   x, meanlog, sdlog, ...
   )
   }

Mathematically, the presence or not of the two commented lines should make
no difference; they multiply the integrand by a constant (with respect to
the integration), then divide the result by the same constant. In practice
they make a big difference! I guess they're altering the behaviour of the
'integrate'.

I'd have thought the presence of the lines would worsen the behaviour.
Without the lines the integrand is reasonably small, the integral is < 1.
With the lines the limit on the integral is x!,  leading to "non-finite
function values" for x much > 170, even if we use logs to get around the
limit on gamma(x).

In fact with the lines the plot of function(x) v. x looks reasonable (but I
don't know if the values are correct!!), but without the lines it looks
silly, I just don't believe it!

I thought the problem might relate to the note in ?integrate "If the
function is approximately constant (in particular, zero) over nearly all its
range it is possible that the result and error estimate may be seriously
wrong.". I wouldn't really expect multiplication by a large constant to fix
such errors (??), but the lognormal distribution is skew so it might be
considered "approximately constant ... over nearly all its range". Even 
though ...
> integrate(dlnorm, 0, Inf)
1 with absolute error < 2.5e-07
... suggests that this is not the source of the problem,  I tried changing
variables to integrate over a normally distributed variable:

function (x, meanlog = 0, sdlog = 1, ...) {
require(stats)
integrand <- function(t, x, meanlog, sdlog) dpois(x,exp(t))*dnorm(t,
meanlog, sdlog)
mapply(function(x, meanlog, sdlog, ...)
 #  (1/gamma(x+1))*
 integrate(function(t, x, meanlog, sdlog)
 #  gamma(x+1)*
  integrand(t, x, meanlog, sdlog),
  lower = -Inf, upper = Inf, x = x, meanlog = meanlog, sdlog =
sdlog, ...)$value,
   x, meanlog, sdlog, ...
   )
   }
-
Still no better; with the constants the values look reasonably smooth (but
are they correct??), without the constants the values are silly.

I've tried reducing rel.tol and increasing subdivisions, they change the
behaviour a little but don't "fix" it, and I still get the marked difference
between the presence and absence of those lines (and I'm increasingly unsure
whether either answer is correct!).

I'm still trying. but I really think I'm going nowhere. Has anyone any
ideas?

Thanks in advance,

Keith Jewell
mailto:[EMAIL PROTECTED] telephone (direct) +44 (0)1386 842055
> -Original Message-
> From: Jewell, Keith
> Sent: 15 February 2008 11:16
> To: 'r-help@r-project.org'
> Subject: Poisson-lognormal probability calculations
> 
> Hi,
> 
> just for the record, although I don't think it's relevant (!)
> -
> > sessionInfo()
> R version 2.6.0 (2007-10-03)
> i386-pc-mingw32
> 
> locale:
> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
> Kingdom.1252;LC_MONETARY=English_United
> Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
> 
> attached base packages:
> [1] stats4splines   stats graphics  grDevices utils
> datasets
> methods   base
> 
> other attached packages:
> [1] VGAM_0.7-5 xlsReadWrite_1.3.2
> 
> 
> I'm having some problems with a Poisson-lognormal density (mass?)
> function.
> 
> VGAM has the dpolono function, but that doesn't work for x-values over
> 170, and I need to go to *much* bigger numbers. It fails first because
> of gamma overflow, then because of non-finite integrand.
> -
> > VGAM::dpolono(170)
> [1] 4.808781e-09
> > VGAM::dpolono(171)
> [1] 0
> Warning message:
> In VGAM::dpolono(171) : value out of range in 'gammafn'
> > VGAM::dpolono(172)
> [1] 0
> Warning message:
> In VGAM::dpolono(172) : value out of range in 'gammafn'
> > VGAM::dpolono(173)
> [1] 0
> Warning message:
> In VGAM::dpolono(173) : value out of range in 'gammafn'
> > VGAM::dpolono(174)
> Error in integrate(f = integrand, lower = -Inf, upper = Inf, x = x[i],
> :
>   non-finite function value
> -
> 
> I tidied up a lit

Re: [R] OT: installing the XML package - xmlOutputBufferCreateBuffer problem

2008-02-15 Thread Prof Brian Ripley
You need a later version of libxml2 (or at least, a different one as 
possibly an older one would also work).  I met this on Windows -- 2.6.23 
is old (more than 2 years), and I believe 2.6.28, 2.6.30 and 2.6.31 work.

The Omegahat lists have been defunct for a while, AFAIK.  I'd have used 
R-devel for this one ('discussion unintelligible to non-programmers').
Although not relevant here, there is a general principle that questions 
about the R-devel version of R should go to R-devel.

On Fri, 15 Feb 2008, Benilton Carvalho wrote:

> Hi,
>
> first of, my apologies for the possibly off-topic message regarding a problem 
> when installing the XML package (I meant to post at omegahat-help, but  I get 
> 404 at http://www.omegahat.org/mailman/listinfo)
>
> When installing the XML package using:
>
> install.packages("XML")
>
> everything seems to go fine... but then I try to load the package and I get:
>
>> library(XML)
> Error in dyn.load(file, ...) :
> unable to load shared library 
> '/microarray/bin/R-devel/library/XML/libs/XML.so':
> /microarray/bin/R-devel/library/XML/libs/XML.so: undefined symbol: 
> xmlOutputBufferCreateBuffer
> Error : .onLoad failed in 'loadNamespace' for 'XML'
> Error: package/namespace load failed for 'XML'
>
> Suggestions?
>
> thanks a lot,
>
> b
>
>> sessionInfo()
> R version 2.7.0 Under development (unstable) (2007-10-10 r43139)
> x86_64-unknown-linux-gnu

If you are going to use R-devel, we suggest you at least use a recent 
version.  That one is lacking all the bug fixes in 2.6.1 and 2.6.2, as 
well as lots of nice features.

> locale:
> LC_CTYPE=en_US.iso885915;LC_NUMERIC=C;LC_TIME=en_US.iso885915;LC_COLLATE=en_US.iso885915;LC_MONETARY=en_US.iso885915;LC_MESSAGES=en_US.iso885915;LC_PAPER=en_US.iso885915;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.iso885915;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] tcltk_2.7.0 tools_2.7.0
>
> $ xml2-config --version
> 2.6.23


-- 
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] Transfer Crosstable to Word-Document

2008-02-15 Thread ukoenig

Thank you Gabor,
but with 1. or 2. I don´t get
a table, which can be changed and formatted using the WORD table functions
(like changing column width and formatting text in rows).

The result of 1. ist an bitmap and
the result of 2. an ASCII-Table

A rich formatted (*.rtf) table/object would be better.
I tried this with the view() (see below).
Udo



Quoting Gabor Grothendieck <[EMAIL PROTECTED]>:

> Here are 2 ways:
>
> 1. Display it on the screen and hit the PrintScreen button.
> Then paste that into Word and use Word's image editor
> to crop it and expand or shrink it appropriately.
>
> 2. Run this in R:
>
> capture.output(CrossTable(...whatever...), file = "clipboard")
>
> Paste the clipboard into Word and change the font of the
> pasted text to Courier or other fixed space font and change its
> size too if need be.
>
> On Fri, Feb 15, 2008 at 10:30 AM,  <[EMAIL PROTECTED]> wrote:
> > # Dear list,
> > # I am an R-beginner and
> > # spent the last days looking for a method to insert tables produced
> > # with R into a word document. I thought about SPPS:  copy a table from
> > # an SPO-file and paste it into a word document
> > # (if needed do some formatting with that table).
> > # Annother idea was, to produce a TEX-file,
> > # insert it and make it a word-table.
> >
> > # I found the following libraries, which seemed to be promising:
> > # xtable
> > # prettyR
> > # R2HTML
> > # Hmisc
> > # SciViews / svViews
> >
> >
> >
> > ###
> > ## My example: a crosstable (made with CrossTable from lib gmodels 
> > ###
> >
> > library(gmodels)
> > library(xtable)
> > library(svViews)
> >
> > # Data for crosstabulation
> > set.seed(1)
> > n <- 200
> > sex <- sample(c("f","m"),n,T)
> > state <- sample(c("AL","AK","CA"),n,T)
> >
> > #Create crosstab
> > ct <- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
> > ct #display crosstab on screen
> >
> > #Trie to produce a html file
> > xtable(ct) #Error message: No method!
> > methods(xtable)
> >
> >
> >
> > #Try to create a rich formatted table and insert it into Word
> > #with svViws, but only a little part of crosstab it inserted
> >
> > docdir <- "r:\\r"
> > WordOpen(file.path(docdir, "cross.doc"))
> > viewfile <- view(ct, type = "summary", browse = FALSE)
> > WordGoto("ctview")
> > WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
> > WordActivate(async = TRUE)
> >
> >
> > #How could I create the latex-code for the crosstable?
> > w <- latex(ct) #would that work?
> >
> > # I could not test this, because I didn´t install Miktex yet
> > # (I will do this soon)
> >
> > Can someone help me?
> >
> > Thanks in advance
> > Udo
> >
> >
> > --
> > Udo Koenig
> > Clinic for child and adolescent psychiatry
> > University of Marburg / Germany
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] RGTK2 and glade on Windows - GUI newbie

2008-02-15 Thread Michael Lawrence
That would be a good idea. I'm finishing up a much more comprehensive guide
that will become available soon.

Thanks for the suggestion,
Michael

2008/2/14 Felix Andrews <[EMAIL PROTECTED]>:

> I just discovered a good introduction to the RGtk2 package:
> RShowDoc("overview2", package="RGtk2")
>
> I have been using RGtk2 for over a year without knowing about that,
> and struggling with the API documentation, so can I suggest that it be
> mentioned somewhere prominent? i.e. put it on the project web-page,
> and make it a vignette so that it appears on the CRAN package page.
>
> Cheers,
> Felix
>
>
> 2008/2/11 Felix Andrews <[EMAIL PROTECTED]>:
> > Yes, a GUI based on GTK+ (with or without Glade) will work on Windows
> XP.
> >
> >  If what you want to do is relatively straightforward (say, without any
> >  fancy formatting, or advanced event handling) then you should consider
> >  gWidgets. Look at the vignette in the gWidgets package.
> >
> >  If you do decide to go with RGtk2 directly rather than gWidgets, look
> >  at demo(package="RGtk2"). If you are using Glade, you might want to
> >  look at the source code for Rattle, which is a GUI built with Glade:
> >  see http://rattle.googlecode.com/
> >  and http://datamining.togaware.com/survivor/Installation_Details.html
> >  (Another example is hydrosanity: http://hydrosanity.googlecode.com/)
> >
> >  By the way, there is a special mailing list for GUI issues:
> >  https://stat.ethz.ch/mailman/listinfo/r-sig-gui
> >
> >  Felix
> >
> >
> >
> >  On Mon, Feb 11, 2008 at 9:52 PM, Anja Kraft
> >  <[EMAIL PROTECTED]> wrote:
> >  > Hallo,
> >  >
> >  >  I'd like to write a GUI (first choice with GTK+).
> >  >  I've surfed through the R- an Omegahat-Pages, because I'd like to
> use
> >  >  RGTK2, GTK 2.10.11 in combination with glade on Windows XP (perhaps
> later
> >  >  Unix, Mac).
> >  >  I've found a lot of different information. Because of the
> information I'm
> >  >  not sure, if this combination is running on Windows XP and I'm
> unsure how
> >  >  it works.
> >  >
> >  >  Is there anyone, who has experience with this combination (if it
> works)
> >  >  and could tell me, where I could find something like a tutorial, how
> this
> >  >  combination is used together and how it works?
> >  >
> >  >  Thank you very much,
> >  >
> >  >  Anja Kraft
> >  >
> >  >  __
> >  >  R-help@r-project.org mailing list
> >  >  https://stat.ethz.ch/mailman/listinfo/r-help
> >  >  PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >  >  and provide commented, minimal, self-contained, reproducible code.
> >  >
> >
> >
> >
> >  --
> >  Felix Andrews / $B0BJ!N)(B
> >  PhD candidate
> >  Integrated Catchment Assessment and Management Centre
> >  The Fenner School of Environment and Society
> >  The Australian National University (Building 48A), ACT 0200
> >  Beijing Bag, Locked Bag 40, Kingston ACT 2604
> >  http://www.neurofractal.org/felix/
> >  3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8
> >
>
>
>
> --
> Felix Andrews / $B0BJ!N)(B
> PhD candidate
> Integrated Catchment Assessment and Management Centre
> The Fenner School of Environment and Society
> The Australian National University (Building 48A), ACT 0200
> Beijing Bag, Locked Bag 40, Kingston ACT 2604
> http://www.neurofractal.org/felix/
> 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8
>

[[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] Error 'singular gradient' in nonlinear model fitting

2008-02-15 Thread Peter Dalgaard
HongSheng Liao wrote:
> w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
> start=list(alpha=1, beta=3),
> data=spottedseatrout2004.female.data)
>
> I am trying to fit above model to length-weight data of a fish species
> (spotted seatrout) by year (1999-2006).  The convergence occurred for all
> the years except 2002 and 2004.  In these two year, R shows the error
> called 'singular gradient' in the model.  Could anyone please help me to
> fix the error?  I don't think there are any problems with my data because I
> can fit the same model to 2004 data without any problems using SAS.  Thank
> you very much in advance.
>   
If your starting values are poor, it can be a toss-up whether nls() 
converges or not. One idea is to try the PORT algorithm, another is to 
get better starting values from
 
cf <- coef(lm(log(WEIGHT*454)~log(TOTAL)))
start = list(alpha=exp(cf[1]), beta=cf[2])
> Hongsheng (Hank) Liao, Ph.D.
> Lab Manager
> Center for Quantitative Fisheries Ecology
> 800 West 46th Street
> Old Dominion University
> Norfolk, Virginia 23508
> Phone:757.683.4571
> Fax:757.683.5293
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


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

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


Re: [R] Error 'singular gradient' in nonlinear model fitting

2008-02-15 Thread Gabor Grothendieck
Try fitting regressing log(WEIGHT) against log(TOTAL) using lm
and then transform the results into starting values for nls (or
possibly that is sufficient and you don't need the nls results).

On Fri, Feb 15, 2008 at 12:41 PM, HongSheng Liao <[EMAIL PROTECTED]> wrote:
>
> w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
>start=list(alpha=1, beta=3),
>data=spottedseatrout2004.female.data)
>
> I am trying to fit above model to length-weight data of a fish species
> (spotted seatrout) by year (1999-2006).  The convergence occurred for all
> the years except 2002 and 2004.  In these two year, R shows the error
> called 'singular gradient' in the model.  Could anyone please help me to
> fix the error?  I don't think there are any problems with my data because I
> can fit the same model to 2004 data without any problems using SAS.  Thank
> you very much in advance.
>
> Hongsheng (Hank) Liao, Ph.D.
> Lab Manager
> Center for Quantitative Fisheries Ecology
> 800 West 46th Street
> Old Dominion University
> Norfolk, Virginia 23508
> Phone:757.683.4571
> Fax:757.683.5293
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] lmList, tapply() and lm()

2008-02-15 Thread Chuck Cleland
On 2/15/2008 11:00 AM, Marc Belisle wrote:
> Howdee,
> 
> *** I know that the lmList() function exists, yet I don't want to use it.
> ***
> 
> Would anyone be kind enough to tell how I can apply the function lm() to
> each level of a given factor so to obtain the intercept and slope for each
> factor level within a matrix?
> 
> For instance, suppose a dataframe containing 3 variables: id, x and y.
> 
> I want to compute the function lm() for each level contained in id, as
> lmList would do...

   Something like this?

t(sapply(split(df, list(df$id)),
function(subd){coef(lm(y ~ x, data = subd))}))

> Thanks for your time,
> 
> Marc
> 
> ===
> Marc Bélisle
> Professeur adjoint
> Chaire de recherche du Canada en écologie spatiale et en écologie du paysage
> Département de biologie
> Université de Sherbrooke
> 2500 Boul. de l'Université
> Sherbrooke, Québec
> J1K 2R1 Canada
> 
> Tél: +1-819-821-8000 poste 61313
> Fax: +1-819-821-8049
> Courriél: [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. 

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

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


[R] Error 'singular gradient' in nonlinear model fitting

2008-02-15 Thread HongSheng Liao

w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
start=list(alpha=1, beta=3),
data=spottedseatrout2004.female.data)

I am trying to fit above model to length-weight data of a fish species
(spotted seatrout) by year (1999-2006).  The convergence occurred for all
the years except 2002 and 2004.  In these two year, R shows the error
called 'singular gradient' in the model.  Could anyone please help me to
fix the error?  I don't think there are any problems with my data because I
can fit the same model to 2004 data without any problems using SAS.  Thank
you very much in advance.

Hongsheng (Hank) Liao, Ph.D.
Lab Manager
Center for Quantitative Fisheries Ecology
800 West 46th Street
Old Dominion University
Norfolk, Virginia 23508
Phone:757.683.4571
Fax:757.683.5293

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

2008-02-15 Thread Gavin Simpson
On Fri, 2008-02-15 at 08:10 -0800, _Fede_ wrote:
> Hi all.
> 
> I have certain problem with the extraction of data from matrices. I know how
> extract elements from a matrix, but what I would like to do is to extract a
> concrete number, not an element. For example if I have this matrix X:
> 
>  [,1] [,2] [,3] [,4]
> [1,]3   13   23   33
> [2,]9   19   29   39
> [3,]   10   20   30   40
> 
> I can do X[-2] or X[2] in order to eliminate the element of the matrix or to
> extract it, respectively.
> 
> But, what I need is to extract or to eliminate a value of the matrix. For
> example the 29.
> 
> Can I do this? How?

Is this the sort of thing you want?

> mat <- matrix(c(3,9,10,13,19,20,23,29,30,33,39,40), ncol = 4)
> mat
 [,1] [,2] [,3] [,4]
[1,]3   13   23   33
[2,]9   19   29   39
[3,]   10   20   30   40
> which(mat == 29)
[1] 8
> mat[which(mat == 29)]
[1] 29
> mat[which(mat == 29)] <- NA
> mat
 [,1] [,2] [,3] [,4]
[1,]3   13   23   33
[2,]9   19   NA   39
[3,]   10   20   30   40

HTH

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.


[R] predict.lm with matrix as newdata

2008-02-15 Thread Marlin Keith Cox
Z is a matrix and when I run the following line, it creates a prediction
estimate using each column, how can I get it an estimate for each individual
number.  I have tried changing Z to a data.frame, but this does not do it
either.

model.lm<-lm(w~x)

pred.est <- predict.lm(model.lm, data.frame(x=Z))

Thanks in advance,
keith

-- 
Keith Cox, Ph.D.
Sitka Sound Science Center
Fisheries Biologist
P.O. Box 464
Sitka, Alaska, 99835

907 752-0563
[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] Error 'singular gradient' in nonlinear model fitting

2008-02-15 Thread Ravi Varadhan
Try a different set of starting values for alpha & beta.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of HongSheng Liao
Sent: Friday, February 15, 2008 12:42 PM
To: r-help@r-project.org
Subject: [R] Error 'singular gradient' in nonlinear model fitting


w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
start=list(alpha=1, beta=3),
data=spottedseatrout2004.female.data)

I am trying to fit above model to length-weight data of a fish species
(spotted seatrout) by year (1999-2006).  The convergence occurred for all
the years except 2002 and 2004.  In these two year, R shows the error
called 'singular gradient' in the model.  Could anyone please help me to
fix the error?  I don't think there are any problems with my data because I
can fit the same model to 2004 data without any problems using SAS.  Thank
you very much in advance.

Hongsheng (Hank) Liao, Ph.D.
Lab Manager
Center for Quantitative Fisheries Ecology
800 West 46th Street
Old Dominion University
Norfolk, Virginia 23508
Phone:757.683.4571
Fax:757.683.5293

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

2008-02-15 Thread Kathy Gerber
Earlier today I sent a question to Frank Harrell as an R developer with 
whom I am most familiar.  He suggested also that I put my questions to 
the list for additional responses.  Next month I'll be giving a talk on 
R as an example of high quality open source software.  I think there is 
much to learn from R as a high quality extensible product that (at least 
as far as I can tell) has never been "spun" or "hyped" like so many open 
source fads.

The question that intrigues me the most is why is R as an open source 
project is so incredibly successful and other projects, say for example, 
Octave don't enjoy that level of success?

I have some ideas of course, but I would really like to know your 
thoughts when you look at R from such a vantage point.

Thanks.
Kathy Gerber
University of Virginia
ITC - Research Computing Support

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


Re: [R] No response for help

2008-02-15 Thread Gabor Grothendieck
You will have better luck in soliciting responses if you
follow the line at the bottom of every r-help message and
post minimal reproducible code.  Also read the posting
guide.

On Fri, Feb 15, 2008 at 8:29 AM, G Ilhamto <[EMAIL PROTECTED]> wrote:
> Dear R admin,
>
> I sent so many emails but none was posted.
> What happened?
>
> Thanks
> Ilham

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

2008-02-15 Thread Douglas Bates
On Fri, Feb 15, 2008 at 8:59 AM, Daniel Malter <[EMAIL PROTECTED]> wrote:
> Thanks for your replies. My real problem is that, for my real data, I get
>  basically the same results from r2 and r3 (so to speak), but the coefficient
>  estimates and significance levels for r1 are very different from those of r2
>  and r3. And therefore, I do not know which of the results to trust and which
>  not (if any).

For these data the development version (0.999375-4) of the lme4
package converges pretty rapidly to an estimate of zero for the
variance component.

> dat <- data.frame(Y = c(0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1),
+   X = c(1,2,3,4,3,1,0,0,2,3,3,2,4,3,2,1,1,3,4,2,3),
+   Subject = gl(7, 1, len = 21, labels = letters[1:7]))
> dat
   Y X Subject
1  0 1   a
2  1 2   b
3  1 3   c
4  1 4   d
5  1 3   e
6  0 1   f
7  0 0   g
8  0 0   a
9  0 2   b
10 0 3   c
11 1 3   d
12 1 2   e
13 1 4   f
14 1 3   g
15 0 2   a
16 0 1   b
17 0 1   c
18 1 3   d
19 1 4   e
20 1 2   f
21 1 3   g
> print(r1 <- lmer(Y~X+(1|Subject), dat, binomial, verbose = 1))
  0: 14.071151: 0.942809 -4.97872  2.43040
  1: 14.006211: 0.861564 -4.96215  2.51055
  2: 13.936051: 0.779991 -5.00923  2.44399
  3: 13.723943: 0.226602 -5.11306  2.46057
  4: 13.699745: 0.0880156 -5.07147  2.47386
  5: 13.695821:  0.0 -4.98859  2.42895
  6: 13.695469:  0.0 -4.98540  2.43314
  7: 13.695462:  0.0 -4.98163  2.43166
  8: 13.695460:  0.0 -4.97873  2.43040
  9: 13.695460:  0.0 -4.97872  2.43040
 10: 13.695460:  0.0 -4.97872  2.43040
Generalized linear mixed model fit by the Laplace approximation
Formula: Y ~ X + (1 | Subject)
   Data: dat
   AIC   BIC logLik deviance
 19.70 22.83 -6.84813.70
Random effects:
 Groups  NameVariance Std.Dev.
 Subject (Intercept)  00
Number of obs: 21, groups: Subject, 7

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept)   -4.979  2.315  -2.150   0.0315 *
X  2.430  1.026   2.368   0.0179 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
  (Intr)
X -0.955

It is not terribly surprising if you look at a plot of the data.
There are only 3 binary responses per subject, which is not much
information per subject.

I'm not sure what PQL would give for these data but the Laplace
approximation will just revert to a generalized linear model without
any random effects.

>
>  The session info follows:
>
>  R version 2.6.0 (2007-10-03)
>  i386-pc-mingw32
>
>  locale:
>  LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
>  States.1252;LC_MONETARY=English_United
>  States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
>  attached base packages:
>  [1] stats graphics  grDevices utils datasets  methods   base
>
>  other attached packages:
>  [1] nlme_3.1-86   mgcv_1.3-29   lme4_0.99875-9Matrix_0.999375-3
>  lattice_0.16-5
>
>  loaded via a namespace (and not attached):
>  [1] grid_2.6.0
>
>  Cheers,
>  Daniel
>
>
>  -
>  cuncta stricte discussurus
>  -
>
>  -Ursprüngliche Nachricht-
>  Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Douglas
>  Bates
>  Gesendet: Friday, February 15, 2008 7:29 AM
>  An: Daniel Malter
>  Cc: [EMAIL PROTECTED]
>  Betreff: Re: [R] LMER
>
>
>
>  Could you send us the output of sessionInfo() please so we can see which
>  version of the lme4 package you are using?  In recent versions, especially
>  the development version available as
>
>  install.packages("lme4", repos = "http://r-forge.r-project.org";)
>
>  the PQL algorithm is no longer used.  The Laplace approximation is now the
>  default.  The adaptive Gauss-Hermite quadrature (AGQ) approximation may be
>  offered in the future.
>
>  If the documentation indicates that PQL is the default then that is a
>  documentation error.  With the currently available implementation of the
>  direct optimization of the Laplace approximation to the log-likelihood for
>  the model there is no purpose in offering PQL.
>
>  On Thu, Feb 14, 2008 at 6:50 PM, Daniel Malter <[EMAIL PROTECTED]> wrote:
>  > Hi,
>  >
>  >  I run the following models:
>  >
>  >  1a. lmer(Y~X+(1|Subject),family=binomial(link="logit")) and  1b.
>  > lmer(Y~X+(1|Subject),family=binomial(link="logit"),method="PQL")
>  >
>  >  Why does 1b produce results different from 1a? The reason why I am
>  > asking is  that the help states that "PQL" is the default of GLMMs
>  >
>  >  and
>  >
>  >  2. gamm(Y~X,family=binomial(link="logit"),random=list(Subject=~1))
>  >
>  >  The interesting thing about the example below is, that gamm is also
>  > supposed  to fit by "PQL". Interestingly, however, the GAMM fit yields
>  > about the  coefficient estimates of 1b. But the significance values of
>  > 1a. Any insight  woul

Re: [R] Transfer Crosstable to Word-Document

2008-02-15 Thread Don MacQueen
I usually use the
   write.table()
function (with tab as the delimiter) to write to 
a text file, then copy/paste into Word,
then use Word's convert text to table command.

Obviously, if one needs to do this for many, 
many, tables, the amount of manual manipulation 
is excessive. That's when products other than 
Word become better choices. (Framemaker, LaTeX 
come to mind)

-Don

At 4:30 PM +0100 2/15/08, [EMAIL PROTECTED] wrote:
># Dear list,
># I am an R-beginner and
># spent the last days looking for a method to insert tables produced
># with R into a word document. I thought about SPPS:  copy a table from
># an SPO-file and paste it into a word document
># (if needed do some formatting with that table).
># Annother idea was, to produce a TEX-file,
># insert it and make it a word-table.
>
># I found the following libraries, which seemed to be promising:
># xtable
># prettyR
># R2HTML
># Hmisc
># SciViews / svViews
>
>
>
>###
>## My example: a crosstable (made with CrossTable from lib gmodels 
>###
>
>library(gmodels)
>library(xtable)
>library(svViews)
>
># Data for crosstabulation
>set.seed(1)
>n <- 200
>sex <- sample(c("f","m"),n,T)
>state <- sample(c("AL","AK","CA"),n,T)
>
>#Create crosstab
>ct <- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
>ct #display crosstab on screen
>
>#Trie to produce a html file
>xtable(ct) #Error message: No method!
>methods(xtable)
>
>
>
>#Try to create a rich formatted table and insert it into Word
>#with svViws, but only a little part of crosstab it inserted
>
>docdir <- "r:\\r"
>WordOpen(file.path(docdir, "cross.doc"))
>viewfile <- view(ct, type = "summary", browse = FALSE)
>WordGoto("ctview")
>WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
>WordActivate(async = TRUE)
>
>
>#How could I create the latex-code for the crosstable?
>w <- latex(ct) #would that work?
>
># I could not test this, because I didn´t install Miktex yet
># (I will do this soon)
>
>Can someone help me?
>
>Thanks in advance
>Udo
>
>
>--
>Udo Koenig
>Clinic for child and adolescent psychiatry
>University of Marburg / Germany
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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

2008-02-15 Thread Henrique Dallazuanna
Try also:

mat[mat==29] <- NA

On 15/02/2008, _Fede_ <[EMAIL PROTECTED]> wrote:
>
>  Hi all.
>
>  I have certain problem with the extraction of data from matrices. I know how
>  extract elements from a matrix, but what I would like to do is to extract a
>  concrete number, not an element. For example if I have this matrix X:
>
>  [,1] [,2] [,3] [,4]
>  [1,]3   13   23   33
>  [2,]9   19   29   39
>  [3,]   10   20   30   40
>
>  I can do X[-2] or X[2] in order to eliminate the element of the matrix or to
>  extract it, respectively.
>
>  But, what I need is to extract or to eliminate a value of the matrix. For
>  example the 29.
>
>  Can I do this? How?
>
>  Thanks for the help.
>  --
>  View this message in context: 
> http://www.nabble.com/Extract-from-matrix-tp15502655p15502655.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.
>


-- 
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] How to estimate weekly Variance

2008-02-15 Thread Felipe Carrillo
Dear All:
Using the Excel formula below I am able to estimate
daily variance(Daily VarPD)for PD,but I can't figure
out how to estimate the Weekly variance for PD. Any
hints?

Daily VarPD = (PD * (1 - TD))/TD + VarTD *
((PD*(1-TD)+ PD^2*TD))/TD^3


WK  TDVARTD  PD   Daily VarPD
28  0.0147350.449   0   0
28  0.0124210.449   0   0
28  0.0143960.449   71  7005
28  0.0148980.449   132 14016
28  0.0135120.449   223 32506
28  0.0138860.449   224 31287
28  0.0137780.449   218 30528
29  0.0132740.449   228 34505
29  0.0130720.449   224 34531
29  0.0125180.449   488 117720
29  0.0132640.449   525 119323
29  0.0132330.449   80  9134
29  0.0101940.449   417 133067
29  0.0125670.449   82  10184
30  0.0146950.449   413 68893
30  0.0106340.449   373 103688
30  0.0139340.449   914 272719
30  0.0141070.449   213 28473
30  0.0143390.449   651 147016
30  0.0143750.449   521 102429
30  0.0163730.449   979 229104


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



  

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] ggplot2 used in a function - variable scope/environment

2008-02-15 Thread hadley wickham
Hi Martin,

Two comments:

 * ggplot always requires the data to be plotted to be stored in a
data.frame, not the environment  - this makes it possible to (e.g.)
save self contained plot objects - but that isn't the problem here,
the problem is setting up the appropriate mapping

 * aes_string makes it easier to build up aesthetic mappings
programmatically - aes_string(x = names(data)[1], y = names(data)[c])

Does that help?

Hadley

On Fri, Feb 15, 2008 at 2:21 PM, Martin Rittner
<[EMAIL PROTECTED]> wrote:
> Hi everybody!
>
>  I'm trying to use ggplot2 to return a plot from a function (so I can add
>  something or alter it then). Unfortunately, if I add a mapping to a
>  layer in the function, the variable *name* is stored in the layer,
>  rather than the variable's *value* - so that after the function returns
>  the ggplot2-object, it doesn't plot because the variable don't exist in
>  the environment calling the function.. e.g:
>
>  my function does something like:
>
>  getPlot<-function(da=NULL,...){
> #1st column holds x-values, others hold data series to plot...
> co<-as.character(names(da))
> co<-co[2:length(co)]
>
> pl<-ggplot(data=da)
> pl<-pl+scale_y_log10()+scale_x_continuous()
> for(c in co){
> 
> pl<-pl+geom_line(x=da[[1]],y=da[[c]],mapping=aes(x=da[[1]],y=da[[c]]))
> }
>
> return(pl)
>  }
>
>  I need to add every layer separately, because I want to be able to
>  explicitly define attributes for every data series (colour, size... e.g.
>  highlight only two specific out of 10 series...).
>
>  Anyway, my problem is this:
>
>  d<-data.frame(x=seq(0.0,1.0,length=5),y1=rnorm(5),y2=rnorm(5))
>  p<-getPlot(da=d)
>  p
>
>  returns with
>
>  Error in data.frame(..., check.names = FALSE) :
>arguments imply differing number of rows: 0, 5
>
>  and the plot object contains:
>
>  Title:
>  Labels:  x=, y=
>  ---
>  Data:x, y1, y2 [5x3]
>  Mapping:
>  Scales:  y,x -> y,x
>  $margins
>  [1] FALSE
>
>  $facets
>  [1] ". ~ ."
>
>  ---
>  geom_line: (colour=black, size=1, linetype=1, x=NA, y=NA) + (x=c(0,
>  0.25, 0.5, 0.75, 1), y=c(0.180036717548597, -0.369556903134046,
>  -0.924474152821948, -2.40773640658189, 0.801471591443009))
>  stat_sort: (...=) + (x=c(0, 0.25, 0.5, 0.75, 1), y=c(0.180036717548597,
>  -0.369556903134046, -0.924474152821948, -2.40773640658189,
>  0.801471591443009))
>  position_identity: ()
>  mapping: (x=da[[1]], y=da[[c]])
>
>  geom_line: (colour=black, size=1, linetype=1, x=NA, y=NA) + (x=c(0,
>  0.25, 0.5, 0.75, 1), y=c(-1.59744511956184, -0.9333541477049,
>  1.88697835844878, 0.921829569181679, -0.741077741846118))
>  stat_sort: (...=) + (x=c(0, 0.25, 0.5, 0.75, 1), y=c(-1.59744511956184,
>  -0.9333541477049, 1.88697835844878, 0.921829569181679, -0.741077741846118))
>  position_identity: ()
>  mapping: (x=da[[1]], y=da[[c]])
>
>  Note the mappings, they refer to "da" and "c" (defined in the function)
>  which are not available in the calling environment. Any Idea how I can
>  avoid the problem/paste the actual values in, like it did for the
>  geometry and the statistics?
>
>  Thanks, Martin
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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://had.co.nz/

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


Re: [R] History of R

2008-02-15 Thread Douglas Bates
On Fri, Feb 15, 2008 at 1:53 PM, Kathy Gerber <[EMAIL PROTECTED]> wrote:
> Earlier today I sent a question to Frank Harrell as an R developer with
>  whom I am most familiar.  He suggested also that I put my questions to
>  the list for additional responses.  Next month I'll be giving a talk on
>  R as an example of high quality open source software.  I think there is
>  much to learn from R as a high quality extensible product that (at least
>  as far as I can tell) has never been "spun" or "hyped" like so many open
>  source fads.

>  The question that intrigues me the most is why is R as an open source
>  project is so incredibly successful and other projects, say for example,
>  Octave don't enjoy that level of success?

First and foremost there is the incredible generosity of Ross Ihaka
and Robert Gentleman who, after spending an enormous amount of time
and effort in development of the initial implementation, did not
demand exclusive ownership of their work but allowed others to make
changes.  I believe Martin Maechler was the first non-Auckland person
to get write access to the source code repository and I'm sure that
the good experience of working at a distance with Martin persuaded R &
R to open it up to others.  Martin is polite, considerate, meticulous
and precise (he is a German-speaking Swiss so meticulous and precise
kind of comes with the territory) and you couldn't ask for a first
experience in sharing something that is very valuable to you with
someone whom you may never have met in person.

Not everyone has been that pleasant to work with.  One of the first
things that I did when I joined R-core was to blow up at Kurt and
Fritz about something - on Christmas Eve!  I surprised the group
didn't boot me out after that start.

When a project is gaining momentum the personalities of the initial
developers have a big influence on its success.  The R project has
been fortunate in that regard.

>  I have some ideas of course, but I would really like to know your
>  thoughts when you look at R from such a vantage point.

>  Thanks.
>  Kathy Gerber
>  University of Virginia
>  ITC - Research Computing Support
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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] History of R

2008-02-15 Thread Douglas Bates
On Fri, Feb 15, 2008 at 3:23 PM, Douglas Bates <[EMAIL PROTECTED]> wrote:
> On Fri, Feb 15, 2008 at 1:53 PM, Kathy Gerber <[EMAIL PROTECTED]> wrote:
>  > Earlier today I sent a question to Frank Harrell as an R developer with
>  >  whom I am most familiar.  He suggested also that I put my questions to
>  >  the list for additional responses.  Next month I'll be giving a talk on
>  >  R as an example of high quality open source software.  I think there is
>  >  much to learn from R as a high quality extensible product that (at least
>  >  as far as I can tell) has never been "spun" or "hyped" like so many open
>  >  source fads.
>
>  >  The question that intrigues me the most is why is R as an open source
>  >  project is so incredibly successful and other projects, say for example,
>  >  Octave don't enjoy that level of success?
>
>  First and foremost there is the incredible generosity of Ross Ihaka
>  and Robert Gentleman who, after spending an enormous amount of time
>  and effort in development of the initial implementation, did not
>  demand exclusive ownership of their work but allowed others to make
>  changes.  I believe Martin Maechler was the first non-Auckland person
>  to get write access to the source code repository and I'm sure that
>  the good experience of working at a distance with Martin persuaded R &
>  R to open it up to others.  Martin is polite, considerate, meticulous
>  and precise (he is a German-speaking Swiss so meticulous and precise
>  kind of comes with the territory) and you couldn't ask for a first

I meant to write "for a better first experience"

>  experience in sharing something that is very valuable to you with
>  someone whom you may never have met in person.
>
>  Not everyone has been that pleasant to work with.  One of the first
>  things that I did when I joined R-core was to blow up at Kurt and
>  Fritz about something - on Christmas Eve!  I surprised the group
>  didn't boot me out after that start.
>
>  When a project is gaining momentum the personalities of the initial
>  developers have a big influence on its success.  The R project has
>  been fortunate in that regard.
>
>
>
>  >  I have some ideas of course, but I would really like to know your
>  >  thoughts when you look at R from such a vantage point.
>
>  >  Thanks.
>  >  Kathy Gerber
>  >  University of Virginia
>  >  ITC - Research Computing Support
>  >
>  >  __
>  >  R-help@r-project.org mailing list
>  >  https://stat.ethz.ch/mailman/listinfo/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] ggplot2 used in a function - variable scope/environment

2008-02-15 Thread Martin Rittner
Hi everybody!

I'm trying to use ggplot2 to return a plot from a function (so I can add 
something or alter it then). Unfortunately, if I add a mapping to a 
layer in the function, the variable *name* is stored in the layer, 
rather than the variable's *value* - so that after the function returns 
the ggplot2-object, it doesn't plot because the variable don't exist in 
the environment calling the function.. e.g:

my function does something like:

getPlot<-function(da=NULL,...){ 
#1st column holds x-values, others hold data series to plot...
co<-as.character(names(da))
co<-co[2:length(co)]

pl<-ggplot(data=da)
pl<-pl+scale_y_log10()+scale_x_continuous()
for(c in co){

pl<-pl+geom_line(x=da[[1]],y=da[[c]],mapping=aes(x=da[[1]],y=da[[c]]))
}

return(pl)
}

I need to add every layer separately, because I want to be able to 
explicitly define attributes for every data series (colour, size... e.g. 
highlight only two specific out of 10 series...).

Anyway, my problem is this:

d<-data.frame(x=seq(0.0,1.0,length=5),y1=rnorm(5),y2=rnorm(5))
p<-getPlot(da=d)
p

returns with

Error in data.frame(..., check.names = FALSE) :
   arguments imply differing number of rows: 0, 5

and the plot object contains:

Title:
Labels:  x=, y=
---
Data:x, y1, y2 [5x3]
Mapping:
Scales:  y,x -> y,x
$margins
[1] FALSE

$facets
[1] ". ~ ."

---
geom_line: (colour=black, size=1, linetype=1, x=NA, y=NA) + (x=c(0, 
0.25, 0.5, 0.75, 1), y=c(0.180036717548597, -0.369556903134046, 
-0.924474152821948, -2.40773640658189, 0.801471591443009))
stat_sort: (...=) + (x=c(0, 0.25, 0.5, 0.75, 1), y=c(0.180036717548597, 
-0.369556903134046, -0.924474152821948, -2.40773640658189, 
0.801471591443009))
position_identity: ()
mapping: (x=da[[1]], y=da[[c]])

geom_line: (colour=black, size=1, linetype=1, x=NA, y=NA) + (x=c(0, 
0.25, 0.5, 0.75, 1), y=c(-1.59744511956184, -0.9333541477049, 
1.88697835844878, 0.921829569181679, -0.741077741846118))
stat_sort: (...=) + (x=c(0, 0.25, 0.5, 0.75, 1), y=c(-1.59744511956184, 
-0.9333541477049, 1.88697835844878, 0.921829569181679, -0.741077741846118))
position_identity: ()
mapping: (x=da[[1]], y=da[[c]])

Note the mappings, they refer to "da" and "c" (defined in the function) 
which are not available in the calling environment. Any Idea how I can 
avoid the problem/paste the actual values in, like it did for the 
geometry and the statistics?

Thanks, Martin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] wire.frame tick labels from matrix

2008-02-15 Thread Deepayan Sarkar
On 2/15/08, Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote:
>
>
>  Marlin Keith Cox said the following on 2/15/2008 11:39 AM:
>
> > Dear R Users, close to the end of this I used wireframe to create a 3D plot
>  > from a matrix.  The x and y axis tick labels (1-6) for each were created
>  > from the matrix being a 6X6 matrix. I need the axis tick labels to be the
>  > row and column headings which you can see in the output (mat.x).  I have
>  > tried several work arounds, but they have not been successful.
>  >
>  > Thanks in advance. keith
>  >
>  >
>  > rm(list=ls())
>  > sen<-read.csv("brooktroutsort.csv")
>  >
>  > #Resistance
>  > R=c(660, 548, 676, 763, 768, 692, 657, 630, 748, 680, 786, 645, 710, 677,
>  > 692, 732, 737, 651, 396,
>  > 601, 640, 448, 464, 472, 434, 487, 495, 426, 429, 456)
>  >
>  > #Detector length
>  > Lend=c(37.0,  39.0,  39.0,  39.0,  40.0,  41.5,  44.0,  45.0,  46.0,  47.0,
>  > 47.0,  48.0,
>  > 48.5,  49.0,  51.0,  53.0, 53.0,  60.0,  89.0, 103.0, 108.5, 118.0, 118.0,
>  > 123.0,
>  > 126.0, 138.0, 139.0, 141.0, 141.0, 151.0)
>  >
>  > #Errors to be multiplied by Restistance
>  > x=c(0,.05,.10,.15,.20,.25)
>  >
>  > #Errors to be multiplied by Detector length
>  > y=c(0,.01,.02,.03,.04,.05)
>  >
>  > #equation to predict water weight in grams
>  > a=3.453*((Lend^2)/R)+1.994
>  >
>  > X=(R%o%x+R)
>  >
>  > Y=((Lend%o%y+Lend)^2)
>  >
>  > num.x.col <- length(X[1,])
>  > num.y.col <- length(Y[1,])
>  > num.rows <- length(X[,1])
>  >
>  > Z <- matrix(nrow=num.rows, ncol=num.x.col*num.y.col)
>  >
>  > for( i in 1:num.rows)  {
>  >Z[i,] <- as.vector( Y[i,] %*% t(X[i,])^-1 )
>  > }
>  >
>  > pred.est <- 3.453*Z+1.994
>  > z=(pred.est-a)/a
>  >
>  > colnames(z)<- rep(c("X1","X2","X3","X4","X5","X6"),6)
>  >
>  > meanz=colMeans(z)
>  > mat.x <- matrix(meanz, nrow=6, ncol=6, byrow=TRUE)
>  >
>  > colnames(mat.x)<- c(0,1,2,3,4,5)
>  > rownames(mat.x)<-c(0,5,10,15,20,25)
>  > mat.x
>  >
>  >
>  > library(lattice)
>  > wireframe(mat.x,drape=TRUE,zlab=list("Proportion Error of Estimate",
>  > rot=90), xlab="Resistance Error (%) ",ylab="Length Error
>  > (%)",scale=list(arrows=FALSE))
>  > detach(z)
>  > detach(sen)
>  >
>  >
>
>
> Try:
>
>  mat.df <- data.frame(z = as.vector(mat.x))
>  mat.df$x <- rep(c(0,5,10,15,20,25), each = 6)
>  mat.df$y <- rep(c(0,1,2,3,4,5), times = 6)
>
>  library(lattice)
>  wireframe(z ~ x * y, mat.df,
>
>drape = TRUE,
>zlab = list("Proportion Error of Estimate", rot=90),
>xlab = "Resistance Error (%) ",
>ylab = "Length Error (%)",
>
>scales = list(arrows = FALSE))

A shortcut is

wireframe(mat.x, drape = TRUE, scales = list(arrows = FALSE),
  xlim = rownames(mat.x), ylim = colnames(mat.x))

It probably makes sense to do this automatically for the matrix method.

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Conditional Autoregressive (CAR) model simulation

2008-02-15 Thread Dae-Jin Lee
Hi all !

I would like to simulate spatial lattice/areal data with a conditional
autoregressive (CAR) structure, for a given neighbouring matrix and for a
autocorrelation "rho".

Is there any package or function in R to perform it ?

I found the function "CARsimu" in the hdeco library, but this is not what
I'm looking for

Thanks in advance

Dae-Jin

-- 
__

Dae-Jin Lee

Office/Despacho: 7.3.J04
Phone/Tlfno:+34 91 624 9175
Fax: +34 91 624 9430

Departamento de Estadística
Av. Universidad 30, Ed. Juan Benet
28911 Leganés (Madrid), SPAIN
Universidad Carlos III de Madrid

e-mail: [EMAIL PROTECTED]
   web: http://www.est.uc3m.es/daejin
__

[[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] wire.frame tick labels from matrix

2008-02-15 Thread Marlin Keith Cox
Dear R Users, close to the end of this I used wireframe to create a 3D plot
from a matrix.  The x and y axis tick labels (1-6) for each were created
from the matrix being a 6X6 matrix. I need the axis tick labels to be the
row and column headings which you can see in the output (mat.x).  I have
tried several work arounds, but they have not been successful.

Thanks in advance. keith


rm(list=ls())
sen<-read.csv("brooktroutsort.csv")

#Resistance
R=c(660, 548, 676, 763, 768, 692, 657, 630, 748, 680, 786, 645, 710, 677,
692, 732, 737, 651, 396,
601, 640, 448, 464, 472, 434, 487, 495, 426, 429, 456)

#Detector length
Lend=c(37.0,  39.0,  39.0,  39.0,  40.0,  41.5,  44.0,  45.0,  46.0,  47.0,
47.0,  48.0,
48.5,  49.0,  51.0,  53.0, 53.0,  60.0,  89.0, 103.0, 108.5, 118.0, 118.0,
123.0,
126.0, 138.0, 139.0, 141.0, 141.0, 151.0)

#Errors to be multiplied by Restistance
x=c(0,.05,.10,.15,.20,.25)

#Errors to be multiplied by Detector length
y=c(0,.01,.02,.03,.04,.05)

#equation to predict water weight in grams
a=3.453*((Lend^2)/R)+1.994

X=(R%o%x+R)

Y=((Lend%o%y+Lend)^2)

num.x.col <- length(X[1,])
num.y.col <- length(Y[1,])
num.rows <- length(X[,1])

Z <- matrix(nrow=num.rows, ncol=num.x.col*num.y.col)

for( i in 1:num.rows)  {
   Z[i,] <- as.vector( Y[i,] %*% t(X[i,])^-1 )
}

pred.est <- 3.453*Z+1.994
z=(pred.est-a)/a

colnames(z)<- rep(c("X1","X2","X3","X4","X5","X6"),6)

meanz=colMeans(z)
mat.x <- matrix(meanz, nrow=6, ncol=6, byrow=TRUE)

colnames(mat.x)<- c(0,1,2,3,4,5)
rownames(mat.x)<-c(0,5,10,15,20,25)
mat.x


library(lattice)
wireframe(mat.x,drape=TRUE,zlab=list("Proportion Error of Estimate",
rot=90), xlab="Resistance Error (%) ",ylab="Length Error
(%)",scale=list(arrows=FALSE))
detach(z)
detach(sen)


-- 
Keith Cox, Ph.D.
Sitka Sound Science Center
Fisheries Biologist
P.O. Box 464
Sitka, Alaska, 99835

907 752-0563
[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] Cholmod error `matrix not positive definite'

2008-02-15 Thread Douglas Bates
On Thu, Feb 14, 2008 at 3:14 PM, Douglas Bates <[EMAIL PROTECTED]> wrote:
> Could you tell us which version of the lme4 package you are using?
>  You can just send the output produced by
>
>  sessionInfo()
>
>  If you can make your data available so we can test it then please do
>  so.  If the data set is large you could send it to me in private email
>  and I will make it available on a web site.
>
>  I think that the development version of the lme4 package, available via
>
>  install.packages("lme4", repos = "http://r-forge.r-project.org";)
>
>  should be resistant to that type of error but I am willing to be shown
>  otherwise.

Thank you for sending your data in a separate message to me, Martjn.
One problem with your model is that the zone variable takes on only
two levels, "coast" and "inland".  It is very difficult to estimate a
variance due to zone, in addtion to a fixed effect for zone, when you
only have two levels.  If you wish to indicate that site is nested
within zone but estimate only fixed-effects for zone then you should
write the model as

aphids ~ densroot + zone + (1|zone:site)

This does give the six distinct levels for site within zone.

Using this model specification and the development version of lmer I
was able to fit models with densroot, vitality and totmas as
predictors.  A bit of exploratory graphics suggested the model

> m4 <- lmer(aphids~vitality*zone+(1|zone:site), aphids, family=quasipoisson)
> m4
Generalized linear mixed model fit by the Laplace approximation
Formula: aphids ~ vitality * zone + (1 | zone:site)
   Data: aphids
  AIC  BIC logLik deviance
 2437 2453  -1212 2425
Random effects:
 GroupsNameVariance Std.Dev.
 zone:site (Intercept) 119.54   10.9334
 Residual   75.138.6678
Number of obs: 120, groups: zone.site, 6

Fixed effects:
Estimate Std. Error t value
(Intercept)   -1.224  6.422 -0.1905
vitality   5.173  2.011  2.5723
zoneinland-8.935  9.714 -0.9198
vitality:zoneinland9.868  4.746  2.0793

Correlation of Fixed Effects:
(Intr) vitlty znnlnd
vitality-0.252
zoneinland  -0.661  0.167
vtlty:znnln  0.107 -0.424 -0.424

or perhaps

> (m5 <- lmer(aphids~vitality*zone+(vitality|zone:site), aphids, 
> family=quasipoisson))
Generalized linear mixed model fit by the Laplace approximation
Formula: aphids ~ vitality * zone + (vitality | zone:site)
   Data: aphids
  AIC  BIC logLik deviance
 2239 2261  -1112 2223
Random effects:
 GroupsNameVariance Std.Dev. Corr
 zone:site (Intercept) 291.78   17.0815
   vitality677.85   26.0355  -0.973
 Residual   29.525.4333
Number of obs: 120, groups: zone.site, 6

Fixed effects:
Estimate Std. Error t value
(Intercept)  -0.9467 9.7669 -0.0969
vitality  4.762514.8494  0.3207
zoneinland   -5.753914.0201 -0.4104
vitality:zoneinland   6.225021.1767  0.2940

Correlation of Fixed Effects:
(Intr) vitlty znnlnd
vitality-0.973
zoneinland  -0.697  0.678
vtlty:znnln  0.682 -0.701 -0.972


The enclosed plot was produced by

xyplot(sqrt(aphids) ~ vitality | zone, aphids, groups = site, type =
c("g", "p", "smooth"))
>  On Thu, Feb 14, 2008 at 10:36 AM, Martijn Vandegehuchte
>  <[EMAIL PROTECTED]> wrote:
>  > Dear R-users,
>  >
>  >  I'm new to R, so my apologies if this question doesn't make sense.
>  >
>  >  I've tried the following model in lmer, and it works perfectly:
>  >  model<-lmer(aphids~densroot+zone+(1|zone/site), family=quasipoisson)
>  >
>  >  But if I try the exact same model with a different variable, totmas, the 
> model looks as follows:
>  >  model<-lmer(aphids~totmas+zone+(1|zone/site), family=quasipoisson)
>  >
>  >  Totmas is also a continuous variable just like densroot, but in this case 
> I receive the following message:
>  >
>  >  CHOLMOD warning: &߆e
>  >  Error in objective(.par, ...) :
>  >   Cholmod error `matrix not positive definite' at 
> file:../Supernodal/t_cholmod_super_numeric.c, line 613
>  >
>  >  Moreover, if I test yet another continuous variable "vitality", to my 
> surprise R just crashes completely.
>  >
>  >
>  >  This is a mystery to me, especially because the variables totmas or 
> vitality don't give any problem when I build the exact same models in SAS 
> with proc glimmix...
>  >
>  >  Does someone have experience with this type of problem?
>  >
>  >  Thank you in advance,
>  >
>  >  Martijn.
>  >
>  >
>  >
>  >
>  >  --
>  >  Martijn Vandegehuchte
>  >  Ghent University
>  >  Department Biology
>  >  Terrestrial Ecology Unit
>  >  K.L.Ledeganckstraat 35
>  >  B-9000 Ghent
>  >  telephone: +32 (0)9/264 50 84
>  >  e-mail: [EMAIL PROTECTED]
>  >
>  >  website TEREC: www.ecology.ugent.be/terec
>  >
>  > [[alternative HTML version deleted]]
>  >
>  >
>  > __
>  >  R-help@r-project.org mailing list
>  >  https://sta

Re: [R] wire.frame tick labels from matrix

2008-02-15 Thread Sundar Dorai-Raj


Marlin Keith Cox said the following on 2/15/2008 11:39 AM:
> Dear R Users, close to the end of this I used wireframe to create a 3D plot
> from a matrix.  The x and y axis tick labels (1-6) for each were created
> from the matrix being a 6X6 matrix. I need the axis tick labels to be the
> row and column headings which you can see in the output (mat.x).  I have
> tried several work arounds, but they have not been successful.
> 
> Thanks in advance. keith
> 
> 
> rm(list=ls())
> sen<-read.csv("brooktroutsort.csv")
> 
> #Resistance
> R=c(660, 548, 676, 763, 768, 692, 657, 630, 748, 680, 786, 645, 710, 677,
> 692, 732, 737, 651, 396,
> 601, 640, 448, 464, 472, 434, 487, 495, 426, 429, 456)
> 
> #Detector length
> Lend=c(37.0,  39.0,  39.0,  39.0,  40.0,  41.5,  44.0,  45.0,  46.0,  47.0,
> 47.0,  48.0,
> 48.5,  49.0,  51.0,  53.0, 53.0,  60.0,  89.0, 103.0, 108.5, 118.0, 118.0,
> 123.0,
> 126.0, 138.0, 139.0, 141.0, 141.0, 151.0)
> 
> #Errors to be multiplied by Restistance
> x=c(0,.05,.10,.15,.20,.25)
> 
> #Errors to be multiplied by Detector length
> y=c(0,.01,.02,.03,.04,.05)
> 
> #equation to predict water weight in grams
> a=3.453*((Lend^2)/R)+1.994
> 
> X=(R%o%x+R)
> 
> Y=((Lend%o%y+Lend)^2)
> 
> num.x.col <- length(X[1,])
> num.y.col <- length(Y[1,])
> num.rows <- length(X[,1])
> 
> Z <- matrix(nrow=num.rows, ncol=num.x.col*num.y.col)
> 
> for( i in 1:num.rows)  {
>Z[i,] <- as.vector( Y[i,] %*% t(X[i,])^-1 )
> }
> 
> pred.est <- 3.453*Z+1.994
> z=(pred.est-a)/a
> 
> colnames(z)<- rep(c("X1","X2","X3","X4","X5","X6"),6)
> 
> meanz=colMeans(z)
> mat.x <- matrix(meanz, nrow=6, ncol=6, byrow=TRUE)
> 
> colnames(mat.x)<- c(0,1,2,3,4,5)
> rownames(mat.x)<-c(0,5,10,15,20,25)
> mat.x
> 
> 
> library(lattice)
> wireframe(mat.x,drape=TRUE,zlab=list("Proportion Error of Estimate",
> rot=90), xlab="Resistance Error (%) ",ylab="Length Error
> (%)",scale=list(arrows=FALSE))
> detach(z)
> detach(sen)
> 
> 

Try:

mat.df <- data.frame(z = as.vector(mat.x))
mat.df$x <- rep(c(0,5,10,15,20,25), each = 6)
mat.df$y <- rep(c(0,1,2,3,4,5), times = 6)

library(lattice)
wireframe(z ~ x * y, mat.df,
   drape = TRUE,
   zlab = list("Proportion Error of Estimate", rot=90),
   xlab = "Resistance Error (%) ",
   ylab = "Length Error (%)",
   scales = list(arrows = FALSE))

HTH,

--sundar

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


[R] Error in my R program

2008-02-15 Thread HongSheng Liao


w.age.female.2004 <- nls(WEIGHT ~ (alpha*TOTAL^beta)/454,
start=list(alpha=1, beta=3),
data=spottedseatrout2004.female.data)

I am trying to fit above model to length-weight data of a fish species
(spotted seatrout) by year (1999-2006).  The convergence occurred for alll
the years except 2002 and 2004.  In these two year, R shows the error
called 'singular gradient' in the model.  Could anyone please help me to
fix the error?  I don't think there are any problems with my data because I
can fit the same model to 2004 data without any problems using SAS.  Thank
you very much in advance.

Hongsheng (Hank) Liao, Ph.D.
Lab Manager
Center for Quantitative Fisheries Ecology
800 West 46th Street
Old Dominion University
Norfolk, Virginia 23508
Phone:757.683.4571
Fax:757.683.5293

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

2008-02-15 Thread J. Arturo Coral Alamo
Look this can help you:
mtz<-matrix(1:20,4,5)
> mtz
 [,1] [,2] [,3] [,4] [,5]
[1,]159   13   17
[2,]26   10   14   18
[3,]37   11   15   19
[4,]48   12   16   20
> mtz[2,3]
[1] 10
> mtz
 [,1] [,2] [,3] [,4] [,5]
[1,]159   13   17
[2,]26   10   14   18
[3,]37   11   15   19
[4,]48   12   16   20
> mtz[2,3]<-NA
> mtz
 [,1] [,2] [,3] [,4] [,5]
[1,]159   13   17
[2,]26   NA   14   18
[3,]37   11   15   19
[4,]48   12   16   20
Best rgrds


*-*

* *

*J. Arturo Coral Alamo*
Consultor

Business Analytics SAC


Telf: (51-1)222-4091

Cel: (51-1)   903-56370 RPM #376-870

Cel: (51-1)   911-10624



On Fri, Feb 15, 2008 at 11:10 AM, _Fede_ <[EMAIL PROTECTED]>
wrote:

>
> Hi all.
>
> I have certain problem with the extraction of data from matrices. I know
> how
> extract elements from a matrix, but what I would like to do is to extract
> a
> concrete number, not an element. For example if I have this matrix X:
>
> [,1] [,2] [,3] [,4]
> [1,]3   13   23   33
> [2,]9   19   29   39
> [3,]   10   20   30   40
>
> I can do X[-2] or X[2] in order to eliminate the element of the matrix or
> to
> extract it, respectively.
>
> But, what I need is to extract or to eliminate a value of the matrix. For
> example the 29.
>
> Can I do this? How?
>
> Thanks for the help.
> --
> View this message in context:
> http://www.nabble.com/Extract-from-matrix-tp15502655p15502655.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.
>



-- 
Saludos cordiales
J Arturo Coral

[[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] Data Mining Competition 2008

2008-02-15 Thread Xiaogang Su
Dear Colleagues, please help distribute the following announcement of a
data mining competition. Thanks, -XG



=
Data Mining Competition 2008
=

Website: http://dms.stat.ucf.edu/competition08/home.htm 

Department of Statistics & Actuarial Science
University of Central Florida


ANNOUNCEMENT

The Data Mining program at the University of Central Florida (UCF) is
announcing a data mining competition on marketing response analysis in
collaboration with BlueCross BlueShields of Florida (BCBSFL). The
purpose of this project is to
develop a predictive model the can generate a list of potential
responders in a future promotion mailing campaign. The response/target
variable is 0-1 binary with value1 indicating a response in the previous
mail campaign. Most of the
explanatory variables or inputs used in this study are from census data
and the rest are from a list data vendor. We have renamed all input
variables as X1, X2, ... for data security and privacy concerns.


DATASET DOWNLOADS

Two formats of the datasets are made available: SAS formatted and
comma-separated values (CSV). Please select the one that serves best to
your  convenience after registration.

Register to Download Dataset

Training   
  Test
SAStraining.sas7bdat (392.53 mb) test.sas7bdat 
(43.89 mb)
CSV training.csv (257.00 mb) test.csv
(28.55 mb)


PARTICIPATION AND AWARDS

This competition is open to anyone interested. Please review the
following rules carefully and contact us with any questions at
[EMAIL PROTECTED]

Please build your model using the training data set and accordingly
obtain your predicted probability of response for each individual in the
test sample. Two deliverables must be submitted by 5:00 pm (Eastern
Time) on 3/31/2008 in order to participate in the contest.

— A data set with two columns: one is ID and the other is your
predicted probabilities of response (not 0-1 predicted outcomes).

— A one-page write-up that contains your contact information and a
brief description of your modeling methods and approaches. The contact
information should list the names, titles, academic degrees,
affiliations, and locations (city, state, and country, if international)
of all authors.


The top three winners will be selected according to predicted
probabilities on the test sample data. All participants will be  ranked
using the following two specific model performance measures.

— Criterion 1:area under the receiver operating characteristic
(ROC) curve.
— Criterion 2:percentage of responders caught among the first
10,000 individuals with highest prediction response probabilities.

Then the final ranking will be the sum of these two separate ranks. In
the case of ties (e.g., Tom has got No.1 in terms of Criterion 1 and
No.3 in terms of Criterion 2, while Jerry has got No. 2 with both
criteria), the one with higher rank in terms of Criterion 1 (i.e., Tom)
would win out.

All sponsored by BLBSFL, a cash prize of $1,000 will be awarded to the
best performer; $500 for the second and $250 for the third. The three
winning individuals or teams will also be invited to present their
results at the Fourth Annual Business Intelligence Symposium in Orlando,
FL on April 11, 2008. Award plates will be presented to the winners
during the symposium. The work can
be completed by an individual or group, but only one individual will be
invited to present their work at the Symposium for a winning team.


IMPORTANT DATES
Feburuary 08, 2008   Competition Announced
March 31, 2008  Submissions for Competition by 5:00 pm
(Eastern Time)
April 02, 2008 Announcement of Winners
April 11-12, 2008Fourth Annual Business Intelligence
Symposium in Orlando, FL




Xiaogang Su, Ph.D.
Associate Professor / Undergraduate Coordinator 
Department of Statistics and Actuarial Science
University of Central Florida
Orlando, FL 32816
(407) 823-2940 [O]
[EMAIL PROTECTED]
http://pegasus.cc.ucf.edu/~xsu/

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

2008-02-15 Thread Gavin Simpson
On Fri, 2008-02-15 at 10:45 -0800, Tim Smith wrote:
> Hi,
> 
> Is there any clustering package in R that can cluster with ordinal data?
> 
> thanks!

daisy() in recommended package 'cluster' can generate dissimilarities
for ordinal data using Gower's general (dis)similarity coefficient for
mixed data. It returns an object that inherits from dist so it can be
used in clustering tools that accept dist objects. Check out the options
in the cluster package itself, but also note you can use hclust in base
R.

For more information, see if the details on the Cluster Task View help:

http://cran.r-project.org/src/contrib/Views/Cluster.html

HTH

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] Transfer Crosstable to Word-Document

2008-02-15 Thread Gabor Grothendieck
In that case you shouldn't be using CrossTable in the first place.

Suggest you look into the functions mentioned under See Also in
?CrossTable or look at the source of CrossTable and modify it for
your purposes.

On Fri, Feb 15, 2008 at 11:52 AM,  <[EMAIL PROTECTED]> wrote:
>
> Thank you Gabor,
> but with 1. or 2. I don´t get
> a table, which can be changed and formatted using the WORD table functions
> (like changing column width and formatting text in rows).
>
> The result of 1. ist an bitmap and
> the result of 2. an ASCII-Table
>
> A rich formatted (*.rtf) table/object would be better.
> I tried this with the view() (see below).
> Udo
>
>
>
>
> Quoting Gabor Grothendieck <[EMAIL PROTECTED]>:
>
> > Here are 2 ways:
> >
> > 1. Display it on the screen and hit the PrintScreen button.
> > Then paste that into Word and use Word's image editor
> > to crop it and expand or shrink it appropriately.
> >
> > 2. Run this in R:
> >
> > capture.output(CrossTable(...whatever...), file = "clipboard")
> >
> > Paste the clipboard into Word and change the font of the
> > pasted text to Courier or other fixed space font and change its
> > size too if need be.
> >
> > On Fri, Feb 15, 2008 at 10:30 AM,  <[EMAIL PROTECTED]> wrote:
> > > # Dear list,
> > > # I am an R-beginner and
> > > # spent the last days looking for a method to insert tables produced
> > > # with R into a word document. I thought about SPPS:  copy a table from
> > > # an SPO-file and paste it into a word document
> > > # (if needed do some formatting with that table).
> > > # Annother idea was, to produce a TEX-file,
> > > # insert it and make it a word-table.
> > >
> > > # I found the following libraries, which seemed to be promising:
> > > # xtable
> > > # prettyR
> > > # R2HTML
> > > # Hmisc
> > > # SciViews / svViews
> > >
> > >
> > >
> > > ###
> > > ## My example: a crosstable (made with CrossTable from lib gmodels 
> > > ###
> > >
> > > library(gmodels)
> > > library(xtable)
> > > library(svViews)
> > >
> > > # Data for crosstabulation
> > > set.seed(1)
> > > n <- 200
> > > sex <- sample(c("f","m"),n,T)
> > > state <- sample(c("AL","AK","CA"),n,T)
> > >
> > > #Create crosstab
> > > ct <- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
> > > ct #display crosstab on screen
> > >
> > > #Trie to produce a html file
> > > xtable(ct) #Error message: No method!
> > > methods(xtable)
> > >
> > >
> > >
> > > #Try to create a rich formatted table and insert it into Word
> > > #with svViws, but only a little part of crosstab it inserted
> > >
> > > docdir <- "r:\\r"
> > > WordOpen(file.path(docdir, "cross.doc"))
> > > viewfile <- view(ct, type = "summary", browse = FALSE)
> > > WordGoto("ctview")
> > > WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
> > > WordActivate(async = TRUE)
> > >
> > >
> > > #How could I create the latex-code for the crosstable?
> > > w <- latex(ct) #would that work?
> > >
> > > # I could not test this, because I didn´t install Miktex yet
> > > # (I will do this soon)
> > >
> > > Can someone help me?
> > >
> > > Thanks in advance
> > > Udo
> > >
> > >
> > > --
> > > Udo Koenig
> > > Clinic for child and adolescent psychiatry
> > > University of Marburg / Germany
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] Clustering with ordinal data

2008-02-15 Thread Tim Smith
Hi,

Is there any clustering package in R that can cluster with ordinal data?

thanks!




  

Be a better friend, newshound, and 


[[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] Extract from matrix

2008-02-15 Thread John Kane
?which 

Does something like this help?

which(aa==29)
aa[ -which(aa==29)]

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

> 
> Hi all.
> 
> I have certain problem with the extraction of data
> from matrices. I know how
> extract elements from a matrix, but what I would
> like to do is to extract a
> concrete number, not an element. For example if I
> have this matrix X:
> 
>  [,1] [,2] [,3] [,4]
> [1,]3   13   23   33
> [2,]9   19   29   39
> [3,]   10   20   30   40
> 
> I can do X[-2] or X[2] in order to eliminate the
> element of the matrix or to
> extract it, respectively.
> 
> But, what I need is to extract or to eliminate a
> value of the matrix. For
> example the 29.
> 
> Can I do this? How?
> 
> Thanks for the help.
> -- 
> View this message in context:
>
http://www.nabble.com/Extract-from-matrix-tp15502655p15502655.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.


Re: [R] No response for help

2008-02-15 Thread Ted Harding
On 15-Feb-08 13:29:06, G Ilhamto wrote:
> Dear R admin,
> 
> I sent so many emails but none was posted.
> What happened?
> 
> Thanks
> Ilham

Are you subscribed to r-help? If not, you will not
receive copies of any mails sent out by the list
(though if a non-subscriber mails to the list, the
mail will be allowed through if it is R-related).

If you are subscribed, check that your list options
are not set to either
a) "nomail" -- i.e. the r-help list will not send
you mail even if you are subscribed;
b) to the option which disables you from receiving copies
of your own mails (though you will receive mails posted
by other people).

In fact, the Februrary r-help archives contain 4 mails
from you:

1) [R] Hastie - Tibshirani - Friedman pg 141 & nnet question
   Tue Feb 12 00:09:08 CET 2008

2) [R] Softmax in nnet
Fri Feb 15 15:13:28 CET 2008

3) [R] Softmax in nnet
   Fri Feb 15 15:23:16 CET 2008

4) [R] No response for help
   Fri Feb 15 14:29:06 CET 2008

Best wishes,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 15-Feb-08   Time: 18:17:03
-- XFMail --

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

2008-02-15 Thread markleeds
>From: Jorge Aseff <[EMAIL PROTECTED]>
>Date: 2008/02/15 Fri PM 04:51:16 CST
>To: r-help@r-project.org
>Subject: [R] Quadratic Programming

Adrian Trapletti has a function in his tseries
package ( the name of the function escapes me ) that uses the solve.QP solver 
to model some kind of quadratic portfolio problem. I don't remember if it does 
exactly what you want but take a look at tseries because it's in there and it 
may be of help to you.

 Mark
>Hi,
>
>I am using solve.QP (from quadprog) to solve a standard quadratic
>programming problem: min_w -0.5*w'Qw st ... I would like solve.QP to do two
>things: 1) to start the optimization from a user-supplied initial
>condition; i.e., from a vector w_0 that satisfies the constraints, and 2) to
>return the values of the lagrange multiplieres associated with the
>constraints. I did not find an obvious way in help(solve.QP). Any thoughts?
>
>Thanks.
>
>Jorge
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] History of R

2008-02-15 Thread John Sorkin
Kathy.
A suggestion. As you gather your information about the history, I suggest you 
put fingers to keyboard and write down the history. You could start with the 
material Douglas just sent to you. Perhaps we can convince the R folks to place 
the history on the CRAN website - perhaps in WIKI format so our founding 
fathers, and mothers, can add to the history. I certainly would be nice to be 
able to give credit to the may people who have selflessly contributed their 
time, effort, and expertise to the R project!.
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
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)

>>> "Douglas Bates" <[EMAIL PROTECTED]> 2/15/2008 4:23 PM >>>
On Fri, Feb 15, 2008 at 1:53 PM, Kathy Gerber <[EMAIL PROTECTED]> wrote:
> Earlier today I sent a question to Frank Harrell as an R developer with
>  whom I am most familiar.  He suggested also that I put my questions to
>  the list for additional responses.  Next month I'll be giving a talk on
>  R as an example of high quality open source software.  I think there is
>  much to learn from R as a high quality extensible product that (at least
>  as far as I can tell) has never been "spun" or "hyped" like so many open
>  source fads.

>  The question that intrigues me the most is why is R as an open source
>  project is so incredibly successful and other projects, say for example,
>  Octave don't enjoy that level of success?

First and foremost there is the incredible generosity of Ross Ihaka
and Robert Gentleman who, after spending an enormous amount of time
and effort in development of the initial implementation, did not
demand exclusive ownership of their work but allowed others to make
changes.  I believe Martin Maechler was the first non-Auckland person
to get write access to the source code repository and I'm sure that
the good experience of working at a distance with Martin persuaded R &
R to open it up to others.  Martin is polite, considerate, meticulous
and precise (he is a German-speaking Swiss so meticulous and precise
kind of comes with the territory) and you couldn't ask for a first
experience in sharing something that is very valuable to you with
someone whom you may never have met in person.

Not everyone has been that pleasant to work with.  One of the first
things that I did when I joined R-core was to blow up at Kurt and
Fritz about something - on Christmas Eve!  I surprised the group
didn't boot me out after that start.

When a project is gaining momentum the personalities of the initial
developers have a big influence on its success.  The R project has
been fortunate in that regard.

>  I have some ideas of course, but I would really like to know your
>  thoughts when you look at R from such a vantage point.

>  Thanks.
>  Kathy Gerber
>  University of Virginia
>  ITC - Research Computing Support
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/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.

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.


Re: [R] Transfer Crosstable to Word-Document

2008-02-15 Thread Marc Schwartz
Udo,

CrossTable() knows nothing about the proprietary formats of Word tables. 
The output is designed for the R console, using a fixed width 
(monospace) font. The cell boundaries are drawn using standard ASCII 
characters.

There are no plans at present to modify the format of the output to 
support third party application functionality, though I am considering a 
future modification to enable LaTeX output to support Sweave functionality.

You are of course free to modify the source code for CrossTable() to fit 
your own requirements, which is the advantage of using an open source 
platform.

Regards,

Marc Schwartz

[EMAIL PROTECTED] wrote:
> Thank you Gabor,
> but with 1. or 2. I don´t get
> a table, which can be changed and formatted using the WORD table functions
> (like changing column width and formatting text in rows).
>
> The result of 1. ist an bitmap and
> the result of 2. an ASCII-Table
>
> A rich formatted (*.rtf) table/object would be better.
> I tried this with the view() (see below).
> Udo
>
>
>
> Quoting Gabor Grothendieck<[EMAIL PROTECTED]>:
>
>> Here are 2 ways:
>>
>> 1. Display it on the screen and hit the PrintScreen button.
>> Then paste that into Word and use Word's image editor
>> to crop it and expand or shrink it appropriately.
>>
>> 2. Run this in R:
>>
>> capture.output(CrossTable(...whatever...), file = "clipboard")
>>
>> Paste the clipboard into Word and change the font of the
>> pasted text to Courier or other fixed space font and change its
>> size too if need be.
>>
>> On Fri, Feb 15, 2008 at 10:30 AM,<[EMAIL PROTECTED]>  wrote:
>>> # Dear list,
>>> # I am an R-beginner and
>>> # spent the last days looking for a method to insert tables produced
>>> # with R into a word document. I thought about SPPS:  copy a table from
>>> # an SPO-file and paste it into a word document
>>> # (if needed do some formatting with that table).
>>> # Annother idea was, to produce a TEX-file,
>>> # insert it and make it a word-table.
>>>
>>> # I found the following libraries, which seemed to be promising:
>>> # xtable
>>> # prettyR
>>> # R2HTML
>>> # Hmisc
>>> # SciViews / svViews
>>>
>>>
>>>
>>> ###
>>> ## My example: a crosstable (made with CrossTable from lib gmodels 
>>> ###
>>>
>>> library(gmodels)
>>> library(xtable)
>>> library(svViews)
>>>
>>> # Data for crosstabulation
>>> set.seed(1)
>>> n<- 200
>>> sex<- sample(c("f","m"),n,T)
>>> state<- sample(c("AL","AK","CA"),n,T)
>>>
>>> #Create crosstab
>>> ct<- CrossTable(state, sex, expected=TRUE, format="SPSS", digits=1)
>>> ct #display crosstab on screen
>>>
>>> #Trie to produce a html file
>>> xtable(ct) #Error message: No method!
>>> methods(xtable)
>>>
>>>
>>>
>>> #Try to create a rich formatted table and insert it into Word
>>> #with svViws, but only a little part of crosstab it inserted
>>>
>>> docdir<- "r:\\r"
>>> WordOpen(file.path(docdir, "cross.doc"))
>>> viewfile<- view(ct, type = "summary", browse = FALSE)
>>> WordGoto("ctview")
>>> WordInsertFile(viewfile, TRUE) #only a little part of crosstab inserted
>>> WordActivate(async = TRUE)
>>>
>>>
>>> #How could I create the latex-code for the crosstable?
>>> w<- latex(ct) #would that work?
>>>
>>> # I could not test this, because I didn´t install Miktex yet
>>> # (I will do this soon)
>>>
>>> Can someone help me?
>>>
>>> Thanks in advance
>>> Udo
>>>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Conditional Autoregressive (CAR) model simulation

2008-02-15 Thread Henrique Dallazuanna
See spautolm function in spdep package

On 15/02/2008, Dae-Jin Lee <[EMAIL PROTECTED]> wrote:
> Hi all !
>
>  I would like to simulate spatial lattice/areal data with a conditional
>  autoregressive (CAR) structure, for a given neighbouring matrix and for a
>  autocorrelation "rho".
>
>  Is there any package or function in R to perform it ?
>
>  I found the function "CARsimu" in the hdeco library, but this is not what
>  I'm looking for
>
>  Thanks in advance
>
>  Dae-Jin
>
>  --
>  __
>
>  Dae-Jin Lee
>
>  Office/Despacho: 7.3.J04
>  Phone/Tlfno:+34 91 624 9175
>  Fax: +34 91 624 9430
>
>  Departamento de Estadística
>  Av. Universidad 30, Ed. Juan Benet
>  28911 Leganés (Madrid), SPAIN
>  Universidad Carlos III de Madrid
>
>  e-mail: [EMAIL PROTECTED]
>web: http://www.est.uc3m.es/daejin
>  __
>
> [[alternative HTML version deleted]]
>
>
> __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>
>


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] anyone know how to plot histograma and line in the same graph

2008-02-15 Thread Xin
Dear:

   I have two series data, which are:
  p1-obs p1-exp 
  13 13 
  20 23.296 
  22 18.139 
  19 14.972 
  10 12.576 
  16 10.658 
  8 9.0794 
  4 7.7625 
  3 6.6536 
  5 5.7141 
  7 4.9146 
  4 4.2321 
  0 3.648 
  4 3.1471 
  4 2.7168 
  2 2.3468 
  4 2.0283 
  2 1.7537 
  2 1.517 
  5 1.3127 
  1 1.1362 


And I want to plot one of series by historgram and the other by line.

such as the attachment.


Thanks

Xin
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lmList, tapply() and lm()

2008-02-15 Thread Jonathan Baron
Here is an example I just did.  I _LOVE_ lmList().  It is such a great
convenience compared to the following.  But right now it doesn't work
for "family=binomial", so I had to do it differently.  This is not
your example, but it should give you an idea.  The [[5]] was because I
was interested only in the 5th coefficient for each subject (the
interaction term).  Note that I used coef() because I was interested
only in the coefficients.

l1g <- by(d1,subject,function(x)
  coef(glm(achoice ~ lnlra*session+lnpodd,data=x,family=binomial))[[5]])


On 02/15/08 11:00, Marc Belisle wrote:
> Howdee,
> 
> *** I know that the lmList() function exists, yet I don't want to use it.
> ***
> 
> Would anyone be kind enough to tell how I can apply the function lm() to
> each level of a given factor so to obtain the intercept and slope for each
> factor level within a matrix?
> 
> For instance, suppose a dataframe containing 3 variables: id, x and y.
> 
> I want to compute the function lm() for each level contained in id, as
> lmList would do...
> 
> Thanks for your time,

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

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


  1   2   >