Re: [R] plot to postscript orientation

2007-08-03 Thread Uwe Ligges


Miruna Petrescu-Prahova wrote:
  Hi
 
  I am trying to save some plots in a postscript file. When I generate the 
 plots in the main window, they appear correctly - their orientation is 
 landscape (i.e., horizontal). However, when I open the .ps file with GSview, 
 the whole page appears vertically, and the plot appears horizontally, which 
 means that the plot is only partially visible (example here 
 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps ). I searched 
 the R-help mailing list archive and found 2 suggestions: setting the width 
 and height and setting horizontal = FALSE. I have tried setting the width 
 and height but it makes no difference. I have also tried using horizontal = 
 FALSE. This rotates and elongates the plot, but it is still displayed 
 horizontally on a vertical page, and so only partially  visible (example 
 here https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps). I 
 am not sure what is wrong. Plots are created with filled.contour.


I guess this is a misconfiguration of your GSview. The plots are fine 
for me. Anyway, you might also want to set the argument
paper=special in the postscript() call.

Uwe Ligges


  Thanks
  Miruna
 
 
 
 Miruna Petrescu-Prahova
 Department of Sociology
 University of California, Irvine
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] plot to postscript orientation

2007-08-03 Thread Vorlow Constantinos
Hi,

My vanilla code works fine... 

See also attached .eps file (seperate email sent directly to you)

 r-rnorm(100)
 postscript(figure.eps)
 plot.ts(r)
 dev.off()

Also this works ok as you have been told already:

 paper=special in the postscript() call.

If you see my eps file wrongly then your GSVIEW setup is wrong. 

Choose Orientation Auto and under Options (bottom half)
click-select-tick everything except Ignore DSC.

That should do the trick...

Costas

Miruna Petrescu-Prahova wrote:

 Hi

 

 I am trying to save some plots in a postscript file. When I generate
the 

 plots in the main window, they appear correctly - their orientation is


 landscape (i.e., horizontal). However, when I open the .ps file with
GSview, 

 the whole page appears vertically, and the plot appears horizontally,
which 

 means that the plot is only partially visible (example here 

 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
https://webfiles.uci.edu/mpetresc/postscript.files/default.ps  ). I
searched 

 the R-help mailing list archive and found 2 suggestions: setting the
width 

 and height and setting horizontal = FALSE. I have tried setting the
width 

 and height but it makes no difference. I have also tried using
horizontal = 

 FALSE. This rotates and elongates the plot, but it is still displayed


 horizontally on a vertical page, and so only partially visible
(example 

 here https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps ). I


 am not sure what is wrong. Plots are created with filled.contour.

 

I guess this is a misconfiguration of your GSview. The plots are fine 

for me. Anyway, you might also want to set the argument

paper=special in the postscript() call.

Uwe Ligges

 

 Thanks

 Miruna

 

 

 

 Miruna Petrescu-Prahova

 Department of Sociology

 University of California, Irvine

 [EMAIL PROTECTED]

 

 __

 R-help@stat.math.ethz.ch mailing list

 https://stat.ethz.ch/mailman/listinfo/r-help
https://stat.ethz.ch/mailman/listinfo/r-help 

 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
http://www.r-project.org/posting-guide.html 

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

 
---
Costas Vorlow
Research Economist
Eurobank EFG
Division of Research  Forecasting

---
tel: +30-210-3337273 (ext 17273)
fax: +30-210-3337687




P Think before you print.

Disclaimer:
This e-mail is confidential. If you are not the intended recipient, you should 
not copy it, re-transmit it, use it or disclose its contents, but should return 
it to the sender immediately and delete the copy from your system.
EFG Eurobank Ergasias S.A. is not responsible for, nor endorses, any opinion, 
recommendation, conclusion, solicitation, offer or agreement or any information 
contained in this communication.
EFG Eurobank Ergasias S.A. cannot accept any responsibility for the accuracy or 
completeness of this message as it has been transmitted over a public network. 
If you suspect that the message may have been intercepted or amended, please 
call the sender.


[[alternative HTML version deleted]]

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


Re: [R] problem with reading data files with different numbers oflines to skip

2007-08-03 Thread john seers \(IFR\)

Hi Tom

It looks as if you are reading in genepix files. I believe the format for the 
start lines includes a second line to say how many lines to skip. Something 
like this, specifying 27 lines to skip:

ATF 1
27  43
Type=GenePix Results 1.4
DateTime=2003/11/14 17:18:30

If so here is a function I use to do what you want to do. If your files have a 
different format then you need to modify how you set the number of lines to 
skip.



# Preprocess the genepix files - strip off first header lines
dopix-function(genepixfiles, workingdir) {
pre-Pre
# Read in each genepix file, strip unwanted rows and write out again
for (pixfile in genepixfiles) {
pixfileout-paste(workingdir, pre, basename(pixfile), sep=)
secondline-read.table(pixfile, skip=1, nrows=1)
skiplines-as.numeric(secondline[1]) + 2
outdf-read.table(pixfile, header=T, skip=skiplines, sep=\t)
write.table(outdf, file=pixfileout, sep=\t, row.names=FALSE)
}
}


Regards

John Seers


 -Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Cohen
Sent: 03 August 2007 13:04
To: r-help@stat.math.ethz.ch
Subject: Re: [R] problem with reading data files with different numbers oflines 
to skip

Thanks to Ted and Gabor for your response. 
  I apology for not being clear with my previous description of the problem. I 
tried with  your suggestions using readLines but couldn't make it work. I now 
explain the problem in more details and hope that you can help me out.
   
   I have 30 data files, where some of them have 33 lines and the rests have 31 
lines that I want to skip (examples below with bold text). That is, I only want 
to keep the lines start from 
  Block  Column  Row  Name  ID
   
  I read in the data files with a loop like below, the problem is how do I tell 
the loop to skip 31 lines in some data files and 33 in the rests ?
   
   for (i in 1:num.files) {
 a-read.table(file=data[i], 
 ,header=T,skip=31,sep='\t',na.strings=NA)  }
   
  Thanks for your help,
  Tom
   
  # 33 lines to skip
   
Type=GenePix Results 3  DateTime=2006/10/20 
13:35:11Settings=  
GalFile=G:\Avdelningar\viv\translational 
immunologi\Peptide-arrays\Gal-files\742-human-pep2.galPixelSize=10  
  Wavelengths=635
ImageFiles=M:\Peptidearrays\061020\742-2.tif 1  
NormalizationMethod=None  NormalizationFactors=1
  JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
pep,742\742-2.s1.jpgStdDev=Type 1
RatioFormulations=W1/W2 (635/)FeatureType=Circular  
Barcode=  BackgroundSubtraction=LocalFeature
ImageOrigin=560, 1360  JpegOrigin=1940, 3670
  Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B [84948]   
 FocusPosition=0Temperature=30.2
LinesAveraged=1  
  Comment=PMTGain=600
ScanPower=100LaserPower=3.36
Filters=EmptyScanRegion=56,136,2123,6532  
Supplier=Genetix Ltd.  ArrayerSoftwareName=MicroArraying
ArrayerSoftwareVersion=QSoft XP Build 6450 (Revision 131)
Block  Column  Row  Name  ID  X  Y  Dia.  F635 Median  F635 Mean1  1  1  
IgG-human  none  2390  4140  200  301  3171  2  1  PGDR_HUMAN (P09619)  
AHASDEIYEIMQK  2630  4140  200  254  2501  3  1  ML1X_HUMAN (Q13585)  
AIAHPVSDDSDLP  2860  4140  200  268  252   
  1000 more rows
   
   
   
  # 31 lines to skip
   
  ATF  1.029  41
Type=GenePix Results 3  DateTime=2006/10/20 13:05:20
Settings=  GalFile=G:\Avdelningar\viv\translational 
immunologi\Peptide-arrays\Gal-files\742-s2.gal  PixelSize=10
Wavelengths=635
ImageFiles=M:\Peptidearrays\061020\742-4.tif 1  
NormalizationMethod=None  NormalizationFactors=1
  JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
pep,742\742-4.s2.jpgStdDev=Type 1
RatioFormulations=W1/W2 (635/)FeatureType=Circular  
Barcode=  BackgroundSubtraction=LocalFeature
ImageOrigin=560, 1360  JpegOrigin=1950, 24310   
   Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B [84948]  
  FocusPosition=0   
 Temperature=28.49LinesAveraged=1
Comment=PMTGain=600ScanPower=100
LaserPower=3.32  

Re: [R] Problem with making dll under Windows

2007-08-03 Thread Uwe Ligges
Please check that you have installed a suitable environment (tools, 
compiler etc.) as mentioned in the R Installation and Administration 
manual. Öooks like your version of Perl is corrupted.

I got with your C program:

d:\aaaR CMD SHLIB dmypow.c
making dmypow.d from dmypow.c
gcc   -It:/R/include  -Wall -O3 -std=gnu99   -c dmypow.c -o dmypow.o
windres -I t:/R/include  -i dmypow_res.rc -o dmypow_res.o
gcc  -shared -s  -o dmypow.dll dmypow.def dmypow.o dmypow_res.o 
-Lt:/R/bin-lR


Uwe Ligges



Albrecht, Dr. Stefan (APEP) wrote:
 Dear all,
  
 I have problems to compile a DLL for Windows XP with R version 2.5.1 
 (2007-06-27).
 See output below:
  
 C:\AZ_DATEN\C, C++\BE_speedupR CMD SHLIB dmypow.c
 Goto undefined subroutine DynaLoader::bootstrap_inherit at 
 C:\Programme\R\R-2.5
 .1\share\perl/XSLoader.pm line 80.
 Compilation failed in require at c:/Programme/Perl/lib/IO/Handle.pm line 262.
 BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/Handle.pm line 
 262
 .
 Compilation failed in require at c:/Programme/Perl/lib/IO/Seekable.pm line 
 101.
 BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/Seekable.pm 
 line 1
 01.
 Compilation failed in require at c:/Programme/Perl/lib/IO/File.pm line 133.
 BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/File.pm line 
 133.
 Compilation failed in require at 
 C:\Programme\R\R-2.5.1\share\perl/FileHandle.pm
  line 6.
 Compilation failed in require at C:\Programme\R\R-2.5.1\share\perl/R/Utils.pm 
 li
 ne 6.
 BEGIN failed--compilation aborted at 
 C:\Programme\R\R-2.5.1\share\perl/R/Utils.p
 m line 6.
 Compilation failed in require at C:\Programme\R\R-2.5.1/bin/SHLIB line 24.
 BEGIN failed--compilation aborted at C:\Programme\R\R-2.5.1/bin/SHLIB line 24.
  
 The file DynaLoader.pm is in the same directory as, e.g. XSLoader.pm
  
 The c-file itself is very simple:
 #include Rinternals.h
 #include math.h
  
 SEXP mypow(SEXP lifeFund, SEXP bow)
 {
  int i;
  double n;
  
  n = length(lifeFund);
  for (i=0; in; i++)
   REAL(lifeFund)[i] = pow((i+1)/n,REAL(bow)[0]);
  return(lifeFund);
 }
 
 Could anybody help, please?
  
 With many thanks and best regards,
 Stefan
  
 
 Dr. Stefan Albrecht, CFA
 Allianz Private Equity Partners GmbH
 Königinstr. 19 | 80539 Munich | Germany
 
 Phone: +49.(0)89.3800.18317
 Fax: +49.(0)89.3800.818317
 EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 Web: www.apep.com http://www.apep.com/ 
 
 
 Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
 Ralf Jung
 Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
 Ust-ID-Nr.: DE 813 264 786
 
 
 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] How to properly finalize external pointers?

2007-08-03 Thread Jens Oehlschlägel
Dear R .Call() insiders,

Can someone enlighten me how to properly finalize external pointers in C code 
(R-2.5.1 win)? What is the relation between R_ClearExternalPtr and the 
finalizer set in R_RegisterCFinalizer?

I succeeded registering a finalizer that works when an R object containing an 
external pointer is garbage collected. However, I have some difficulties 
figuring out how to do that in an explicit closing function. 

I observed that 
- calling R_ClearExternalPtr does not trigger the finalizer and is dangerous 
because it removes the pointer before the finalizer needs it at 
garbage-collection-time (no finalization = memory leak)
- calling the finalizer directly ensures finalization but now the finalizer is 
called twice (once again at garbage collection time, and I did not find 
documentation how to unregister the finalizer)
- It works to delete the SEXP external pointer object but only if not calling 
R_ClearExternalPtr (but why then do we need it?) Furthermore it is unfortunate 
to delay freeing the external pointers memory if I know during runtime that it 
can be done immediately.

Shouldn't R_ClearExternalPtr call the finalizer and then unregister it? (this 
would also work when removing the SEXP external pointer object is difficult 
because it was handed over to the closing function directly as a parameter)

Best regards


Jens Oehlschlägel


// C-code

static void rindex_finalize(SEXP extPtr){
  pINT ptr = R_ExternalPtrAddr(extPtr);
  if(ptr){
Free(ptr);
Rprintf(finalized\n);
  }else{
Rprintf(nothing to finalize\n);
  }
  return;
}


SEXP rindex_open(
  SEXP Sn
){
  int i,n = INTEGER(Sn)[0];
  pINT ptr = Calloc(sizeof(INT)*n, INT);
  SEXP extPtr, ret;
  for (i=0;in;i++){
ptr[i] = i;
  }
  extPtr = R_MakeExternalPtr(ptr, install(Rindex_extPtr), R_NilValue);
  R_RegisterCFinalizer(extPtr, rindex_finalize);

  PROTECT(ret = allocVector(VECSXP, 1));
  SET_VECTOR_ELT(ret,0,extPtr);
  UNPROTECT(1);
  return ret;
}

SEXP rindex_close(
  SEXP obj
){
  int i, n= 10;
  SEXP ret, extPtr=VECTOR_ELT(obj, 0);
  pINT p, ptr = R_ExternalPtrAddr(extPtr);

  PROTECT(ret = allocVector(INTSXP, n));
  p = INTEGER(ret);
  for (i=0;in;i++){
Rprintf(ptri=%d\n,ptr[i]);
p[i] = ptr[i];
  }

  /* this does finalize immediately but at next garbage collection again
  rindex_finalize(extPtr);
  */

  /* this must not called otherwise the pointer is gone at garbage collection 
time
  R_ClearExternalPtr(extPtr);
  */

  /* this triggers the finalizer but only at next garbage collection */
  SET_VECTOR_ELT(obj,0,R_NilValue);

  UNPROTECT(1);
  return ret;
}


# R-Code
initRindex - function(){
  dyn.load(file.path(.libPaths(), rindex, libs, paste(rindex, 
.Platform$dynlib.ext, sep = )))
}

doneRindex - function(){
  dyn.unload(file.path(.libPaths(), rindex, libs, paste(rindex, 
.Platform$dynlib.ext, sep = )))
}


openRindex - function(n=10){
  .Call(rindex_open, as.integer(n))
}

closeRindex - function(extPtr){
  .Call(rindex_close, extPtr)
}

if (FALSE){
  # now try it
  require(rindex)

  initRindex()

  extPtr - openRindex()
  extPtr
  extPtr2 - closeRindex(extPtr)
  extPtr2
  gc()

  extPtr - openRindex()
  extPtr2 - extPtr
  extPtr2
  rm(extPtr)
  gc()
  extPtr2
  rm(extPtr2)
  gc()
  extPtr2

  doneRindex()
}


 version
   _   
platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  5.1 
year   2007
month  06  
day27  
svn rev42083   
language   R   
version.string R version 2.5.1 (2007-06-27)



-- 
Pt! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

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


[R] Problem with making dll under Windows

2007-08-03 Thread Albrecht, Dr. Stefan (APEP)
Dear all,
 
I have problems to compile a DLL for Windows XP with R version 2.5.1 
(2007-06-27).
See output below:
 
C:\AZ_DATEN\C, C++\BE_speedupR CMD SHLIB dmypow.c
Goto undefined subroutine DynaLoader::bootstrap_inherit at C:\Programme\R\R-2.5
.1\share\perl/XSLoader.pm line 80.
Compilation failed in require at c:/Programme/Perl/lib/IO/Handle.pm line 262.
BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/Handle.pm line 262
.
Compilation failed in require at c:/Programme/Perl/lib/IO/Seekable.pm line 101.
BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/Seekable.pm line 1
01.
Compilation failed in require at c:/Programme/Perl/lib/IO/File.pm line 133.
BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/File.pm line 133.
Compilation failed in require at C:\Programme\R\R-2.5.1\share\perl/FileHandle.pm
 line 6.
Compilation failed in require at C:\Programme\R\R-2.5.1\share\perl/R/Utils.pm li
ne 6.
BEGIN failed--compilation aborted at C:\Programme\R\R-2.5.1\share\perl/R/Utils.p
m line 6.
Compilation failed in require at C:\Programme\R\R-2.5.1/bin/SHLIB line 24.
BEGIN failed--compilation aborted at C:\Programme\R\R-2.5.1/bin/SHLIB line 24.
 
The file DynaLoader.pm is in the same directory as, e.g. XSLoader.pm
 
The c-file itself is very simple:
#include Rinternals.h
#include math.h
 
SEXP mypow(SEXP lifeFund, SEXP bow)
{
 int i;
 double n;
 
 n = length(lifeFund);
 for (i=0; in; i++)
  REAL(lifeFund)[i] = pow((i+1)/n,REAL(bow)[0]);
 return(lifeFund);
}

Could anybody help, please?
 
With many thanks and best regards,
Stefan
 

Dr. Stefan Albrecht, CFA
Allianz Private Equity Partners GmbH
Königinstr. 19 | 80539 Munich | Germany

Phone: +49.(0)89.3800.18317
Fax: +49.(0)89.3800.818317
EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
Web: www.apep.com http://www.apep.com/ 


Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
Ralf Jung
Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
Ust-ID-Nr.: DE 813 264 786



[[alternative HTML version deleted]]

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


Re: [R] problem with reading data files with different numbers of lines to skip

2007-08-03 Thread Tom Cohen
Thanks to Ted and Gabor for your response. 
  I apology for not being clear with my previous description of the problem. I 
tried with  your suggestions using readLines but couldn't make it work. I now 
explain the problem in more details and hope that you can help me out.
   
   I have 30 data files, where some of them have 33 lines and the rests have 31 
lines that I want to skip (examples below with bold text). That is, I only want 
to keep the lines start from 
  Block  Column  Row  Name  ID
   
  I read in the data files with a loop like below, the problem is how do I tell 
the loop to skip 31 lines in some data files and 33 in the rests ?
   
   for (i in 1:num.files) {
 a-read.table(file=data[i], ,header=T,skip=31,sep='\t',na.strings=NA)  }
   
  Thanks for your help,
  Tom
   
  # 33 lines to skip
   
Type=GenePix Results 3  DateTime=2006/10/20 
13:35:11Settings=  
GalFile=G:\Avdelningar\viv\translational 
immunologi\Peptide-arrays\Gal-files\742-human-pep2.galPixelSize=10  
  Wavelengths=635
ImageFiles=M:\Peptidearrays\061020\742-2.tif 1  
NormalizationMethod=None  NormalizationFactors=1
  JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
pep,742\742-2.s1.jpgStdDev=Type 1
RatioFormulations=W1/W2 (635/)FeatureType=Circular  
Barcode=  BackgroundSubtraction=LocalFeature
ImageOrigin=560, 1360  JpegOrigin=1940, 3670
  Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B [84948]   
 FocusPosition=0Temperature=30.2
LinesAveraged=1  
  Comment=PMTGain=600
ScanPower=100LaserPower=3.36
Filters=EmptyScanRegion=56,136,2123,6532  
Supplier=Genetix Ltd.  ArrayerSoftwareName=MicroArraying
ArrayerSoftwareVersion=QSoft XP Build 6450 (Revision 131)
Block  Column  Row  Name  ID  X  Y  Dia.  F635 Median  F635 Mean1  1  1  
IgG-human  none  2390  4140  200  301  3171  2  1  PGDR_HUMAN (P09619)  
AHASDEIYEIMQK  2630  4140  200  254  2501  3  1  ML1X_HUMAN (Q13585)  
AIAHPVSDDSDLP  2860  4140  200  268  252   
  1000 more rows
   
   
   
  # 31 lines to skip
   
  ATF  1.029  41
Type=GenePix Results 3  DateTime=2006/10/20 13:05:20
Settings=  GalFile=G:\Avdelningar\viv\translational 
immunologi\Peptide-arrays\Gal-files\742-s2.gal  PixelSize=10
Wavelengths=635
ImageFiles=M:\Peptidearrays\061020\742-4.tif 1  
NormalizationMethod=None  NormalizationFactors=1
  JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
pep,742\742-4.s2.jpgStdDev=Type 1
RatioFormulations=W1/W2 (635/)FeatureType=Circular  
Barcode=  BackgroundSubtraction=LocalFeature
ImageOrigin=560, 1360  JpegOrigin=1950, 24310   
   Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B [84948]  
  FocusPosition=0   
 Temperature=28.49LinesAveraged=1
Comment=PMTGain=600ScanPower=100
LaserPower=3.32Filters=Empty  
  ScanRegion=56,136,2113,6532  Supplier=  
Block  Column  Row  Name  ID  X  Y  Dia.  F635 Median  F635 Mean1  1  1  
IgG-human  none  2370  24780  200  133  1751  2  1  PGDR_HUMAN (P09619)  
AHASDEIYEIMQK  2600  24780  200  120  1211  3  1  ML1X_HUMAN (Q13585)  
AIAHPVSDDSDLP  2840  24780  200  120  118
  1000 more rows
   
  
[EMAIL PROTECTED] skrev:
  On 02-Aug-07 21:14:20, Tom Cohen wrote:
 Dear List, 
 
 I have 30 data files with different numbers of lines (31 and 33) that
 I want to skip before reading the files. If I use the skip option I can
 only choose either to skip 31 or 33 lines. The data files with 31 lines
 have no blank rows between the lines and the header row. How can I read
 the files without manually checking which files have 31 respectively 33
 lines ? The only text line I want to keep is the header.
 
 Thamks for your help,
 Tom
 
 
 for (i in 1:num.files) {
 a-read.table(file=data[i],
 ,header=T,skip=31,sep='\t',na.strings=NA) 
 
 }

Apologies, I misunderstood your description in my previous response
(I thought that the total number of lines in one of your files was
either 31 or 33, and you wanted to know which was which).

I now 

Re: [R] [R-SIG-Finance] question on analyzing of correlation structure

2007-08-03 Thread Leeds, Mark \(IED\)
I don't understand your question but there is a package called VARs
that may be helpful to you.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of liu lu
Sent: Friday, August 03, 2007 8:39 AM
To: [EMAIL PROTECTED]
Subject: [R-SIG-Finance] question on analyzing of correlation structure

I am currently working on an empirical analysis of the respective A and
B series in the three markets: X, Y, and Z.  Suppose the correlation of
the A  B series in market X shows a different pattern for the
significant short-run adjustment as the impulse reponse fuctions
indicate (Haan, Wouter J. den. 2000. The comovement between output and
prices. Journal of Monetary Economics 46:3-30.). 

 

Could somebody share some ideas about any package can do the following:
(1) to work out the factors contributing the disparity; (2) to contrast
and highlight the difference.

 

Many thanks to your kind attention.

 

Wei-han Liu

 


[[alternative HTML version deleted]]

___
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. 
-- If you want to post, subscribe first.


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

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


Re: [R] Simple table with frequency variable

2007-08-03 Thread Johan Lindbäck
Ok, then tapply() might be your friend:

set.seed(1)
b - rbinom(10,6,0.3)
c - rbinom(10,6,0.9)
w - trunc(runif(10)*3)
b;c;w

table(b, c)
tapply(w, list(b, c), sum)

Is this what you were looking for?
/Johan



G. Draisma skrev:
 Thanks Johan,
 
 I realize that I did not use the right example.
 I have a table with two factors, say b and c,
 and a third case weight variable, say w.
 Then I would like the table command to sum the weights w
 for each combination of i and j.
 For instance, with
   b - rbinom(10,6,0.3)
   c - rbinom(10,6,0.9)
   w - trunc(runif(10)*3)
 the command
   table(i,j)
 counts the occurrences of combinations (b,c).
 I am looking for a command like
   table(i,j,weight=w)
 that would print the sum of the w's for each combination.
 e.g. if the combination (2,5) occurs twice
 I would like to see the sum of the two weights
 in the table, instead of the count 2.
 
 Gerrit.
 
 
 
 
 on 02-Aug-2007 11:03 Johan Lindbäck said the following:
 Would it be ok with a matrix?

 i - 1:5; j - 1:2

 li - length(i)
 lj - length(j)
 A - matrix(numeric(li * lj), nrow = li, dimnames = list(i, j))
 for (r in 1:li)
   for (s in 1:lj)
 A[r, s] - 10*r + s
 A

 HTH
 /Johan



 G. Draisma skrev:
 Thank you Jim,
 Sorry, that I was not clear enough.
 Each case has a frequency variable N.
 so when tabulating combinations (i,j) they
 should be weighted with weight N.

 In this case I would like a command
 table(i,j,N)
 resulting in
  j
   i   1  2
 1 11 12
 2 21 22
 ...
 5 51 52

 And I was looking for a table command
 that allows for a case weight variable.
 Gerrit.


 on 01-Aug-2007 22:38 jim holtman said the following:
 I am not exactly sure what you are asking for.  I am assuming that you
 want a vector that represent the combinations that are given
 combinations that are present:

 N
  [1] 11 22 31 42 51 12 21 32 41 52
 table(i,j)
j
 i   1 2
   1 1 1
   2 1 1
   3 1 1
   4 1 1
   5 1 1
 z - table(i,j)
 which(z==1)
  [1]  1  2  3  4  5  6  7  8  9 10
 which(z==1,arr.ind=T)
   row col
 1   1   1
 2   2   1
 3   3   1
 4   4   1
 5   5   1
 1   1   2
 2   2   2
 3   3   2
 4   4   2
 5   5   2
 x - which(z==1,arr.ind=T)
 paste(rownames(z)[x[,'row']], colnames(z)[x[,'col']], sep='')
  [1] 11 21 31 41 51 12 22 32 42 52


 On 8/1/07, G. Draisma [EMAIL PROTECTED] wrote:
 Hallo,

 Im trying to find out how to tabulate frequencies
 of factors when the data have a frequency variable.

 e,g:
 i-rep(1:5,2)
 j-rep(1:2,5)
 N-10*i+j

 table(i,j) gives a table of ones
 as each combination occurs only once.
 How does one get a table with the corresponding N's?

 Thanks!
 Gerrit.


 -- 
 Gerrit Draisma
 Department of Public Health
 Erasmus MC, University Medical Center Rotterdam
 Room AE-103
 P.O. Box 2040 3000 CA  Rotterdam The Netherlands
 Phone: +31 10 4087124 Fax: +31 10 4638474
 http://mgzlx4.erasmusmc.nl/pwp/?gdraisma

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


 

-- 
  O|  Johan Lindbäck,  Biostatistician
 /\|   Uppsala Clinical Research Center
 | \_. SE-751 85  UPPSALA
~~ http://www.ucr.uu.se --

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


Re: [R] How to properly finalize external pointers?

2007-08-03 Thread Duncan Murdoch
On 8/3/2007 9:19 AM, Jens Oehlschlägel wrote:
 Dear R .Call() insiders,
 
 Can someone enlighten me how to properly finalize external pointers in C code 
 (R-2.5.1 win)? What is the relation between R_ClearExternalPtr and the 
 finalizer set in R_RegisterCFinalizer?
 
 I succeeded registering a finalizer that works when an R object containing an 
 external pointer is garbage collected. However, I have some difficulties 
 figuring out how to do that in an explicit closing function. 
 
 I observed that 
 - calling R_ClearExternalPtr does not trigger the finalizer and is dangerous 
 because it removes the pointer before the finalizer needs it at 
 garbage-collection-time (no finalization = memory leak)
 - calling the finalizer directly ensures finalization but now the finalizer 
 is called twice (once again at garbage collection time, and I did not find 
 documentation how to unregister the finalizer)
 - It works to delete the SEXP external pointer object but only if not calling 
 R_ClearExternalPtr (but why then do we need it?) Furthermore it is 
 unfortunate to delay freeing the external pointers memory if I know during 
 runtime that it can be done immediately.
 
 Shouldn't R_ClearExternalPtr call the finalizer and then unregister it? (this 
 would also work when removing the SEXP external pointer object is difficult 
 because it was handed over to the closing function directly as a parameter)

I think we want R_ClearExternalPtr to work even if the finalizer would 
fail (e.g. to clean up when there was an error when trying to build the 
external object).

So I'd suggest that when you want to get rid of an external object 
immediately, you call the finalizer explicitly, then call 
R_ClearExternalPtr.  The documentation doesn't address the question of 
whether this will clear the registered finalizer so I don't know if 
you'll get a second call to the finalizer during garbage collection, but 
even if you do, isn't it easy enough to do nothing when you see the null 
ptr, as you do below?

By the way, questions about programming at this level are better asked 
in the R-devel group.

Duncan Murdoch

 Best regards
 
 
 Jens Oehlschlägel
 
 
 // C-code
 
 static void rindex_finalize(SEXP extPtr){
   pINT ptr = R_ExternalPtrAddr(extPtr);
   if(ptr){
 Free(ptr);
 Rprintf(finalized\n);
   }else{
 Rprintf(nothing to finalize\n);
   }
   return;
 }
 
 
 SEXP rindex_open(
   SEXP Sn
 ){
   int i,n = INTEGER(Sn)[0];
   pINT ptr = Calloc(sizeof(INT)*n, INT);
   SEXP extPtr, ret;
   for (i=0;in;i++){
 ptr[i] = i;
   }
   extPtr = R_MakeExternalPtr(ptr, install(Rindex_extPtr), R_NilValue);
   R_RegisterCFinalizer(extPtr, rindex_finalize);
 
   PROTECT(ret = allocVector(VECSXP, 1));
   SET_VECTOR_ELT(ret,0,extPtr);
   UNPROTECT(1);
   return ret;
 }
 
 SEXP rindex_close(
   SEXP obj
 ){
   int i, n= 10;
   SEXP ret, extPtr=VECTOR_ELT(obj, 0);
   pINT p, ptr = R_ExternalPtrAddr(extPtr);
 
   PROTECT(ret = allocVector(INTSXP, n));
   p = INTEGER(ret);
   for (i=0;in;i++){
 Rprintf(ptri=%d\n,ptr[i]);
 p[i] = ptr[i];
   }
 
   /* this does finalize immediately but at next garbage collection again
   rindex_finalize(extPtr);
   */
 
   /* this must not called otherwise the pointer is gone at garbage collection 
 time
   R_ClearExternalPtr(extPtr);
   */
 
   /* this triggers the finalizer but only at next garbage collection */
   SET_VECTOR_ELT(obj,0,R_NilValue);
 
   UNPROTECT(1);
   return ret;
 }
 
 
 # R-Code
 initRindex - function(){
   dyn.load(file.path(.libPaths(), rindex, libs, paste(rindex, 
 .Platform$dynlib.ext, sep = )))
 }
 
 doneRindex - function(){
   dyn.unload(file.path(.libPaths(), rindex, libs, paste(rindex, 
 .Platform$dynlib.ext, sep = )))
 }
 
 
 openRindex - function(n=10){
   .Call(rindex_open, as.integer(n))
 }
 
 closeRindex - function(extPtr){
   .Call(rindex_close, extPtr)
 }
 
 if (FALSE){
   # now try it
   require(rindex)
 
   initRindex()
 
   extPtr - openRindex()
   extPtr
   extPtr2 - closeRindex(extPtr)
   extPtr2
   gc()
 
   extPtr - openRindex()
   extPtr2 - extPtr
   extPtr2
   rm(extPtr)
   gc()
   extPtr2
   rm(extPtr2)
   gc()
   extPtr2
 
   doneRindex()
 }
 
 
 version
_   
 platform   i386-pc-mingw32 
 arch   i386
 os mingw32 
 system i386, mingw32   
 status 
 major  2   
 minor  5.1 
 year   2007
 month  06  
 day27  
 svn rev42083   
 language   R   
 version.string R version 2.5.1 (2007-06-27)
 
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Streamlining Prcomp Data

2007-08-03 Thread Bjørn-Helge Mevik
Try this

result - summary(prcomp(USArrests))
names(result)
M - result$importance
M[2,]

The labels are the dimnames of the importance matrix.  They only
show up when the matrix is printed.  If you wish, you can remove
them with dimnames(M) - NULL.

-- 
Bjørn-Helge Mevik

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


Re: [R] plot to postscript orientation

2007-08-03 Thread Prof Brian Ripley
Do you have the Orientation menu set to 'Auto'?
The effect described seems that if 'Rotate media' is selected, which it 
should not be.

The files look fine to me in GSView 4.8 on Windows and other viewers on 
Linux.  I agree with Uwe that it is a viewer issue (most reported 
postscript/PDF are).

On Fri, 3 Aug 2007, John Kane wrote:


 I seem to see the same problem that Miruna gets just
 to confirm that it is not just her set-up.

 I'm using GSview4.8 if that helps

 --- Uwe Ligges [EMAIL PROTECTED]
 wrote:




 Miruna Petrescu-Prahova wrote:
  Hi

  I am trying to save some plots in a postscript
 file. When I generate the
 plots in the main window, they appear correctly -
 their orientation is
 landscape (i.e., horizontal). However, when I open
 the .ps file with GSview,
 the whole page appears vertically, and the plot
 appears horizontally, which
 means that the plot is only partially visible
 (example here


 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
 ). I searched
 the R-help mailing list archive and found 2
 suggestions: setting the width
 and height and setting horizontal = FALSE. I have
 tried setting the width
 and height but it makes no difference. I have also
 tried using horizontal =
 FALSE. This rotates and elongates the plot, but
 it is still displayed
 horizontally on a vertical page, and so only
 partially  visible (example
 here

 https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps).
 I
 am not sure what is wrong. Plots are created with
 filled.contour.


 I guess this is a misconfiguration of your GSview.
 The plots are fine
 for me. Anyway, you might also want to set the
 argument
 paper=special in the postscript() call.

 Uwe Ligges


  Thanks
  Miruna


 
 Miruna Petrescu-Prahova
 Department of Sociology
 University of California, Irvine
 [EMAIL PROTECTED]

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

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


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


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

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


Re: [R] t-distribution

2007-08-03 Thread Greg Snow
Look at the power.examp and run.power.examp functions in the
TeachingDemos package.  Do these do what you want?  If not you can look
at the code in them to see how to fill part of the area under the curve.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Nair, 
 Murlidharan T
 Sent: Friday, August 03, 2007 8:46 AM
 To: Stephen Tucker; r-help@stat.math.ethz.ch
 Subject: Re: [R] t-distribution
 
 I am trying to shade the critical regions for normal 
 distribution with different means and making overlaps of the 
 plots to explain Type I and Type II errors. I tried the 
 following. If I calculate the z score and as I did below, can 
 I use it to pick regions from the original data? I think I am 
 making mistake by calculating the z scores for d$x, can 
 someone explain the mistake I am making? 
 
 left- -1.96
 right- 1.96
 mu1-rnorm(10,20,5)
 d-(density(mu1))
 x.tmp-d$x
 y.tmp-d$y
 x-x.tmp
 y-y.tmp
 mu1z-(x.tmp-mean(x.tmp))/sd(x.tmp) # is it correct? 
 a-which(mu1z =left)
 b-which(mu1z =right)
 plot(x.tmp,y.tmp, type=l)
 polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
 y.tmp[a]))
 ),col=gray90)
 polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
 y.tmp[b]))
 ),col=gray90)
 
 -Original Message-
 From: Stephen Tucker [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 02, 2007 3:11 PM
 To: Nair, Murlidharan T; r-help@stat.math.ethz.ch
 Subject: RE: [R] t-distribution
 
 yes, or
 
 p - seq(0.001,0.999,,1000)
 x - qt(p,df=9)
 y - dt(x,df=9)
 plot(x,y,type=l)
 
 f - function(x,y,...) {
   polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
 }
 with(data.frame(x,y)[x = 2.3,],f(x,y,col=gray90)) 
 with(data.frame(x,y)[x = -2.3,],f(x,y,col=gray90))
 
 
 --- Nair, Murlidharan T [EMAIL PROTECTED] wrote:
 
  
  I tried doing it this way. 
  
  left--2.3
  right-2.3
  p - seq(0.001,0.999,,1000)
  x - qt(p,df=9)
  y - dt(x,df=9)
  plot(x,y,type=l)
  x.tmp-x
  y.tmp-y
  a-which(x=left)
 
 polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
 y.tmp[a]))
 ),col=gray90)
  b-which(x=right)
 
 polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
 y.tmp[b]))
 ),col=gray90)
  
  Please let me know if I have made any mistakes. 
  Thanks ../Murli
  
  
  
  -Original Message-
  From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
  Sent: Thu 8/2/2007 10:25 AM
  To: Nair, Murlidharan T; Stephen Tucker; r-help@stat.math.ethz.ch
  Subject: Re: [R] t-distribution
   
  I believe you are looking for the functionality I have in the 
  norm.curve function in the HH package.
  
  Download and install HH from CRAN and then look at
  
  example(norm.curve)
  
  
 
 
 

 __
 __
 Ready for the edge of your seat? 
 Check out tonight's top picks on Yahoo! TV. 
 http://tv.yahoo.com/
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Re : change the names of all listed objects

2007-08-03 Thread Duncan Murdoch
On 8/3/2007 11:28 AM, justin bem wrote:
 It not too simple what ls return the variable that have been create in your 
 environment even if you change their names, ls will not return a1 b1 ...
 
 The names attribute in OOP of an object is just an attribute and it is 
 different with an instance of the object. ls() show instance
 
 But you can try this :
 
 a-10
 ls()
 [1] a
 
 assign(paste(deparse(substitute(a)),1,sep=),a)  # here I 
 create a new instance with name   
   # a1 and the same value than a
 rm(a) 
# In destroy the original.

The use of deparse(substitute(a)) suggests you want to do this in a 
function, but then your rm() will only remove the local copy.  Writing a 
gemeral purpose function for this is tricky, because it's not obvious 
what should happen in certain weird cases.  For example:

rename( c, collect )

to rename the c() function to collect():  should it really try to go 
into the base environment and delete the c object?  That would be fairly 
disastrous if it succeeded.  But if it found a c() function in the 
global environment, removing it from there might be sensible (maybe even 
if this rename request were executed from a function, rather than at the 
top level).

Duncan Murdoch

 
ls()
 [1] a1
 
 
  
 Justin BEM
 BP 1917 Yaoundé
 Tél (237) 99597295
 (237) 22040246
 
 - Message d'origine 
 De : Luca Laghi [EMAIL PROTECTED]
 À : r-help@stat.math.ethz.ch
 Envoyé le : Vendredi, 3 Août 2007, 15h23mn 01s
 Objet : [R] change the names of all listed objects
 
 Dear list members,
 I have created seven objects, from a to g, so that ls() gives me
 [1] a b c d e f g
 
 how can I automatically change their names in
 
 a1 b1 c1 d1 e1 f1 g1
 
 It seems simple, ut it is driving me mad.
 Thank you very much for your help.
 Luca Laghi
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 
 
 
   
 _ 
 
 l 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Background color of symbols in xyplot

2007-08-03 Thread Sébastien
Dear R-users,

I am using plot symbols given by pch=21:25 in a xyplot. The background 
color of these symbols can be defined by 'fill' in the panel argument, 
however I have a hard time to find how to define the same background 
color in the key. I tried different options like using the auto.key 
argument and modifying the par.settings, or using normal key argument 
plus 'fill', 'bg' or 'background'... nothing seems to do I want. What 
should I change in the following code to make it work ?

key=list(space=bottom,
 points = list(pch = 21:25,
  col = 32,
  bg=15),
 text=list(mylegend)),


Thank in advance

Sebastien

PS: cheng

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


[R] Saving an expression to a file

2007-08-03 Thread Yuchen Luo
Dear Friends.
I have a very long expression and I use function D to find its derivative,
which will be even longer. I save the resulting expression in a variavle,
say bbb. But when I tried to display bbb on the screen, the R screen is not
long enough for me to view it. Is there a way to save the expression to a
file?

Best Wishes
Yuchen Luo

[[alternative HTML version deleted]]

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


Re: [R] t-distribution

2007-08-03 Thread Nair, Murlidharan T
Thanks, I figured it out after I realized my mistake here is the
corrected one. But I will certainly look at the teaching demos package.

left- -1.96
right- 1.96
mu1-rnorm(10,20,5)
d-(density(mu1))
x.tmp-d$x
y.tmp-d$y
x-x.tmp
y-y.tmp
x.int1-20 + (5*1.96)
x.int2-20 - (5*1.96)
a-which(x =x.int2)
b-which(x =x.int1)
plot(x.tmp,y.tmp, type=l)
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))
),col=gray90)
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))
),col=gray90)

-Original Message-
From: Greg Snow [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 03, 2007 11:01 AM
To: Nair, Murlidharan T; Stephen Tucker; r-help@stat.math.ethz.ch
Subject: RE: [R] t-distribution

Look at the power.examp and run.power.examp functions in the
TeachingDemos package.  Do these do what you want?  If not you can look
at the code in them to see how to fill part of the area under the curve.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Nair, 
 Murlidharan T
 Sent: Friday, August 03, 2007 8:46 AM
 To: Stephen Tucker; r-help@stat.math.ethz.ch
 Subject: Re: [R] t-distribution
 
 I am trying to shade the critical regions for normal 
 distribution with different means and making overlaps of the 
 plots to explain Type I and Type II errors. I tried the 
 following. If I calculate the z score and as I did below, can 
 I use it to pick regions from the original data? I think I am 
 making mistake by calculating the z scores for d$x, can 
 someone explain the mistake I am making? 
 
 left- -1.96
 right- 1.96
 mu1-rnorm(10,20,5)
 d-(density(mu1))
 x.tmp-d$x
 y.tmp-d$y
 x-x.tmp
 y-y.tmp
 mu1z-(x.tmp-mean(x.tmp))/sd(x.tmp) # is it correct? 
 a-which(mu1z =left)
 b-which(mu1z =right)
 plot(x.tmp,y.tmp, type=l)
 polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
 y.tmp[a]))
 ),col=gray90)
 polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
 y.tmp[b]))
 ),col=gray90)
 
 -Original Message-
 From: Stephen Tucker [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 02, 2007 3:11 PM
 To: Nair, Murlidharan T; r-help@stat.math.ethz.ch
 Subject: RE: [R] t-distribution
 
 yes, or
 
 p - seq(0.001,0.999,,1000)
 x - qt(p,df=9)
 y - dt(x,df=9)
 plot(x,y,type=l)
 
 f - function(x,y,...) {
   polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
 }
 with(data.frame(x,y)[x = 2.3,],f(x,y,col=gray90)) 
 with(data.frame(x,y)[x = -2.3,],f(x,y,col=gray90))
 
 
 --- Nair, Murlidharan T [EMAIL PROTECTED] wrote:
 
  
  I tried doing it this way. 
  
  left--2.3
  right-2.3
  p - seq(0.001,0.999,,1000)
  x - qt(p,df=9)
  y - dt(x,df=9)
  plot(x,y,type=l)
  x.tmp-x
  y.tmp-y
  a-which(x=left)
 
 polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
 y.tmp[a]))
 ),col=gray90)
  b-which(x=right)
 
 polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
 y.tmp[b]))
 ),col=gray90)
  
  Please let me know if I have made any mistakes. 
  Thanks ../Murli
  
  
  
  -Original Message-
  From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
  Sent: Thu 8/2/2007 10:25 AM
  To: Nair, Murlidharan T; Stephen Tucker; r-help@stat.math.ethz.ch
  Subject: Re: [R] t-distribution
   
  I believe you are looking for the functionality I have in the 
  norm.curve function in the HH package.
  
  Download and install HH from CRAN and then look at
  
  example(norm.curve)
  
  
 
 
 

 __
 __
 Ready for the edge of your seat? 
 Check out tonight's top picks on Yahoo! TV. 
 http://tv.yahoo.com/
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] change the names of all listed objects

2007-08-03 Thread Duncan Murdoch
On 8/3/2007 10:23 AM, Luca Laghi wrote:
 Dear list members,
 I have created seven objects, from a to g, so that ls() gives me
 [1] a b c d e f g
 
 how can I automatically change their names in
 
 a1 b1 c1 d1 e1 f1 g1
 
 It seems simple, ut it is driving me mad.

R doesn't have a rename operation, so you need to copy the objects and 
then delete the original.  For example:

# create a vector of the names of your objects
namelist - letters[1:7]

for (i in seq_along(namelist)) {
   oldname - namelist[i]

   # compute a new name from the old one
   newname - paste(oldname, 1, sep=)

   # create a variable with the new name
   assign(newname, get(oldname))

   # delete the old object
   rm(list=oldname)
}


The code above should work in simple cases where you run it in the 
console and it works on objects in the global workspace.  If you want to 
write a function to do this things get more complicated, because you 
want to make the assignment in the same place the function found the 
original.

There are quicker ways (using mget() and apply()), but they'd really 
just be doing the same as the above in a less clear way.

Duncan Murdoch

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


[R] question about logistic models (AIC)

2007-08-03 Thread Tom Willems
 Dear fellow R-ussers,
I have a question about the Akaike Information Criterion  in the  R 
output.
Normally you would want it to be as small as possible, yet when i check up 
the information in my study books, the AIC is usually displayed as a 
negative number. In the exercises it is given as  - AIC .
R displays it as a positive number, does this mean that a large AIC 
gives a small  - AIC , so the bigger the better?


Kind regards,
Tom.



 
Tom Willems
CODA-CERVA-VAR
Department of Virology
Epizootic Diseases Section
Groeselenberg 99
B-1180 Ukkel

Tel.: +32 2 3790522
Fax: +32 2 3790666
E-mail: [EMAIL PROTECTED]

www.var.fgov.be 




Disclaimer: click here
[[alternative HTML version deleted]]

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


Re: [R] t-distribution

2007-08-03 Thread Nair, Murlidharan T
I am trying to shade the critical regions for normal distribution with
different means and making overlaps of the plots to explain Type I and
Type II errors. I tried the following. If I calculate the z score and as
I did below, can I use it to pick regions from the original data? I
think I am making mistake by calculating the z scores for d$x, can
someone explain the mistake I am making? 

left- -1.96 
right- 1.96
mu1-rnorm(10,20,5)
d-(density(mu1))
x.tmp-d$x
y.tmp-d$y
x-x.tmp
y-y.tmp
mu1z-(x.tmp-mean(x.tmp))/sd(x.tmp) # is it correct? 
a-which(mu1z =left)
b-which(mu1z =right)
plot(x.tmp,y.tmp, type=l)
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))
),col=gray90)
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))
),col=gray90)

-Original Message-
From: Stephen Tucker [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 02, 2007 3:11 PM
To: Nair, Murlidharan T; r-help@stat.math.ethz.ch
Subject: RE: [R] t-distribution

yes, or

p - seq(0.001,0.999,,1000)
x - qt(p,df=9)
y - dt(x,df=9)
plot(x,y,type=l)

f - function(x,y,...) {
  polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
}
with(data.frame(x,y)[x = 2.3,],f(x,y,col=gray90))
with(data.frame(x,y)[x = -2.3,],f(x,y,col=gray90))


--- Nair, Murlidharan T [EMAIL PROTECTED] wrote:

 
 I tried doing it this way. 
 
 left--2.3
 right-2.3
 p - seq(0.001,0.999,,1000)
 x - qt(p,df=9)
 y - dt(x,df=9)
 plot(x,y,type=l)
 x.tmp-x
 y.tmp-y
 a-which(x=left)

polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))
),col=gray90)
 b-which(x=right)

polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))
),col=gray90)
 
 Please let me know if I have made any mistakes. 
 Thanks ../Murli
 
 
 
 -Original Message-
 From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
 Sent: Thu 8/2/2007 10:25 AM
 To: Nair, Murlidharan T; Stephen Tucker; r-help@stat.math.ethz.ch
 Subject: Re: [R] t-distribution
  
 I believe you are looking for the functionality I have
 in the norm.curve function in the HH package.
 
 Download and install HH from CRAN and then look at
 
 example(norm.curve)
 
 



   

Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/

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


Re: [R] Background color of symbols in xyplot

2007-08-03 Thread deepayan . sarkar
On 8/2/07, Sébastien [EMAIL PROTECTED] wrote:
 Dear R-users,

 I am using plot symbols given by pch=21:25 in a xyplot. The background
 color of these symbols can be defined by 'fill' in the panel argument,
 however I have a hard time to find how to define the same background
 color in the key. I tried different options like using the auto.key
 argument and modifying the par.settings, or using normal key argument
 plus 'fill', 'bg' or 'background'... nothing seems to do I want. What
 should I change in the following code to make it work ?

 key=list(space=bottom,
  points = list(pch = 21:25,
   col = 32,
   bg=15),
  text=list(mylegend)),

For starters, upgrade to the latest version of R and lattice.

-Deepayan

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


Re: [R] Saving an expression to a file

2007-08-03 Thread Doran, Harold
Maybe use the sink() function 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Yuchen Luo
 Sent: Thursday, August 02, 2007 10:17 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Saving an expression to a file
 
 Dear Friends.
 I have a very long expression and I use function D to find 
 its derivative, which will be even longer. I save the 
 resulting expression in a variavle, say bbb. But when I tried 
 to display bbb on the screen, the R screen is not long enough 
 for me to view it. Is there a way to save the expression to a file?
 
 Best Wishes
 Yuchen Luo
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] change the names of all listed objects

2007-08-03 Thread Marc Schwartz
On Fri, 2007-08-03 at 16:23 +0200, Luca Laghi wrote:
 Dear list members,
 I have created seven objects, from a to g, so that ls() gives me
 [1] a b c d e f g
 
 how can I automatically change their names in
 
 a1 b1 c1 d1 e1 f1 g1
 
 It seems simple, ut it is driving me mad.
 Thank you very much for your help.
 Luca Laghi

Try this:

 ls()
character(0)


# Create the 7 objects
for (i in seq(7)) assign(letters[i], i)


 ls()
[1] a b c d e f g i


# Just get the objects we want
MyObj - ls(pattern = ^[a-g]$)


 MyObj
[1] a b c d e f g


# Rename to new and delete old
for (i in MyObj)
{ 
  assign(paste(i, 1, sep = ), get(i))  
  rm(list = i)
}


 ls()
[1] a1b1c1d1e1f1g1i
[9] MyObj
 

See ?assign and ?get

You could encapsulate the above in a function, but need to be cautious
relative to environments and the old to new naming schema. 

HTH,

Marc Schwartz

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


Re: [R] Problem with making dll under Windows

2007-08-03 Thread Albrecht, Dr. Stefan (APEP)
Dear all,

Now everything is fine. Thanks a lot for your responses.

After the first attempts did not work, I moved some perl files into the 
C:\Programme\R\R-2.5.1\share\perl
folder. 

However, also this did not help either. 


Finally, after you emails, I (re)installed R, Rtools and Perl (and removed 
cygwin and DevC++ before) and so the R CMD SHLIB is now working.

I am not fully aware, what was exactly going wrong, but I guess the PATH names 
did make some trouble, but this might not have been the only reason.

Best regards,
Stefan Albrecht


Dr. Stefan Albrecht, CFA
Allianz Private Equity Partners GmbH
Königinstr. 19 | 80539 Munich | Germany

Phone: +49.(0)89.3800.18317
Fax: +49.(0)89.3800.818317
EMail: [EMAIL PROTECTED]
Web: www.apep.com


Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
Ralf Jung
Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
Ust-ID-Nr.: DE 813 264 786

-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Gesendet: Friday, August 03, 2007 15:10
An: Albrecht, Dr. Stefan (APEP)
Cc: r-help@stat.math.ethz.ch
Betreff: Re: [R] Problem with making dll under Windows

Please check that you have installed a suitable environment (tools, 
compiler etc.) as mentioned in the R Installation and Administration 
manual. Öooks like your version of Perl is corrupted.

I got with your C program:

d:\aaaR CMD SHLIB dmypow.c
making dmypow.d from dmypow.c
gcc   -It:/R/include  -Wall -O3 -std=gnu99   -c dmypow.c -o dmypow.o
windres -I t:/R/include  -i dmypow_res.rc -o dmypow_res.o
gcc  -shared -s  -o dmypow.dll dmypow.def dmypow.o dmypow_res.o 
-Lt:/R/bin-lR


Uwe Ligges



Albrecht, Dr. Stefan (APEP) wrote:
 Dear all,
  
 I have problems to compile a DLL for Windows XP with R version 2.5.1 
 (2007-06-27).
 See output below:
  
 C:\AZ_DATEN\C, C++\BE_speedupR CMD SHLIB dmypow.c
 Goto undefined subroutine DynaLoader::bootstrap_inherit at 
 C:\Programme\R\R-2.5
 .1\share\perl/XSLoader.pm line 80.
 Compilation failed in require at c:/Programme/Perl/lib/IO/Handle.pm line 262.
 BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/Handle.pm line 
 262
 .
 Compilation failed in require at c:/Programme/Perl/lib/IO/Seekable.pm line 
 101.
 BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/Seekable.pm 
 line 1
 01.
 Compilation failed in require at c:/Programme/Perl/lib/IO/File.pm line 133.
 BEGIN failed--compilation aborted at c:/Programme/Perl/lib/IO/File.pm line 
 133.
 Compilation failed in require at 
 C:\Programme\R\R-2.5.1\share\perl/FileHandle.pm
  line 6.
 Compilation failed in require at C:\Programme\R\R-2.5.1\share\perl/R/Utils.pm 
 li
 ne 6.
 BEGIN failed--compilation aborted at 
 C:\Programme\R\R-2.5.1\share\perl/R/Utils.p
 m line 6.
 Compilation failed in require at C:\Programme\R\R-2.5.1/bin/SHLIB line 24.
 BEGIN failed--compilation aborted at C:\Programme\R\R-2.5.1/bin/SHLIB line 24.
  
 The file DynaLoader.pm is in the same directory as, e.g. XSLoader.pm
  
 The c-file itself is very simple:
 #include Rinternals.h
 #include math.h
  
 SEXP mypow(SEXP lifeFund, SEXP bow)
 {
  int i;
  double n;
  
  n = length(lifeFund);
  for (i=0; in; i++)
   REAL(lifeFund)[i] = pow((i+1)/n,REAL(bow)[0]);
  return(lifeFund);
 }
 
 Could anybody help, please?
  
 With many thanks and best regards,
 Stefan
  
 
 Dr. Stefan Albrecht, CFA
 Allianz Private Equity Partners GmbH
 Königinstr. 19 | 80539 Munich | Germany
 
 Phone: +49.(0)89.3800.18317
 Fax: +49.(0)89.3800.818317
 EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 Web: www.apep.com http://www.apep.com/ 
 
 
 Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
 Ralf Jung
 Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
 Ust-ID-Nr.: DE 813 264 786
 
 
 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Saving an expression to a file

2007-08-03 Thread Gabor Grothendieck
See ?save

Also you might be able to use the Ryacas package to simplify your derivative.
See Simplify in 5.5 of:
http://ryacas.googlecode.com/svn/trunk/inst/doc/Ryacas.pdf

More info at:
http://code.google.com/p/ryacas/

On 8/2/07, Yuchen Luo [EMAIL PROTECTED] wrote:
 Dear Friends.
 I have a very long expression and I use function D to find its derivative,
 which will be even longer. I save the resulting expression in a variavle,
 say bbb. But when I tried to display bbb on the screen, the R screen is not
 long enough for me to view it. Is there a way to save the expression to a
 file?

 Best Wishes
 Yuchen Luo

[[alternative HTML version deleted]]

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


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


Re: [R] question about logistic models (AIC)

2007-08-03 Thread Kyle.
Tom:

That's a good question.  AIC, as i'm sure you know, is usually  
calculated as 2k-2ln(L), where k is the number of free parameters in  
the model, and L is the log-likelihood of the model.  The goal of  
AIC--and the reason one normally tries to select a model with minimal  
AIC--is to minimize what's referred to as the Kullback-Leibler  
distance between the distribution of your data's density from the  
theoretical true theoretical density as defined by the model.  More  
concisely, the AIC is an index of the amount of information regarding  
your data that is lost when your model is used to describe it.  To  
get back to your question, I can't say without a little more  
information why the AIC's your referring to are negative (but perhaps  
it's an issue of using the log-likelihood instead of the negative log- 
likelihood), but my first instinct is that it doesn't matter.  I  
would go with the AIC that is closest to zero.  I hope that helps.


Kyle H. Ambert
Graduate Student, Dept. Behavioral Neuroscience
Oregon Health  Science University
[EMAIL PROTECTED]


On Aug 3, 2007, at 8:41 AM, Tom Willems wrote:

  Dear fellow R-ussers,
 I have a question about the Akaike Information Criterion  in the  R
 output.
 Normally you would want it to be as small as possible, yet when i  
 check up
 the information in my study books, the AIC is usually displayed as a
 negative number. In the exercises it is given as  - AIC .
 R displays it as a positive number, does this mean that a large AIC
 gives a small  - AIC , so the bigger the better?


 Kind regards,
 Tom.




 Tom Willems
 CODA-CERVA-VAR
 Department of Virology
 Epizootic Diseases Section
 Groeselenberg 99
 B-1180 Ukkel

 Tel.: +32 2 3790522
 Fax: +32 2 3790666
 E-mail: [EMAIL PROTECTED]

 www.var.fgov.be




 Disclaimer: click here
   [[alternative HTML version deleted]]

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


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


[R] Functional data analysis

2007-08-03 Thread Maurizio Manuguerra
Hi,

Does anyone know if exist a library or a method to perform functional
logistic regression in R?
I have the FDA package, but I think it makes possible to do at most
functional linear regression with the fRegress routine, not logistic
regression.

Is there such a thing like fGLM from S+FDA library for Splus?


Thanks,
Maurizio

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


Re: [R] plot to postscript orientation

2007-08-03 Thread John Kane

I seem to see the same problem that Miruna gets just
to confirm that it is not just her set-up.  

I'm using GSview4.8 if that helps

--- Uwe Ligges [EMAIL PROTECTED]
wrote:


 
 
 Miruna Petrescu-Prahova wrote:
   Hi
  
   I am trying to save some plots in a postscript
 file. When I generate the 
  plots in the main window, they appear correctly -
 their orientation is 
  landscape (i.e., horizontal). However, when I open
 the .ps file with GSview, 
  the whole page appears vertically, and the plot
 appears horizontally, which 
  means that the plot is only partially visible
 (example here 
 

https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
 ). I searched 
  the R-help mailing list archive and found 2
 suggestions: setting the width 
  and height and setting horizontal = FALSE. I have
 tried setting the width 
  and height but it makes no difference. I have also
 tried using horizontal = 
  FALSE. This rotates and elongates the plot, but
 it is still displayed 
  horizontally on a vertical page, and so only
 partially  visible (example 
  here

https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps).
 I 
  am not sure what is wrong. Plots are created with
 filled.contour.
 
 
 I guess this is a misconfiguration of your GSview.
 The plots are fine 
 for me. Anyway, you might also want to set the
 argument
 paper=special in the postscript() call.
 
 Uwe Ligges
 
 
   Thanks
   Miruna
  
  
  
  Miruna Petrescu-Prahova
  Department of Sociology
  University of California, Irvine
  [EMAIL PROTECTED]
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


Re: [R] two plots super-impose

2007-08-03 Thread Greg Snow
It's not clear exactly what you want, but you may want to look at the
layout function, or the subplot function in the TeachingDemos package.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 [EMAIL PROTECTED]
 Sent: Thursday, August 02, 2007 12:07 PM
 To: R-help@stat.math.ethz.ch
 Subject: [R] two plots super-impose
 
 Dear R users,
 
 I used plot(x,y) to draw a scatter plot. I need to add 
 another smaller histogram on the same plot I just had. 
 However when I used hist(y), the histogram was on another page. 
 
 Any suggestion?
 
 Best Regards,
 
 Philip
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


[R] change the names of all listed objects

2007-08-03 Thread Luca Laghi
Dear list members,
I have created seven objects, from a to g, so that ls() gives me
[1] a b c d e f g

how can I automatically change their names in

a1 b1 c1 d1 e1 f1 g1

It seems simple, ut it is driving me mad.
Thank you very much for your help.
Luca Laghi

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


Re: [R] problem with reading data files with different numbers of lines to skip

2007-08-03 Thread Gabor Grothendieck
Please read the last line of every message
to r-help:
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

We don't know what you did.

On 8/3/07, Tom Cohen [EMAIL PROTECTED] wrote:
 Thanks to Ted and Gabor for your response.
  I apology for not being clear with my previous description of the problem. I 
 tried with  your suggestions using readLines but couldn't make it work. I now 
 explain the problem in more details and hope that you can help me out.

   I have 30 data files, where some of them have 33 lines and the rests have 
 31 lines that I want to skip (examples below with bold text). That is, I only 
 want to keep the lines start from
  Block  Column  Row  Name  ID

  I read in the data files with a loop like below, the problem is how do I 
 tell the loop to skip 31 lines in some data files and 33 in the rests ?

   for (i in 1:num.files) {
  a-read.table(file=data[i], ,header=T,skip=31,sep='\t',na.strings=NA)  }

  Thanks for your help,
  Tom

  # 33 lines to skip

Type=GenePix Results 3  DateTime=2006/10/20 
 13:35:11Settings=  
 GalFile=G:\Avdelningar\viv\translational 
 immunologi\Peptide-arrays\Gal-files\742-human-pep2.galPixelSize=10
 Wavelengths=635
 ImageFiles=M:\Peptidearrays\061020\742-2.tif 1  
 NormalizationMethod=None  NormalizationFactors=1  
 JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
 pep,742\742-2.s1.jpgStdDev=Type 1
 RatioFormulations=W1/W2 (635/)FeatureType=Circular
   Barcode=  BackgroundSubtraction=LocalFeature
 ImageOrigin=560, 1360  JpegOrigin=1940, 3670  
 Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B 
 [84948]FocusPosition=0Temperature=30.2
 LinesAveraged=1
  Comment=PMTGain=600
 ScanPower=100LaserPower=3.36
 Filters=EmptyScanRegion=56,136,2123,6532
   Supplier=Genetix Ltd.  ArrayerSoftwareName=MicroArraying
 ArrayerSoftwareVersion=QSoft XP Build 6450 (Revision 131) 
Block  Column  Row  Name  ID  X  Y  Dia.  F635 Median  F635 Mean1  1  
 1  IgG-human  none  2390  4140  200  301  3171  2  1  PGDR_HUMAN 
 (P09619)  AHASDEIYEIMQK  2630  4140  200  254  2501  3  1  ML1X_HUMAN 
 (Q13585)  AIAHPVSDDSDLP  2860  4140  200  268  252
  1000 more rows



  # 31 lines to skip

  ATF  1.029  41
 Type=GenePix Results 3  DateTime=2006/10/20 13:05:20  
   Settings=  GalFile=G:\Avdelningar\viv\translational 
 immunologi\Peptide-arrays\Gal-files\742-s2.gal  PixelSize=10  
   Wavelengths=635
 ImageFiles=M:\Peptidearrays\061020\742-4.tif 1  
 NormalizationMethod=None  NormalizationFactors=1  
 JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
 pep,742\742-4.s2.jpgStdDev=Type 1
 RatioFormulations=W1/W2 (635/)FeatureType=Circular
   Barcode=  BackgroundSubtraction=LocalFeature
 ImageOrigin=560, 1360  JpegOrigin=1950, 24310 
  Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B 
 [84948]FocusPosition=0
  Temperature=28.49LinesAveraged=1
 Comment=PMTGain=600ScanPower=100  
   LaserPower=3.32Filters=Empty  
   ScanRegion=56,136,2113,6532  Supplier=  
 Block  Column  Row  Name  ID  X  Y  Dia.  F635 Median  F635 Mean1  1  
 1  IgG-human  none  2370  24780  200  133  1751  2  1  PGDR_HUMAN 
 (P09619)  AHASDEIYEIMQK  2600  24780  200  120  1211  3  1  ML1X_HUMAN 
 (Q13585)  AIAHPVSDDSDLP  2840  24780  200  120  118
  1000 more rows


 [EMAIL PROTECTED] skrev:
  On 02-Aug-07 21:14:20, Tom Cohen wrote:
  Dear List,
 
  I have 30 data files with different numbers of lines (31 and 33) that
  I want to skip before reading the files. If I use the skip option I can
  only choose either to skip 31 or 33 lines. The data files with 31 lines
  have no blank rows between the lines and the header row. How can I read
  the files without manually checking which files have 31 respectively 33
  lines ? The only text line I want to keep is the header.
 
  Thamks for your help,
  Tom
 
 
  for (i in 1:num.files) {
  

[R] 'font' argument in text function unevaluated

2007-08-03 Thread Luis Ridao Cruz
R-help,

I have a plot in which I use the following:

text(1 , 2, expression(61*degree ~ paste(N)), font = 2)

but the expression(61*degree ~ paste(N)) will not come out in font
= 2.
However cex=2 will work.

What is the problem?


Thanks in advance.


 version
   _   
platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  5.1 
year   2007
month  06  
day27  
svn rev42083   
language   R   
version.string R version 2.5.1 (2007-06-27)

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


[R] Sourcing commands but delaying their execution

2007-08-03 Thread Dennis Fisher
Colleagues:

I have encountered the following situation:
SERIES OF COMMANDS
source(File1)
MORE COMMANDS
source(File2)

Optimally, I would like File1 and File2 to be merged into a single  
file (FileMerged).  However, if I wrote the following:
SERIES OF COMMANDS
source(FileMerged)
MORE COMMANDS

I encounter an error: the File2 portion of FileMerged contains  
commands that cannot be executed properly until MORE COMMANDS are  
executed.  Similarly, sourcing FileMerged after MORE COMMANDS does  
not work because MORE COMMANDS requires the information from the  
File1 portion of FileMerged.

I am looking for a means to source FileMerged but not execute some of  
the commands immediately.  Functionally this would look like:
SERIES OF COMMANDS
source(FileMerged)# but withhold execution of some of the commands
MORE COMMANDS
COMMAND TO EXECUTE THE WITHHELD COMMANDS

Does R offer some option to accomplish this?

Dennis

Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com

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


[R] useR! 2008

2007-08-03 Thread Uwe Ligges
We are happy to announce that the R user conference

   useR! 2008

is scheduled for August 12-14, 2008, and will take place at the
University of Dortmund.

As for the predecessor conferences, the program will consist of two parts:
invited lectures and user-contributed sessions (abstract submission will
be available online starting from December 2007). Prior to the
conference, there will be tutorials on R (proposals for tutorials should
be sent before 2007-10-31).


INVITED LECTURES

Invited speakers will include

 Peter Bühlmann, John Fox, Kurt Hornik, Gary King, Duncan Murdoch,
 Jean Thioulouse, Graham J. Williams, and Keith Worsley.


USER-CONTRIBUTED SESSIONS

The sessions will be a platform to bring together R users, contributors,
package maintainers and developers in the S spirit that `users are
developers'. People from different fields will show us how they solve
problems with R in fascinating applications.
The sessions are organized by members of the program committee, including

 Micah Altman, Roger Bivand, Peter Dalgaard, Jan de Leeuw,
 Ramón Díaz-Uriarte, Spencer Graves, Leonhard Held, Torsten Hothorn,
 François Husson, Christian Kleiber, Friedrich Leisch, Andy Liaw,
 Martin Mächler, Kate Mullen, Ei-ji Nakama, Thomas Petzold,
 Martin Theus, and Heather Turner.

The program will cover topics such as

 * Applied Statistics  Biostatistics
 * Bayesian Statistics
 * Bioinformatics
 * Chemometrics and Computational Physics
 * Data Mining
 * Econometrics  Finance
 * Environmetrics  Ecological Modeling
 * High Performance Computing
 * Machine Learning
 * Marketing  Business Analytics
 * Psychometrics
 * Robust Statistics
 * Sensometrics
 * Spatial Statistics
 * Statistics in the Social and Political Sciences
 * Teaching
 * Visualization  Graphics
 * and many more.


PRE-CONFERENCE TUTORIALS

Before the official program, half-day tutorials will be offered
on Monday, August 11th.
We invite R users to submit proposals for three hour tutorials on
special topics on R. The proposals should give a brief description of
the tutorial, including goals, detailed outline, justification why the
tutorial is important, background knowledge required and potential
attendees. The proposals should be sent before 2007-10-31 to
[EMAIL PROTECTED]


A web page offering more information on the `useR!' conference is
available at

   http://www.R-project.org/useR-2008


ABOUT DORTMUND

In the past, Dortmund was famous for coal, steel and the beer industry -
quite typical for a city in the Ruhrgebiet. Today, Dortmund evolves to a
city with high tech industry, exhibitions and service companies.
Dortmund's football (i.e. soccer) club is world famous and attracts
roughly 8 people on a regular basis.


IMPORTANT DATES

 2007-10-31: submission deadline of tutorial proposals
 2007-12-01: start of registration
 2007-12-01: start of online abstract submission
 2008-03-31: early registration deadline:
 2008-03-31: submission deadline of abstracts
 2008-05-15: notification of acceptance
 2008-05-31: regular registration deadline
 2008-07-25: registration deadline


We hope to meet you in Dortmund!


The conference committee:
 Uwe Ligges (conference), Achim Zeileis (program), Claus Weihs,
 Gerd Kopp (local organization), Friedrich Leisch, Torsten Hothorn

___
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

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


Re: [R] How to properly finalize external pointers?

2007-08-03 Thread Prof Brian Ripley

On Fri, 3 Aug 2007, Duncan Murdoch wrote:


On 8/3/2007 9:19 AM, Jens Oehlschlägel wrote:

Dear R .Call() insiders,

Can someone enlighten me how to properly finalize external pointers in C code 
(R-2.5.1 win)? What is the relation between R_ClearExternalPtr and the 
finalizer set in R_RegisterCFinalizer?

I succeeded registering a finalizer that works when an R object containing an 
external pointer is garbage collected. However, I have some difficulties 
figuring out how to do that in an explicit closing function.

I observed that
- calling R_ClearExternalPtr does not trigger the finalizer and is dangerous 
because it removes the pointer before the finalizer needs it at 
garbage-collection-time (no finalization = memory leak)
- calling the finalizer directly ensures finalization but now the finalizer is 
called twice (once again at garbage collection time, and I did not find 
documentation how to unregister the finalizer)
- It works to delete the SEXP external pointer object but only if not calling 
R_ClearExternalPtr (but why then do we need it?) Furthermore it is unfortunate 
to delay freeing the external pointers memory if I know during runtime that it 
can be done immediately.

Shouldn't R_ClearExternalPtr call the finalizer and then unregister it? 
(this would also work when removing the SEXP external pointer object is 
difficult because it was handed over to the closing function directly 
as a parameter)


I think we want R_ClearExternalPtr to work even if the finalizer would
fail (e.g. to clean up when there was an error when trying to build the
external object).

So I'd suggest that when you want to get rid of an external object
immediately, you call the finalizer explicitly, then call
R_ClearExternalPtr.  The documentation doesn't address the question of
whether this will clear the registered finalizer so I don't know if
you'll get a second call to the finalizer during garbage collection, but
even if you do, isn't it easy enough to do nothing when you see the null
ptr, as you do below?


You will get a further finalizer call at GC, and I know of no way to 
unregister finalizers. So make sure the finalizer does nothing the second 
time.


The way connections are handled in R-devel provides an example (although 
it is work in progress).


Another possibility is to call the GC yourself if you know there are a lot 
of objects to clear up.



By the way, questions about programming at this level are better asked
in the R-devel group.


Indeed.

[...]

--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re : change the names of all listed objects

2007-08-03 Thread justin bem
It not too simple what ls return the variable that have been create in your 
environment even if you change their names, ls will not return a1 b1 ...

The names attribute in OOP of an object is just an attribute and it is 
different with an instance of the object. ls() show instance

But you can try this :

a-10
 ls()
[1] a

assign(paste(deparse(substitute(a)),1,sep=),a)  # here I 
create a new instance with name 
# a1 and the same value than a
rm(a)   
 # In destroy the original.

ls()
[1] a1


 
Justin BEM
BP 1917 Yaoundé
Tél (237) 99597295
(237) 22040246

- Message d'origine 
De : Luca Laghi [EMAIL PROTECTED]
À : r-help@stat.math.ethz.ch
Envoyé le : Vendredi, 3 Août 2007, 15h23mn 01s
Objet : [R] change the names of all listed objects

Dear list members,
I have created seven objects, from a to g, so that ls() gives me
[1] a b c d e f g

how can I automatically change their names in

a1 b1 c1 d1 e1 f1 g1

It seems simple, ut it is driving me mad.
Thank you very much for your help.
Luca Laghi

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







  
_ 

l 
[[alternative HTML version deleted]]

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


Re: [R] question about logistic models (AIC)

2007-08-03 Thread Ben Bolker
Tom Willems Tom.Willems at var.fgov.be writes:

 I have a question about the Akaike Information Criterion  in the  R 
 output.
 Normally you would want it to be as small as possible, yet when i check up 
 the information in my study books, the AIC is usually displayed as a 
 negative number. In the exercises it is given as  - AIC .
 R displays it as a positive number, does this mean that a large AIC 
 gives a small  - AIC , so the bigger the better?
 

  I don't know about your books, but confirm that smaller AIC is better.
AIC is usually positive (likelihood is between 0 and 1,
therefore log-likelihood is negative, therefore -2L + 2k is positive),
although continuous probability densities or neglected normalization
coefficients can lead to negative AICs -- but smaller (more negative,
if AIC0) is still better.

  Ben Bolker

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


Re: [R] Sourcing commands but delaying their execution

2007-08-03 Thread Mark Wardle
While I don't use such a workflow, one option would be to place the
series of commands in a function, and then run that as appropriate.

do.initialisation - function() {
  ...
}


do.cleanup - function() {
}



Best wishes,

Mark

On 03/08/07, Dennis Fisher [EMAIL PROTECTED] wrote:
 Colleagues:

 I have encountered the following situation:
 SERIES OF COMMANDS
 source(File1)
 MORE COMMANDS
 source(File2)

 Optimally, I would like File1 and File2 to be merged into a single
 file (FileMerged).  However, if I wrote the following:
 SERIES OF COMMANDS
 source(FileMerged)
 MORE COMMANDS

 I encounter an error: the File2 portion of FileMerged contains
 commands that cannot be executed properly until MORE COMMANDS are
 executed.  Similarly, sourcing FileMerged after MORE COMMANDS does
 not work because MORE COMMANDS requires the information from the
 File1 portion of FileMerged.

 I am looking for a means to source FileMerged but not execute some of
 the commands immediately.  Functionally this would look like:
 SERIES OF COMMANDS
 source(FileMerged)# but withhold execution of some of the 
 commands
 MORE COMMANDS
 COMMAND TO EXECUTE THE WITHHELD COMMANDS

 Does R offer some option to accomplish this?

 Dennis

 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-415-564-2220
 www.PLessThan.com

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


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Clinical research fellow and specialist registrar, Neurology
Cardiff, UK

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


[R] FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Steven McKinney
Hi all,

What are current methods people use in R to identify
mis-spelled column names when selecting columns
from a data frame?

Alice Johnson recently tackled this issue
(see [BioC] posting below).

Due to a mis-spelled column name (FileName
instead of Filename) which produced no warning,
Alice spent a fair amount of time tracking down
this bug.  With my fumbling fingers I'll be tracking
down such a bug soon too.

Is there any options() setting, or debug technique
that will flag data frame column extractions that
reference a non-existent column?  It seems to me
that the [.data.frame extractor used to throw an
error if given a mis-spelled variable name, and I
still see lines of code in [.data.frame such as

if (any(is.na(cols))) 
stop(undefined columns selected)



In R 2.5.1 a NULL is silently returned.

 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
NULL

Has something changed so that the code lines
if (any(is.na(cols))) 
stop(undefined columns selected)
in [.data.frame no longer work properly (if
I am understanding the intention properly)?

If not, could  [.data.frame check an
options() variable setting (say
warn.undefined.colnames) and throw a warning
if a non-existent column name is referenced?




 sessionInfo()
R version 2.5.1 (2007-06-27) 
powerpc-apple-darwin8.9.1 

locale:
en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
 plotrix lme4   Matrix  lattice 
 2.2-3  0.99875-4 0.999375-0 0.16-2 
 



Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
Sent: Wed 8/1/2007 7:20 PM
To: [EMAIL PROTECTED]
Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame
 
 For interest sake, I have found out why I wasn't getting my expected
results when using read.AnnotatedDataFrame
Turns out the error was made in the ReadAffy command, where I specified
the filenames to be read from my AnnotatedDataFrame object.  There was a
typo error with a capital N ($FileName) rather than lowercase n
($Filename) as in my target file..whoops.  However this meant the
filename argument was ignored without the error message(!) and instead
of using the information in the AnnotatedDataFrame object (which
included filenames, but not alphabetically) it read the .cel files in
alphabetical order from the working directory - hence the wrong file was
given the wrong label (given by the order of Annotated object) and my
comparisons were confused without being obvious as to why or where.
Our solution: specify that filename is as.character so assignment of
file to target is correct(after correcting $Filename) now that using
read.AnnotatedDataFrame rather than readphenoData.

Data-ReadAffy(filenames=as.character(pData(pd)$Filename),phenoData=pd)

Hurrah!

It may be beneficial to others, that if the filename argument isn't
specified, that filenames are read from the phenoData object if included
here.

Thanks!

-Original Message-
From: Martin Morgan [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 26 July 2007 11:49 a.m.
To: Johnstone, Alice
Cc: [EMAIL PROTECTED]
Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame

Hi Alice --

Johnstone, Alice [EMAIL PROTECTED] writes:

 Using R2.5.0 and Bioconductor I have been following code to analysis 
 Affymetrix expression data: 2 treatments vs control.  The original 
 code was run last year and used the read.phenoData command, however 
 with the newer version I get the error message Warning messages:
 read.phenoData is deprecated, use read.AnnotatedDataFrame instead The 
 phenoData class is deprecated, use AnnotatedDataFrame (with
 ExpressionSet) instead
  
 I use the read.AnnotatedDataFrame command, but when it comes to the 
 end of the analysis the comparison of the treatment to the controls 
 gets mixed up compared to what you get using the original 
 read.phenoData ie it looks like the 3 groups get labelled wrong and so

 the comparisons are different (but they can still be matched up).
 My questions are,
 1) do you need to set up your target file differently when using 
 read.AnnotatedDataFrame - what is the standard format?

I can't quite tell where things are going wrong for you, so it would
help if you can narrow down where the problem occurs.  I think
read.AnnotatedDataFrame should be comparable to read.phenoData. Does

 pData(pd)

look right? What about

 pData(Data)

and

 pData(eset.rma)

? It's not important but pData(pd)$Target is the same as pd$Target.
Since the analysis is on eset.rma, it probably makes sense to use the
pData from there to construct your design matrix

 

Re: [R] question about logistic models (AIC)

2007-08-03 Thread Ted Harding
On 03-Aug-07 16:42:33, Kyle. wrote:
 Tom:
 
 That's a good question.  AIC, as i'm sure you know, is usually  
 calculated as 2k-2ln(L), where k is the number of free parameters in  
 the model, and L is the log-likelihood of the model.  The goal of  
 AIC--and the reason one normally tries to select a model with minimal  
 AIC--is to minimize what's referred to as the Kullback-Leibler  
 distance between the distribution of your data's density from the  
 theoretical true theoretical density as defined by the model.  More  
 concisely, the AIC is an index of the amount of information regarding  
 your data that is lost when your model is used to describe it.  To  
 get back to your question, I can't say without a little more  
 information why the AIC's your referring to are negative (but perhaps  
 it's an issue of using the log-likelihood instead of the negative log- 
 likelihood), but my first instinct is that it doesn't matter.  I  
 would go with the AIC that is closest to zero.  I hope that helps.

That could be wrong! Don't forget that ln(L) is indeterminate to
within an additive constant (for given data), so one man's negative
AIC could be another mans positive AIC -- but if each compared
their AICs with different models (the same different models for each)
then they should get the same *difference* of AIC.

The correct approach is to compare AICs on the basis of algebraic
difference: AIC1 - AIC2 in comparing Model1 with Model2.

If this is positive then Model2 is better than Model1 (on the AIC
criterion). Taking the AIC that is closest to zero would be the
wrong way round for negative AICs.

Ted.


 On Aug 3, 2007, at 8:41 AM, Tom Willems wrote:
 
 Dear fellow R-ussers,
 I have a question about the Akaike Information Criterion  in the  R
 output.
 Normally you would want it to be as small as possible, yet when i  
 check up the information in my study books, the AIC is usually
 displayed as a negative number. In the exercises it is given as
  - AIC .
 R displays it as a positive number, does this mean that a large AIC
 gives a small  - AIC , so the bigger the better?

 Kind regards,
 Tom.

 Tom Willems
 CODA-CERVA-VAR
 Department of Virology
 Epizootic Diseases Section
 Groeselenberg 99
 B-1180 Ukkel

 Tel.: +32 2 3790522
 Fax: +32 2 3790666
 E-mail: [EMAIL PROTECTED]

 www.var.fgov.be


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 03-Aug-07   Time: 18:31:51
-- XFMail --

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


Re: [R] question about logistic models (AIC)

2007-08-03 Thread Kyle Ambert
Ah.  Very good point.  I stand corrected.


---Kyle.


 [EMAIL PROTECTED] 08/03/07 10:32 AM 
On 03-Aug-07 16:42:33, Kyle. wrote:
 Tom:
 
 That's a good question.  AIC, as i'm sure you know, is usually  
 calculated as 2k-2ln(L), where k is the number of free parameters in  
 the model, and L is the log-likelihood of the model.  The goal of  
 AIC--and the reason one normally tries to select a model with minimal 

 AIC--is to minimize what's referred to as the Kullback-Leibler  
 distance between the distribution of your data's density from the  
 theoretical true theoretical density as defined by the model.  More 

 concisely, the AIC is an index of the amount of information regarding 

 your data that is lost when your model is used to describe it.  To  
 get back to your question, I can't say without a little more  
 information why the AIC's your referring to are negative (but perhaps 

 it's an issue of using the log-likelihood instead of the negative log-

 likelihood), but my first instinct is that it doesn't matter.  I  
 would go with the AIC that is closest to zero.  I hope that helps.

That could be wrong! Don't forget that ln(L) is indeterminate to
within an additive constant (for given data), so one man's negative
AIC could be another mans positive AIC -- but if each compared
their AICs with different models (the same different models for each)
then they should get the same *difference* of AIC.

The correct approach is to compare AICs on the basis of algebraic
difference: AIC1 - AIC2 in comparing Model1 with Model2.

If this is positive then Model2 is better than Model1 (on the AIC
criterion). Taking the AIC that is closest to zero would be the
wrong way round for negative AICs.

Ted.


 On Aug 3, 2007, at 8:41 AM, Tom Willems wrote:
 
 Dear fellow R-ussers,
 I have a question about the Akaike Information Criterion  in the  R
 output.
 Normally you would want it to be as small as possible, yet when i  
 check up the information in my study books, the AIC is usually
 displayed as a negative number. In the exercises it is given as
  - AIC .
 R displays it as a positive number, does this mean that a large AIC
 gives a small  - AIC , so the bigger the better?

 Kind regards,
 Tom.

 Tom Willems
 CODA-CERVA-VAR
 Department of Virology
 Epizootic Diseases Section
 Groeselenberg 99
 B-1180 Ukkel

 Tel.: +32 2 3790522
 Fax: +32 2 3790666
 E-mail: [EMAIL PROTECTED]

 www.var.fgov.be


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 03-Aug-07   Time: 18:31:51
-- XFMail --

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

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


Re: [R] Sourcing commands but delaying their execution

2007-08-03 Thread Gabor Grothendieck
Merged file can become:

... current file1 contents ...
f - function() {
... current file 2 contents ...
}

and then source that followed by running your middle code
followed by running f().

Of course, you may need to make some changes in the body
of f due to the changed scoping that this introduces.

On 8/3/07, Dennis Fisher [EMAIL PROTECTED] wrote:
 Colleagues:

 I have encountered the following situation:
SERIES OF COMMANDS
source(File1)
MORE COMMANDS
source(File2)

 Optimally, I would like File1 and File2 to be merged into a single
 file (FileMerged).  However, if I wrote the following:
SERIES OF COMMANDS
source(FileMerged)
MORE COMMANDS

 I encounter an error: the File2 portion of FileMerged contains
 commands that cannot be executed properly until MORE COMMANDS are
 executed.  Similarly, sourcing FileMerged after MORE COMMANDS does
 not work because MORE COMMANDS requires the information from the
 File1 portion of FileMerged.

 I am looking for a means to source FileMerged but not execute some of
 the commands immediately.  Functionally this would look like:
SERIES OF COMMANDS
source(FileMerged)# but withhold execution of some of the 
 commands
MORE COMMANDS
COMMAND TO EXECUTE THE WITHHELD COMMANDS

 Does R offer some option to accomplish this?

 Dennis

 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-415-564-2220
 www.PLessThan.com

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


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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC]read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Steven McKinney


I see now that for my example


 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
NULL

the issue is in this clause of the 
[.data.frame extractor.

The lines
if (drop  length(y) == 1L) 
return(.subset2(y, 1L)) 
return the NULL result just before the
error check
cols - names(y)
if (any(is.na(cols))) 
stop(undefined columns selected)
is performed.

Is this intended behaviour, or has a logical
bug crept into the [.data.frame extractor?


if (missing(i)) {
if (missing(j)  drop  length(x) == 1L) 
return(.subset2(x, 1L))
y - if (missing(j)) 
x
else .subset(x, j)
if (drop  length(y) == 1L) 
return(.subset2(y, 1L)) ## This returns a result before undefined 
columns check is done.  Is this intended?
cols - names(y)
if (any(is.na(cols))) 
stop(undefined columns selected)
if (any(duplicated(cols))) 
names(y) - make.unique(cols)
nrow - .row_names_info(x, 2L)
if (drop  !mdrop  nrow == 1L) 
return(structure(y, class = NULL, row.names = NULL))
else return(structure(y, class = oldClass(x), row.names = 
.row_names_info(x, 
0L)))
}




 sessionInfo()
R version 2.5.1 (2007-06-27) 
powerpc-apple-darwin8.9.1 

locale:
en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
 plotrix lme4   Matrix  lattice 
 2.2-3  0.99875-4 0.999375-0 0.16-2 

Should this discussion move to R-devel?

Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: [EMAIL PROTECTED] on behalf of Steven McKinney
Sent: Fri 8/3/2007 10:37 AM
To: r-help@stat.math.ethz.ch
Subject: [R] FW: Selecting undefined column of a data frame (was 
[BioC]read.phenoData vs read.AnnotatedDataFrame)
 
Hi all,

What are current methods people use in R to identify
mis-spelled column names when selecting columns
from a data frame?

Alice Johnson recently tackled this issue
(see [BioC] posting below).

Due to a mis-spelled column name (FileName
instead of Filename) which produced no warning,
Alice spent a fair amount of time tracking down
this bug.  With my fumbling fingers I'll be tracking
down such a bug soon too.

Is there any options() setting, or debug technique
that will flag data frame column extractions that
reference a non-existent column?  It seems to me
that the [.data.frame extractor used to throw an
error if given a mis-spelled variable name, and I
still see lines of code in [.data.frame such as

if (any(is.na(cols))) 
stop(undefined columns selected)



In R 2.5.1 a NULL is silently returned.

 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
NULL

Has something changed so that the code lines
if (any(is.na(cols))) 
stop(undefined columns selected)
in [.data.frame no longer work properly (if
I am understanding the intention properly)?

If not, could  [.data.frame check an
options() variable setting (say
warn.undefined.colnames) and throw a warning
if a non-existent column name is referenced?




 sessionInfo()
R version 2.5.1 (2007-06-27) 
powerpc-apple-darwin8.9.1 

locale:
en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
 plotrix lme4   Matrix  lattice 
 2.2-3  0.99875-4 0.999375-0 0.16-2 
 



Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
Sent: Wed 8/1/2007 7:20 PM
To: [EMAIL PROTECTED]
Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame
 
 For interest sake, I have found out why I wasn't getting my expected
results when using read.AnnotatedDataFrame
Turns out the error was made in the ReadAffy command, where I specified
the filenames to be read from my AnnotatedDataFrame object.  There was a
typo error with a capital N ($FileName) rather than lowercase n
($Filename) as in my target file..whoops.  However this meant the
filename argument was ignored without the error message(!) and instead
of using the information in the AnnotatedDataFrame object (which
included filenames, but not alphabetically) it read the .cel files in
alphabetical order from the working directory - hence the wrong file was
given the wrong label (given by the order of 

Re: [R] Background color of symbols in xyplot

2007-08-03 Thread Sébastien
Thank you very much for your help. I have installed the latest versions 
of R and lattice are installed, and now the 'fill' argument (instead of 
bg) gives me what I want.

[EMAIL PROTECTED] a écrit :
 On 8/2/07, Sébastien [EMAIL PROTECTED] wrote:
   
 Dear R-users,

 I am using plot symbols given by pch=21:25 in a xyplot. The background
 color of these symbols can be defined by 'fill' in the panel argument,
 however I have a hard time to find how to define the same background
 color in the key. I tried different options like using the auto.key
 argument and modifying the par.settings, or using normal key argument
 plus 'fill', 'bg' or 'background'... nothing seems to do I want. What
 should I change in the following code to make it work ?

 key=list(space=bottom,
  points = list(pch = 21:25,
   col = 32,
   bg=15),
  text=list(mylegend)),
 

 For starters, upgrade to the latest version of R and lattice.

 -Deepayan
   

[[alternative HTML version deleted]]

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


[R] lme and aov

2007-08-03 Thread Gang Chen
I have a mixed balanced ANOVA design with a between-subject factor  
(Grp) and a within-subject factor (Rsp). When I tried the following  
two commands which I thought are equivalent,

  fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
  fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);

I got totally different results. What did I do wrong?

Thanks,
Gang

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


Re: [R] plot to postscript orientation

2007-08-03 Thread John Kane
I don't know about for Miruna but it does not work for
me.

I  tried 
postscript (figure.eps, paper=letter)

http://ca.geocities.com/jrkrideau/R/eps.figure.pdf
 
postscript(figure.eps, paper=special, width=5,
height=4)

with similaar same results.

Interstingly enough figure.eps imports completely into
Word but rotated 90 degrees as Miruna noted.  

Where are you finding the Options for Auto? I don't
see them.

john

--- Vorlow Constantinos [EMAIL PROTECTED] wrote:

 Hi,
 
 My vanilla code works fine... 
 
 See also attached .eps file (seperate email sent
 directly to you)
 
  r-rnorm(100)
  postscript(figure.eps)
  plot.ts(r)
  dev.off()
 
 Also this works ok as you have been told already:
 
  paper=special in the postscript() call.
 
 If you see my eps file wrongly then your GSVIEW
 setup is wrong. 
 
 Choose Orientation Auto and under Options (bottom
 half)
 click-select-tick everything except Ignore DSC.
 
 That should do the trick...
 
 Costas
 
 Miruna Petrescu-Prahova wrote:
 
  Hi
 
  
 
  I am trying to save some plots in a postscript
 file. When I generate
 the 
 
  plots in the main window, they appear correctly -
 their orientation is
 
 
  landscape (i.e., horizontal). However, when I open
 the .ps file with
 GSview, 
 
  the whole page appears vertically, and the plot
 appears horizontally,
 which 
 
  means that the plot is only partially visible
 (example here 
 
 

https://webfiles.uci.edu/mpetresc/postscript.files/default.ps

https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
  ). I
 searched 
 
  the R-help mailing list archive and found 2
 suggestions: setting the
 width 
 
  and height and setting horizontal = FALSE. I have
 tried setting the
 width 
 
  and height but it makes no difference. I have also
 tried using
 horizontal = 
 
  FALSE. This rotates and elongates the plot, but
 it is still displayed
 
 
  horizontally on a vertical page, and so only
 partially visible
 (example 
 
  here

https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps

https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
 ). I
 
 
  am not sure what is wrong. Plots are created with
 filled.contour.
 
  
 
 I guess this is a misconfiguration of your GSview.
 The plots are fine 
 
 for me. Anyway, you might also want to set the
 argument
 
 paper=special in the postscript() call.
 
 Uwe Ligges
 
  
 
  Thanks
 
  Miruna
 
  
 
  
 
  
 
  Miruna Petrescu-Prahova
 
  Department of Sociology
 
  University of California, Irvine
 
  [EMAIL PROTECTED]
 
  
 
  __
 
  R-help@stat.math.ethz.ch mailing list
 
  https://stat.ethz.ch/mailman/listinfo/r-help
 https://stat.ethz.ch/mailman/listinfo/r-help 
 
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html 
 
  and provide commented, minimal, self-contained,
 reproducible code.
 
  

---
 Costas Vorlow
 Research Economist
 Eurobank EFG
 Division of Research  Forecasting
 

---
 tel: +30-210-3337273 (ext 17273)
 fax: +30-210-3337687
 
 
 
 
 P Think before you print.
 
 Disclaimer:
 This e-mail is confidential. If you are not the
 intended recipient, you should not copy it,
 re-transmit it, use it or disclose its contents, but
 should return it to the sender immediately and
 delete the copy from your system.
 EFG Eurobank Ergasias S.A. is not responsible for,
 nor endorses, any opinion, recommendation,
 conclusion, solicitation, offer or agreement or any
 information contained in this communication.
 EFG Eurobank Ergasias S.A. cannot accept any
 responsibility for the accuracy or completeness of
 this message as it has been transmitted over a
 public network. If you suspect that the message may
 have been intercepted or amended, please call the
 sender.
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


Re: [R] plot to postscript orientation

2007-08-03 Thread Miruna Petrescu-Prahova
None of the suggestions work for me, either. I see Costas's plot just like 
mine, i.e., incorrectly. I tried modifying the Orientation to Auto, 
selecting all the Options, and using paper=special. It does not work. I am 
using GSView 4.8 under Windows.

Miruna


- Original Message - 
From: John Kane [EMAIL PROTECTED]
To: Vorlow Constantinos [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Friday, August 03, 2007 11:40 AM
Subject: Re: [R] plot to postscript orientation


I don't know about for Miruna but it does not work for
 me.

 I  tried
 postscript (figure.eps, paper=letter)

 http://ca.geocities.com/jrkrideau/R/eps.figure.pdf
 
 postscript(figure.eps, paper=special, width=5,
 height=4)

 with similaar same results.

 Interstingly enough figure.eps imports completely into
 Word but rotated 90 degrees as Miruna noted.

 Where are you finding the Options for Auto? I don't
 see them.

 john

 --- Vorlow Constantinos [EMAIL PROTECTED] wrote:

 Hi,

 My vanilla code works fine...

 See also attached .eps file (seperate email sent
 directly to you)

  r-rnorm(100)
  postscript(figure.eps)
  plot.ts(r)
  dev.off()

 Also this works ok as you have been told already:

  paper=special in the postscript() call.

 If you see my eps file wrongly then your GSVIEW
 setup is wrong.

 Choose Orientation Auto and under Options (bottom
 half)
 click-select-tick everything except Ignore DSC.

 That should do the trick...

 Costas

 Miruna Petrescu-Prahova wrote:

  Hi

 

  I am trying to save some plots in a postscript
 file. When I generate
 the

  plots in the main window, they appear correctly -
 their orientation is


  landscape (i.e., horizontal). However, when I open
 the .ps file with
 GSview,

  the whole page appears vertically, and the plot
 appears horizontally,
 which

  means that the plot is only partially visible
 (example here

 

 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps

 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
  ). I
 searched

  the R-help mailing list archive and found 2
 suggestions: setting the
 width

  and height and setting horizontal = FALSE. I have
 tried setting the
 width

  and height but it makes no difference. I have also
 tried using
 horizontal =

  FALSE. This rotates and elongates the plot, but
 it is still displayed


  horizontally on a vertical page, and so only
 partially visible
 (example

  here

 https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps

 https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
 ). I


  am not sure what is wrong. Plots are created with
 filled.contour.



 I guess this is a misconfiguration of your GSview.
 The plots are fine

 for me. Anyway, you might also want to set the
 argument

 paper=special in the postscript() call.

 Uwe Ligges



  Thanks

  Miruna

 

 

  

  Miruna Petrescu-Prahova

  Department of Sociology

  University of California, Irvine

  [EMAIL PROTECTED]

 

  __

  R-help@stat.math.ethz.ch mailing list

  https://stat.ethz.ch/mailman/listinfo/r-help
 https://stat.ethz.ch/mailman/listinfo/r-help

  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html

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



 ---
 Costas Vorlow
 Research Economist
 Eurobank EFG
 Division of Research  Forecasting


 ---
 tel: +30-210-3337273 (ext 17273)
 fax: +30-210-3337687




 P Think before you print.

 Disclaimer:
 This e-mail is confidential. If you are not the
 intended recipient, you should not copy it,
 re-transmit it, use it or disclose its contents, but
 should return it to the sender immediately and
 delete the copy from your system.
 EFG Eurobank Ergasias S.A. is not responsible for,
 nor endorses, any opinion, recommendation,
 conclusion, solicitation, offer or agreement or any
 information contained in this communication.
 EFG Eurobank Ergasias S.A. cannot accept any
 responsibility for the accuracy or completeness of
 this message as it has been transmitted over a
 public network. If you suspect that the message may
 have been intercepted or amended, please call the
 sender.


 [[alternative HTML version deleted]]

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




  Ask a question on any topic and get answers from real people. Go to 



__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

Re: [R] Sourcing commands but delaying their execution

2007-08-03 Thread Liaw, Andy
Here's one possibility:

The file garbage.R has

  x - rnorm(100)
  print(summary(x))

You can do:

  cmds - parse(file=garbage.R, n=NA)

and when you want to execute those commands, do

  eval(cmds)

Andy 

From: Dennis Fisher
 
 Colleagues:
 
 I have encountered the following situation:
   SERIES OF COMMANDS
   source(File1)
   MORE COMMANDS
   source(File2)
 
 Optimally, I would like File1 and File2 to be merged into a single  
 file (FileMerged).  However, if I wrote the following:
   SERIES OF COMMANDS
   source(FileMerged)
   MORE COMMANDS
 
 I encounter an error: the File2 portion of FileMerged contains  
 commands that cannot be executed properly until MORE COMMANDS are  
 executed.  Similarly, sourcing FileMerged after MORE COMMANDS does  
 not work because MORE COMMANDS requires the information from the  
 File1 portion of FileMerged.
 
 I am looking for a means to source FileMerged but not execute 
 some of  
 the commands immediately.  Functionally this would look like:
   SERIES OF COMMANDS
   source(FileMerged)# but withhold execution of 
 some of the commands
   MORE COMMANDS
   COMMAND TO EXECUTE THE WITHHELD COMMANDS
 
 Does R offer some option to accomplish this?
 
 Dennis
 
 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-415-564-2220
 www.PLessThan.com
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 


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

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


Re: [R] plot to postscript orientation-update

2007-08-03 Thread John Kane
Follow-up 

I seem to have manged to get the eps file to work
using:
 
postscript(C:/temp/figure.eps, horizontal=F,
paper=special, height=8, width=8, pointsize=12)

Exactly why I'm not sure since I just copied some old
code that I had used a year or so ago.
--- Vorlow Constantinos [EMAIL PROTECTED] wrote:

 Hi,
 
 My vanilla code works fine... 
 
 See also attached .eps file (seperate email sent
 directly to you)
 
  r-rnorm(100)
  postscript(figure.eps)
  plot.ts(r)
  dev.off()
 
 Also this works ok as you have been told already:
 
  paper=special in the postscript() call.
 
 If you see my eps file wrongly then your GSVIEW
 setup is wrong. 
 
 Choose Orientation Auto and under Options (bottom
 half)
 click-select-tick everything except Ignore DSC.
 
 That should do the trick...
 
 Costas
 
 Miruna Petrescu-Prahova wrote:
 
  Hi
 
  
 
  I am trying to save some plots in a postscript
 file. When I generate
 the 
 
  plots in the main window, they appear correctly -
 their orientation is
 
 
  landscape (i.e., horizontal). However, when I open
 the .ps file with
 GSview, 
 
  the whole page appears vertically, and the plot
 appears horizontally,
 which 
 
  means that the plot is only partially visible
 (example here 
 
 

https://webfiles.uci.edu/mpetresc/postscript.files/default.ps

https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
  ). I
 searched 
 
  the R-help mailing list archive and found 2
 suggestions: setting the
 width 
 
  and height and setting horizontal = FALSE. I have
 tried setting the
 width 
 
  and height but it makes no difference. I have also
 tried using
 horizontal = 
 
  FALSE. This rotates and elongates the plot, but
 it is still displayed
 
 
  horizontally on a vertical page, and so only
 partially visible
 (example 
 
  here

https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps

https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
 ). I
 
 
  am not sure what is wrong. Plots are created with
 filled.contour.
 
  
 
 I guess this is a misconfiguration of your GSview.
 The plots are fine 
 
 for me. Anyway, you might also want to set the
 argument
 
 paper=special in the postscript() call.
 
 Uwe Ligges
 
  
 
  Thanks
 
  Miruna
 
  
 
  
 
  
 
  Miruna Petrescu-Prahova
 
  Department of Sociology
 
  University of California, Irvine
 
  [EMAIL PROTECTED]
 
  
 
  __
 
  R-help@stat.math.ethz.ch mailing list
 
  https://stat.ethz.ch/mailman/listinfo/r-help
 https://stat.ethz.ch/mailman/listinfo/r-help 
 
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html 
 
  and provide commented, minimal, self-contained,
 reproducible code.
 
  

---
 Costas Vorlow
 Research Economist
 Eurobank EFG
 Division of Research  Forecasting
 

---
 tel: +30-210-3337273 (ext 17273)
 fax: +30-210-3337687
 
 
 
 
 P Think before you print.
 
 Disclaimer:
 This e-mail is confidential. If you are not the
 intended recipient, you should not copy it,
 re-transmit it, use it or disclose its contents, but
 should return it to the sender immediately and
 delete the copy from your system.
 EFG Eurobank Ergasias S.A. is not responsible for,
 nor endorses, any opinion, recommendation,
 conclusion, solicitation, offer or agreement or any
 information contained in this communication.
 EFG Eurobank Ergasias S.A. cannot accept any
 responsibility for the accuracy or completeness of
 this message as it has been transmitted over a
 public network. If you suspect that the message may
 have been intercepted or amended, please call the
 sender.
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


[R] Rmetrics and log returns

2007-08-03 Thread Kerpel, John
Hi all.  How do I compute a Monday Open to Friday Close weekly return in
Rmetrics from daily data?  Thanks!

 

John


[[alternative HTML version deleted]]

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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Prof Brian Ripley
You are reading the wrong part of the code for your argument list:

  foo[FileName]
Error in `[.data.frame`(foo, FileName) : undefined columns selected

[.data.frame is one of the most complex functions in R, and does many 
different things depending on which arguments are supplied.


On Fri, 3 Aug 2007, Steven McKinney wrote:

 Hi all,

 What are current methods people use in R to identify
 mis-spelled column names when selecting columns
 from a data frame?

 Alice Johnson recently tackled this issue
 (see [BioC] posting below).

 Due to a mis-spelled column name (FileName
 instead of Filename) which produced no warning,
 Alice spent a fair amount of time tracking down
 this bug.  With my fumbling fingers I'll be tracking
 down such a bug soon too.

 Is there any options() setting, or debug technique
 that will flag data frame column extractions that
 reference a non-existent column?  It seems to me
 that the [.data.frame extractor used to throw an
 error if given a mis-spelled variable name, and I
 still see lines of code in [.data.frame such as

 if (any(is.na(cols)))
stop(undefined columns selected)



 In R 2.5.1 a NULL is silently returned.

 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
 NULL

 Has something changed so that the code lines
 if (any(is.na(cols)))
stop(undefined columns selected)
 in [.data.frame no longer work properly (if
 I am understanding the intention properly)?

 If not, could  [.data.frame check an
 options() variable setting (say
 warn.undefined.colnames) and throw a warning
 if a non-existent column name is referenced?




 sessionInfo()
 R version 2.5.1 (2007-06-27)
 powerpc-apple-darwin8.9.1

 locale:
 en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

 other attached packages:
 plotrix lme4   Matrix  lattice
 2.2-3  0.99875-4 0.999375-0 0.16-2




 Steven McKinney

 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre

 email: smckinney +at+ bccrc +dot+ ca

 tel: 604-675-8000 x7561

 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C.
 V5Z 1L3
 Canada




 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
 Sent: Wed 8/1/2007 7:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame

 For interest sake, I have found out why I wasn't getting my expected
 results when using read.AnnotatedDataFrame
 Turns out the error was made in the ReadAffy command, where I specified
 the filenames to be read from my AnnotatedDataFrame object.  There was a
 typo error with a capital N ($FileName) rather than lowercase n
 ($Filename) as in my target file..whoops.  However this meant the
 filename argument was ignored without the error message(!) and instead
 of using the information in the AnnotatedDataFrame object (which
 included filenames, but not alphabetically) it read the .cel files in
 alphabetical order from the working directory - hence the wrong file was
 given the wrong label (given by the order of Annotated object) and my
 comparisons were confused without being obvious as to why or where.
 Our solution: specify that filename is as.character so assignment of
 file to target is correct(after correcting $Filename) now that using
 read.AnnotatedDataFrame rather than readphenoData.

 Data-ReadAffy(filenames=as.character(pData(pd)$Filename),phenoData=pd)

 Hurrah!

 It may be beneficial to others, that if the filename argument isn't
 specified, that filenames are read from the phenoData object if included
 here.

 Thanks!

 -Original Message-
 From: Martin Morgan [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 26 July 2007 11:49 a.m.
 To: Johnstone, Alice
 Cc: [EMAIL PROTECTED]
 Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame

 Hi Alice --

 Johnstone, Alice [EMAIL PROTECTED] writes:

 Using R2.5.0 and Bioconductor I have been following code to analysis
 Affymetrix expression data: 2 treatments vs control.  The original
 code was run last year and used the read.phenoData command, however
 with the newer version I get the error message Warning messages:
 read.phenoData is deprecated, use read.AnnotatedDataFrame instead The
 phenoData class is deprecated, use AnnotatedDataFrame (with
 ExpressionSet) instead

 I use the read.AnnotatedDataFrame command, but when it comes to the
 end of the analysis the comparison of the treatment to the controls
 gets mixed up compared to what you get using the original
 read.phenoData ie it looks like the 3 groups get labelled wrong and so

 the comparisons are different (but they can still be matched up).
 My questions are,
 1) do you need to set up your target file differently when using
 read.AnnotatedDataFrame - what is the standard format?

 I can't quite tell where things are going wrong for you, so it would
 help if you can narrow 

Re: [R] plot to postscript orientation-update

2007-08-03 Thread Miruna Petrescu-Prahova
Well, it seems that having a square page works...If you modify the width or 
height so that they are not equal, it goes back to the same problem. I guess 
this is good enough for now.

Miruna

- Original Message - 
From: John Kane [EMAIL PROTECTED]
To: Vorlow Constantinos [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Friday, August 03, 2007 11:52 AM
Subject: Re: [R] plot to postscript orientation-update


 Follow-up

 I seem to have manged to get the eps file to work
 using:

 postscript(C:/temp/figure.eps, horizontal=F,
 paper=special, height=8, width=8, pointsize=12)

 Exactly why I'm not sure since I just copied some old
 code that I had used a year or so ago.
 --- Vorlow Constantinos [EMAIL PROTECTED] wrote:

 Hi,

 My vanilla code works fine...

 See also attached .eps file (seperate email sent
 directly to you)

  r-rnorm(100)
  postscript(figure.eps)
  plot.ts(r)
  dev.off()

 Also this works ok as you have been told already:

  paper=special in the postscript() call.

 If you see my eps file wrongly then your GSVIEW
 setup is wrong.

 Choose Orientation Auto and under Options (bottom
 half)
 click-select-tick everything except Ignore DSC.

 That should do the trick...

 Costas

 Miruna Petrescu-Prahova wrote:

  Hi

 

  I am trying to save some plots in a postscript
 file. When I generate
 the

  plots in the main window, they appear correctly -
 their orientation is


  landscape (i.e., horizontal). However, when I open
 the .ps file with
 GSview,

  the whole page appears vertically, and the plot
 appears horizontally,
 which

  means that the plot is only partially visible
 (example here

 

 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps

 https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
  ). I
 searched

  the R-help mailing list archive and found 2
 suggestions: setting the
 width

  and height and setting horizontal = FALSE. I have
 tried setting the
 width

  and height but it makes no difference. I have also
 tried using
 horizontal =

  FALSE. This rotates and elongates the plot, but
 it is still displayed


  horizontally on a vertical page, and so only
 partially visible
 (example

  here

 https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps

 https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
 ). I


  am not sure what is wrong. Plots are created with
 filled.contour.



 I guess this is a misconfiguration of your GSview.
 The plots are fine

 for me. Anyway, you might also want to set the
 argument

 paper=special in the postscript() call.

 Uwe Ligges



  Thanks

  Miruna

 

 

  

  Miruna Petrescu-Prahova

  Department of Sociology

  University of California, Irvine

  [EMAIL PROTECTED]

 

  __

  R-help@stat.math.ethz.ch mailing list

  https://stat.ethz.ch/mailman/listinfo/r-help
 https://stat.ethz.ch/mailman/listinfo/r-help

  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 http://www.r-project.org/posting-guide.html

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



 ---
 Costas Vorlow
 Research Economist
 Eurobank EFG
 Division of Research  Forecasting


 ---
 tel: +30-210-3337273 (ext 17273)
 fax: +30-210-3337687




 P Think before you print.

 Disclaimer:
 This e-mail is confidential. If you are not the
 intended recipient, you should not copy it,
 re-transmit it, use it or disclose its contents, but
 should return it to the sender immediately and
 delete the copy from your system.
 EFG Eurobank Ergasias S.A. is not responsible for,
 nor endorses, any opinion, recommendation,
 conclusion, solicitation, offer or agreement or any
 information contained in this communication.
 EFG Eurobank Ergasias S.A. cannot accept any
 responsibility for the accuracy or completeness of
 this message as it has been transmitted over a
 public network. If you suspect that the message may
 have been intercepted or amended, please call the
 sender.


 [[alternative HTML version deleted]]

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




  Ask a question on any topic and get answers from real people. Go to 



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


Re: [R] lme and aov

2007-08-03 Thread Peter Dalgaard
Gang Chen wrote:
 I have a mixed balanced ANOVA design with a between-subject factor  
 (Grp) and a within-subject factor (Rsp). When I tried the following  
 two commands which I thought are equivalent,

   fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
   fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
   
 I got totally different results. What did I do wrong?

   
Except for not telling us what your data are and what you mean by 
totally different?

One model has a random interaction between Subj and Rsp, the other does 
not. This may make a difference, unless the interaction term is aliased 
with the residual error.

If your data are unbalanced, aov is not guaranteed to give meaningful 
results.

-pd

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


Re: [R] Sourcing commands but delaying their execution

2007-08-03 Thread Duncan Murdoch
On 8/3/2007 3:01 PM, Liaw, Andy wrote:
 Here's one possibility:
 
 The file garbage.R has
 
   x - rnorm(100)
   print(summary(x))
 
 You can do:
 
   cmds - parse(file=garbage.R, n=NA)
 
 and when you want to execute those commands, do
 
   eval(cmds)

And since it's Friday afternoon, I'll suggest something that allows the 
commands to be broken into two parts and executed separately (but which 
is ridiculous overkill for this problem):

Put

   x - rnorm(100)
   divider
   print(summary(x))

into your file, then

   cmds - parse(file=garbage.R, n=NA)

as in Andy's suggestion.  Then find the dividing line using

   divider - which(unlist(lapply(cmds, deparse)) == divider)

and then

   part_one - 1:(divider-1)
   part_two - (divider+1):length(cmds)

Finally, execute as

   eval(cmds[part_one])
   MORE_COMMANDS
   eval(cmds[part_two])

Duncan Murdoch
 
 Andy 
 
 From: Dennis Fisher
 
 Colleagues:
 
 I have encountered the following situation:
  SERIES OF COMMANDS
  source(File1)
  MORE COMMANDS
  source(File2)
 
 Optimally, I would like File1 and File2 to be merged into a single  
 file (FileMerged).  However, if I wrote the following:
  SERIES OF COMMANDS
  source(FileMerged)
  MORE COMMANDS
 
 I encounter an error: the File2 portion of FileMerged contains  
 commands that cannot be executed properly until MORE COMMANDS are  
 executed.  Similarly, sourcing FileMerged after MORE COMMANDS does  
 not work because MORE COMMANDS requires the information from the  
 File1 portion of FileMerged.
 
 I am looking for a means to source FileMerged but not execute 
 some of  
 the commands immediately.  Functionally this would look like:
  SERIES OF COMMANDS
  source(FileMerged)# but withhold execution of 
 some of the commands
  MORE COMMANDS
  COMMAND TO EXECUTE THE WITHHELD COMMANDS
 
 Does R offer some option to accomplish this?
 
 Dennis
 
 Dennis Fisher MD
 P  (The P Less Than Company)
 Phone: 1-866-PLessThan (1-866-753-7784)
 Fax: 1-415-564-2220
 www.PLessThan.com
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 
 --
 Notice:  This e-mail message, together with any attachments,...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Steven McKinney
Thanks Prof Ripley,

I used double indexing (if I understand the doc correctly)
so my call was

 foo[, FileName]

I traced through each line of `[.data.frame`
following the sequence of commands executed
for my call.

In the code section

if (missing(i)) {
if (missing(j)  drop  length(x) == 1L)
return(.subset2(x, 1L))
y - if (missing(j))
x
else .subset(x, j)
if (drop  length(y) == 1L)
return(.subset2(y, 1L)) ## This returns a result before undefined 
columns check is done.  Is this intended?
cols - names(y)
if (any(is.na(cols)))
stop(undefined columns selected)
if (any(duplicated(cols)))
names(y) - make.unique(cols)
nrow - .row_names_info(x, 2L)
if (drop  !mdrop  nrow == 1L)
return(structure(y, class = NULL, row.names = NULL))
else return(structure(y, class = oldClass(x), row.names = 
.row_names_info(x,
0L)))
}

the return happened after execution of
if (drop  length(y) == 1L)
return(.subset2(y, 1L))
before the check on column names.

Shouldn't the check on column names
cols - names(y)
if (any(is.na(cols)))
stop(undefined columns selected)
occur before
if (drop  length(y) == 1L)
return(.subset2(y, 1L))
rather than after?




-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
Sent: Fri 8/3/2007 12:25 PM
To: Steven McKinney
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] FW: Selecting undefined column of a data frame (was [BioC] 
read.phenoData vs read.AnnotatedDataFrame)
 
You are reading the wrong part of the code for your argument list:

  foo[FileName]
Error in `[.data.frame`(foo, FileName) : undefined columns selected

[.data.frame is one of the most complex functions in R, and does many 
different things depending on which arguments are supplied.


On Fri, 3 Aug 2007, Steven McKinney wrote:

 Hi all,

 What are current methods people use in R to identify
 mis-spelled column names when selecting columns
 from a data frame?

 Alice Johnson recently tackled this issue
 (see [BioC] posting below).

 Due to a mis-spelled column name (FileName
 instead of Filename) which produced no warning,
 Alice spent a fair amount of time tracking down
 this bug.  With my fumbling fingers I'll be tracking
 down such a bug soon too.

 Is there any options() setting, or debug technique
 that will flag data frame column extractions that
 reference a non-existent column?  It seems to me
 that the [.data.frame extractor used to throw an
 error if given a mis-spelled variable name, and I
 still see lines of code in [.data.frame such as

 if (any(is.na(cols)))
stop(undefined columns selected)



 In R 2.5.1 a NULL is silently returned.

 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
 NULL

 Has something changed so that the code lines
 if (any(is.na(cols)))
stop(undefined columns selected)
 in [.data.frame no longer work properly (if
 I am understanding the intention properly)?

 If not, could  [.data.frame check an
 options() variable setting (say
 warn.undefined.colnames) and throw a warning
 if a non-existent column name is referenced?




 sessionInfo()
 R version 2.5.1 (2007-06-27)
 powerpc-apple-darwin8.9.1

 locale:
 en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

 other attached packages:
 plotrix lme4   Matrix  lattice
 2.2-3  0.99875-4 0.999375-0 0.16-2




 Steven McKinney

 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre

 email: smckinney +at+ bccrc +dot+ ca

 tel: 604-675-8000 x7561

 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C.
 V5Z 1L3
 Canada




 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
 Sent: Wed 8/1/2007 7:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame

 For interest sake, I have found out why I wasn't getting my expected
 results when using read.AnnotatedDataFrame
 Turns out the error was made in the ReadAffy command, where I specified
 the filenames to be read from my AnnotatedDataFrame object.  There was a
 typo error with a capital N ($FileName) rather than lowercase n
 ($Filename) as in my target file..whoops.  However this meant the
 filename argument was ignored without the error message(!) and instead
 of using the information in the AnnotatedDataFrame object (which
 included filenames, but not alphabetically) it read the .cel files in
 alphabetical order from the working directory - hence the wrong file was
 given the wrong label (given by the order of Annotated object) and my
 comparisons were confused without being obvious as to why or where.
 Our solution: specify that filename is as.character so assignment 

Re: [R] lme and aov

2007-08-03 Thread Gang Chen
Thanks for the response!

It is indeed a balanced design. The results are different in the  
sense all the F tests for main effects are not the same. Do you mean  
that a random interaction is modeled in the aov command? If so, what  
would be an equivalent command of aov to the one with lme?

Thanks,
Gang

On Aug 3, 2007, at 3:52 PM, Peter Dalgaard wrote:

 Gang Chen wrote:
 I have a mixed balanced ANOVA design with a between-subject  
 factor  (Grp) and a within-subject factor (Rsp). When I tried the  
 following  two commands which I thought are equivalent,

   fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
   fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
  
 I got totally different results. What did I do wrong?


 Except for not telling us what your data are and what you mean by  
 totally different?

 One model has a random interaction between Subj and Rsp, the other  
 does not. This may make a difference, unless the interaction term  
 is aliased with the residual error.

 If your data are unbalanced, aov is not guaranteed to give  
 meaningful results.

-pd

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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Prof Brian Ripley
I've since seen your followup a more detailed explanation may help.
The path through the code for your argument list does not go where you 
quoted, and there is a reason for it.

Generally when you extract in R and ask for an non-existent index you get 
NA or NULL as the result (and no warning), e.g.

 y - list(x=1, y=2)
 y[[z]]
NULL

Because data frames 'must' have (column) names, they are a partial 
exception and when the result is a data frame you get an error if it would 
contain undefined columns.

But in the case of foo[, FileName], the result is a single column and so 
will not have a name: there seems no reason to be different from

 foo[[FileName]]
NULL
 foo$FileName
NULL

which similarly select a single column.  At one time they were different 
in R, for no documented reason.


On Fri, 3 Aug 2007, Prof Brian Ripley wrote:

 You are reading the wrong part of the code for your argument list:

  foo[FileName]
 Error in `[.data.frame`(foo, FileName) : undefined columns selected

 [.data.frame is one of the most complex functions in R, and does many 
 different things depending on which arguments are supplied.


 On Fri, 3 Aug 2007, Steven McKinney wrote:

 Hi all,
 
 What are current methods people use in R to identify
 mis-spelled column names when selecting columns
 from a data frame?
 
 Alice Johnson recently tackled this issue
 (see [BioC] posting below).
 
 Due to a mis-spelled column name (FileName
 instead of Filename) which produced no warning,
 Alice spent a fair amount of time tracking down
 this bug.  With my fumbling fingers I'll be tracking
 down such a bug soon too.
 
 Is there any options() setting, or debug technique
 that will flag data frame column extractions that
 reference a non-existent column?  It seems to me
 that the [.data.frame extractor used to throw an
 error if given a mis-spelled variable name, and I
 still see lines of code in [.data.frame such as
 
 if (any(is.na(cols)))
stop(undefined columns selected)
 
 
 
 In R 2.5.1 a NULL is silently returned.
 
 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
 NULL
 
 Has something changed so that the code lines
 if (any(is.na(cols)))
stop(undefined columns selected)
 in [.data.frame no longer work properly (if
 I am understanding the intention properly)?
 
 If not, could  [.data.frame check an
 options() variable setting (say
 warn.undefined.colnames) and throw a warning
 if a non-existent column name is referenced?
 
 
 
 
 sessionInfo()
 R version 2.5.1 (2007-06-27)
 powerpc-apple-darwin8.9.1
 
 locale:
 en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods 
 base
 
 other attached packages:
 plotrix lme4   Matrix  lattice
 2.2-3  0.99875-4 0.999375-0 0.16-2
 
 
 
 
 Steven McKinney
 
 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre
 
 email: smckinney +at+ bccrc +dot+ ca
 
 tel: 604-675-8000 x7561
 
 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C.
 V5Z 1L3
 Canada
 
 
 
 
 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
 Sent: Wed 8/1/2007 7:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame
 
 For interest sake, I have found out why I wasn't getting my expected
 results when using read.AnnotatedDataFrame
 Turns out the error was made in the ReadAffy command, where I specified
 the filenames to be read from my AnnotatedDataFrame object.  There was a
 typo error with a capital N ($FileName) rather than lowercase n
 ($Filename) as in my target file..whoops.  However this meant the
 filename argument was ignored without the error message(!) and instead
 of using the information in the AnnotatedDataFrame object (which
 included filenames, but not alphabetically) it read the .cel files in
 alphabetical order from the working directory - hence the wrong file was
 given the wrong label (given by the order of Annotated object) and my
 comparisons were confused without being obvious as to why or where.
 Our solution: specify that filename is as.character so assignment of
 file to target is correct(after correcting $Filename) now that using
 read.AnnotatedDataFrame rather than readphenoData.
 
 Data-ReadAffy(filenames=as.character(pData(pd)$Filename),phenoData=pd)
 
 Hurrah!
 
 It may be beneficial to others, that if the filename argument isn't
 specified, that filenames are read from the phenoData object if included
 here.
 
 Thanks!
 
 -Original Message-
 From: Martin Morgan [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 26 July 2007 11:49 a.m.
 To: Johnstone, Alice
 Cc: [EMAIL PROTECTED]
 Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame
 
 Hi Alice --
 
 Johnstone, Alice [EMAIL PROTECTED] writes:
 
 Using R2.5.0 and Bioconductor I have been following code to analysis
 Affymetrix expression data: 2 treatments vs 

Re: [R] lme and aov

2007-08-03 Thread Doran, Harold
Gang:

I think what Peter is asking for is for you to put some of your output
in an email. If the values of the fixed effects are the same across
models, but the F-tests are different, then there is a whole other
thread we will point you to for an explanation. (I don't presume to
speak for other people, btw, and I'm happy to stand corrected)

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Gang Chen
 Sent: Friday, August 03, 2007 4:01 PM
 To: Peter Dalgaard
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] lme and aov
 
 Thanks for the response!
 
 It is indeed a balanced design. The results are different in 
 the sense all the F tests for main effects are not the same. 
 Do you mean that a random interaction is modeled in the aov 
 command? If so, what would be an equivalent command of aov to 
 the one with lme?
 
 Thanks,
 Gang
 
 On Aug 3, 2007, at 3:52 PM, Peter Dalgaard wrote:
 
  Gang Chen wrote:
  I have a mixed balanced ANOVA design with a 
 between-subject factor  
  (Grp) and a within-subject factor (Rsp). When I tried the 
 following  
  two commands which I thought are equivalent,
 
fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);   
  fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
 
  I got totally different results. What did I do wrong?
 
 
  Except for not telling us what your data are and what you mean by 
  totally different?
 
  One model has a random interaction between Subj and Rsp, the other 
  does not. This may make a difference, unless the 
 interaction term is 
  aliased with the residual error.
 
  If your data are unbalanced, aov is not guaranteed to give 
 meaningful 
  results.
 
 -pd
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Steven McKinney

 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
 Sent: Fri 8/3/2007 1:05 PM
 To: Steven McKinney
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] FW: Selecting undefined column of a data frame (was [BioC] 
 read.phenoData vs read.AnnotatedDataFrame)
  
 I've since seen your followup a more detailed explanation may help.
 The path through the code for your argument list does not go where you 
 quoted, and there is a reason for it.
 

Using a copy of  [.data.frame with browser() I have traced
the flow of execution. (My copy with the browser command is at the end
of this email)


   foo[, FileName]
  Called from: `[.data.frame`(foo, , FileName)
  Browse[1] n
  debug: mdrop - missing(drop)
  Browse[1] n
  debug: Narg - nargs() - (!mdrop)
  Browse[1] n
  debug: if (Narg  3) {
  if (!mdrop) 
  warning(drop argument will be ignored)
  if (missing(i)) 
  return(x)
  if (is.matrix(i)) 
  return(as.matrix(x)[i])
  y - NextMethod([)
  cols - names(y)
  if (!is.null(cols)  any(is.na(cols))) 
  stop(undefined columns selected)
  if (any(duplicated(cols))) 
  names(y) - make.unique(cols)
  return(structure(y, class = oldClass(x), row.names = .row_names_info(x, 
  0L)))
  }
  Browse[1] n
  debug: if (missing(i)) {
  if (missing(j)  drop  length(x) == 1L) 
  return(.subset2(x, 1L))
  y - if (missing(j)) 
  x
  else .subset(x, j)
  if (drop  length(y) == 1L) 
  return(.subset2(y, 1L))
  cols - names(y)
  if (any(is.na(cols))) 
  stop(undefined columns selected)
  if (any(duplicated(cols))) 
  names(y) - make.unique(cols)
  nrow - .row_names_info(x, 2L)
  if (drop  !mdrop  nrow == 1L) 
  return(structure(y, class = NULL, row.names = NULL))
  else return(structure(y, class = oldClass(x), row.names = 
.row_names_info(x, 
  0L)))
  }
  Browse[1] n
  debug: if (missing(j)  drop  length(x) == 1L) return(.subset2(x, 
  1L))
  Browse[1] n
  debug: y - if (missing(j)) x else .subset(x, j)
  Browse[1] n
  debug: if (drop  length(y) == 1L) return(.subset2(y, 1L))
  Browse[1] n
  NULL
   

So `[.data.frame` is exiting after executing 
+ if (drop  length(y) == 1L) 
+ return(.subset2(y, 1L)) ## This returns a result before undefined 
columns check is done.  Is this intended?

Couldn't the error check
+ cols - names(y)
+ if (any(is.na(cols))) 
+ stop(undefined columns selected)
be done before the above return()?

What would break if the error check on column names was done
before returning a NULL result due to incorrect column name spelling?

Why should

 foo[, FileName]
NULL

differ from

 foo[seq(nrow(foo)), FileName]
Error in `[.data.frame`(foo, seq(nrow(foo)), FileName) : 
undefined columns selected
 

Thank you for your explanations.



 Generally when you extract in R and ask for an non-existent index you get 
 NA or NULL as the result (and no warning), e.g.
 
  y - list(x=1, y=2)
  y[[z]]
 NULL
 
 Because data frames 'must' have (column) names, they are a partial 
 exception and when the result is a data frame you get an error if it would 
 contain undefined columns.
 
 But in the case of foo[, FileName], the result is a single column and so 
 will not have a name: there seems no reason to be different from
 
  foo[[FileName]]
 NULL
  foo$FileName
 NULL
 
 which similarly select a single column.  At one time they were different 
 in R, for no documented reason.
 
 
 On Fri, 3 Aug 2007, Prof Brian Ripley wrote:
 
  You are reading the wrong part of the code for your argument list:
 
   foo[FileName]
  Error in `[.data.frame`(foo, FileName) : undefined columns selected
 
  [.data.frame is one of the most complex functions in R, and does many 
  different things depending on which arguments are supplied.
 
 
  On Fri, 3 Aug 2007, Steven McKinney wrote:
 
  Hi all,
  
  What are current methods people use in R to identify
  mis-spelled column names when selecting columns
  from a data frame?
  
  Alice Johnson recently tackled this issue
  (see [BioC] posting below).
  
  Due to a mis-spelled column name (FileName
  instead of Filename) which produced no warning,
  Alice spent a fair amount of time tracking down
  this bug.  With my fumbling fingers I'll be tracking
  down such a bug soon too.
  
  Is there any options() setting, or debug technique
  that will flag data frame column extractions that
  reference a non-existent column?  It seems to me
  that the [.data.frame extractor used to throw an
  error if given a mis-spelled variable name, and I
  still see lines of code in [.data.frame such as
  
  if (any(is.na(cols)))
 stop(undefined columns selected)
  
  
  
  In R 2.5.1 a NULL is silently returned.
  
  foo - data.frame(Filename = c(a, b))
  foo[, FileName]
  NULL
  
  Has something changed so that the code lines
  if (any(is.na(cols)))
 

Re: [R] lme and aov

2007-08-03 Thread Peter Dalgaard
Gang Chen wrote:
 Thanks a lot for clarification! I just started to learn programming in 
 R for a week, and wanted to try a simple mixed design of balanced 
 ANOVA with a between-subject factor
 (Grp) and a within-subject factor (Rsp), but I'm not sure whether I'm 
 modeling the data correctly with either of the command lines.

 Here is the result. Any help would be highly appreciated.

  fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
  summary(fit.lme)
 Linear mixed-effects model fit by REML
 Data: Model
   AIC  BIClogLik
   233.732 251.9454 -108.8660

 Random effects:
 Formula: ~1 | Subj
 (Intercept)  Residual
 StdDev:1.800246 0.3779612

 Fixed effects: Beta ~ Grp * Rsp
  Value Std.Error DFt-value p-value
 (Intercept)  1.1551502 0.5101839 36  2.2641837  0.0297
 GrpB-1.1561248 0.7215090 36 -1.6023706  0.1178
 GrpC-1.2345321 0.7215090 36 -1.7110417  0.0957
 RspB-0.0563077 0.1482486 36 -0.3798196  0.7063
 GrpB:RspB   -0.3739339 0.2096551 36 -1.7835665  0.0829
 GrpC:RspB0.3452539 0.2096551 36  1.6467705  0.1083
 Correlation:
   (Intr) GrpB   GrpC   RspB   GrB:RB
 GrpB  -0.707
 GrpC  -0.707  0.500
 RspB  -0.145  0.103  0.103
 GrpB:RspB  0.103 -0.145 -0.073 -0.707
 GrpC:RspB  0.103 -0.073 -0.145 -0.707  0.500

 Standardized Within-Group Residuals:
 Min  Q1 Med  Q3 Max
 -1.72266114 -0.41242552  0.02994094  0.41348767  1.72323563

 Number of Observations: 78
 Number of Groups: 39

  fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
  fit.aov

 Call:
 aov(formula = Beta ~ Rsp * Grp + Error(Subj/Rsp) + Grp, data = Model)

 Grand Mean: 0.3253307

 Stratum 1: Subj

 Terms:
  Grp
 Sum of Squares  5.191404
 Deg. of Freedom1

 1 out of 2 effects not estimable
 Estimated effects are balanced

 Stratum 2: Subj:Rsp

 Terms:
  Rsp
 Sum of Squares  7.060585e-05
 Deg. of Freedom1

 2 out of 3 effects not estimable
 Estimated effects are balanced

 Stratum 3: Within

 Terms:
   Rsp   Grp   Rsp:Grp Residuals
 Sum of Squares0.33428  36.96518   1.50105 227.49594
 Deg. of Freedom 1 2 270

 Residual standard error: 1.802760
 Estimated effects may be unbalanced

This looks odd.  It is a standard split-plot layout, right? 3 groups of 
13 subjects, each measured with two kinds of Rsp = 3x13x2 = 78 
observations.

In that case you shouldn't see the same effect allocated to multiple 
error strata. I suspect you forgot to declare Subj as factor.

Also: summary(fit.aov) is nicer, and anova(fit.lme) should be informative.

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


Re: [R] lme and aov

2007-08-03 Thread Gang Chen
Thanks a lot for clarification! I just started to learn programming  
in R for a week, and wanted to try a simple mixed design of balanced  
ANOVA with a between-subject factor
(Grp) and a within-subject factor (Rsp), but I'm not sure whether I'm  
modeling the data correctly with either of the command lines.

Here is the result. Any help would be highly appreciated.

  fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
  summary(fit.lme)
Linear mixed-effects model fit by REML
Data: Model
   AIC  BIClogLik
   233.732 251.9454 -108.8660

Random effects:
Formula: ~1 | Subj
 (Intercept)  Residual
StdDev:1.800246 0.3779612

Fixed effects: Beta ~ Grp * Rsp
  Value Std.Error DFt-value p-value
(Intercept)  1.1551502 0.5101839 36  2.2641837  0.0297
GrpB-1.1561248 0.7215090 36 -1.6023706  0.1178
GrpC-1.2345321 0.7215090 36 -1.7110417  0.0957
RspB-0.0563077 0.1482486 36 -0.3798196  0.7063
GrpB:RspB   -0.3739339 0.2096551 36 -1.7835665  0.0829
GrpC:RspB0.3452539 0.2096551 36  1.6467705  0.1083
Correlation:
   (Intr) GrpB   GrpC   RspB   GrB:RB
GrpB  -0.707
GrpC  -0.707  0.500
RspB  -0.145  0.103  0.103
GrpB:RspB  0.103 -0.145 -0.073 -0.707
GrpC:RspB  0.103 -0.073 -0.145 -0.707  0.500

Standardized Within-Group Residuals:
 Min  Q1 Med  Q3 Max
-1.72266114 -0.41242552  0.02994094  0.41348767  1.72323563

Number of Observations: 78
Number of Groups: 39

  fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
  fit.aov

Call:
aov(formula = Beta ~ Rsp * Grp + Error(Subj/Rsp) + Grp, data = Model)

Grand Mean: 0.3253307

Stratum 1: Subj

Terms:
  Grp
Sum of Squares  5.191404
Deg. of Freedom1

1 out of 2 effects not estimable
Estimated effects are balanced

Stratum 2: Subj:Rsp

Terms:
  Rsp
Sum of Squares  7.060585e-05
Deg. of Freedom1

2 out of 3 effects not estimable
Estimated effects are balanced

Stratum 3: Within

Terms:
   Rsp   Grp   Rsp:Grp Residuals
Sum of Squares0.33428  36.96518   1.50105 227.49594
Deg. of Freedom 1 2 270

Residual standard error: 1.802760
Estimated effects may be unbalanced



Thanks,
Gang



On Aug 3, 2007, at 4:09 PM, Doran, Harold wrote:

 Gang:

 I think what Peter is asking for is for you to put some of your output
 in an email. If the values of the fixed effects are the same across
 models, but the F-tests are different, then there is a whole other
 thread we will point you to for an explanation. (I don't presume to
 speak for other people, btw, and I'm happy to stand corrected)

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Gang Chen
 Sent: Friday, August 03, 2007 4:01 PM
 To: Peter Dalgaard
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] lme and aov

 Thanks for the response!

 It is indeed a balanced design. The results are different in
 the sense all the F tests for main effects are not the same.
 Do you mean that a random interaction is modeled in the aov
 command? If so, what would be an equivalent command of aov to
 the one with lme?

 Thanks,
 Gang

 On Aug 3, 2007, at 3:52 PM, Peter Dalgaard wrote:

 Gang Chen wrote:
 I have a mixed balanced ANOVA design with a
 between-subject factor
 (Grp) and a within-subject factor (Rsp). When I tried the
 following
 two commands which I thought are equivalent,

 fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);  
 fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);

 I got totally different results. What did I do wrong?


 Except for not telling us what your data are and what you mean by
 totally different?

 One model has a random interaction between Subj and Rsp, the other
 does not. This may make a difference, unless the
 interaction term is
 aliased with the residual error.

 If your data are unbalanced, aov is not guaranteed to give
 meaningful
 results.

-pd

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


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


Re: [R] lme and aov

2007-08-03 Thread Gang Chen
 This looks odd.  It is a standard split-plot layout, right? 3  
 groups of 13 subjects, each measured with two kinds of Rsp = 3x13x2  
 = 78 observations.

Yes, that is right.


 In that case you shouldn't see the same effect allocated to  
 multiple error strata. I suspect you forgot to declare Subj as factor.


This is exactly the problem I had: Model$Subj was not a factor! Now  
they converge. A lesson well learned.

Thanks a lot for the help,
Gang


On Aug 3, 2007, at 4:53 PM, Peter Dalgaard wrote:

 Gang Chen wrote:
 Thanks a lot for clarification! I just started to learn  
 programming in R for a week, and wanted to try a simple mixed  
 design of balanced ANOVA with a between-subject factor
 (Grp) and a within-subject factor (Rsp), but I'm not sure whether  
 I'm modeling the data correctly with either of the command lines.

 Here is the result. Any help would be highly appreciated.

  fit.lme - lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
  summary(fit.lme)
 Linear mixed-effects model fit by REML
 Data: Model
   AIC  BIClogLik
   233.732 251.9454 -108.8660

 Random effects:
 Formula: ~1 | Subj
 (Intercept)  Residual
 StdDev:1.800246 0.3779612

 Fixed effects: Beta ~ Grp * Rsp
  Value Std.Error DFt-value p-value
 (Intercept)  1.1551502 0.5101839 36  2.2641837  0.0297
 GrpB-1.1561248 0.7215090 36 -1.6023706  0.1178
 GrpC-1.2345321 0.7215090 36 -1.7110417  0.0957
 RspB-0.0563077 0.1482486 36 -0.3798196  0.7063
 GrpB:RspB   -0.3739339 0.2096551 36 -1.7835665  0.0829
 GrpC:RspB0.3452539 0.2096551 36  1.6467705  0.1083
 Correlation:
   (Intr) GrpB   GrpC   RspB   GrB:RB
 GrpB  -0.707
 GrpC  -0.707  0.500
 RspB  -0.145  0.103  0.103
 GrpB:RspB  0.103 -0.145 -0.073 -0.707
 GrpC:RspB  0.103 -0.073 -0.145 -0.707  0.500

 Standardized Within-Group Residuals:
 Min  Q1 Med  Q3 Max
 -1.72266114 -0.41242552  0.02994094  0.41348767  1.72323563

 Number of Observations: 78
 Number of Groups: 39

  fit.aov - aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
  fit.aov

 Call:
 aov(formula = Beta ~ Rsp * Grp + Error(Subj/Rsp) + Grp, data = Model)

 Grand Mean: 0.3253307

 Stratum 1: Subj

 Terms:
  Grp
 Sum of Squares  5.191404
 Deg. of Freedom1

 1 out of 2 effects not estimable
 Estimated effects are balanced

 Stratum 2: Subj:Rsp

 Terms:
  Rsp
 Sum of Squares  7.060585e-05
 Deg. of Freedom1

 2 out of 3 effects not estimable
 Estimated effects are balanced

 Stratum 3: Within

 Terms:
   Rsp   Grp   Rsp:Grp Residuals
 Sum of Squares0.33428  36.96518   1.50105 227.49594
 Deg. of Freedom 1 2 270

 Residual standard error: 1.802760
 Estimated effects may be unbalanced

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


[R] a mixed effects model with collinear parameters.

2007-08-03 Thread ivan . borozan
Hi all,

I have the following unbalanced data set :

F1-rep(F1,29)
F2-rep(F2,83)
F3-rep(F3,18)
F4-rep(F4,11)
F5-rep(F5,25)
F6-rep(F6,10)

all.fac-c(F1,F2,F3,F4,F5,F6)

batch1-rep(B1,29)
batch2-rep(B2,83)
batch3-rep(B2,18)
batch4-rep(B1,11)
batch5-rep(B2,25)
batch6-rep(B2,10)


batch-c(batch1,batch2,batch3,batch4,batch5,batch6)


sample0[batch == B1]-rnorm(length(sample0[batch == B1]),5,1)
sample0[batch == B2]-rnorm(length(sample0[batch == B2]),2,1)


dataA - data.frame(samples = sample0, batches=factor(batch),  
soil=factor(all.fac))
dataA$soil - relevel(dataA$soil,ref=F2)

X-matrix
XX-t(X)%*%X
solve(XX)
Error in solve.default(XX) : system is computationally singular:  
reciprocal condition number = 3.74708e-18


Meaning there is collinearity between predictors. (F1 and B1) and (F4 and B1)


I have tried a mixed effects model.


 amod - lme(fixed = samples ~ soil, random = ~ 1|batches, dataA, method=ML)
 summary(amod)
Linear mixed-effects model fit by maximum likelihood
  Data: dataA
AIC  BIClogLik
   507.0955 532.4594 -245.5478

Random effects:
  Formula: ~1 | batches
 (Intercept)  Residual
StdDev: 2.02532e-05 0.9764997

Fixed effects: samples ~ soil
  Value Std.Error  DF   t-value p-value
(Intercept)  2.1540927 0.1090599 169 19.751470  0.
soilF1   3.1223796 0.2143260 169 14.568363  0.
soilF3  -0.2070161 0.2583386 169 -0.801336  0.4241
soilF4   2.7412508 0.3188104 169  8.598372  0.
soilF5  -0.1668292 0.2266767 169 -0.735979  0.4628
soilF6  -0.2522510 0.3325879 169 -0.758449  0.4492
  Correlation:
(Intr) soilF1 soilF3 soilF4 soilF5
soilF1 -0.509
soilF3 -0.422  0.215
soilF4 -0.342  0.174  0.144
soilF5 -0.481  0.245  0.203  0.165
soilF6 -0.328  0.167  0.138  0.112  0.158

Standardized Within-Group Residuals:
 Min  Q1 Med  Q3 Max
-3.02335670 -0.59885469  0.03137624  0.65601671  3.71106690

Number of Observations: 176
Number of Groups: 2

 ranef(amod)
 (Intercept)
B1 5.944455e-23
B2 1.795242e-23


The fixed effects part seems to be right, should I just ignore the  
random effects part ?

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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC] read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Steven McKinney

 What would break is that three methods for doing the same thing would
 give different answers.
 
 Please do have the courtesy to actually read the detailed explanation you
 are given.

Sorry Prof. Ripley, I am attempting to read carefully, as this
issue has deeper coding/debugging implications, and as you
point out, 
  [.data.frame is one of the most complex functions in R
so please bear with me.  This change in behaviour has 
taken away a side-effect debugging tool, discussed below.


 
 
 On Fri, 3 Aug 2007, Steven McKinney wrote:
 
 
  -Original Message-
  From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
  Sent: Fri 8/3/2007 1:05 PM
  To: Steven McKinney
  Cc: r-help@stat.math.ethz.ch
  Subject: Re: [R] FW: Selecting undefined column of a data frame (was 
  [BioC] read.phenoData vs read.AnnotatedDataFrame)
 
  I've since seen your followup a more detailed explanation may help.
  The path through the code for your argument list does not go where you
  quoted, and there is a reason for it.
 
 
  Generally when you extract in R and ask for an non-existent index you get
  NA or NULL as the result (and no warning), e.g.
 
  y - list(x=1, y=2)
  y[[z]]
  NULL
 
  Because data frames 'must' have (column) names, they are a partial
  exception and when the result is a data frame you get an error if it would
  contain undefined columns.
 
  But in the case of foo[, FileName], the result is a single column and so
  will not have a name: there seems no reason to be different from
 
  foo[[FileName]]
  NULL
  foo$FileName
  NULL
 
  which similarly select a single column.  At one time they were different
  in R, for no documented reason.


This difference provided a side-effect debugging tool, in that where

   bar - foo[, FileName]

used to throw an error, alerting as to a typo, it now does not.

Having been burned by NULL results due to typos in code lines using
the $ extractor such as
 
   bar - foo$FileName

I learned to use
   bar - foo[, FileName]
to help cut down on typo bugs.  With the ubiquity of
camelCase object names, this is a constant typing bug hazard.


I am wondering what to do now to double check spelling
when accessing columns of a dataframe.

If [.data.frame stays as is, can a debug mechanism
be implemented in R that forces strict adherence
to existing list names in debug mode?  This would also help debug
typos in camelCase names when using the $ and [[
extractors and accessors.

Are there other debugging tools already in R that
can help point out such camelCase list element
name typos?



 
 
  On Fri, 3 Aug 2007, Prof Brian Ripley wrote:
 
  You are reading the wrong part of the code for your argument list:
 
   foo[FileName]
  Error in `[.data.frame`(foo, FileName) : undefined columns selected
 
  [.data.frame is one of the most complex functions in R, and does many
  different things depending on which arguments are supplied.
 
 
  On Fri, 3 Aug 2007, Steven McKinney wrote:
 
  Hi all,
 
  What are current methods people use in R to identify
  mis-spelled column names when selecting columns
  from a data frame?
 
  Alice Johnson recently tackled this issue
  (see [BioC] posting below).
 
  Due to a mis-spelled column name (FileName
  instead of Filename) which produced no warning,
  Alice spent a fair amount of time tracking down
  this bug.  With my fumbling fingers I'll be tracking
  down such a bug soon too.
 
  Is there any options() setting, or debug technique
  that will flag data frame column extractions that
  reference a non-existent column?  It seems to me
  that the [.data.frame extractor used to throw an
  error if given a mis-spelled variable name, and I
  still see lines of code in [.data.frame such as
 
  if (any(is.na(cols)))
 stop(undefined columns selected)
 
 
 
  In R 2.5.1 a NULL is silently returned.
 
  foo - data.frame(Filename = c(a, b))
  foo[, FileName]
  NULL
 
  Has something changed so that the code lines
  if (any(is.na(cols)))
 stop(undefined columns selected)
  in [.data.frame no longer work properly (if
  I am understanding the intention properly)?
 
  If not, could  [.data.frame check an
  options() variable setting (say
  warn.undefined.colnames) and throw a warning
  if a non-existent column name is referenced?
 
 
 
 
  sessionInfo()
  R version 2.5.1 (2007-06-27)
  powerpc-apple-darwin8.9.1
 
  locale:
  en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
 
  attached base packages:
  [1] stats graphics  grDevices utils datasets  methods
  base
 
  other attached packages:
  plotrix lme4   Matrix  lattice
  2.2-3  0.99875-4 0.999375-0 0.16-2
 
 
 
 
  Steven McKinney
 
  Statistician
  Molecular Oncology and Breast Cancer Program
  British Columbia Cancer Research Centre
 
  email: smckinney +at+ bccrc +dot+ ca
 
  tel: 604-675-8000 x7561
 
  BCCRC
  Molecular Oncology
  675 West 10th Ave, Floor 4
  Vancouver B.C.
  V5Z 1L3
  Canada
 
 
 
 
  --
  Brian D. Ripley,

Re: [R] FW: Selecting undefined column of a data frame (was [BioC]read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Bert Gunter
I suspect you'll get some creative answers, but if all you're worried about
is whether a column exists before you do something with it, what's wrong
with:

nm - ... ## a character vector of names
if(!all(nm %in% names(yourdata))) ## complain
else ## do something


I think this is called defensive programming.

Bert Gunter
Genentech


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven McKinney
Sent: Friday, August 03, 2007 10:38 AM
To: r-help@stat.math.ethz.ch
Subject: [R] FW: Selecting undefined column of a data frame (was
[BioC]read.phenoData vs read.AnnotatedDataFrame)

Hi all,

What are current methods people use in R to identify
mis-spelled column names when selecting columns
from a data frame?

Alice Johnson recently tackled this issue
(see [BioC] posting below).

Due to a mis-spelled column name (FileName
instead of Filename) which produced no warning,
Alice spent a fair amount of time tracking down
this bug.  With my fumbling fingers I'll be tracking
down such a bug soon too.

Is there any options() setting, or debug technique
that will flag data frame column extractions that
reference a non-existent column?  It seems to me
that the [.data.frame extractor used to throw an
error if given a mis-spelled variable name, and I
still see lines of code in [.data.frame such as

if (any(is.na(cols))) 
stop(undefined columns selected)



In R 2.5.1 a NULL is silently returned.

 foo - data.frame(Filename = c(a, b))
 foo[, FileName]
NULL

Has something changed so that the code lines
if (any(is.na(cols))) 
stop(undefined columns selected)
in [.data.frame no longer work properly (if
I am understanding the intention properly)?

If not, could  [.data.frame check an
options() variable setting (say
warn.undefined.colnames) and throw a warning
if a non-existent column name is referenced?




 sessionInfo()
R version 2.5.1 (2007-06-27) 
powerpc-apple-darwin8.9.1 

locale:
en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

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

other attached packages:
 plotrix lme4   Matrix  lattice 
 2.2-3  0.99875-4 0.999375-0 0.16-2 
 



Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
Sent: Wed 8/1/2007 7:20 PM
To: [EMAIL PROTECTED]
Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame
 
 For interest sake, I have found out why I wasn't getting my expected
results when using read.AnnotatedDataFrame
Turns out the error was made in the ReadAffy command, where I specified
the filenames to be read from my AnnotatedDataFrame object.  There was a
typo error with a capital N ($FileName) rather than lowercase n
($Filename) as in my target file..whoops.  However this meant the
filename argument was ignored without the error message(!) and instead
of using the information in the AnnotatedDataFrame object (which
included filenames, but not alphabetically) it read the .cel files in
alphabetical order from the working directory - hence the wrong file was
given the wrong label (given by the order of Annotated object) and my
comparisons were confused without being obvious as to why or where.
Our solution: specify that filename is as.character so assignment of
file to target is correct(after correcting $Filename) now that using
read.AnnotatedDataFrame rather than readphenoData.

Data-ReadAffy(filenames=as.character(pData(pd)$Filename),phenoData=pd)

Hurrah!

It may be beneficial to others, that if the filename argument isn't
specified, that filenames are read from the phenoData object if included
here.

Thanks!

-Original Message-
From: Martin Morgan [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 26 July 2007 11:49 a.m.
To: Johnstone, Alice
Cc: [EMAIL PROTECTED]
Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame

Hi Alice --

Johnstone, Alice [EMAIL PROTECTED] writes:

 Using R2.5.0 and Bioconductor I have been following code to analysis 
 Affymetrix expression data: 2 treatments vs control.  The original 
 code was run last year and used the read.phenoData command, however 
 with the newer version I get the error message Warning messages:
 read.phenoData is deprecated, use read.AnnotatedDataFrame instead The 
 phenoData class is deprecated, use AnnotatedDataFrame (with
 ExpressionSet) instead
  
 I use the read.AnnotatedDataFrame command, but when it comes to the 
 end of the analysis the comparison of the treatment to the controls 
 gets mixed up compared to what you get using the original 
 read.phenoData ie it looks like the 3 groups get labelled wrong and so

 the comparisons are different (but they can still be matched up).
 

Re: [R] ROC curve in R

2007-08-03 Thread Dylan Beaudette
On Thursday 26 July 2007 10:45, Frank E Harrell Jr wrote:
 Dylan Beaudette wrote:
  On Thursday 26 July 2007 06:01, Frank E Harrell Jr wrote:
  Note that even though the ROC curve as a whole is an interesting
  'statistic' (its area is a linear translation of the
  Wilcoxon-Mann-Whitney-Somers-Goodman-Kruskal rank correlation
  statistics), each individual point on it is an improper scoring rule,
  i.e., a rule that is optimized by fitting an inappropriate model.  Using
  curves to select cutoffs is a low-precision and arbitrary operation, and
  the cutoffs do not replicate from study to study.  Probably the worst
  problem with drawing an ROC curve is that it tempts analysts to try to
  find cutoffs where none really exist, and it makes analysts ignore the
  whole field of decision theory.
 
  Frank Harrell
 
  Frank,
 
  This thread has caught may attention for a couple reasons, possibly
  related to my novice-level experience.
 
  1. in a logistic regression study, where i am predicting the probability
  of the response being 1 (for example) - there exists a continuum of
  probability values - and a finite number of {1,0} realities when i either
  look within the original data set, or with a new 'verification' data set.
  I understand that drawing a line through the probabilities returned from
  the logistic regression is a loss of information, but there are times
  when a 'hard' decision requiring prediction of {1,0} is required. I have
  found that the ROCR package (not necessarily the ROC Curve) can be useful
  in identifying the probability cutoff where accuracy is maximized. Is
  this an unreasonable way of using logistic regression as a predictor?

Thanks for the detailed response Frank. My follow-up questions are below:

 Logistic regression (with suitable attention to not assuming linearity
 and to avoiding overfitting) is a great way to estimate P[Y=1].  Given
 good predicted P[Y=1] and utilities (losses, costs) for incorrect
 positive and negative decisions, an optimal decision is one that
 optimizes expected utility.  The ROC curve does not play a direct role
 in this regard.  

Ok.

 If per-subject utilities are not available, the analyst 
 may make various assumptions about utilities (including the unreasonable
 but often used assumption that utilities do not vary over subjects) to
 find a cutoff on P[Y=1]. 

Can you elaborate on what exactly a per-subject utility is? In my case, I am 
trying to predict the occurance of specific soil features based on two 
predictor variables: 1 continuous, the other categorical.  Thus far my 
evaluation of how well this method works is based on how often I can 
correctly predict (a categorical) quality.


 A very nice feature of P[Y=1] is that error 
 probabilities are self-contained.  For example if P[Y=1] = .02 for a
 single subject and you predict Y=0, the probability of an error is .02
 by definition.  One doesn't need to compute an overall error probability
 over the whole distribution of subjects' risks.  If the cost of a false
 negative is C, the expected cost is .02*C in this example.

Interesting. The hang-up that I am having is that I need to predict from 
{O,1}, as the direct users of this information are not currently interested 
in in raw probabilities. As far as I know, in order to predict a class from a 
probability I need use a cutoff... How else can I accomplish this without 
imposing a cutoff on the entire dataset? One thought, identify a cutoff for 
each level of the categorical predictor term in the model... (?)

  2. The ROC curve can be a helpful way of communicating false positives /
  false negatives to other users who are less familiar with the output and
  interpretation of logistic regression.

 What is more useful than that is a rigorous calibration curve estimate
 to demonstrate the faithfulness of predicted P[Y=1] and a histogram
 showing the distribution of predicted P[Y=1]

Ok. I can make that histogram - how would one go about making the 'rigorous 
calibration curve' ? Note that I have a training set, from which the model is 
built, and a smaller testing set for evaluation. 


 .  Models that put a lot of 
 predictions near 0 or 1 are the most discriminating.  Calibration curves
 and risk distributions are easier to explain than ROC curves.

By 'risk discrimination' do you mean said histogram ?

 Too often 
 a statistician will solve for a cutoff on P[Y=1], imposing her own
 utility function without querying any subjects.

in this case I have picked a cutoff that resulted in the smallest number of 
incorrectly classified observations , or highest kappa / tau statistics -- 
the results were very close.


  3. I have been using the area under the ROC Curve, kendall's tau, and
  cohen's kappa to evaluate the accuracy of a logistic regression based
  prediction, the last two statistics based on a some probability cutoff
  identified before hand.

 ROC area (equiv. to Wilcoxon-Mann-Whitney and Somers' Dxy rank
 correlation 

[R] extracting dispersion parameter from quasipoisson lmer model

2007-08-03 Thread wayne hallstrom
Hi,
  I would like to obtain the dispersion parameter for a quasipoisson model for 
later use in calculating QAIC values for model comparison.Can anyone suggest a 
method of how to go about doing this?
   
  The idea I have now is that I could use the residual deviance divided by the 
residual degrees of freedom to obtain the dispersion parameter. The residual 
deviance is available in the summary output for the lmer model. The problem 
with this idea is that the residual degrees of freedom is not directly 
available. I have been assuming that the estimated/approximate DF can be 
obtained through the formula listed below, and then subsequently used to obtain 
the dispersion parameter as described above. Is this correct?
   
  samp.m4 - mcmcsamp(m4, n = 1000)
print(summary(samp.m4))
(eDF - mean(samp.m4[,deviance]) - deviance(m4, REML=FALSE)) 
  # potentially useful approximate DF?

   
  However, rather than going through this roundabout, there appears to be an 
easier way to obtain the dispersion parameter. I have noted that the 
'quasibinomial' produces a dispersion parameter in the model output, but the 
'quasipoisson' output does not contain this useful number. Given that each of 
my models is fit by lmer with a quasipoisson distribution, the program must be 
internally calculating the dispersion parameter as it runs. Perhaps there is a 
way to obtain this number directly since I assume it has already been 
calculated? Can somone who has experience with this code provide some advice on 
whether this is possible and how I might manage to do this?
   
   
  Thank you for your time,
   
  Wayne Hallstrom
  403-370-3832
   
   

   
-

[[alternative HTML version deleted]]

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


[R] Opening a script with the R editor via file association (on Windows)

2007-08-03 Thread Christopher Green
Is there an easy way to open an R script file in the R Editor found in
more recent versions of R on Windows via a file association? I am looking
for functionality akin to how the .ssc file extension works for S-Plus:
upon double-clicking on a .R file, Rgui.exe starts up and loads the script 
file in the R Editor.

As far as I can tell, Rgui.exe does not have a command line option to load
a file (so associating .R with Rgui.exe %1 won't work). I can get Windows
to start Rgui.exe when I double-click on a script file, but that's about it.
I also don't see any way to have Rgui.exe evaluate an expression provided on
the command line (which would allow file.edit(%1)). I also thought about
creating a custom .First calling 'file.edit' in a batch file, but then I'd have
to start R, load the .First file, then quit and restart R, so that's out.

Is there an easy way to do this without resorting to some other R GUI?

Thanks,

Chris Green



Christopher G. Green (cggreen AT stat.washington.edu) 
Doctoral Candidate
Department of Statistics, Box 354322, Seattle, WA, 98195-4322, U.S.A.
http://www.stat.washington.edu/cggreen/

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


[R] Sorting data for multiple regressions

2007-08-03 Thread Paul Young
So I am trying to perform a robust regression (fastmcd in the robust
package) on a dataset and I want to perform individual regressions based
on the groups within the data.  We have over 300 sites and we want to
perform a regression based on the day of week and the hour for every
site.  I was wondering if anyone knows of a 'by' command similar to the
one used in SAS that automatically groups the data for the regressions.
If not, does anyone have any tips on how to split the data into smaller
sets and then perform the regression on each set.  I am new to R, so I
don't know all of the common work arounds and such.  At the moment the
only method I can think of is to split the data using condition
statements and manually running the regression on each set.  Thanks or
your help

-Paul
 
 _

 
CONFIDENTIALITY NOTICE\ IMPORTANT: This communication, toget...{{dropped}}

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


Re: [R] FW: Selecting undefined column of a data frame (was [BioC]read.phenoData vs read.AnnotatedDataFrame)

2007-08-03 Thread Steven McKinney

Hi Bert,

 -Original Message-
 From: Bert Gunter [mailto:[EMAIL PROTECTED]
 Sent: Fri 8/3/2007 3:19 PM
 To: Steven McKinney; r-help@stat.math.ethz.ch
 Subject: RE: [R] FW: Selecting undefined column of a data frame (was 
 [BioC]read.phenoData vs read.AnnotatedDataFrame)
  
 I suspect you'll get some creative answers, but if all you're worried about
 is whether a column exists before you do something with it, what's wrong
 with:
 
 nm - ... ## a character vector of names
 if(!all(nm %in% names(yourdata))) ## complain
 else ## do something
 
 
 I think this is called defensive programming.

This is a good example of good defensive programming.
I do indeed check variable/object names whenever
obtaining them from an external source (user input,
file input, a list in code).


I was able to practice a defensive programming style in the past
by using
  bar - foo[, FileName]
instead of
  bar - foo$FileName

but this has changed recently, so I need to figure out
some other mechanisms.

R is such a productive language, but this change will
lead many of us to chase elusive typos that used to
get revealed.

I'm hoping that some kind of explicit data frame variable
checking mechanism might be introduced since we've
lost this one.  

It would also be great to have such a
mechanism to help catch list access and extraction
errors.  Why should
foo$FileName
always quietly return NULL?

I'm not sure why the following incongruity is okay.

 foo - matrix(1:4, nrow = 2)
 dimnames(foo) - list(NULL, c(a, b))
 bar - foo[, A]
Error: subscript out of bounds

 foo.df - as.data.frame(foo)
 foo.df
  a b
1 1 3
2 2 4
 bar - foo.df[, A]
 bar
NULL
 


It is a lot of extra typing to wrap every command in
extra code, but more of that will need to happen
going forward.

Steve McKinney


 
 Bert Gunter
 Genentech
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Steven McKinney
 Sent: Friday, August 03, 2007 10:38 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] FW: Selecting undefined column of a data frame (was
 [BioC]read.phenoData vs read.AnnotatedDataFrame)
 
 Hi all,
 
 What are current methods people use in R to identify
 mis-spelled column names when selecting columns
 from a data frame?
 
 Alice Johnson recently tackled this issue
 (see [BioC] posting below).
 
 Due to a mis-spelled column name (FileName
 instead of Filename) which produced no warning,
 Alice spent a fair amount of time tracking down
 this bug.  With my fumbling fingers I'll be tracking
 down such a bug soon too.
 
 Is there any options() setting, or debug technique
 that will flag data frame column extractions that
 reference a non-existent column?  It seems to me
 that the [.data.frame extractor used to throw an
 error if given a mis-spelled variable name, and I
 still see lines of code in [.data.frame such as
 
 if (any(is.na(cols))) 
 stop(undefined columns selected)
 
 
 
 In R 2.5.1 a NULL is silently returned.
 
  foo - data.frame(Filename = c(a, b))
  foo[, FileName]
 NULL
 
 Has something changed so that the code lines
 if (any(is.na(cols))) 
 stop(undefined columns selected)
 in [.data.frame no longer work properly (if
 I am understanding the intention properly)?
 
 If not, could  [.data.frame check an
 options() variable setting (say
 warn.undefined.colnames) and throw a warning
 if a non-existent column name is referenced?
 
 
 
 
  sessionInfo()
 R version 2.5.1 (2007-06-27) 
 powerpc-apple-darwin8.9.1 
 
 locale:
 en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods
 base 
 
 other attached packages:
  plotrix lme4   Matrix  lattice 
  2.2-3  0.99875-4 0.999375-0 0.16-2 
  
 
 
 
 Steven McKinney
 
 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre
 
 email: smckinney +at+ bccrc +dot+ ca
 
 tel: 604-675-8000 x7561
 
 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C. 
 V5Z 1L3
 Canada
 
 
 
 
 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Johnstone, Alice
 Sent: Wed 8/1/2007 7:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [BioC] read.phenoData vs read.AnnotatedDataFrame
  
  For interest sake, I have found out why I wasn't getting my expected
 results when using read.AnnotatedDataFrame
 Turns out the error was made in the ReadAffy command, where I specified
 the filenames to be read from my AnnotatedDataFrame object.  There was a
 typo error with a capital N ($FileName) rather than lowercase n
 ($Filename) as in my target file..whoops.  However this meant the
 filename argument was ignored without the error message(!) and instead
 of using the information in the AnnotatedDataFrame object (which
 included filenames, but not alphabetically) it read the .cel files in
 alphabetical order from the working directory - hence the wrong file was
 given the wrong label 

Re: [R] Opening a script with the R editor via file association (on Windows)

2007-08-03 Thread Duncan Murdoch
On 03/08/2007 7:16 PM, Christopher Green wrote:
 Is there an easy way to open an R script file in the R Editor found in
 more recent versions of R on Windows via a file association? I am looking
 for functionality akin to how the .ssc file extension works for S-Plus:
 upon double-clicking on a .R file, Rgui.exe starts up and loads the script 
 file in the R Editor.
 
 As far as I can tell, Rgui.exe does not have a command line option to load
 a file (so associating .R with Rgui.exe %1 won't work). I can get Windows
 to start Rgui.exe when I double-click on a script file, but that's about it.
 I also don't see any way to have Rgui.exe evaluate an expression provided on
 the command line (which would allow file.edit(%1)). I also thought about
 creating a custom .First calling 'file.edit' in a batch file, but then I'd 
 have
 to start R, load the .First file, then quit and restart R, so that's out.
 
 Is there an easy way to do this without resorting to some other R GUI?

Easy?  Not sure.  But the following works:

Set up the association as

F:\R\R-2.5.1\bin\Rgui.exe --args %1

(with obvious modifications to the path) and put this line in your 
RHOME/etc/Rprofile.site file:

utils::file.edit(commandArgs(TRUE))

You could make things more sophisticated if you don't want a blank edit 
window to open in case you're not using this shortcut.

Duncan Murdoch

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


Re: [R] ggplot2 qplot and add

2007-08-03 Thread hadley wickham
On 8/2/07, Emilio Gagliardi [EMAIL PROTECTED] wrote:
 Hi Thierry and Hadley,

 Thanks for your help! I got it working almost 100% to what I want. My last
 questions are simple I think ;)
 1) How can I pass a label to colour and assign the color at the same time?
 The auto-selection of colors is awesome for learning, but makes it harder to
 see some patterns.

I'm not sure what you mean?  Could you provide an example?

 2) in regards to 1), where can I find a list of the possible values that can
 be passed to colour=?  I've seen in some examples gray50 but when I try
 it, it doesn't come out gray50, it just prints that as the label.  For
 example, in my case, I could have 4 colors with 4 different shades of each.
 Or maybe I can use word length and gray scale, and make longer words darker,
 etc...

I will try and explain this more in the book - but there's a
difference between mapping and setting.  In qplot values are always
mapped (this is usually what you want - you want to specify the raw
values and have them automatically mapped to sensible visual
properties).  If you manually add on geoms you can map or set:

 * mapping:  + geom_point(aes(colour = Treatment A))
 * setting: + geom_point(colour = green)

Note in the second case, the colour must be a valid R colour.

Hadley

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


[R] request

2007-08-03 Thread zahid khan
 I want to calculate the commulative sum of any numeric vector with the 
following command but this following command does not work  comsum
  My question is , how we can calculate the commulative sum of any numeric 
vector with above command
  Thanks


Zahid Khan
Lecturer in Statistics
Department of Mathematics
Hazara University Mansehra.
   
-

[[alternative HTML version deleted]]

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


Re: [R] request

2007-08-03 Thread Stephen Tucker
?cumsum

--- zahid khan [EMAIL PROTECTED] wrote:

  I want to calculate the commulative sum of any numeric vector with the
 following command but this following command does not work  comsum
   My question is , how we can calculate the commulative sum of any numeric
 vector with above command
   Thanks
 
 
 Zahid Khan
 Lecturer in Statistics
 Department of Mathematics
 Hazara University Mansehra.

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


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


Re: [R] Sorting data for multiple regressions

2007-08-03 Thread Prof Brian Ripley
Well, R has a by() function that does what you want, and its help page 
contains an example of doing regression by group.

(There are other ways.)

On Fri, 3 Aug 2007, Paul Young wrote:

 So I am trying to perform a robust regression (fastmcd in the robust
 package) on a dataset and I want to perform individual regressions based

fastmcd does not do regression ... or I would have adapted the ?by 
example to show you.

 on the groups within the data.  We have over 300 sites and we want to
 perform a regression based on the day of week and the hour for every
 site.  I was wondering if anyone knows of a 'by' command similar to the
 one used in SAS that automatically groups the data for the regressions.
 If not, does anyone have any tips on how to split the data into smaller
 sets and then perform the regression on each set.  I am new to R, so I
 don't know all of the common work arounds and such.  At the moment the
 only method I can think of is to split the data using condition
 statements and manually running the regression on each set.  Thanks or
 your help

 -Paul


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

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