Re: [R] why-s of method dispatching

2004-03-18 Thread Prof Brian Ripley
On Wed, 17 Mar 2004, Vadim Ogranovich wrote:

 I am having a problem to understand why as.data.frame method doesn't
 dispatch properly on my class:
 
  setClass(Foo, character)
 [1] Foo
  as.data.frame(list(foo=new(Foo, .Data=a)))
 Error in as.data.frame.default(x[[i]], optional = TRUE) : 
  can't coerce Foo into a data.frame
 
 I was expecting that this would call as.data.frame.character.

You have set an S4 class and as.data.frame is an S3 generic.

 list(foo=new(Foo, .Data=a))
$foo
An object of class Foo
[1] a

and what as.data.frame sees is

 attributes(list(foo=new(Foo, .Data=a))$foo)
$class
[1] Foo
attr(,package)
[1] .GlobalEnv

so thinks this is an S3 class it knows nothing about.

 Another puzzle. If I explicitly call as.data.frame.character() it would
 fail but for a different reason:
 
  as.data.frame.character(list(foo=new(Foo, .Data=a)))
 Error in unique.default(x) : unique() applies only to vectors
 
 I was under an impression that an instance of Foo would be welcome
 anywhere a character was, but it seems to be more subtle. What am I
 missing?

The difference between S3 and S4 classes.

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R and package don't know they're built on same system

2004-03-18 Thread Ross Boylan
I just had the interesting experience of building a package and R on
the same system, and having R refuse to load the resultant dynamic
library because it was thought to be for a different system.

The system was non-standard and beta, being a Linux-based 64 bit
Opteron system.  It uses the gnu tool chain.  The dynamic library was
built from C source.

When I tried to load the library R (1.8.1) complained
package Rpmi was built for i686-pc-linux-gnu
Inspection of R.version$platform, which is the thing the i686 is
being compared to, shows that it is x86_64-unknown-linux-gnu.

I worked around this by removing the test causing the error (in
library.R), but, considering I built both R and Rmpi (an unofficial
version 0.4.6 from the author) within minutes of each other, it was
very surprising to find they had different notions of their system.

Any idea what's behind this, or how to fix it?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Question: Assigning the values of a time series to another one with dif. length and resolution

2004-03-18 Thread Daebel Helge
Hi,
I have two time series organized in matixes data.1 and data.2. 
They have different length and resolution.

matrix data.1
t1  v1
t3  v3
t5  v5
...

matrix data.2
t1  0
t2  0
t3  0
...

desired result:
data.2
t1  v1
t2  0
t3  v3
...

What is the MOST EFFECTIVE way (since the matrixes are very large) to assign the 
values of data.1 to data.2 whenever time values are equal?

Thanks for your help,
Helge

P.S: My solution so far:

for ( i in 1 : nrow(data.1) )
{
index  - which ( data.2[,1] == data.1[i,1] )
data.2[index,2] - data.1[i,2]
}

_ 
Swiss Federal Institute for Environmental
Science and Technology (EAWAG)

Dept. of Engineering Sciences

Helge Daebel
EAWAG, ING - CB D35
Ueberlandstrasse 133
CH-8600 Dübendorf, Switzerland

phone: +41 1 823 5052  
fax:   +41 1 823 5389
mail:  [EMAIL PROTECTED]
http:  www.eawag.ch/research_e/ing/uwe/daebel/bivariate_probability.htm

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] cannot allocate vector

2004-03-18 Thread Prof Brian Ripley
On Wed, 17 Mar 2004, Matt Loveland wrote:

 I'm having trouble with glmmPQL.

I think you are having trouble with memory limits, actually.  As the 
author of glmmPQL, I don't appreciate my code being blamed for something 
else.

 I'm fitting a 2 level random intercept model, with 90,000 cases and about 330 
 groups.  I'm unable to get any results on the full data set.  I can get it to work 
 if I sample down to about 30,000 cases.  But for models with N's much larger than 
 that I get the following warning message:
 
  
 m3=glmmPQL(prepfood~iage+iemployed+iwhite+ieduclevl+imarried+servcomm+leadgrup+leadsty4,
  family=binomial, random=~1|congrega1,data=data)
 Error: cannot allocate vector of size 4135 Kb
 In addition: Warning message: 
 Reached total allocation of 253Mb: see help(memory.size) 
 
 I've tried increasing my virtual memory size, and also defragmenting my
 hard drive.  It hasn't helped.  I've seen other people asking similar
 questions on the archive, but it seems that this problem should have
 gone away after earlier versions of R, is that right?

Do read the page it asks you too.  You are on Windows, and you need to use 
the --max-mem-size flag when starting R to increase the memory available 
to R.  However, if you do swapping may make your machine nigh unusable.

What did you not understand about help(memory.size)?
This is also in the rw-FAQ: what in that did you not understand?

 Is this a data problem, am I fitting a bad model, or is it a memory size
 problem.  I'm hoping the last one, and any help is appreciated.

Yes, so try a machine with 2Gb RAM.

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] logistic regression with temporal correlation

2004-03-18 Thread merser
Hello

We would like to perform a logistic regression analysis weighting the
independent variable in  a temporal fashion, i.e. events occuring most
recent get highest weight. Does anyone know how to do this in R??

Regards
S. Merser and S. Lophaven

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] tapply

2004-03-18 Thread mike . campana
Dear all
I have a dataframe containing hourly data of 3 parameters. 
I would like to create a dataframe containg daily mean values of these 
parameters. Additionally I want to keep information about time of 
measurement (year,month,day). 
With the function tapply I can average  over a column of the dataframe. 
I can repeat the function 2 time and  merge the vectors. In this way I 
obtain my new dataframe (see below).If I want to add the column day, 
month and year I can repeat tapply other three time. This system works.  


Question: is there a function that average in a single step over the 3 
columns?

Thanks a lot for your answer!
Regards
Mike Campana   

 read the data
setwd(c:/R)
data - NULL
data - as.data.frame(read.table(file=Montreal.txt,header=F,skip=15))
colnames(data) 
-c(year,month,day,hour,min,temp,press,ozone)
### create  mean value
temp_daily - 
tapply(data$temp,data$year*1+data$month*100+data$day,FUN=mean)
press_daily - 
tapply(data$press,data$year*1+data$month*100+data$day,FUN=mean)
ozone_daily - 
tapply(data$ozone,data$year*1+data$month*100+data$day,FUN=mean)
### merge the data
newdata - as.data.frame (cbind(temp_daily,temp_daily,temp_daily))

---



---



---



---



---

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] logistic regression with temporal correlation

2004-03-18 Thread Wayne Jones

Hello, 

You can either use nls and add weights see ?nls. 
Or use a generalized linear model and also change the weights. se ?glm

Regards

Wayne
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 18 March 2004 08:37
To: [EMAIL PROTECTED]
Subject: [R] logistic regression with temporal correlation


Hello

We would like to perform a logistic regression analysis weighting the
independent variable in  a temporal fashion, i.e. events occuring most
recent get highest weight. Does anyone know how to do this in R??

Regards
S. Merser and S. Lophaven

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


KSS Ltd
Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS  England
Company Registration Number 2800886 
Tel: +44 (0) 161 228 0040   Fax: +44 (0) 161 236 6305
mailto:[EMAIL PROTECTED]http://www.kssg.com


The information in this Internet email is confidential and m...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] logistic regression with temporal correlation

2004-03-18 Thread Prof Brian Ripley
This is not `temporal correlation'.  You can supply a weights argument to 
glm and so downweight older observations.  Since the theory is no longer 
exactly apposite, treat the standard errors etc with some caution.

On Thu, 18 Mar 2004 [EMAIL PROTECTED] wrote:

 We would like to perform a logistic regression analysis weighting the
 independent variable in  a temporal fashion, i.e. events occuring most
 recent get highest weight. Does anyone know how to do this in R??
 
 Regards
 S. Merser and S. Lophaven

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] reading short int and float from binary connection

2004-03-18 Thread Jim Lemon
Angel Lopez wrote:
 Thanks for the advise.
 I think I've found the solution, the problem was that the file had been
 written from a C program using a structure containing floats and int, if
 I rewrite the C code not using a structure but independent floats and
 ints the data then is read smoothly into R. I still can't figure out why
 a structure is different or how should I have read it into R but it is
 probably more a C than an R question .
 
You're probably right there. A C structure may be silently aligned by the 
compiler so that value fields are not contiguous in memory. A binary write of 
such a structure cannot be assumed to have bytes in the same order described 
in the structure definition.

Jim

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] R and package don't know they're built on same system

2004-03-18 Thread Liaw, Andy
One thing to make sure is that all compilers used match; i.e., all 32-bit or
all 64-bit.  On our SLES8 pre-installed on Opteron, g++ was left out of the
64-bit toolchain.  R itself compiled fine (as 64-bit), but some packages
failed to install.  It was strange because the packages were built, but
failed to load.  I was only able to track it down because I happen to know
that the packages that failed contain C++ code, so they were compiled with
the 32-bit g++, and thus cannot be loaded into 64-bit R.

HTH,
Andy

 From: Ross Boylan
 
 I just had the interesting experience of building a package and R on
 the same system, and having R refuse to load the resultant dynamic
 library because it was thought to be for a different system.
 
 The system was non-standard and beta, being a Linux-based 64 bit
 Opteron system.  It uses the gnu tool chain.  The dynamic library was
 built from C source.
 
 When I tried to load the library R (1.8.1) complained
 package Rpmi was built for i686-pc-linux-gnu
 Inspection of R.version$platform, which is the thing the i686 is
 being compared to, shows that it is x86_64-unknown-linux-gnu.
 
 I worked around this by removing the test causing the error (in
 library.R), but, considering I built both R and Rmpi (an unofficial
 version 0.4.6 from the author) within minutes of each other, it was
 very surprising to find they had different notions of their system.
 
 Any idea what's behind this, or how to fix it?
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R-business case

2004-03-18 Thread Federico Calboli

 
 Just to be provocative, it would be best to state the ultimate goals, then
 R users could be of more help.  We have submitted and published articles
 using R and are using R in production work on contracts from
 pharmaceutical companies.  It's difficult to know from the original note
 why we should spend time compiling such data.  Is anyone finding that R
 has some deficiencies with respect to their own work?
 

All the analysis I do is done with R, so anything published where I am
in the author list is likely to have been done/revised with R.

The fact than R requires me to know what I am doing is more of an
advantage, IMHO, rather than a shortcoming... from a usability
standpoint I never felt I had any problem I could not deal with after
some thinking, or asking the list.

Regards,

Federico Calboli 

-- 



=

Federico C. F. Calboli

Dipartimento di Biologia
Via Selmi 3
40126 Bologna
Italy

tel (+39) 051 209 4187
fax (+39) 051 251 4286

f.calboli at ucl.ac.uk

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] SVM question

2004-03-18 Thread Frank Gerrit Zoellner
Hi!

I have a question concerning the svm in the e1071 package.
I trained the svm by a set of samples, doing a 10 cross validation.
The summary function then prints out the total accuracy and single accuracies, works 
fine.

My question is then: Is it possible to get classification results per cross validation 
out the svm? I mean e.g. numbers about the true positives ,fp,fn,tf ? How do I get a 
list of the classified examples ? 

Thanks,
-- 
Frank G. Zoellner
AG Angewandte Informatik
Technische Fakultat
Universitat Bielefeld
phone: +49(0)521-106-2951
fax:   +49(0)521-106-2992
email: [EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] R and package don't know they're built on same system

2004-03-18 Thread Prof Brian Ripley
You may also want to check why the error message refers to Rpmi, since you 
said you have just built Rmpi, not the same thing!

Something is wrong about the story we are being told: if that is really 
the error message which was produced then pilot error is involved, and if 
not inaccurate reporting is involved.  My guess is that there is a 32-bit 
package (sic, not library) Rpmi.

On Thu, 18 Mar 2004, Liaw, Andy wrote:

 One thing to make sure is that all compilers used match; i.e., all 32-bit or
 all 64-bit.  On our SLES8 pre-installed on Opteron, g++ was left out of the
 64-bit toolchain.  R itself compiled fine (as 64-bit), but some packages
 failed to install.  It was strange because the packages were built, but
 failed to load.  I was only able to track it down because I happen to know
 that the packages that failed contain C++ code, so they were compiled with
 the 32-bit g++, and thus cannot be loaded into 64-bit R.
 
 HTH,
 Andy
 
  From: Ross Boylan
  
  I just had the interesting experience of building a package and R on
  the same system, and having R refuse to load the resultant dynamic
  library because it was thought to be for a different system.
  
  The system was non-standard and beta, being a Linux-based 64 bit
  Opteron system.  It uses the gnu tool chain.  The dynamic library was
  built from C source.
  
  When I tried to load the library R (1.8.1) complained
  package Rpmi was built for i686-pc-linux-gnu
  Inspection of R.version$platform, which is the thing the i686 is
  being compared to, shows that it is x86_64-unknown-linux-gnu.
  
  I worked around this by removing the test causing the error (in
  library.R), but, considering I built both R and Rmpi (an unofficial
  version 0.4.6 from the author) within minutes of each other, it was
  very surprising to find they had different notions of their system.
  
  Any idea what's behind this, or how to fix it?

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] (BRMA) Mensagem não autorizada

2004-03-18 Thread BRmultiaccess

Mensagem não autorizada

Mensagem possui anexo proibido na lista (\.pif)

Para:  [EMAIL PROTECTED]
Assunto:  Re: Re: Re: Your document

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help with file

2004-03-18 Thread Uwe Ligges
MARGARET GALIETTI wrote:

Hi,

I am new at R, and I need some help with some basic stuff.

I want to do clustering of data. It works perfectly, but now I want to 
export my file form R to my Linux directory. The problem is that the file 
is generated only with the cluster numbers, but it does not carry over the 
identifiers. Let me show you what I did :

1. demo-read.table(my_table, sep=,, header=TRUE)  # I 
imported my table into R as a data frame. I had header and one of my 
columns was called KEYS; this was the unique identifier for my data.
2. #clustering part
names(demo) 
dm-dist(demo[,c(3,4,5)])  
names(dm)-demo[,2]#the unique Id called KEYS is in 
my column number 2
cluster-hclust(dm)
plot(cluster)#my data is 
displayed in dendogram

3. Now I want to see the breakdowns; I want to see every unique KEYS and 
corresponding cluster number
 
result-cutree(cluster, h =1)
   result   #I can see KEYS and 
corresponding cluster numbers

4. Now I want to export this info out of R into a file
How do I do this??? I am going CRAZY. All I get is the cluster numbers 
but not the KEYS.

HELP!!!

Margaret
[[alternative HTML version deleted]]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


See ?write.table.
Or ?sink for redirecting R's output, and ?dump for saving R objects 
Uwe Ligges

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R and package don't know they're built on same system

2004-03-18 Thread A.J. Rossini
Liaw, Andy [EMAIL PROTECTED] writes:

 One thing to make sure is that all compilers used match; i.e., all 32-bit or
 all 64-bit.  On our SLES8 pre-installed on Opteron, g++ was left out of the
 64-bit toolchain.  R itself compiled fine (as 64-bit), but some packages
 failed to install.  It was strange because the packages were built, but
 failed to load.  I was only able to track it down because I happen to know
 that the packages that failed contain C++ code, so they were compiled with
 the 32-bit g++, and thus cannot be loaded into 64-bit R.

Not sure which system Ross is referring to (i.e. built from scratch,
or a distribution?) but there are bi-arch systems for the Opteron
which get confused.  This, along with Andy's guess about g++, suggest
the possibility of a mix-up.

best,
-tony

-- 
[EMAIL PROTECTED]http://www.analytics.washington.edu/ 
Biomedical and Health Informatics   University of Washington
Biostatistics, SCHARP/HVTN  Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC  (M/W): 206-667-7025 FAX=206-667-4812 | use Email

CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Install R on Mac OS.X

2004-03-18 Thread Andrew Robinson
In what way does 1.8.1 not work for your friend?

Andrew

On Thursday 18 March 2004 02:01, Tor A Strand wrote:
 I am running R 1.8.1 flawlessly on my mac with OS.X.3

 My friend is running 1.6.1 but it is impossible for him to make 1.8.1
 work. I do not understand why it should work better in my computer. I
 do, however, have X.11 installed, he doesnt, could that be an issue and
 if it is, does it suffice to install X.11 after RAqua has been
 installed?

 Tor A Strand, MD PhD
 Centre for International Health
 University of Bergen
 Norway

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Andrew Robinson  Ph: 208 885 7115
Department of Forest Resources   Fa: 208 885 6226
University of Idaho  E : [EMAIL PROTECTED]
PO Box 441133W : http://www.uidaho.edu/~andrewr
Moscow ID 83843  Or: http://www.biometrics.uidaho.edu
No statement above necessarily represents my employer's opinion.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] tapply

2004-03-18 Thread Gabor Grothendieck



Try this (untested):

aggregate( data[,6:8], list(date = as.matrix(data[,1:3]) %*% c(1,100,1)), mean )

---
Date:   Thu, 18 Mar 2004 09:39:02 +0100 
From:   [EMAIL PROTECTED]
To:   [EMAIL PROTECTED] 
Subject:   [R] tapply 

 
Dear all
I have a dataframe containing hourly data of 3 parameters. 
I would like to create a dataframe containg daily mean values of these 
parameters. Additionally I want to keep information about time of 
measurement (year,month,day). 
With the function tapply I can average over a column of the dataframe. 
I can repeat the function 2 time and merge the vectors. In this way I 
obtain my new dataframe (see below).If I want to add the column day, 
month and year I can repeat tapply other three time. This system works. 


Question: is there a function that average in a single step over the 3 
columns?

Thanks a lot for your answer!
Regards
Mike Campana 

 read the data
setwd(c:/R)
data - NULL
data - as.data.frame(read.table(file=Montreal.txt,header=F,skip=15))
colnames(data) 
-c(year,month,day,hour,min,temp,press,ozone)
### create mean value
temp_daily - 
tapply(data$temp,data$year*1+data$month*100+data$day,FUN=mean)
press_daily - 
tapply(data$press,data$year*1+data$month*100+data$day,FUN=mean)
ozone_daily - 
tapply(data$ozone,data$year*1+data$month*100+data$day,FUN=mean)
### merge the data
newdata - as.data.frame (cbind(temp_daily,temp_daily,temp_daily))

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] tapply

2004-03-18 Thread Thomas Petzoldt
[EMAIL PROTECTED] wrote:

Question: is there a function that average in a single step over the 3 
columns?
You may look for ?aggregate

Thomas P.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] don't stop when error occurs

2004-03-18 Thread pastaska1934
hi,
i'm doing some bootstraping on a data set, using kmeans for each bootstrap,
i mean i do a loop(200 times) and in each loop i use kmeans.
i have to count some occurences in a matrix result,
but somentimes kmeans fail, cause of the algorithm.
so i would like to avoid my function to stop on kmeans error
is there a way to do such a thing?
like
if(kmeans()=error)continue
or
if(kmeans != -1) go on

thanks

sebeuu^^

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] cannot allocate vector

2004-03-18 Thread Douglas Bates
Matt Loveland [EMAIL PROTECTED] writes:

 I'm having trouble with glmmPQL.
 
 I'm fitting a 2 level random intercept model, with 90,000 cases and
 about 330 groups.  I'm unable to get any results on the full data
 set.  I can get it to work if I sample down to about 30,000 cases.
 But for models with N's much larger than that I get the following
 warning message:
 
  
 m3=glmmPQL(prepfood~iage+iemployed+iwhite+ieduclevl+imarried+servcomm+leadgrup+leadsty4,
  family=binomial, random=~1|congrega1,data=data)
 Error: cannot allocate vector of size 4135 Kb
 In addition: Warning message: 
 Reached total allocation of 253Mb: see help(memory.size) 

It may be possible to fit the model on your current machine with the
current setting using function GLMM from package lme4.  This function
by default uses essentially the same algorithm as glmmPQL from MASS
(iteratively weighted calls to lme) but it employs a different version
of lme (glmmPQL calls lme from the nlme package while GLMM calls a
more efficient representation in the lme4 package itself).

Finally, there is yet another implementation of lme in development - a
version that is more economical in storage, more flexible in the model
structures that can be fit (for those who have been waiting, yes it
can fit models with crossed and partially crossed random effects using
a reasonable syntax and data representation), and is fast.  On models
fit to large data sets this version is remarkably fast.

Our schedule is to release new versions of the lme4 and Matrix
packages with R-1.9.0 (2004-04-04).  Please contact me off-list if you
want to participate in testing these packages or if you can provide
data for our testing.

-- 
Douglas Bates[EMAIL PROTECTED]
Statistics Department608/262-2598
University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] don't stop when error occurs

2004-03-18 Thread Andy Bunn
You can do that easily with 'try'
?try
 'try' is a wrapper to run an expression that might fail and allow
 the user's code to handle error-recovery.
HTH, Andy

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] don't stop when error occurs

2004-03-18 Thread Liaw, Andy
Read ?try, ?tryCatch, as well as the posting guide mentioned in the footer.

Andy

 From: pastaska1934
 
 hi,
 i'm doing some bootstraping on a data set, using kmeans for 
 each bootstrap,
 i mean i do a loop(200 times) and in each loop i use kmeans.
 i have to count some occurences in a matrix result,
 but somentimes kmeans fail, cause of the algorithm.
 so i would like to avoid my function to stop on kmeans error
 is there a way to do such a thing?
 like
 if(kmeans()=error)continue
 or
 if(kmeans != -1) go on
 
 thanks
 
 sebeuu^^
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] don't stop when error occurs

2004-03-18 Thread Wayne Jones
Look up ?try

Regards

Wayne

-Original Message-
From: pastaska1934 [mailto:[EMAIL PROTECTED]
Sent: 18 March 2004 14:36
To: [EMAIL PROTECTED]
Subject: [R] don't stop when error occurs


hi,
i'm doing some bootstraping on a data set, using kmeans for each bootstrap,
i mean i do a loop(200 times) and in each loop i use kmeans.
i have to count some occurences in a matrix result,
but somentimes kmeans fail, cause of the algorithm.
so i would like to avoid my function to stop on kmeans error
is there a way to do such a thing?
like
if(kmeans()=error)continue
or
if(kmeans != -1) go on

thanks

sebeuu^^

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


KSS Ltd
Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS  England
Company Registration Number 2800886
Tel: +44 (0) 161 228 0040   Fax: +44 (0) 161 236 6305
mailto:[EMAIL PROTECTED]http://www.kssg.com


The information in this Internet email is confidential and m...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: projection pursuit

2004-03-18 Thread Jim_Garrett
Luis,

See the fastICA package, in particular the final example in the function
fastICA's help page.  This doesn't leave you with density estimates, but
with projection-pursuit directions; you still have to figure out how to fit
a density estimate to the rotated data.  Actually, as I understand it,
XGobi also finds directions but does not fit a density.  However, any
multivariate density estimator ought to be applicable.  I'm not aware at
the moment of the tools R offers for multivariate density estimation, but
I'm sure there are multiple possibilities.

_The Elements of Statistical Learning_ by Hastie, Tibshirani, and Friedman
mention a trick to use classification tools (which model class
probabilities) to estimate density.  Fundamentally, generate data from a
reference distribution, and use the classification tool to estimate
probability of observed data (as opposed to generated data) as a function
of the inputs.  These probabilities, normalized to integrate to 1, form a
density estimate.  Since there are so very many classification tools
available, this trick offers a lot of flexibility.

Good luck.

Jim Garrett
Baltimore, Maryland, USA


**
This message is intended only for the designated recipient(s...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Draw abbreviated key (lattice, xyplot)

2004-03-18 Thread Vaclav Petricek

Hello

I have been experimenting with xyplot, reading the help and googling but
I am still unable to draw an abbreviated key.

I would like to display key for a few particular countries.

My dataset looks like this

   year paperscountry papers.total
1  1988403USA  551
2  1988 31 United Kingdom  551
3  1988 24 Canada  551
4  1988 20Netherlands  551
5  1988 19 Israel  551
6  1988 16Germany  551
7  1988 13 France  551
8  1988 10  Italy  551
9  1988  8Switzerland  551
10 1988  5  Japan  551
11 1988  5Denmark  551
12 1988  3  Spain  551
13 1988  3 Russia  551
14 1988  2 Sweden  551
15 1988  2 Poland  551
16 1988  2Finland  551
17 1988  2 Brasil  551
18 1988  2  Australia  551
19 1988  1   Thailand  551
20 1988  1 Norway  551
21 1988  1 Mexico  551
22 1988  1Ireland  551
23 1988  1 Greece  551
24 1989649USA  926
25 1989 53 United Kingdom  926
26 1989 43 France  926
27 1989 37 Canada  926
28 1989 36Germany  926
29 1989 28Netherlands  926
30 1989 19 Sweden  926
[...]

I use xyplot to show how many papers

 xyplot(papers~year,groups=country,type='l',auto.key=T)

produces an extremely long key

 xyplot(papers~year,groups=country,type='l',key=simpleKey(levels(as.factor(country))[1:5]))

shows *alphabetically* first five countries in the key

 xyplot(papers~year,groups=country,type='l',key=simpleKey(c('USA','Germany')))

displays correct countries but the colors obviously do not match.

Could you please point me in the right direction?

Vaclav

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] two lme questions

2004-03-18 Thread Scott Rifkin
1) I have the following data situation:

96 plots
12 varieties
2 time points
2 technical treatments

the experiment is arranged as follows:

a single plot has two varieties tested on it. if variety A on plot #1 has 
treatment T1 applied to it, then variety B on plot #1 has treatment T2 
applied to it.  across the whole experiment variety A is exposed to 
treatment T1 the same number of times as treatment T2.

with respect to time points, plots come in 3 kinds. (1) varietyA,
timepoint#1 vs. variety B, timepoint#1 (2) varietyA timepoint #2 vs. 
varietyB timepoint #2, and (3) varietyA timepoint #1 vs. variety A 
timepoint#2

plots and varieties are random samples from a population of plots and 
varieties, so they are random effects.  The technical treatment and 
timepoints are fixed effects.

i am particularly interested in the variance components for variety and 
timepoint within variety, in the estimate for the fixed stage effect and 
in the predictions (BLUP) for variety and stage within variety.

My First Question is about specifying the random part of the lme() 
statement

the fixed part is Measurement~Treatment+Time
the random part, i think, should include random=~1|variety/time or 
equivalently(?) list(variety=~1,Time=~1)

but how do i also specify that plot should be a random effect?  it's not 
nested within variety, nor is variety nested within it.



2) I have fixed effects as above where each only has two kinds (2 
Treatments, 2 Times).  When I use lme and look at the estimates for the 
fixed effects I get output that looks like:

summary(asdf.lme)
...

Fixed effects: Measurement ~ Treatment+Time
ValueStd.Error ...
(Intercept) xxx xxx
TreatmentHotxxx xxx
TimeEarly   xxx xxx
  Correlation
...


where my two treatments are Hot and Cold and my two times are Early and 
Late and the xxx are actual numbers.

Why isnt there any line for the Cold treatment and the late time?  is it 
because these necessarily are the opposite of the Hot and Early ones so 
putting them in would be redundant (i.e. Hot+Cold=0, Early+Late=0)?


Thanks much,
Scott Rifkin
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Draw abbreviated key (lattice, xyplot)

2004-03-18 Thread Deepayan Sarkar

Both auto.key and simpleKey are convenience tools to make key drawing 
easy in 'typical' cases. For more flexibility, define the key as a list 
(the structure is described under 'key' in ?xyplot). You may want to 
look at ?Rows as well, in conjunction with trellis.par.get(). 
See ?splom and ?cloud for examples.

You are not very explicit in your description, but perhaps your only 
problem with your second solution is that the first 5 levels are in 
alphabetical order (but you haven't said what order you want them to be 
in). This is an artifact of R's factor() function, where the levels are 
by default 

 factor(x, levels = sort(unique.default(x), na.last = TRUE), ...

So your problem may be solved simply by redefining your country variable 
appropriately:

yourdata$country - 
factor(as.character(yourdata$country), 
   levels = c('USA', 'Germany',  ... ))

(the as.character() is probably redundant)

Hope that helps,

Deepayan

On Thursday 18 March 2004 09:42, Vaclav Petricek wrote:
 Hello

 I have been experimenting with xyplot, reading the help and googling
 but I am still unable to draw an abbreviated key.

 I would like to display key for a few particular countries.

 My dataset looks like this

year paperscountry papers.total
 1  1988403USA  551
 2  1988 31 United Kingdom  551
 3  1988 24 Canada  551
 4  1988 20Netherlands  551
 5  1988 19 Israel  551
 6  1988 16Germany  551
 7  1988 13 France  551
 8  1988 10  Italy  551
 9  1988  8Switzerland  551
 10 1988  5  Japan  551
 11 1988  5Denmark  551
 12 1988  3  Spain  551
 13 1988  3 Russia  551
 14 1988  2 Sweden  551
 15 1988  2 Poland  551
 16 1988  2Finland  551
 17 1988  2 Brasil  551
 18 1988  2  Australia  551
 19 1988  1   Thailand  551
 20 1988  1 Norway  551
 21 1988  1 Mexico  551
 22 1988  1Ireland  551
 23 1988  1 Greece  551
 24 1989649USA  926
 25 1989 53 United Kingdom  926
 26 1989 43 France  926
 27 1989 37 Canada  926
 28 1989 36Germany  926
 29 1989 28Netherlands  926
 30 1989 19 Sweden  926
 [...]

 I use xyplot to show how many papers

  xyplot(papers~year,groups=country,type='l',auto.key=T)

 produces an extremely long key

  xyplot(papers~year,groups=country,type='l',key=simpleKey(levels(as.
 factor(country))[1:5]))

 shows *alphabetically* first five countries in the key

  xyplot(papers~year,groups=country,type='l',key=simpleKey(c('USA','G
 ermany')))

 displays correct countries but the colors obviously do not match.

 Could you please point me in the right direction?

 Vaclav

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] dsn

2004-03-18 Thread David Middleton

Margarida

 odbcConnect(H:\\Desktop\\bd1,uid=tiago,pwd=archi,case=nochange,believeNRows=TRUE)
 [1] -1
 Warning messages:
 1: [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver 
 Manager]Data source name not found, and no default driver specified

You simply need to give the data source name (DSN), not a path, as the first argument 
to odbcConnect.  If you want to connect directly to a database file, rather than via a 
DSN, the RODBC package also provides odbcConnectAccess etc.

I am slightly surprised that you appear to be using unixODBC on what appears to be 
(from the path specification) a windows system.  I guess this may be possible via 
cygwin - maybe there's even a win32 release of unixODBC.  RODBC works fine with the 
standard MS ODBC setup on windows systems as far as I can tell.

David

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dsn

2004-03-18 Thread Prof Brian Ripley
You appear to be using unixODBC and DOS paths!

You haven't told us what OS, what version of R, what version of RODBC, 
what driver manager, what driver   But it does seem unlikely that
unixODBC understands DOS paths.

The issue is very simple: the driver manager is not finding the path you 
specified.  We can only guess at why.


On Wed, 1 Jan 1997, Margarida =?iso-8859-1?Q?Júlia?= Rodrigues Igreja wrote:

Wow, your computer is living in the past!

 I've finally got a DSN working on my ODBC installation and I've tested it 
 with the ODBC DataManager so I'm sure it's working.
 However when trying to connect to the DSN via R interface I get an error:
 
   
 odbcConnect(H:\\Desktop\\bd1,uid=tiago,pwd=archi,case=nochange,believeNRows=TRUE)
 [1] -1
 Warning messages:
 1: [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver 
 Manager]Data source name not found, and no default driver specified
 2: ODBC connection failed in: odbcDriverConnect(paste(DSN=, dsn, ;UID=, 
 uid, ;PWD=, pwd,
 
 Before the odbcCOnnect() command I gave the library(RODBC) command and it 
 gave no error
 What am I missing?
 
 Margarida
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 
 

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] substitute question

2004-03-18 Thread Thomas Lumley
On Wed, 17 Mar 2004, Gabor Grothendieck wrote:



 I left out the brackets in my last email but the problem
 (a reappears after have been substituted out) still remains:

  z - substitute( function(){a+1}, list(a=quote(b)) )
  z
 function() {
 b + 1
 }
  eval(z)
 function(){a+1}


Interesting.

Appearances are misleading, however:
 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 f-eval(z)
 f()
Error in f() : Object b not found
 f
function(){a+1}
 attr(f,source)-NULL
 f
function ()
{
b + 1
}

So it isn't that eval(z) has a+1 inside, it just has a source attribute
with a+1.

Looking more carefully at z
 as.list(z)
[[1]]
`function`

[[2]]
NULL

[[3]]
{
b + 1
}

[[4]]
[1] function(){a+1}

so the original construction of z has kept the source (not, however, as a
source attribute).

There is method to our madness here.  It is impossible (or at least too
complicated) to keep comments in the right place as a function is
parsed and deparsed.  In the old days, comments would occasionally move
around, sometimes in very misleading ways (IIRC with if(){}else{} cases)

Now we keep a copy of the source code with functions created interactively
or with source(), and drop the comments on parsing.  This is controlled by
options(keep.source).

If you do a lot of substitute()-style programming you may want
options(keep.source=FALSE).

-thomas

PS: There are, of course, interesting possibilities for creative abuse of
the source attribute

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] substitute question

2004-03-18 Thread Tony Plate
This is because of the saved attribute source on z (that doesn't get 
printed out before evaluating z, because z is not yet then a function).

To complete your example:

 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 eval(z)
function(){a+1}
 ze - eval(z)
 attributes(ze)
$source
[1] function(){a+1}
 attr(ze, source) - NULL
 ze
function ()
{
b + 1
}

I previously wrote on this topic:

Date: Fri, 24 Oct 2003 09:42:55 -0600
To: [EMAIL PROTECTED], Peter Dalgaard [EMAIL PROTECTED]
From: Tony Plate [EMAIL PROTECTED]
Subject: Re: [R] what's going on here with substitute() ?
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Peter, thank you for the explanation.  This is indeed what is happening.

Might I suggest the following passage for inclusion in the help page for 
function, and possibly also body, in the DETAILS or WARNING section:

Note that the text of the original function definition is saved as an 
attribute source on the function, and this is printed out when the 
function is printed.  Hence, if the function body is changed in some way 
other than by assigning a value via body() (which removes the source 
attribute), the printed form of the function may not be the same as the 
actual function body.

Something along these lines could also go in the help for eval, though if 
it were only there it might be very difficult to find if one were trying to 
look up puzzling behavior of a function.

Here is a transcript that shows what is happening, with another suggestion 
following it.

 eval(substitute(this.is.R - function() X, 
list(X=!is.null(options(CRAN)[[1]]
 this.is.R
function() X
 body(this.is.R)
[1] TRUE
 attributes(this.is.R)
$source
[1] function() X
 attributes(this.is.R) - NULL
 this.is.R
function ()
TRUE
 # the source attribute comes from function definition:
 attributes(function() X)
$source
[1] function() X
 # and seems to be added by eval:
 attr(eval(parse(text=function() TRUE)[[1]]), source)
[1] function() TRUE


 # we can assign bogus source
 attr(this.is.R, source) - a totally bogus function body
 this.is.R
a totally bogus function body
 # assigning to body() removes source
 body(this.is.R) - list(666)
 this.is.R
function ()
666
 attr(this.is.R, source)
NULL

An even better approach might be something that gave a warning on printing 
if the parsed source attribute was not identical to the language object 
being printed.  This would probably belong in the code for case LANGSXP: 
in the function PrintValueRec in main/print.c (if it were written in R, I 
could contribute a patch, but right now I don't have time to try to 
understand the C there.)  R code to do the test could be something like this:

 f - this.is.R
 identical(f, eval(parse(text=attr(f, source))[[1]]))
[1] FALSE
 f - function() TRUE
 identical(f, eval(parse(text=attr(f, source))[[1]]))
[1] TRUE

-- Tony Plate

At Wednesday 08:09 PM 3/17/2004, Gabor Grothendieck wrote:


I left out the brackets in my last email but the problem
(a reappears after have been substituted out) still remains:
 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 eval(z)
function(){a+1}


---
Date:   Wed, 17 Mar 2004 20:10:43 -0500 (EST)
From:   Gabor Grothendieck [EMAIL PROTECTED]
[ Add to Address Book | Block Address | Report as Spam ]
To:   [EMAIL PROTECTED]
Subject:   [R] substitute question




Consider the following example:

# substitute a with b in the indicated function. Seems to work.
 z - substitute( function()a+1, list(a=quote(b)) )
 z
function() b + 1
# z is an object of class call so use eval
# to turn it into an object of class expression; however,
# when z is evaluated, the variable a returns.
 eval(z)
function()a+1
Why did a suddenly reappear again after it had already been replaced?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] projection pursuit

2004-03-18 Thread Prof Brian Ripley
I don't think anyone has actually answered this.  PPDE is a technical 
term, defined in

Friedman, Steutzle and Schroeder (1984) Projection pursuit density
estimation. Journal of the American Statistical Association,
79(387):599-608, September 1984.

I don't know of an R implementation, but have known of S ones (to which I
no longer have access).

If that is not what you mean by PPDE, please give us the reference(s) you 
have in mind.


On Wed, 17 Mar 2004 [EMAIL PROTECTED] wrote:

 Does R have a package that performs projection pursuit density estimation? Or 
 anyone knows code in Matlab or C for example to do this?


-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] .First.lib failed

2004-03-18 Thread Frank E Harrell Jr
Using R-devel of 2Mar04 on debian linux I am getting an error when running
/usr/local/src/R-devel/bin/R CMD check --no-clean Hmisc:


* checking S3 generic/method consistency ... WARNING
Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc,
character.
only = TRUE, verbose = FALSE) : 
.First.lib failed
Execution halted

I remember having to solve this problem previously but I can't remember
how.

Contents of R/Hmisc/s/First.lib.s (main functions in Hmisc are in
R/Hmisc/R/Hmisc.R):

.First.lib - function(lib, pkg, verbose=TRUE, ...) {
  if(verbose)
cat(Hmisc library by Frank E Harrell Jr\n\n,
Type library(help='Hmisc'), ?Overview, or ?Hmisc.Overview')\n,
to see overall documentation.\n\n,
Hmisc redefines [.factor to drop unused levels of factor
variables\n,
when subscripting. To prevent this behaviour, issue the
command\n,
options(drop.unused.levels=F).\n\n,
sep='')
  library.dynam(Hmisc, pkg, lib)
  invisible()
}

If I run /usr/local/src/R-devel/bin/R and type library(Hmisc) everything
is fine.

Thanks for any pointers.  -Frank Harrell

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Re: projection pursuit

2004-03-18 Thread Liaw, Andy
 From: [EMAIL PROTECTED]
 
 Luis,
 
 See the fastICA package, in particular the final example in 
 the function
 fastICA's help page.  This doesn't leave you with density 
 estimates, but
 with projection-pursuit directions; you still have to figure 
 out how to fit
 a density estimate to the rotated data.  Actually, as I understand it,
 XGobi also finds directions but does not fit a density.  However, any
 multivariate density estimator ought to be applicable.  I'm 
 not aware at
 the moment of the tools R offers for multivariate density 
 estimation, but
 I'm sure there are multiple possibilities.

I believe locfit() can handle up to 5 dimensions.


 _The Elements of Statistical Learning_ by Hastie, Tibshirani, 
 and Friedman
 mention a trick to use classification tools (which model class
 probabilities) to estimate density.  Fundamentally, generate 
 data from a
 reference distribution, and use the classification tool to estimate
 probability of observed data (as opposed to generated data) 
 as a function
 of the inputs.  These probabilities, normalized to integrate 
 to 1, form a
 density estimate.  Since there are so very many classification tools
 available, this trick offers a lot of flexibility.

Leo Breiman had talked about this `trick' in his early presentations on
random forest.  However, from my limited experiment, this is an extremely
poor way of estimating density.  Has anyone else tried it?

Cheers,
Andy

 
 Good luck.
 
 Jim Garrett
 Baltimore, Maryland, USA
 
 
 **
 This message is intended only for the designated 
 recipient(s...{{dropped}}
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] help with aov

2004-03-18 Thread Martin Olivier
Hi all,

Suppose the following data and the simple model
y-1:12+rnorm(12)
fac1-c(rep(A,4),rep(B,4),rep(C,4))
fac2-rep(c(D,C),6)
dat-data.frame(y,fac1,fac2)
tmp-aov(y~fac1+fac2,dat)
the command tmp$coeff gives the fllowing results :

(Intercept)   fac1B   fac1C   fac2D
3.3078882.8981877.409010   -1.088588
But mean(y) gives 6.199327 and is different of Intercept..
So, I don't understand the parametrization with the aov() function.
I would like the estimations with the constraints
fac1A+fac1B+fac1C =0 and fac2D+fac2C=0...
What is the solution?

Thanks,
Olivier.
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] help with aov

2004-03-18 Thread Prof Brian Ripley
This is nothing to do with aov: if you want to look at coefficients you 
may as well use lm().  The idea of aov is to look at factors as a whole.

You do need to understand codings: looks like you want to specify 
contr.sum contrasts.  The best place to read about this is chapter 6 of 
MASS.


On Thu, 18 Mar 2004, Martin Olivier wrote:

 Hi all,
 
 Suppose the following data and the simple model
 y-1:12+rnorm(12)
 fac1-c(rep(A,4),rep(B,4),rep(C,4))
 fac2-rep(c(D,C),6)
 dat-data.frame(y,fac1,fac2)
 tmp-aov(y~fac1+fac2,dat)
 
 the command tmp$coeff gives the fllowing results :
 
 (Intercept)   fac1B   fac1C   fac2D
 3.3078882.8981877.409010   -1.088588
 
 But mean(y) gives 6.199327 and is different of Intercept..
 So, I don't understand the parametrization with the aov() function.
 I would like the estimations with the constraints
  fac1A+fac1B+fac1C =0 and fac2D+fac2C=0...
 
 What is the solution?
 
 
 Thanks,
 Olivier.
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 
 

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] substitute question

2004-03-18 Thread Gabor Grothendieck

Tony, Thomas.  Thanks for your help.  Your comments were very
useful.

Unfortunately, my next step gives me a new round of problems.

The following is the same as the last example except that instead
of hard coding the function into the expression I wanted to 
pass it to the expression.  It seems like one has to do a double
substitute to get this effect but I am having problems getting this
to work.

In the code below we first show that the keep.source option has been
set to FALSE so that the source attribute does not mislead us.

Then we do a double substitute.  The outer substitute just creates
the substitute that was in my previous question.  This outer
substitute produces z, a call object.  So far its as expected.

We then do ze - eval(z) but we get a function object right away.  I was
expecting that we get an expression object.  Even worse, the function does not
have  a  replaced with  b -- even though this did work in the previous example 
that I posted.  

What's wrong?


 options()$keep.source
[1] FALSE
 f - function(){a+1}
 z - substitute(substitute(f,list(a=quote(b))),list(f=f))
 class(z)
[1] call
 as.list(z)
[[1]]
substitute

[[2]]
function () 
{
a + 1
}

[[3]]
list(a = quote(b))

 ze - eval(z)
 class(ze)
[1] function
 ze
function () 
{
a + 1
}
 attr(ze,source)
NULL
 

---

Date:   Thu, 18 Mar 2004 09:00:02 -0800 (PST) 
From:   Thomas Lumley [EMAIL PROTECTED]
To:   Gabor Grothendieck [EMAIL PROTECTED] 
Cc:   [EMAIL PROTECTED] 
Subject:   RE: [R] substitute question 

 
On Wed, 17 Mar 2004, Gabor Grothendieck wrote:



 I left out the brackets in my last email but the problem
 (a reappears after have been substituted out) still remains:

  z - substitute( function(){a+1}, list(a=quote(b)) )
  z
 function() {
 b + 1
 }
  eval(z)
 function(){a+1}


Interesting.

Appearances are misleading, however:
 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 f-eval(z)
 f()
Error in f() : Object b not found
 f
function(){a+1}
 attr(f,source)-NULL
 f
function ()
{
b + 1
}

So it isn't that eval(z) has a+1 inside, it just has a source attribute
with a+1.

Looking more carefully at z
 as.list(z)
[[1]]
`function`

[[2]]
NULL

[[3]]
{
b + 1
}

[[4]]
[1] function(){a+1}

so the original construction of z has kept the source (not, however, as a
source attribute).

There is method to our madness here. It is impossible (or at least too
complicated) to keep comments in the right place as a function is
parsed and deparsed. In the old days, comments would occasionally move
around, sometimes in very misleading ways (IIRC with if(){}else{} cases)

Now we keep a copy of the source code with functions created interactively
or with source(), and drop the comments on parsing. This is controlled by
options(keep.source).

If you do a lot of substitute()-style programming you may want
options(keep.source=FALSE).

 -thomas

PS: There are, of course, interesting possibilities for creative abuse of
the source attribute

---

Date:   Thu, 18 Mar 2004 08:41:54 -0700 
From:   Tony Plate [EMAIL PROTECTED]
To:   [EMAIL PROTECTED], [EMAIL PROTECTED] 
Subject:   RE: [R] substitute question 

 
This is because of the saved attribute source on z (that doesn't get 
printed out before evaluating z, because z is not yet then a function).

To complete your example:

 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 eval(z)
function(){a+1}
 ze - eval(z)
 attributes(ze)
$source
[1] function(){a+1}

 attr(ze, source) - NULL
 ze
function ()
{
b + 1
}


I previously wrote on this topic:

Date: Fri, 24 Oct 2003 09:42:55 -0600
To: [EMAIL PROTECTED], Peter Dalgaard [EMAIL PROTECTED]
From: Tony Plate [EMAIL PROTECTED]
Subject: Re: [R] what's going on here with substitute() ?
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed

Peter, thank you for the explanation. This is indeed what is happening.

Might I suggest the following passage for inclusion in the help page for 
function, and possibly also body, in the DETAILS or WARNING section:

Note that the text of the original function definition is saved as an 
attribute source on the function, and this is printed out when the 
function is printed. Hence, if the function body is changed in some way 
other than by assigning a value via body() (which removes the source 
attribute), the printed form of the function may not be the same as the 
actual function body.

Something along these lines could also go in the help for eval, though if 
it were only there it might be very difficult to find if one were trying to 
look up puzzling behavior of a function.

Here is a transcript that shows what is happening, with another suggestion 
following it.

 eval(substitute(this.is.R - function() X, 
list(X=!is.null(options(CRAN)[[1]]
 this.is.R
function() X
 body(this.is.R)
[1] TRUE
 attributes(this.is.R)
$source
[1] function() X
 attributes(this.is.R) - NULL
 this.is.R
function ()
TRUE
 # the source attribute comes from 

RE: [R] substitute question

2004-03-18 Thread Tony Plate
Gabor, I suspect you are overlooking the fact that substitute() does not 
evaluate its first argument.  So, in the previous example you were giving 
an unevaluated expression as the first argument of substitute().  In your 
most recent example you are supplying a function object as the first 
argument of substitute() (by supplying it as the value to be substituted 
for f).  I think you can get what you want by first doing f - 
Quote(function(){a+1}):

 f - Quote(function(){a+1})
 f
function() {
a + 1
}
 z - substitute(substitute(f,list(a=quote(b))),list(f=f))
 z
substitute(function() {
a + 1
}, list(a = quote(b)))
 eval(z)
function() {
b + 1
}
 eval(eval(z)) # this displays the source attribute
function(){a+1}
 body(eval(eval(z)))
{
b + 1
}

hope this helps,

Tony Plate

At Thursday 12:00 PM 3/18/2004, you wrote:

Tony, Thomas.  Thanks for your help.  Your comments were very
useful.
Unfortunately, my next step gives me a new round of problems.

The following is the same as the last example except that instead
of hard coding the function into the expression I wanted to
pass it to the expression.  It seems like one has to do a double
substitute to get this effect but I am having problems getting this
to work.
In the code below we first show that the keep.source option has been
set to FALSE so that the source attribute does not mislead us.
Then we do a double substitute.  The outer substitute just creates
the substitute that was in my previous question.  This outer
substitute produces z, a call object.  So far its as expected.
We then do ze - eval(z) but we get a function object right away.  I was
expecting that we get an expression object.  Even worse, the function does not
have  a  replaced with  b -- even though this did work in the previous 
example
that I posted.

What's wrong?

 options()$keep.source
[1] FALSE
 f - function(){a+1}
 z - substitute(substitute(f,list(a=quote(b))),list(f=f))
 class(z)
[1] call
 as.list(z)
[[1]]
substitute
[[2]]
function ()
{
a + 1
}
[[3]]
list(a = quote(b))
 ze - eval(z)
 class(ze)
[1] function
 ze
function ()
{
a + 1
}
 attr(ze,source)
NULL

---

Date:   Thu, 18 Mar 2004 09:00:02 -0800 (PST)
From:   Thomas Lumley [EMAIL PROTECTED]
To:   Gabor Grothendieck [EMAIL PROTECTED]
Cc:   [EMAIL PROTECTED]
Subject:   RE: [R] substitute question
On Wed, 17 Mar 2004, Gabor Grothendieck wrote:



 I left out the brackets in my last email but the problem
 (a reappears after have been substituted out) still remains:

  z - substitute( function(){a+1}, list(a=quote(b)) )
  z
 function() {
 b + 1
 }
  eval(z)
 function(){a+1}
Interesting.

Appearances are misleading, however:
 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 f-eval(z)
 f()
Error in f() : Object b not found
 f
function(){a+1}
 attr(f,source)-NULL
 f
function ()
{
b + 1
}
So it isn't that eval(z) has a+1 inside, it just has a source attribute
with a+1.
Looking more carefully at z
 as.list(z)
[[1]]
`function`
[[2]]
NULL
[[3]]
{
b + 1
}
[[4]]
[1] function(){a+1}
so the original construction of z has kept the source (not, however, as a
source attribute).
There is method to our madness here. It is impossible (or at least too
complicated) to keep comments in the right place as a function is
parsed and deparsed. In the old days, comments would occasionally move
around, sometimes in very misleading ways (IIRC with if(){}else{} cases)
Now we keep a copy of the source code with functions created interactively
or with source(), and drop the comments on parsing. This is controlled by
options(keep.source).
If you do a lot of substitute()-style programming you may want
options(keep.source=FALSE).
 -thomas

PS: There are, of course, interesting possibilities for creative abuse of
the source attribute
---

Date:   Thu, 18 Mar 2004 08:41:54 -0700
From:   Tony Plate [EMAIL PROTECTED]
To:   [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject:   RE: [R] substitute question
This is because of the saved attribute source on z (that doesn't get
printed out before evaluating z, because z is not yet then a function).
To complete your example:

 z - substitute( function(){a+1}, list(a=quote(b)) )
 z
function() {
b + 1
}
 eval(z)
function(){a+1}
 ze - eval(z)
 attributes(ze)
$source
[1] function(){a+1}
 attr(ze, source) - NULL
 ze
function ()
{
b + 1
}

I previously wrote on this topic:

Date: Fri, 24 Oct 2003 09:42:55 -0600
To: [EMAIL PROTECTED], Peter Dalgaard [EMAIL PROTECTED]
From: Tony Plate [EMAIL PROTECTED]
Subject: Re: [R] what's going on here with substitute() ?
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Peter, thank you for the explanation. This is indeed what is happening.

Might I suggest the following passage for inclusion in the help page for
function, and possibly also body, in the DETAILS or WARNING section:
Note that the text of the original function definition is saved as an
attribute source on the function, and this is printed out when the

RE: [R] substitute question

2004-03-18 Thread Thomas Lumley
On Thu, 18 Mar 2004, Gabor Grothendieck wrote:


 Tony, Thomas.  Thanks for your help.  Your comments were very
 useful.

 Unfortunately, my next step gives me a new round of problems.

 The following is the same as the last example except that instead
 of hard coding the function into the expression I wanted to
 pass it to the expression.  It seems like one has to do a double
 substitute to get this effect but I am having problems getting this
 to work.


The problem is that f is a function, not an expression. You need to work
with body(f)

Either
 f-function(){a+1}
body(f)-do.call(substitute,list(body(f),list(a=quote(b f
function ()
{
b + 1
}

or
 f-function(){a+1}
 body(f)-eval(substitute(substitute(expr,list(a=quote(b))),list(expr=body(f
 f
function ()
{
b + 1
}


-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] substitute question

2004-03-18 Thread Leonard Assis
 Anyone Knows How Shoud I Build Rasch Models (Partial Credit Models)
In R?


[]s
Leonard Assis
Estatístico - CONFE 7439

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] why-s of method dispatching

2004-03-18 Thread Vadim Ogranovich
I see. Thank you very much!

This brings another question. Does R-Core have any plan to promote
data.frame to an S4 class? In general, is there any road-map (formal
or informal) to phasing out S3 classes?

Thanks,
Vadim

 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 18, 2004 12:24 AM
 To: Vadim Ogranovich
 Cc: R Help List
 Subject: Re: [R] why-s of method dispatching
 
 
 On Wed, 17 Mar 2004, Vadim Ogranovich wrote:
 
  I am having a problem to understand why as.data.frame
 method doesn't
  dispatch properly on my class:
  
   setClass(Foo, character)
  [1] Foo
   as.data.frame(list(foo=new(Foo, .Data=a)))
  Error in as.data.frame.default(x[[i]], optional = TRUE) :  can't 
  coerce Foo into a data.frame
  
  I was expecting that this would call as.data.frame.character.
 
 You have set an S4 class and as.data.frame is an S3 generic.
 
  list(foo=new(Foo, .Data=a))
 $foo
 An object of class Foo
 [1] a
 
 and what as.data.frame sees is
 
  attributes(list(foo=new(Foo, .Data=a))$foo)
 $class
 [1] Foo
 attr(,package)
 [1] .GlobalEnv
 
 so thinks this is an S3 class it knows nothing about.
 
  Another puzzle. If I explicitly call as.data.frame.character() it
  would fail but for a different reason:
  
   as.data.frame.character(list(foo=new(Foo, .Data=a)))
  Error in unique.default(x) : unique() applies only to vectors
  
  I was under an impression that an instance of Foo would
 be welcome
  anywhere a character was, but it seems to be more subtle.
 What am I
  missing?
 
 The difference between S3 and S4 classes.
 
 -- 
 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
 


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Problem getting SJava to work on windows

2004-03-18 Thread Ramasubbu Venkatesh




Hi,

I installed SJava on Windows. But I am not able to invoke SJava as when I
try to load the library(SJava) it complains saying JAVA_HOME is not set?
What is the best way to resolve this problem?

Thanks,

Venky

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] why-s of method dispatching

2004-03-18 Thread Vadim Ogranovich
I see. Thank you very much! 

Does R-Core have any plan to promote data.frame to an S4 class? In
general, is there any road-map (formal or informal) for phasing out S3
classes?

Thanks,
Vadim

 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, March 18, 2004 12:24 AM
 To: Vadim Ogranovich
 Cc: R Help List
 Subject: Re: [R] why-s of method dispatching
 
 
 On Wed, 17 Mar 2004, Vadim Ogranovich wrote:
 
  I am having a problem to understand why as.data.frame 
 method doesn't 
  dispatch properly on my class:
  
   setClass(Foo, character)
  [1] Foo
   as.data.frame(list(foo=new(Foo, .Data=a)))
  Error in as.data.frame.default(x[[i]], optional = TRUE) :
   can't coerce Foo into a data.frame
  
  I was expecting that this would call as.data.frame.character.
 
 You have set an S4 class and as.data.frame is an S3 generic.
 
  list(foo=new(Foo, .Data=a))
 $foo
 An object of class Foo
 [1] a
 
 and what as.data.frame sees is
 
  attributes(list(foo=new(Foo, .Data=a))$foo)
 $class
 [1] Foo
 attr(,package)
 [1] .GlobalEnv
 
 so thinks this is an S3 class it knows nothing about.
 
  Another puzzle. If I explicitly call as.data.frame.character() it 
  would fail but for a different reason:
  
   as.data.frame.character(list(foo=new(Foo, .Data=a)))
  Error in unique.default(x) : unique() applies only to vectors
  
  I was under an impression that an instance of Foo would 
 be welcome 
  anywhere a character was, but it seems to be more subtle. 
 What am I 
  missing?
 
 The difference between S3 and S4 classes.
 
 -- 
 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
 


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] substitute question

2004-03-18 Thread Gabor Grothendieck


Tony, Thomas,  Thanks, again.

If the problem with my last example was just that I was passing a function
rather than an unevaluated expression, then why don't the following 
return f with b in place of a?  In both cases, a is still there in the
final output.

f - function() { a + 1 }
z - substitute(substitute(f=f,list(a=quote(b))),list(f=parse(text=deparse(f
eval(eval(z))

or

f - function() { a + 1 }
z - substitute(substitute(expression(f),list(a=quote(b))),list(f=f))
eval(eval(eval(z)))

---

Date:   Thu, 18 Mar 2004 11:29:39 -0800 (PST) 
From:   Thomas Lumley [EMAIL PROTECTED]
To:   Gabor Grothendieck [EMAIL PROTECTED] 
Cc:   [EMAIL PROTECTED], [EMAIL PROTECTED] 
Subject:   RE: [R] substitute question 

 
On Thu, 18 Mar 2004, Gabor Grothendieck wrote:


 Tony, Thomas. Thanks for your help. Your comments were very
 useful.

 Unfortunately, my next step gives me a new round of problems.

 The following is the same as the last example except that instead
 of hard coding the function into the expression I wanted to
 pass it to the expression. It seems like one has to do a double
 substitute to get this effect but I am having problems getting this
 to work.


The problem is that f is a function, not an expression. You need to work
with body(f)

Either
 f-function(){a+1}
body(f)-do.call(substitute,list(body(f),list(a=quote(b f
function ()
{
b + 1
}

or
 f-function(){a+1}
 body(f)-eval(substitute(substitute(expr,list(a=quote(b))),list(expr=body(f
 f
function ()
{
b + 1
}


 -thomas

---

Date:   Thu, 18 Mar 2004 12:15:45 -0700 
From:   Tony Plate [EMAIL PROTECTED]
To:   [EMAIL PROTECTED] 
Cc:   [EMAIL PROTECTED] 
Subject:   RE: [R] substitute question 

 
Gabor, I suspect you are overlooking the fact that substitute() does not 
evaluate its first argument. So, in the previous example you were giving 
an unevaluated expression as the first argument of substitute(). In your 
most recent example you are supplying a function object as the first 
argument of substitute() (by supplying it as the value to be substituted 
for f). I think you can get what you want by first doing f - 
Quote(function(){a+1}):

 f - Quote(function(){a+1})
 f
function() {
a + 1
}
 z - substitute(substitute(f,list(a=quote(b))),list(f=f))
 z
substitute(function() {
a + 1
}, list(a = quote(b)))
 eval(z)
function() {
b + 1
}
 eval(eval(z)) # this displays the source attribute
function(){a+1}
 body(eval(eval(z)))
{
b + 1
}


hope this helps,

Tony Plate

At Thursday 12:00 PM 3/18/2004, you wrote:

Tony, Thomas. Thanks for your help. Your comments were very
useful.

Unfortunately, my next step gives me a new round of problems.

The following is the same as the last example except that instead
of hard coding the function into the expression I wanted to
pass it to the expression. It seems like one has to do a double
substitute to get this effect but I am having problems getting this
to work.

In the code below we first show that the keep.source option has been
set to FALSE so that the source attribute does not mislead us.

Then we do a double substitute. The outer substitute just creates
the substitute that was in my previous question. This outer
substitute produces z, a call object. So far its as expected.

We then do ze - eval(z) but we get a function object right away. I was
expecting that we get an expression object. Even worse, the function does not
have a replaced with b -- even though this did work in the previous 
example
that I posted.

What's wrong?


  options()$keep.source
[1] FALSE
  f - function(){a+1}
  z - substitute(substitute(f,list(a=quote(b))),list(f=f))
  class(z)
[1] call
  as.list(z)
[[1]]
substitute

[[2]]
function ()
{
 a + 1
}

[[3]]
list(a = quote(b))

  ze - eval(z)
  class(ze)
[1] function
  ze
function ()
{
 a + 1
}
  attr(ze,source)
NULL
 

---

Date: Thu, 18 Mar 2004 09:00:02 -0800 (PST)
From: Thomas Lumley [EMAIL PROTECTED]
To: Gabor Grothendieck [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: [R] substitute question


On Wed, 17 Mar 2004, Gabor Grothendieck wrote:

 
 
  I left out the brackets in my last email but the problem
  (a reappears after have been substituted out) still remains:
 
   z - substitute( function(){a+1}, list(a=quote(b)) )
   z
  function() {
  b + 1
  }
   eval(z)
  function(){a+1}


Interesting.

Appearances are misleading, however:
  z - substitute( function(){a+1}, list(a=quote(b)) )
  z
function() {
b + 1
}
  f-eval(z)
  f()
Error in f() : Object b not found
  f
function(){a+1}
  attr(f,source)-NULL
  f
function ()
{
b + 1
}

So it isn't that eval(z) has a+1 inside, it just has a source attribute
with a+1.

Looking more carefully at z
  as.list(z)
[[1]]
`function`

[[2]]
NULL

[[3]]
{
b + 1
}

[[4]]
[1] function(){a+1}

so the original construction of z has kept the source (not, however, as a
source attribute).

There is method to our madness here. It is impossible (or at least too
complicated) to keep comments in the right place as a function is
parsed and 

[R] printf and sprintf: Where are they??

2004-03-18 Thread Ford Prefect
Hi,

Others on this list have happily commented that there
exists printf and/or sprintf in R.  I can't find it.
help(sprintf) and help.search(sprintf) come up
empty!

Is it in some non-standard package?

Thanks!

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] printf and sprintf: Where are they??

2004-03-18 Thread Sundar Dorai-Raj


Ford Prefect wrote:
Hi,

Others on this list have happily commented that there
exists printf and/or sprintf in R.  I can't find it.
help(sprintf) and help.search(sprintf) come up
empty!
Is it in some non-standard package?

Thanks!

On what platform/R-version?

on R-1.8.1 for Windows I get:

help.search(sprintf)

sprintf(base)   Use C-style String Formatting Commands
capture(gregmisc)   Capture printed output of an R expression in a
string
So sprintf is in the base package.

-sundar

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] RE: Frequency table (JCFaria)

2004-03-18 Thread joseclaudio.faria
Hi,

Same time ago I made this generic function for frequency table.
I think that it can help you.


data - c(65, 70, 85, 65, 65, 65, 62, 55, 82, 59,
   55, 66, 74, 55, 65, 56, 80, 73, 45, 64,
   75, 58, 60, 56, 60, 65, 53, 63, 72, 80,
   90, 95, 55, 70, 79, 62, 57, 65, 60, 47,
   61, 53, 80, 75, 72, 87, 52, 72, 80, 85,
   75, 70, 84, 60, 72, 70, 76, 70, 79, 72,
   69, 80, 62, 74, 54, 58, 58, 69, 81, 84)

# begin options of table---
min -  40
max - 100
h   -  10
#-- end options of table---

# begin declaration of variables---
Fi   - numeric()
FacA - numeric();  FacP - numeric()
FrA  - numeric();  FrP  - numeric()
# end declaration of variables-

#- begin function--
Createtable - function()
{
  Fi - table(cut(data, br = seq(min, max, h), right = FALSE))
  K - length(names(Fi))

  for(i in 1:K)
  {
FrA[i] = Fi[i] / 70
  }

  for(i in 1:K)
  {
FrP[i] = (Fi[i] / 70) * 100
  }

  for(i in 1:K)
  {
FacA[i] = sum(Fi[1:i])
  }

  for(i in 1:K)
  {
FacP[i] = (sum(Fi[1:i]) / 70) * 100
  }

  table - data.frame(Fi, FrA, FrP, FacA, FacP)
}
#- end function--

tab - Createtable()
print(Complete table:)
print(tab)


José Cláudio Faria
UESC/DCET
Brasil
73-634.2779
[EMAIL PROTECTED]
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] why-s of method dispatching

2004-03-18 Thread Rolf Turner
Vadim Ogranovich wrote:

 Does R-Core have any plan to promote data.frame to an S4 class? In
 general, is there any road-map (formal or informal) for phasing out
 S3 classes?

FOR GOD'S SAKE DON'T!!!  S4 classes and methods are incomprehensible
to the human mind, which is what I'm equipped with.  If S3 is phased
out, R will become effectively unusable as a programming language.

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Peter Dalgaard
Gabor Grothendieck [EMAIL PROTECTED] writes:

 Tony, Thomas,  Thanks, again.
 
 If the problem with my last example was just that I was passing a function
 rather than an unevaluated expression, then why don't the following 
 return f with b in place of a?  In both cases, a is still there in the
 final output.
 
 f - function() { a + 1 }
 z - substitute(substitute(f=f,list(a=quote(b))),list(f=parse(text=deparse(f
 eval(eval(z))
 
 or
 
 f - function() { a + 1 }
 z - substitute(substitute(expression(f),list(a=quote(b))),list(f=f))
 eval(eval(eval(z)))

As far as I can see you don't quote *the expression that creates f* in
either of the above

f - quote(function() { a + 1 })
attr(f,source) - NULL
g - eval(substitute(substitute(f, list(a=quote(b))),list(f=f)))
g
g() # oops, g is not a function but a call to function
g - eval(g)
b - 500
g()

If you have only the function to begin with, try something along these
lines 

f - function() { a + 1 }
g - f
attr(g,source) - NULL
body(g) - eval(substitute(substitute(f, list(a=quote(b))),list(f=body(f
g
g()


(The real pain in these examples is that substitute autoquotes its
expr argument. Therefore, when you want to modify an expression that
is already stored in a variable, you need an extra outer layer of
eval(substitute(...)) to poke the content of the variable into the
inner substitute. An esub function  with standard evaluation
semantics would make this much easier.)

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] why-s of method dispatching

2004-03-18 Thread Prof Brian Ripley
On Thu, 18 Mar 2004, Vadim Ogranovich wrote:

 I see. Thank you very much! 
 
 Does R-Core have any plan to promote data.frame to an S4 class? In
 general, is there any road-map (formal or informal) for phasing out S3
 classes?

No, no.  There is a vast amount of existing code depending on S3 classes.
As you will see from Rolf Turner's reaction, many users wish to keep it 
that way.

BTW, not all of us would see it as promotion, as S3 and S4 classes have
different strengths.  It is unfortunate that the particular way S4 classes 
are implemented at present that they get confused with S3 classes.


 
 Thanks,
 Vadim
 
  -Original Message-
  From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
  Sent: Thursday, March 18, 2004 12:24 AM
  To: Vadim Ogranovich
  Cc: R Help List
  Subject: Re: [R] why-s of method dispatching
  
  
  On Wed, 17 Mar 2004, Vadim Ogranovich wrote:
  
   I am having a problem to understand why as.data.frame 
  method doesn't 
   dispatch properly on my class:
   
setClass(Foo, character)
   [1] Foo
as.data.frame(list(foo=new(Foo, .Data=a)))
   Error in as.data.frame.default(x[[i]], optional = TRUE) :
can't coerce Foo into a data.frame
   
   I was expecting that this would call as.data.frame.character.
  
  You have set an S4 class and as.data.frame is an S3 generic.
  
   list(foo=new(Foo, .Data=a))
  $foo
  An object of class Foo
  [1] a
  
  and what as.data.frame sees is
  
   attributes(list(foo=new(Foo, .Data=a))$foo)
  $class
  [1] Foo
  attr(,package)
  [1] .GlobalEnv
  
  so thinks this is an S3 class it knows nothing about.
  
   Another puzzle. If I explicitly call as.data.frame.character() it 
   would fail but for a different reason:
   
as.data.frame.character(list(foo=new(Foo, .Data=a)))
   Error in unique.default(x) : unique() applies only to vectors
   
   I was under an impression that an instance of Foo would 
  be welcome 
   anywhere a character was, but it seems to be more subtle. 
  What am I 
   missing?
  
  The difference between S3 and S4 classes.
  
  -- 
  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
  
 
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 
 

-- 
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] two lme questions

2004-03-18 Thread Scott Rifkin
This is an update to my previous post today after finding some previous 
posts about crossed random effects.  Any comments would be much 
appreciated.


I have two random factors (Plot and Variety), one fixed factor (Time).  I 
got rid of one of the fixed factors from my previous post for simplicity.  
Each Variety is tested at each of two Times, so I would like to include 
Time %in% Variety in my random factors.

I tried the following based on a suggestion from Douglas Bates 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/26424.html

 Data = groupedData(Measurement ~Time|Variety, data = 
read.table(mvone.txt,header = TRUE))
 Data$vt = factor(paste(Data$Variety,Data$Time,sep=/))
 Data$const=factor(rep(1,nrow(Data)))
 Data.lme=lme(Measurement~Time,data=Data,random=list(const=pdBlocked(list(pdIdent(~Plot-1),pdIdent(~Variety-1),pdIdent(~vt-1)

I'd like some help interpreting the results.(the ... mean that I deleted 
repetitive stuff)

summary(Data.lme)
...
 Block 1: Plot18Ea18La, Plot18Ea49Ea, Plot18Ea59Ea, Plot18Ea67Ea, 
Plot18La18Ea, Plot18La21La, Plot18La46La, Plot18La71La, Plot21Ea21La, 
...
Plot71La67La, Plot71La71Ea
 Formula: ~Plot - 1 | const
 Structure: Multiple of an Identity
Plot18Ea18La Plot18Ea49Ea Plot18Ea59Ea Plot18Ea67Ea Plot18La18Ea
StdDev: 0.973655 0.973655 0.973655 0.973655 0.973655
Plot18La21La Plot18La46La Plot18La71La Plot21Ea21La Plot21Ea59Ea
StdDev: 0.973655 0.973655 0.973655 0.973655 0.973655
...

I take it that these StdDevs are the sqrt of the variance component for 
Plot.  They are the diagonal of the pdBlocked matrix corresponding to 
pdIdent(~Plot-1)

same thing for 

 Block 2: VarietyL23, VarietyL54, VarietyL59, VarietyL71, VarietyL49, 
...
 Formula: ~Variety - 1 | const
 Structure: Multiple of an Identity
VarietyL23 VarietyL54 VarietyL59 VarietyL71 VarietyL49 VarietyL21
StdDev: 0.04296328 0.04296328 0.04296328 0.04296328 0.04296328 0.04296328
...
and

 Block 3: vtL18/Early, vtL18/Late, vtL21/Early, vtL21/Late, vtL23/Early, 
...
vtL71/Late
 Formula: ~vt - 1 | const
 Structure: Multiple of an Identity
vtL18/Early  vtL18/Late vtL21/Early  vtL21/Late vtL23/Early  vtL23/Late
StdDev: 0.006307627 0.006307627 0.006307627 0.006307627 0.006307627 0.006307627
...

and 

 Residual
StdDev: 0.1299986

is just the sigma(e)

Fixed effects: Measurement ~ Time 
Value  Std.Error  DF  t-value p-value
(Intercept)  9.762629 0.10228970 190 95.44097  .0001
TimeLate-0.222656 0.03712913 190 -5.99680  .0001

I'm still wondering why I only get TimeLate...is it because TimeEarly is 
just 0.222656?

when I do:

 intervals(Data.lme)
Approximate 95% confidence intervals

 Fixed effects:
 lower   est.  upper
(Intercept)  9.5608597  9.7626290  9.9643984
TimeLate-0.2958942 -0.2226559 -0.1494177
attr(,label)
[1] Fixed effects:

 Random Effects:
  Level: const 
   lowerest. upper
sd(Plot - 1)8.436375e-01 0.973655068 1.1237103
sd(Variety - 1) 1.577451e-02 0.042963279 0.1170143
sd(vt - 1)  4.186565e-06 0.006307627 9.5032935

 Within-group standard error:
lower  est. upper 
0.1119908 0.1299986 0.1509019 


These are my confidence intervals on the variance components, I assume.  
I'm slightly confused on this because in one of the posts I found:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/21857.html

it seems to be much more complicated to find the variance componenets.

Thanks much,
Scott Rifkin
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Gabor Grothendieck


From:   Peter Dalgaard [EMAIL PROTECTED]
 (The real pain in these examples is that substitute autoquotes its
 expr argument. Therefore, when you want to modify an expression that
 is already stored in a variable, you need an extra outer layer of
 eval(substitute(...)) to poke the content of the variable into the
 inner substitute. An esub function with standard evaluation
 semantics would make this much easier.)

That is one of the frustrations of using substitute.  

The other is that even if you do perform two levels of substitute,
as I have been trying, you still can't count on it working for
an arbitrary unevaluated expression, as my examples show.  

Even putting aside the source attribute which is super confusing
until you know about it, all the solutions that I can see to 
the problem I presented are ugly.

(1) One can either pick apart the function using body, or 

(2) I  assume one could convert the function to text and 
paste together the correct substitute command with the text of 
the function inserted in its argument.   

The quote mechanism works but is not applicable if all you have
is the function itself (as you point out).

This is sooo frustrating.

Thanks to you, Tony and Thomas for all your help.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] profile error on an nls object

2004-03-18 Thread Adrian Dragulescu
Hello all,

This is the error message that I get.
   hyp.res - nls(log(y)~log(pdf.hyperb(theta,X)), data=dataModel,
+  start=list(theta=thetaE0),
+  trace=TRUE)
45.54325 :   0.100  1.3862944 -4.5577142  0.0005503
3.728302 :   0.0583857346  0.4757772859 -4.9156128701  0.0005563154
1.584317 :   0.0194149477  0.3444648833 -4.9365149150  0.0004105426
1.569333 :   0.0139310639  0.3824648048 -4.9024001228  0.0004089738
1.569311 :   0.0137155342  0.3888648619 -4.8979817546  0.0004137501
1.569311 :   0.0136895846  0.3893564152 -4.8976182201  0.0004141057
1.569311 :   0.0136876315  0.3894059947 -4.8975821760  0.0004141343
   hyp.res.S - summary(hyp.res)
   hyp.res.S

Formula: log(y) ~ log(pdf.hyperb(theta, X))

Parameters:
 Estimate Std. Error t value Pr(|t|)
theta1  0.0136876  0.0359964   0.3800.705
theta2  0.3894060  0.3079860   1.2640.211
theta3 -4.8975822  0.2219928 -22.062   2e-16 ***
theta4  0.0004141  0.0005457   0.7590.451
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

Residual standard error: 0.1542 on 66 degrees of freedom

Correlation of Parameter Estimates:
 theta1theta2theta3
theta2 -0.02168
theta3 -0.02029  0.997736
theta4 -0.97182 -0.008054 -0.008952

   pr1 - profile(hyp.res)
1.825584 :   0.3894059947 -4.8975821760  0.0004141343
1.58426 :   0.373691474 -4.909091289  0.000824045
1.583673 :   0.4176596873 -4.8774106487  0.0008176545
1.583670 :   0.4196944963 -4.8760375504  0.0008187918
1.583670 :   0.4199010211 -4.8758854269  0.0008188162
1.624899 :   0.449756713 -4.854643555  0.001215014
1.624743 :   0.46804752 -4.84185838  0.00122343
1.624741 :   0.470384534 -4.840195293  0.001224199
1.624741 :   0.470638282 -4.840013199  0.001224298
1.624741 :   0.470670500 -4.839990112  0.001224309
1.692158 :   0.522188258 -4.803565745  0.001635778
1.691853 :   0.540794581 -4.791027785  0.001650730
1.691847 :   0.544973564 -4.788090229  0.001652321
1.691847 :   0.545500818 -4.787718964  0.001652616
1.691847 :   0.545592388 -4.787654441  0.001652658
1.784749 :   0.622277872 -4.734086833  0.002091090
1.784039 :   0.642139831 -4.721442413  0.00211
1.784022 :   0.649929188 -4.716068239  0.002119126
1.784021 :   0.651094995 -4.715267692  0.002119963
1.784021 :   0.65136956 -4.71507850  0.00212012
1.784021 :   0.651420684 -4.715043256  0.002120153
1.901667 :   0.760981513 -4.639871097  0.002604136
1.899765 :   0.782870773 -4.627113544  0.002644289
1.899703 :   0.798044378 -4.616913842  0.002653139
1.899699 :   0.800930030 -4.614996517  0.002655646
1.899699 :   0.801815115 -4.614404602  0.002656286
1.899699 :   0.802033012 -4.614258879  0.002656455
1.899699 :   0.802090888 -4.614220164  0.002656499
2.042311 :   0.960722487 -4.508069592  0.003221186
2.036028 :   0.985442669 -4.495703574  0.003291724
2.035767 :   1.017849320 -4.474692317  0.003317203
2.035736 :   1.026482531 -4.469203277  0.003326355
2.035733 :   1.029937702 -4.466987738  0.003329627
2.035732 :   1.031114541 -4.466233213  0.003330776
2.035732 :   1.03153247 -4.46596514  0.00333118
2.035732 :   1.031679019 -4.465871141  0.003331322
2.035732 :   1.031730150 -4.465838341  0.003331371
1.583425 :   3.595503e-01 -4.918824e+00  1.793668e-05
1.583270 :   3.783622e-01 -4.905413e+00  2.175254e-05
1.58327 :   3.793739e-01 -4.904683e+00  2.134353e-05
1.58327 :   3.794562e-01 -4.904622e+00  2.133204e-05
1.624847 :   0.3695765499 -4.9116128267 -0.0003687005
1.624748 :   0.3877816645 -4.8985581022 -0.0003699797
1.624747 :   0.3890277914 -4.8976645481 -0.0003706884
1.624747 :   0.3891837724 -4.8975508910 -0.0003707385
1.693266 :   0.3989123147 -4.8904787597 -0.0007628478
1.693170 :   0.4172349434 -4.8774484377 -0.0007692982
1.693168 :   0.4193992605 -4.8759045536 -0.0007705839
1.693168 :   0.4197576966 -4.8756463144 -0.0007707548
1.693168 :   0.4198094076 -4.8756090629 -0.0007707816
1.788041 :   0.450653198 -4.853510937 -0.001173674
1.787884 :   0.469850125 -4.840178495 -0.001186483
1.787878 :   0.473941725 -4.837285088 -0.001188994
1.787878 :   0.474783800 -4.836687703 -0.001189518
1.787878 :   0.474960093 -4.836562526 -0.001189627
1.787878 :   0.474996400 -4.836536741 -0.001189650
1.908362 :   0.531011661 -4.796878005 -0.001614805
1.907987 :   0.552282889 -4.782714884 -0.001637055
1.907965 :   0.560264832 -4.777154923 -0.001642437
1.907964 :   0.562346209 -4.775709348 -0.001644026
1.907963 :   0.56295255 -4.77528733 -0.00164447
1.907963 :   0.563123513 -4.775168321 -0.001644596
1.907963 :   0.563172014 -4.775134556 -0.001644632
2.053048 :   0.653571857 -4.712183501 -0.002111091
2.051874 :   0.678913471 -4.696423681 -0.002150202
2.051785 :   0.69544095 -4.68518302 -0.00216328
2.051772 :   0.701166962 -4.681323343 -0.002168564
2.051770 :   0.703471045 -4.679765756 -0.002170603
2.051769 :   0.704360670 -4.679164327 -0.002171397
2.051769 :   0.704707691 -4.678929683 -0.002171706
2.051769 :   0.704842651 -4.678838422 -0.002171826
2.051769 :   0.704895042 -4.678802995 -0.002171872

Re: [R] substitute question

2004-03-18 Thread Peter Dalgaard
Gabor Grothendieck [EMAIL PROTECTED] writes:

 From:   Peter Dalgaard [EMAIL PROTECTED]
  (The real pain in these examples is that substitute autoquotes its
  expr argument. Therefore, when you want to modify an expression that
  is already stored in a variable, you need an extra outer layer of
  eval(substitute(...)) to poke the content of the variable into the
  inner substitute. An esub function with standard evaluation
  semantics would make this much easier.)
 
 That is one of the frustrations of using substitute.  
 
 The other is that even if you do perform two levels of substitute,
 as I have been trying, you still can't count on it working for
 an arbitrary unevaluated expression, as my examples show.  

Er, I don't think so. All I have seen is a couple of cases where you
tried to pass something that was not a language object (e.g. a
function as opposed to an expression or call generating a function.)

 Even putting aside the source attribute which is super confusing
 until you know about it, all the solutions that I can see to 
 the problem I presented are ugly.
 
 (1) One can either pick apart the function using body, or 
 
 (2) I  assume one could convert the function to text and 
 paste together the correct substitute command with the text of 
 the function inserted in its argument.   
 
 The quote mechanism works but is not applicable if all you have
 is the function itself (as you point out).
 
 This is sooo frustrating.

Well, the certain road to frustration is to try to do the impossible.
A function is not a language object and you can only do substitutions
on language objects.

 f - function()x
 g - quote(function()x)
 f
function()x
 g
function() x
 mode(f)
[1] function
 mode(g)
[1] call
 is.language(f)
[1] FALSE
 is.language(g)
[1] TRUE

However, a function is basically a triplet consisting of an argument
list, a body, and an environment, the middle of which *is* a language
object. So I don't think your (1) is ugly, it's the logical way to
proceed. 

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Gabor Grothendieck

 Date:   18 Mar 2004 23:52:47 +0100 
 From:   Peter Dalgaard [EMAIL PROTECTED]
 To:   [EMAIL PROTECTED] 
 Cc:   [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL 
 PROTECTED] 
 Subject:   Re: [R] substitute question 
 
  
 Gabor Grothendieck [EMAIL PROTECTED] writes:
 
  From: Peter Dalgaard [EMAIL PROTECTED]
   (The real pain in these examples is that substitute autoquotes its
   expr argument. Therefore, when you want to modify an expression that
   is already stored in a variable, you need an extra outer layer of
   eval(substitute(...)) to poke the content of the variable into the
   inner substitute. An esub function with standard evaluation
   semantics would make this much easier.)
  
  That is one of the frustrations of using substitute. 
  
  The other is that even if you do perform two levels of substitute,
  as I have been trying, you still can't count on it working for
  an arbitrary unevaluated expression, as my examples show. 
 
 Er, I don't think so. All I have seen is a couple of cases where you
 tried to pass something that was not a language object (e.g. a
 function as opposed to an expression or call generating a function.)
 
 

The parse/deparse one definitely is an expression:

 z - parse(text=deparse(f))
 class(z);mode(z);typeof(z)
[1] expression
[1] expression
[1] expression

In the other one, it is not an expression in the inner substitute
but should be by the time it gets to the outer one since I
explicitly added expression(...).  It is expanded which shows
it did do that part right.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Tony Plate
Gabor, you might have less frustration if you work with Peter's esub() 
suggestion (use it instead of substitute()):

esub - function(expr, subst.list) do.call(substitute, list(expr, 
subst.list))

When you say

In the other one, it is not an expression in the inner substitute
but should be by the time it gets to the outer one since I explicitly added 
expression(...).  It is expanded which shows it did do that part right.

something to bear in mind is the natural order of evaluation is reversed 
with nested substitute()'s (because the inner substitute() is quoted by the 
outer substitute())  (but I haven't carefully reasoned through this being 
an explanation for your particular frustration here.)

hope this might help,

Tony Plate



At Thursday 04:06 PM 3/18/2004, Gabor Grothendieck wrote:

 Date:   18 Mar 2004 23:52:47 +0100
 From:   Peter Dalgaard [EMAIL PROTECTED]
 To:   [EMAIL PROTECTED]
 Cc:   [EMAIL PROTECTED], [EMAIL PROTECTED], 
[EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject:   Re: [R] substitute question


 Gabor Grothendieck [EMAIL PROTECTED] writes:

  From: Peter Dalgaard [EMAIL PROTECTED]
   (The real pain in these examples is that substitute autoquotes its
   expr argument. Therefore, when you want to modify an expression that
   is already stored in a variable, you need an extra outer layer of
   eval(substitute(...)) to poke the content of the variable into the
   inner substitute. An esub function with standard evaluation
   semantics would make this much easier.)
 
  That is one of the frustrations of using substitute.
 
  The other is that even if you do perform two levels of substitute,
  as I have been trying, you still can't count on it working for
  an arbitrary unevaluated expression, as my examples show.

 Er, I don't think so. All I have seen is a couple of cases where you
 tried to pass something that was not a language object (e.g. a
 function as opposed to an expression or call generating a function.)



The parse/deparse one definitely is an expression:

 z - parse(text=deparse(f))
 class(z);mode(z);typeof(z)
[1] expression
[1] expression
[1] expression
In the other one, it is not an expression in the inner substitute
but should be by the time it gets to the outer one since I
explicitly added expression(...).  It is expanded which shows
it did do that part right.


___
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] character - list

2004-03-18 Thread David Andel
Hi

I have a matrix of type character (strangly) and am trying to apply 
the function aggregate to it, but unfortunately without success.
It seems to me that aggregate would work, if I only could get rid of the 
quotation marks around each item.

So for a very simple example which looks as my actual data look (of 
course here I put the quotation marks on purpose, but I have no idea 
where they come from in my actual data):

 x - matrix(c(a,b,1,a,c,3,b,b,2), nr=3, byrow=T, 
dimnames=list(1:3, c(type,group,value)))
 x
  type group value
1 a  b   1
2 a  c   3
3 b  b   2

I can't access the columns the way I think would be necessary for 
aggregate to work:
 x$type
NULL

And this seems to be the problem:
 typeof(x)
[1] character
I think I would need to have type list to be able to apply aggregate.

How can I accomplish this?

Thanks,
David
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] sd(): why error with NA's?

2004-03-18 Thread Raubertas, Richard
R 1.8.1 with Windows XP.

I have a question about how sd() behaves with NA's:

 mean(c(1,2,3,NA))
[1] NA
 median(c(1,2,3,NA))
[1] NA
 mad(c(1,2,3,NA))
[1] NA
 sd(c(1,2,3,NA))
Error in var(x, na.rm = na.rm) : missing observations in cov/cor


What is so special about the standard deviation, relative to
other descriptive statistics, that the presence of NA's 
deserves an error instead of simply returning NA?
(I know about na.rm=TRUE, but that is not the point here.)

A few small changes to sd() would seem to resolve the anomaly:

sd - function(x, na.rm=FALSE)
# Function like built-in 'sd', but return NA instead of error when
# 'na.rm' is FALSE and 'x' has NA's.
{
if (is.matrix(x)) {
apply(x, 2, sd, na.rm = na.rm)
} else if (is.vector(x)) {
if (!na.rm  any(is.na(x)))  NA
else sqrt(var(x, na.rm = na.rm))
} else if (is.data.frame(x)) {
sapply(x, sd, na.rm = na.rm)
} else {
x - as.vector(x)
if (!na.rm  any(is.na(x)))  NA
else sqrt(var(x, na.rm = na.rm))
}
}

Rich Raubertas
Merck  Co.


--Notice:  
This e-mail message, together with any attachments, contains information of Merck  
Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its 
affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp 
 Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary 
copyrighted and/or legally privileged. It is intended solely for the use of the 
individual or entity named on this message.  If you are not the intended recipient, 
and have received this message in error, please notify us immediately by reply e-mail 
and then delete it from your system.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Thomas Lumley
On Thu, 18 Mar 2004, Gabor Grothendieck wrote:



 From:   Peter Dalgaard [EMAIL PROTECTED]
  (The real pain in these examples is that substitute autoquotes its
  expr argument. Therefore, when you want to modify an expression that
  is already stored in a variable, you need an extra outer layer of
  eval(substitute(...)) to poke the content of the variable into the
  inner substitute. An esub function with standard evaluation
  semantics would make this much easier.)

 That is one of the frustrations of using substitute.

 The other is that even if you do perform two levels of substitute,
 as I have been trying, you still can't count on it working for
 an arbitrary unevaluated expression, as my examples show.

You can, but a function isn't an arbitrary unevaluated expression
 You still aren't passing an expression containg the symbol `a`. You are
passing an expression containing the function f, whose body is an
expression containing the symbol `a`.  Functions aren't expressions.

 f - function() { a + 1 }
 z - substitute(substitute(f=f,list(a=quote(b))),list(f=parse(text=deparse(f)$
 eval(eval(z))

 or

 f - function() { a + 1 }
 z - substitute(substitute(expression(f),list(a=quote(b))),list(f=f))
 eval(eval(eval(z)))


 (1) One can either pick apart the function using body, or

Actually, I think this is fairly natural -- it is only body(f) that is an
expression.  Certainly substitute() could have been written to operate on
functions as well, but it wasn't.



-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Reading image file formats

2004-03-18 Thread Teresa Alarcon
Hi!
Is there exists an instruction to read images (bmp, jpg, etc.) in R?
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] character - list

2004-03-18 Thread Liaw, Andy
Use as.data.frame() on the matrix.

HTH,
Andy

 From: David Andel
 
 Hi
 
 I have a matrix of type character (strangly) and am trying to apply 
 the function aggregate to it, but unfortunately without success.
 It seems to me that aggregate would work, if I only could get 
 rid of the 
 quotation marks around each item.
 
 So for a very simple example which looks as my actual data look (of 
 course here I put the quotation marks on purpose, but I have no idea 
 where they come from in my actual data):
 
   x - matrix(c(a,b,1,a,c,3,b,b,2), nr=3, byrow=T, 
 dimnames=list(1:3, c(type,group,value)))
   x
type group value
 1 a  b   1
 2 a  c   3
 3 b  b   2
 
 I can't access the columns the way I think would be necessary for 
 aggregate to work:
   x$type
 NULL
 
 And this seems to be the problem:
   typeof(x)
 [1] character
 
 I think I would need to have type list to be able to apply 
 aggregate.
 
 How can I accomplish this?
 
 Thanks,
 David
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


--Notice:  
This e-mail message, together with any attachments, contains information of Merck  
Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its 
affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp 
 Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary 
copyrighted and/or legally privileged. It is intended solely for the use of the 
individual or entity named on this message.  If you are not the intended recipient, 
and have received this message in error, please notify us immediately by reply e-mail 
and then delete it from your system.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] How to do a truncated regression

2004-03-18 Thread Howard Alper

  Hi,
 
  I'm interested in performing a regression of dependent variable y on
independent variable x, where (x,y) are known only for y  c, where c
is
a constant.  For y = c, neither x or y are known.  This is called a
truncated regression, I believe.
 
  I read a post on the R help list, that recommended doing the
following:
 
  The form for the response is Surv(c,y,1), but it doesn't recycle
arguments
so you actually need Surv(rep(c,length(y)),y,rep(1,length(y)))
 
  I have tried to follow the above procedure, but I obtain the error
message
 
   Stop time must be  start time
 
which I don't understand.  I think that at least part of the problem
is
that its hard to know what Surv(c,y,1) means, i.e, what quantity in
the input list to Surv is supposed to be set equal to c, to y, etc. 
There also may be other parameters I've not set correctly. The code
that
actually performs the regression is below:
 
trunc - survreg(Surv(c,yx[,2],event=rep(1,length(yx[,2]))) ~ yx[,1],
dist='gaussian', data=yxfr) , where c is already defined as
c-rep(200,npoints), where npoints is the number of (x,y) data pairs.
 
  I should mention that I have R v1.8.1, and to perform these
calculations I've invoked librarys MASS and SURVIVAL.  I have tried to
look this up in the manuals, but so far I've not found anything on
truncated regression.
 
  If you could tell me what my error(s) is(are), and/or a detailed
description of how to perform truncated regression, that would be
great.
 
  Thanks,
 
  Howard Alper


[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Gabor Grothendieck


I don't think I expressed myself very well on that.  

Looking at what we get from the example:

 z - substitute(substitute(expression(f),list(a=quote(b))),list(f=f))

 z
substitute(expression(function () 
{
a + 1
}), list(a = quote(b)))

 class(z);mode(z);typeof(z)
[1] call
[1] call
[1] language


we see that the function seems to be expanded correctly and 
the statement does produce a call object.  However, 
applying eval one, two or three times does not give what 
you would think if you looked at z above.  In all cases, 
a is still there.  Some posters have claimed that the
problem is that list(f=f) cannot hold a function and must be
an expression but that's not what the help page says, the
examples are not all of class expression or call and
even if that were true then my parse/deparse example should 
work since it is unquestionably an expression.

Date:   Thu, 18 Mar 2004 16:41:31 -0700 
From:   Tony Plate [EMAIL PROTECTED]
To:   [EMAIL PROTECTED], [EMAIL PROTECTED] 
Cc:   [EMAIL PROTECTED], [EMAIL PROTECTED] 
Subject:   Re: [R] substitute question 

 
Gabor, you might have less frustration if you work with Peter's esub() 
suggestion (use it instead of substitute()):

esub - function(expr, subst.list) do.call(substitute, list(expr, 
subst.list))

When you say

In the other one, it is not an expression in the inner substitute
but should be by the time it gets to the outer one since I explicitly added 
expression(...). It is expanded which shows it did do that part right.

something to bear in mind is the natural order of evaluation is reversed 
with nested substitute()'s (because the inner substitute() is quoted by the 
outer substitute()) (but I haven't carefully reasoned through this being 
an explanation for your particular frustration here.)

hope this might help,

Tony Plate




At Thursday 04:06 PM 3/18/2004, Gabor Grothendieck wrote:

  Date: 18 Mar 2004 23:52:47 +0100
  From: Peter Dalgaard [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], 
 [EMAIL PROTECTED], [EMAIL PROTECTED]
  Subject: Re: [R] substitute question
 
 
  Gabor Grothendieck [EMAIL PROTECTED] writes:
 
   From: Peter Dalgaard [EMAIL PROTECTED]
(The real pain in these examples is that substitute autoquotes its
expr argument. Therefore, when you want to modify an expression that
is already stored in a variable, you need an extra outer layer of
eval(substitute(...)) to poke the content of the variable into the
inner substitute. An esub function with standard evaluation
semantics would make this much easier.)
  
   That is one of the frustrations of using substitute.
  
   The other is that even if you do perform two levels of substitute,
   as I have been trying, you still can't count on it working for
   an arbitrary unevaluated expression, as my examples show.
 
  Er, I don't think so. All I have seen is a couple of cases where you
  tried to pass something that was not a language object (e.g. a
  function as opposed to an expression or call generating a function.)
 
 

The parse/deparse one definitely is an expression:

  z - parse(text=deparse(f))
  class(z);mode(z);typeof(z)
[1] expression
[1] expression
[1] expression

In the other one, it is not an expression in the inner substitute
but should be by the time it gets to the outer one since I
explicitly added expression(...). It is expanded which shows
it did do that part right.


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Gabor Grothendieck

Date:   Thu, 18 Mar 2004 15:56:59 -0800 (PST) 
From:   Thomas Lumley [EMAIL PROTECTED]
  
 On Thu, 18 Mar 2004, Gabor Grothendieck wrote:
  (1) One can either pick apart the function using body, or

 Actually, I think this is fairly natural -- it is only body(f) 
 that is an
 expression. Certainly substitute() could have been written to 
 operate on
 functions as well, but it wasn't.

In the context of R, natural is performing operations on whole
objects at once.  Its the same difference as indexing vs. vector
operations.

I am not sure where this came from about not operating on functions.
Are you sure?  I know just about everyone is saying this but
the help page does not refer to that and the 
example I gave where we do use list(f=f) for f a function does
seem to expand properly (see my last posting) although 
the subsitution never appears to take effect.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Thomas Lumley
On Thu, 18 Mar 2004, Gabor Grothendieck wrote:



 I don't think I expressed myself very well on that.

 Looking at what we get from the example:

  z - substitute(substitute(expression(f),list(a=quote(b))),list(f=f))

  z
 substitute(expression(function ()
 {
 a + 1
 }), list(a = quote(b)))

  class(z);mode(z);typeof(z)
 [1] call
 [1] call
 [1] language


 we see that the function seems to be expanded correctly and
 the statement does produce a call object.  However,
 applying eval one, two or three times does not give what
 you would think if you looked at z above.

Maybe we didn't express ourselves well enough.

Looking at z above isn't enough.  z is a call to substitute().
Its first operand is an expression. The expression contains a single term,
which is a function.

If you typed
notz- quote(substitute(expression(function ()
 {
 a + 1
 }), list(a = quote(b

you would obtain something that deparsed the same as z, and so looked the
same, but was actually different.  In notz the first operand of substitute
is an expression containing multiple terms, which if evaluated would
return a function.

substitute() goes though this expression and checks each term to see if it
is `a`. In z there is only one term and it isn't `a`.  In notz there is
(after sufficient recursion) an `a` and it gets replaced.

So

 z[[2]][[2]]
function ()
{
a + 1
}
 notz[[2]][[2]]
function() {
a + 1
}

are the respective operands, and they still look the same. But

 mode(z[[2]][[2]])
[1] function
 mode(notz[[2]][[2]])
[1] call
 length(z[[2]][[2]])
[1] 1
 length(notz[[2]][[2]])
[1] 4

and if we try to find the actual `a` in there
 notz[[2]][[2]][[3]][[2]][[2]]
a
 z[[2]][[2]][[3]][[2]][[2]]
Error in z[[2]][[2]][[3]] : object is not subsettable



-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Specifying interaction terms in glm

2004-03-18 Thread Chris Compton
Firstly, I want to say thanks to the developers and maintainers of R and
its packages- it is a great resource and I appreciate their work.

 

My question relates to setting the reference level in interaction terms
using glm in the base package. I would normally set contrasts for the
treatment factors so that the base is zero (control), and the treatment
(one) is compared to it. However, when I specify an interaction between
2 such factors in a glm model, the reference in the glm summary is both
the level 2 factors combined. My example code is below:

 

dat$treat - factor(dat$treat, labels=c(no, yes))

contrasts(dat$treat) - contr.treatment(2, base=1, contrasts = TRUE)

 

dat$sample - factor(dat$sample, labels=c(no, yes))

contrasts(dat$sample) - contr.treatment(2, base=1, contrasts = TRUE)

 

I tried reordering the base for the contrasts, but it didn't change the
output.

Is there some way around this without reversing the coding of my
variables?

 

Chris Compton (Veterinarian)

Animal Health Centre

P.O Box 21 Morrinsville

New Zealand

 


[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] profile error on an nls object

2004-03-18 Thread Bill.Venables
Adrian Dragulescu asks:
 
 Hello all,
 
 This is the error message that I get.
hyp.res - nls(log(y)~log(pdf.hyperb(theta,X)), data=dataModel,
 +  start=list(theta=thetaE0),
 +  trace=TRUE)
 45.54325 :   0.100  1.3862944 -4.5577142  0.0005503
 3.728302 :   0.0583857346  0.4757772859 -4.9156128701  0.0005563154
 1.584317 :   0.0194149477  0.3444648833 -4.9365149150  0.0004105426
 1.569333 :   0.0139310639  0.3824648048 -4.9024001228  0.0004089738
 1.569311 :   0.0137155342  0.3888648619 -4.8979817546  0.0004137501
 1.569311 :   0.0136895846  0.3893564152 -4.8976182201  0.0004141057
 1.569311 :   0.0136876315  0.3894059947 -4.8975821760  0.0004141343
hyp.res.S - summary(hyp.res)
hyp.res.S
 
 Formula: log(y) ~ log(pdf.hyperb(theta, X))
 
 Parameters:
  Estimate Std. Error t value Pr(|t|)
 theta1  0.0136876  0.0359964   0.3800.705
 theta2  0.3894060  0.3079860   1.2640.211
 theta3 -4.8975822  0.2219928 -22.062   2e-16 ***
 theta4  0.0004141  0.0005457   0.7590.451
 ---
 Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
 
 Residual standard error: 0.1542 on 66 degrees of freedom
 
 Correlation of Parameter Estimates:
  theta1theta2theta3
 theta2 -0.02168
 theta3 -0.02029  0.997736
 theta4 -0.97182 -0.008054 -0.008952
 
pr1 - profile(hyp.res)
 1.825584 :   0.3894059947 -4.8975821760  0.0004141343
 ...
 1.875413 :  0.000300086 1.830592703 0.000608001
 Error in prof$getProfile() : step factor 0.000488281 reduced below
`minFactor' of 0.000976563
 
 
 Why is there an error on profile, which should only evaluate the
 objective function for different parameter values?

profile() doesn't merely evaluate the objective function at
different parameter values. It holds one of the parameters constant
and optimises the objective function with respect to all the others.
This is repeated for a sequence of values passing through the mle, and
the same for each parameter.  

If you fix a parameter at a very unrealistic value (as can happen) it
is not surprising that the optimisation with respect to all the others
runs into trouble.  This is a computationally difficult area and I am
more surprised by the cases that work without a hitch than by the ones
that don't.  You can expect to have to tweak things a bit in many cases.

Bill Venables.

 
 Thanks a lot.
 
 Adrian
 
 __

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] substitute question

2004-03-18 Thread Thomas Lumley
On Thu, 18 Mar 2004, Gabor Grothendieck wrote:

 I am not sure where this came from about not operating on functions.
 Are you sure?  I know just about everyone is saying this but
 the help page does not refer to that and the
 example I gave where we do use list(f=f) for f a function does
 seem to expand properly (see my last posting) although
 the subsitution never appears to take effect.


Yes, I am sure.

It's not that it is invalid to have a function as the first argument of
substitute, it's that substitute() does not recurse into either the body
or the formal arguments of the function (or into the environment, though
no-one would expect that).


-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] character - list

2004-03-18 Thread Gabor Grothendieck

It would be helpful if you were more explicit on what you mean
by not successful.

Is the problem that:
1. you can't get aggregate to work with character data or 
2. you want to convert the numeric column to numbers or
3. you want to have a structure that has both numbers and character
columns

Also, I am not sure if you actually want the characters or if you
want the character columns converted to factors or, if applicable
to numbers.

In case 1, it actually does work:

 aggregate(x[,-2], list(x[,2]), length)
  Group.1 type value
1   b2 2
2   c1 1

In case 2, use as.numeric:

 aggregate(list(value=as.numeric(x[,3])),list(group=x[,2]), mean)
  group value
1 b   1.5
2 c   3.0

In case 3, create a data frame:
x.df - data.frame(type = I(x[,1]), group = I(x[,2]), value = as.numeric(x[,3]))

If you want the character columns converted to factors then get
rid of the I's.


Date:   19 Mar 2004 00:47:38 +0100 
From:   David Andel [EMAIL PROTECTED]
To:   [EMAIL PROTECTED] 
Subject:   [R] character -  list 

 
Hi

I have a matrix of type character (strangly) and am trying to apply 
the function aggregate to it, but unfortunately without success.
It seems to me that aggregate would work, if I only could get rid of the 
quotation marks around each item.

So for a very simple example which looks as my actual data look (of 
course here I put the quotation marks on purpose, but I have no idea 
where they come from in my actual data):

 x - matrix(c(a,b,1,a,c,3,b,b,2), nr=3, byrow=T, 
dimnames=list(1:3, c(type,group,value)))
 x
type group value
1 a b 1
2 a c 3
3 b b 2

I can't access the columns the way I think would be necessary for 
aggregate to work:
 x$type
NULL

And this seems to be the problem:
 typeof(x)
[1] character

I think I would need to have type list to be able to apply aggregate.

How can I accomplish this?

Thanks,
David

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Incomplete Gamma Functions and GammaDistribution Doc errata.

2004-03-18 Thread Adrian Custer
Hello all,

In the course of trying to implement the CDF of an
InverseGammaDistribution, I have run across the need for an igamma()
function. Several others have needed this function but the answers I
have found so far are not totally clear to me. I'm writing for three
reasons:
1) to present a small error in the docs
2) to clarify the approach we are expected to take
3) to request,for the ease of use of myself and others, that the  R
developers implement igamma(), document the approach they want users
to take or do both.

1) An error in the docs of the gamma distribution:
-

The GammaDistribution(param1,param2) is defined alternatively with two
versions of the second parameter which are inverses of one another.
'Rate' arises from one derivation such as that presented in Mathworld: 
http://mathworld.wolfram.com/GammaDistribution.html
(see just below equation (2) )
define $\theta \equiv 1 / \lambda$ to be the time between
changes
which makes \theta in equation (3) a rate parameter. In the R
documentation (i.e. ?pgamma) this same equation is presented but the
parameter \theta is now called s and is termed the scale. This goes
against general usage of mathworld, wikipaedia, the COLT library, and
others who call the s term a rate. 

Please either change the equation or replace the name with rate and
the label with r or nu or theta.



2) Using existing functions to build the igamma(\alpha,\beta):
-

The incomplete gamma has been mentioned in two previous emails that I
could find:
http://www.r-project.org/nocvs/mail/r-help/2000/1006.html
and
http://www.r-project.org/nocvs/mail/r-help/2000/3618.html
both of which suggest that the upper incomplete gamma can be obtained 
using the pgamma() function. 

Is Prof. Ripley's message (the first above) saying that

upperIncompletegamma(x,\rate) = pgamma(x,\rate) * gamma(\rate) ?

I have not yet been able to see why this would be true. I keep tripping
myself up on the differing notation of R, mathworld, wikipaedia and
Abramowitz and Stegun's Handbook of mathematical functions.

Would someone please confirm that this is mathematically correct? 


3) Adding an igamma() function or documentation for how to generate it.


Since I am at least the third person not clever enough to see the way to
derive the igamma directly, because the lack of an igamma() function has
cost me a chunk of my day, because using functions related to
distributions to derive pure mathematical functions is counter
intuitive, and because two implementations already exist, I hope the R
developers would be willing to incorporate an igamma() function directly
into R. 

The implementation could either use the code posted to the list:
http://www.r-project.org/nocvs/mail/r-help/1998/0295.html
or be a convinience function around the pgamma and gamma solution
suggested in the emails presented above. 

Alternatively, if this approach doesn't suit you, would someone please
add an explanation to the documentation for the gamma function
explaining how to generate an igamma(\alpha, \beta) using the current
functions?

Thanks to all,
adrian

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Frequency table

2004-03-18 Thread joseclaudio.faria
Hi,

See if this generic function I made can help you.

data - c(65, 70, 85, 65, 65, 65, 62, 55, 82, 59,
   55, 66, 74, 55, 65, 56, 80, 73, 45, 64,
   75, 58, 60, 56, 60, 65, 53, 63, 72, 80,
   90, 95, 55, 70, 79, 62, 57, 65, 60, 47,
   61, 53, 80, 75, 72, 87, 52, 72, 80, 85,
   75, 70, 84, 60, 72, 70, 76, 70, 79, 72,
   69, 80, 62, 74, 54, 58, 58, 69, 81, 84)

# begin options of table---
min -40
max - 100
h   - 10
#-- end options of table---

# begin declaration of variables---
Fi - numeric(); FacA - numeric(); FacP - numeric(); FrA   - numeric();
FrP- numeric()
# end declaration of variables-

#- begin function--
Createtable - function()
{
  Fi - table(cut(data, br = seq(min, max, h), right = FALSE))
  K - length(names(Fi))
  n - length(data)

  for(i in 1:K)
  {
FrA[i] = Fi[i] / n
  }

  for(i in 1:K)
  {
FrP[i] = (Fi[i] / n) * 100
  }

  for(i in 1:K)
  {
FacA[i] = sum(Fi[1:i])
  }

  for(i in 1:K)
  {
FacP[i] = (sum(Fi[1:i]) / n) * 100
  }

  table - data.frame(Fi, FrA, FrP, FacA, FacP)
}
#- end function--

tab - Createtable()
print(Complete table:)
print(tab)

José Cláudio Faria
UESC/DCET
Brasil
73-634.2779
[EMAIL PROTECTED]
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Why is rpart() so slow?

2004-03-18 Thread Richard A. O'Keefe
I've had rpart running on a problem now for a couple of *days*,
but I'd expect a decision tree builder to run in minutes if not
seconds.  Why is rpart slow?  Is there anything I can do to make
it quicker?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Why is rpart() so slow?

2004-03-18 Thread Patrick Connolly
On Fri, 19-Mar-2004 at 04:44PM +1300, Richard A. O'Keefe wrote:

| I've had rpart running on a problem now for a couple of *days*,
| but I'd expect a decision tree builder to run in minutes if not
| seconds.  Why is rpart slow?  Is there anything I can do to make
| it quicker?

Yes.  You could give us an indication of just what you're trying to
do, with what, and to what, so we would be in a position to say what
improvements could be made.



-- 
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand 
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] data frame output

2004-03-18 Thread Randy Zelick
Hello list,

Is there a way to *not* supress leading zeros when printing (to the
console window or to a file) a dataframe?

Thanks,

=Randy=

R. Zelick   email: [EMAIL PROTECTED]
Department of Biology   voice: 503-725-3086
Portland State University   fax:   503-725-3888

mailing:
P.O. Box 751
Portland, OR 97207

shipping:
1719 SW 10th Ave, Room 246
Portland, OR 97201

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html