Re: [R] Zipping Rdata Files

2005-04-08 Thread Prof Brian Ripley
On Thu, 7 Apr 2005 [EMAIL PROTECTED] wrote:
Saving Rdata files in a zip archive form can in some cases save a
considerable amount of disk space.
Not if they were saved with compress=TRUE: it is likely to increase the 
size of compressed saved images.

R has the zip.file.extract function to extract files from zip archives, 
but appears not to have any corresponding function to save in zipped 
form. (At least I have not been able to find anything in the help files 
or through searching the mail archives.)
That is true, but I think you are looking for gzip format.  If you want 
zip format, just use a system call to zip (if you have it). 
zip.file.extract is provided only because R for Windows needs to unzip on 
systems without unzip.  (On other platforms it calls unzip.)

The system function can be used to call gzip or some other utility, but 
perhaps there is a more direct method.
Yes, for gzip (not zip).  gzfile() connections, as used by 
save(compress=TRUE) and by load().

Also, when I use gzip to zip a file, I get an error message when using
That's because gzip gzips a file, not zips a file.  gzip and zip are 
different formats.

zip.file.extract to extract the file as follows:
 save(trips, file=trips.Rdata)
 system(gzip trips.Rdata)  # saves trips.Rdata in an archive
named trips.Rdata.gz
 load(zip.file.extract(trips.Rdata, trips.Rdata.gz))
[1] trips.Rdata
Warning message:
error 1 in extracting from zip file
Setting options(unzip=gunzip) or options(unzip=gunzip.exe) does not
solve the error.
 load(zip.file.extract(trips.Rdata, trips.Rdata.gz))
Error in open.connection(con, rb) : unable to open connection
In addition: Warning message:
cannot open compressed file `trips.Rdata'
Of course I could reverse the process with,
system(gunzip trips.Rdata.gz)
load(trips.Rdata)
but perhaps there is a simpler solution.
P.S. I'm running R 2.0.1 on a Windows XP computer.
--
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


Re: [R] hex format

2005-04-08 Thread Martin Maechler
 David == David Forrest [EMAIL PROTECTED]
 on Thu, 7 Apr 2005 16:19:33 -0500 (CDT) writes:





David I think R has the hex to decimal OK, but might be
David lacking in the decimal to hex case

David zz-function(x){ x-as.numeric(sub(#,'0x',x));
David c(x%/%256^2, x%/%256%%256, x%%256) }

 zz('#0f0e0d')
David [1] 15 14 13
 zz('#ff0080')
David [1] 255 0 128

I think you have overlooked  the  col2rgb() function
which does this (and more).

David If you already have the 3 byte triplet in read in as
David a binary, the same integer arithmetic does the
David extraction.

__
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


Re: [R] /bin/exec/R: No such file or directory

2005-04-08 Thread Uwe Ligges
Jarmila Bohmanova wrote:
I have just installed R-2.0.1 from R-2.0.1.tar.gz on SUSe 9.1 64bit. When I
am trying to launch R: R_HOME_DIR/bin/R; I am getting following message:
./R: line 151: /R_HOME_DIR/bin/exec/R: No such file or directory
./R: line 151: exec: /R_HOME_DIR/bin/exec/R: cannot execute: No such file or
directory
I do not have exec directory in bin directory. Does anybody know what went
wrong?

Looks like make failed.
What was the error message from ./configure and/or make?
Uwe Ligges

Thank you.
Jarmila.
Jarmila Bohmanova
University of Georgia
Department of Animal and Dairy Science
Athens, GA
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-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


Re: [R] Adapt Function Examples

2005-04-08 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:
I have read the help file for Adapt, but I cannot
create a functn that works.  I believe this is because
I do not understand how to do this, and I have not
found any working examples posted in the help.  I have
recieved many different errors in my attempts.
Please post a simple but working use of the adapt
function in 2 dimensions other than the one in the
help(adapt) or explain it differently.  
So we are talking about function adapt() in package adapt?
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
Please specify a simple example of what you are going to do and specify 
a non-working piece of code. Nobody wants to rephrase a help page not 
knowing whether it will help or not.

Uwe Ligges


Thank you
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-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


Re: [R] NA in table with integer types

2005-04-08 Thread Prof Brian Ripley
NaN only applies to double values: there is no integer NaN (nor Inf nor 
-Inf).  The difference is clear from

factor(x, exclude=NaN)
[1] 1233NA
Levels: 1 2 3 NA
factor(as.integer(x), exclude=NaN)
[1] 1233NA
Levels: 1 2 3
If you read ?factor it says
 exclude: a vector of values to be excluded when forming the set of
  levels. This should be of the same type as 'x', and will be
  coerced if necessary.
and as.integer(NaN) is integer NA.  So  factor(as.integer(x), exclude=NaN) 
is the same as  factor(as.integer(x), exclude=NA).

On Thu, 7 Apr 2005, Paul Rathouz wrote:
Hi -- I am having the following problem with table() when applied to
vectors of type (mode) integer.  When I use the table() command, I can
*only obtain an entry in the table for NA values by using exclude=NULL*.
Just issuing exclude=NaN will not do it.  See below, where x is double at
first, and then coerced to integer and notice the difference.  Is this a
bug or is there something that I do not understand about the integer data
type?  That is, is there some other value besides NA and NaN that missing
integers take? Thanks -- pr
--
x - c(1,2,3,3,NA)
is.double(x)
[1] TRUE
table(x,exclude=NA)
x
1 2 3
1 1 2
table(x,exclude=NaN)
x
  123 NA
  1121
table(x,exclude=NULL)
x
  123 NA
  1121
x - as.integer(x)
x
[1]  1  2  3  3 NA
is.na(x)
[1] FALSE FALSE FALSE FALSE  TRUE
is.integer(x)
[1] TRUE
table(x,exclude=NA)
x
1 2 3
1 1 2
table(x,exclude=NaN)
x
1 2 3
1 1 2
table(x,exclude=NULL)
x
  123 NA
  1121
--
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


[R] weird results w/ prcomp-princomp

2005-04-08 Thread Alessandro Bigi
I am doing a Principal Component Analaysis (PCA) on a 44x19 matrix.
with
 princomp(x,cor=TRUE,scores=TRUE)
and
 prcomp(x,scale=TRUE,center=TRUE)
The resulted eigenv. and rotated matrix are the same (as expected), however 
the sum of eigenvalues is lower than 19 (number of variables).

With a commercial stat software it worked correctly, with the same dataset.
Am I doing something wrong?
Thanks
Alex

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
__
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


Re: [R] weird results w/ prcomp-princomp

2005-04-08 Thread Jari Oksanen
On Fri, 2005-04-08 at 11:12 +0200, Alessandro Bigi wrote:
 I am doing a Principal Component Analaysis (PCA) on a 44x19 matrix.
 with
   princomp(x,cor=TRUE,scores=TRUE)
 and
   prcomp(x,scale=TRUE,center=TRUE)
 The resulted eigenv. and rotated matrix are the same (as expected), however 
 the sum of eigenvalues is lower than 19 (number of variables).
 
What about the sum of squared sdev? (Hint, the prcomp help page says
that the returned sdev are the square root of the eigenvalues. While
princomp help does not say this explicitly, it says that sdev are
standard deviations).

cheers, jari oksanen
-- 
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
Ph. +358 8 5531526, cell +358 40 5136529, fax +358 8 5531061
email [EMAIL PROTECTED], homepage http://cc.oulu.fi/~jarioksa/

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


[R] Can't get function to run iteratively

2005-04-08 Thread Uzuner, Tolga
Trying to do something very simple...

 numerical.grad
function(func,x, eps=1e-12) {
#  very simple (crude) numerical approximation
  f -func(x)
  df -1:length(x)
  for (i in 1:length(x)) {
dx - x
dx[i] - dx[i] +eps 
df[i] - (func(dx)-f)/eps
   }
df
}
 test-function(x){x^2}
 y-seq(0.1,0.5,0.1)
 numerical.grad(test,y)
[1] 0.197 0.000 0.000 0.000 0.000
Warning messages: 
1: number of items to replace is not a multiple of replacement length 
2: number of items to replace is not a multiple of replacement length 
3: number of items to replace is not a multiple of replacement length 
4: number of items to replace is not a multiple of replacement length 
5: number of items to replace is not a multiple of replacement length 
 


Any thoughts why this doesn't seem to be working ?


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.

__
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


Re: [R] Can't get function to run iteratively

2005-04-08 Thread Dimitris Rizopoulos
R is a vectorized language, look at this:
fd - function(b, gn, ..., eps=sqrt(.Machine$double.neg.eps)){
   n - length(b)
   g0 - gn(b, ...)
   out - numeric(n)
   b. -  b + eps*max(abs(b), 1)
   c(gn(b., ...) - g0) / (b. - b)
}
##
test - function(x) x*x
fd(seq(0.1, 0.5, 0.1), test)
2*seq(0.1, 0.5, 0.1)
I hope it helps.
Best,
Dimitris

Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message - 
From: Uzuner, Tolga [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, April 08, 2005 12:08 PM
Subject: [R] Can't get function to run iteratively


Trying to do something very simple...
numerical.grad
function(func,x, eps=1e-12) {
#  very simple (crude) numerical approximation
 f -func(x)
 df -1:length(x)
 for (i in 1:length(x)) {
   dx - x
   dx[i] - dx[i] +eps
   df[i] - (func(dx)-f)/eps
  }
df
}
test-function(x){x^2}
y-seq(0.1,0.5,0.1)
numerical.grad(test,y)
[1] 0.197 0.000 0.000 0.000 0.000
Warning messages:
1: number of items to replace is not a multiple of replacement 
length
2: number of items to replace is not a multiple of replacement 
length
3: number of items to replace is not a multiple of replacement 
length
4: number of items to replace is not a multiple of replacement 
length
5: number of items to replace is not a multiple of replacement 
length


Any thoughts why this doesn't seem to be working ?
==
This message is for the sole use of the intended recipient. If you 
received
this message in error please delete it and notify us. If this 
message was
misdirected, CSFB does not waive any confidentiality or privilege. 
CSFB
retains and monitors electronic communications sent through its 
network.
Instructions transmitted over this system are not binding on CSFB 
until they
are confirmed by us. Message transmission is not guaranteed to be 
secure.

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

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


Re: [R] off-topic question: Latex and R in industries

2005-04-08 Thread Rolf Turner

Donald Ingram wrote:
 
 ( Is there a universal vector format I could use ? )

If there were one, you can be sure that Microsoft would take
steps to corrupt their implementation of the ``universal''
format so that material produced by non-Microsoft software
would be unusable by Microsoft software.

Microsoft's goal is to create an effective ***monopoly*** for
themselves.  People being the idiots that they are, Microsoft
is succeeding admirably.

 My problems - are not R but with general UNIX - PC interoperability

This terminology is incorrect and misleading.  It is not a
``PC'' problem --- the PC is the hardware on which any
software/operating system can run.  UNIX (in the guise of
Linux) runs on PCs.  The problem is the Micrsoft Windoze
operating system, which goes out of its way to be
incompatible with everything else.

cheers,

Rolf Turner
[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


RE: [R] /bin/exec/R: No such file or directory

2005-04-08 Thread Jarmila Bohmanova
Make gives me following error message:

R_HOME_DIR/src/main/array.c:504: undefined reference to `zgemm'
array.o(.text+0x2526): In function `do_matprod':
R_HOME_DIR/src/main/array.c:472: undefined reference to `dsyrk'
array.o(.text+0x2601):R_HOME_DIR/src/main/array.c:487: undefined reference
to `dgemm'
array.o(.text+0x2667):R_HOME_DIR/src/main/array.c:432: undefined reference
to `zgemm'
array.o(.text+0x27f0):R_HOME_DIR/src/main/array.c:405: undefined reference
to `dgemm'
registration.o(.data+0xb8): undefined reference to `cg'
registration.o(.data+0xe0): undefined reference to `ch'
registration.o(.data+0x108): undefined reference to `rg'
registration.o(.data+0x130): undefined reference to `rs'
../appl/libappl.a(bakslv.o)(.text+0x12a): In function `bakslv':
R_HOME_DIR/src/appl/bakslv.c:108: undefined reference to `dtrsm'
../appl/libappl.a(uncmin.o)(.text+0x15e5): In function `secunf':
R_HOME_DIR/src/appl/uncmin.c:1187: undefined reference to `dnrm2'
../appl/libappl.a(uncmin.o)(.text+0x15fd):R_HOME_DIR/src/appl/uncmin.c:1188:
undefined reference to `dnrm2'
../appl/libappl.a(uncmin.o)(.text+0x1abb): In function `secfac':
R_HOME_DIR/src/appl/uncmin.c:1271: undefined reference to `dnrm2'
../appl/libappl.a(uncmin.o)(.text+0x1ade):R_HOME_DIR/src/appl/uncmin.c:1272:
undefined reference to `dnrm2'
../appl/libappl.a(uncmin.o)(.text+0x3859): In function `optdrv':
R_HOME_DIR/src/appl/uncmin.c:970: undefined reference to `dnrm2'
../appl/libappl.a(uncmin.o)(.text+0x3bb6):R_HOME_DIR/src/appl/uncmin.c:1016:
more undefined references to `dnrm2' follow
../appl/libappl.a(blas.o)(.text+0x21e0): In function `DGBMV':
R_HOME_DIR/src/appl/blas.f:357: undefined reference to `XERBLA'
../appl/libappl.a(blas.o)(.text+0x41c6): In function `DGEMM':
R_HOME_DIR/src/appl/blas.f:682: undefined reference to `XERBLA'
../appl/libappl.a(blas.o)(.text+0x642e): In function `DGEMV':
R_HOME_DIR/src/appl/blas.f:940: undefined reference to `XERBLA'
../appl/libappl.a(blas.o)(.text+0x7ab2): In function `DGER':
R_HOME_DIR/src/appl/blas.f:1171: undefined reference to `XERBLA'
../appl/libappl.a(blas.o)(.text+0xaf29): In function `DSBMV':
R_HOME_DIR/src/appl/blas.f:1794: undefined reference to `XERBLA'
../appl/libappl.a(blas.o)(.text+0xda14):R_HOME_DIR/src/appl/blas.f:2177:
more undefined references to `XERBLA' follow
collect2: ld returned 1 exit status
make[3]: *** [R.bin] Error 1
make[3]: Leaving directory `R_HOME_DIR/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `R_HOME_DIR/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `R_HOME_DIR/src'
make: *** [R] Error 1




-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 08, 2005 3:19 AM
To: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] /bin/exec/R: No such file or directory

Jarmila Bohmanova wrote:

 I have just installed R-2.0.1 from R-2.0.1.tar.gz on SUSe 9.1 64bit. When
I
 am trying to launch R: R_HOME_DIR/bin/R; I am getting following message:
 ./R: line 151: /R_HOME_DIR/bin/exec/R: No such file or directory
 ./R: line 151: exec: /R_HOME_DIR/bin/exec/R: cannot execute: No such file
or
 directory
 
 I do not have exec directory in bin directory. Does anybody know what went
 wrong?


Looks like make failed.
What was the error message from ./configure and/or make?

Uwe Ligges



 Thank you.
 Jarmila.
 
 
 Jarmila Bohmanova
 University of Georgia
 Department of Animal and Dairy Science
 Athens, GA
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

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


[R] is there any function to do oblique rotation in factor analysis?

2005-04-08 Thread ronggui
splus  has many different rotation methods,but i can only find 2 in R.i want to 
do oblique rotation .has any function for this?
i have search the web,but can not find.

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


[R] TR: The results of your email commands

2005-04-08 Thread Kervahu Anne

Hi,

I try to minimize the sum of the sum of sce. The following program has
been
created but it only takes in consideration the last kinetic and not the
first ones. I think that I have forget a subscrib but I don't know
where. so
if you can help me, it will be great
I have try an other program where y and x are directly calculate in sce
function but the time of running was to long.
Thanks in advance,
Anne KERVAHU

rm(list=ls())
nbr=10
#list of data
x_a-c(0,0.5,1,1.5,2,3,4,6,8,15,20,40,60,80,120)
 
y_a-c(5.4771213,5.0791812,4.8450980,4.3010300,4,2.30103,1.5563025,1.30103,1
,1.6434527,0.60206,0.60206,0.30103,0,0.4771213)
x_b-c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)
 
y_b-c(5.3424227,4.9867717,4.6627578,4.0606978,3.07182,3.4771213,2.7993405,2
 
.9395193,2.69897,2.6127839,1.9777236,1.3222193,1.4149733,0.7781513,1.322219)

x_c-c(0,3,6,10,12,14,16,18,20,24,26,28,30,34)
 
y_c-c(5.5185139,5.1461280,4.3617278,3.771513,3.20412,3.0413927,2.7781513,2.
5682017,2.255272,1.7823917,1.447158,1.3222193,1.2787536,0.69897)

#number of kinetics
nb=3

#complete data set
x-c(x_a,x_b,x_c)
y-c(y_a,y_b,y_c)

#cumulative length 
long-c(0,15,30,44)

coeff-matrix(nrow=1,ncol=(nb*2)+2)

#function to minimise
sce-function(param){
return(sum(sum((yy-(param[i+nb]-(xx/param[i])^param[(nb*2)+1]))^2)))
}

#initial value for optim function
ninit-vector(length=nb)
for(i in 1:nb){
ninit[i]-x[long[i]+1]
}

pinf=c(rep(0.01,nb),rep(3,nb),0.5)
psup=c(rep(10,nb),rep(8,nb),4)

pinit=c(runif(nb,min=0.1,max=5),ninit,runif(1,min=0.5,max=4))
print(pinit)

for (i in 1:nb)
{
yy-y[((long[i]+1):long[i+1])]
for( k in 1:length(yy)){
 
ifelse((yy[k]=log10(nbr)),(yy-yy[1:(min(which(yy=log10(nbr),arr.ind=FALSE
))-1)]),(yy-yy))
}
vv-x[((long[i]+1):long[i+1])]
xx-x[((long[i]+1):((long[i]+1)+(length(vv)=length(yy))-1))]
fl-optim(p=pinit,sce,method=L-BFGS-B,lower=pinf,upper=psup,
control=list(maxit=20,temp=200))
co-fl$par
coe-fl$value
coeff-c(co,coe)
}
coeff

#graphical verification
plot(x_b,y_b)
y_est-coeff[6]-(x_b/coeff[2])^coeff[7]
points(x_b,y_est)




---BeginMessage---

Hi,

I try to minimize the sum of the sum of sce. The following program has been
created but it only takes in consideration the last kinetic and not the
first ones. I think that I have forget a subscrib but I don't know where. so
if you can help me, it will be great
I have try an other program where y and x are directly calculate in sce
function but the time of running was to long.

Thanks in advance,

Anne KERVAHU

rm(list=ls())
nbr=10

#list of data
x_a-c(0,0.5,1,1.5,2,3,4,6,8,15,20,40,60,80,120)
y_a-c(5.4771213,5.0791812,4.8450980,4.3010300,4,2.30103,1.5563025,1.30103,1
,1.6434527,0.60206,0.60206,0.30103,0,0.4771213)

x_b-c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)
y_b-c(5.3424227,4.9867717,4.6627578,4.0606978,3.07182,3.4771213,2.7993405,2
.9395193,2.69897,2.6127839,1.9777236,1.3222193,1.4149733,0.7781513,1.3222193
)

x_c-c(0,3,6,10,12,14,16,18,20,24,26,28,30,34)
y_c-c(5.5185139,5.1461280,4.3617278,3.771513,3.20412,3.0413927,2.7781513,2.
5682017,2.255272,1.7823917,1.447158,1.3222193,1.2787536,0.69897)

#number of kinetics
nb=3

#complete data set
x-c(x_a,x_b,x_c)
y-c(y_a,y_b,y_c)

#cumulative length 
long-c(0,15,30,44)

coeff-matrix(nrow=1,ncol=(nb*2)+2)

#function to minimise
sce-function(param){
return(sum(sum((yy-(param[i+nb]-(xx/param[i])^param[(nb*2)+1]))^2)))
}

#initial value for optim function
ninit-vector(length=nb)
for(i in 1:nb){
ninit[i]-x[long[i]+1]
}

pinf=c(rep(0.01,nb),rep(3,nb),0.5)
psup=c(rep(10,nb),rep(8,nb),4)

pinit=c(runif(nb,min=0.1,max=5),ninit,runif(1,min=0.5,max=4))
print(pinit)

for (i in 1:nb)
{
yy-y[((long[i]+1):long[i+1])]
for( k in 1:length(yy)){
ifelse((yy[k]=log10(nbr)),(yy-yy[1:(min(which(yy=log10(nbr),arr.ind=FALSE
))-1)]),(yy-yy))
}
vv-x[((long[i]+1):long[i+1])]
xx-x[((long[i]+1):((long[i]+1)+(length(vv)=length(yy))-1))]
fl-optim(p=pinit,sce,method=L-BFGS-B,lower=pinf,upper=psup,
control=list(maxit=20,temp=200))
co-fl$par
coe-fl$value
coeff-c(co,coe)
}
coeff

#graphical verification
plot(x_b,y_b)
y_est-coeff[6]-(x_b/coeff[2])^coeff[7]
points(x_b,y_est)
---End Message---
__
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

RE: [R] 'skewing' a normal random variable

2005-04-08 Thread Mohammad A. Chaudhary
Hi: Thank you and sorry for getting back late. Your input helped me a
lot. I particularly liked using box.cox. Regards,
Ashraf

__
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


Re: [R] NA in table with integer types

2005-04-08 Thread Paul Rathouz

OK.  Thanks.  So, if you use table() on a factor that contains NA's, but
for which NA is not a level, is there any way to get table to generate an
entry for the NAs?  For example, in below, even exclude=NULL will not
give me an entry for NA on the factor y:

 x - c(1,2,3,3,NA)
 y - factor(x)
 y
[1] 1233NA
Levels: 1 2 3
 table(y,exclude=NA)
y
1 2 3
1 1 2
 table(y,exclude=NaN)
y
1 2 3
1 1 2
 table(y,exclude=NULL)
y
1 2 3
1 1 2

On Fri, 8 Apr 2005, Prof Brian Ripley wrote:

 NaN only applies to double values: there is no integer NaN (nor Inf nor
 -Inf).  The difference is clear from

  factor(x, exclude=NaN)
 [1] 1233NA
 Levels: 1 2 3 NA
  factor(as.integer(x), exclude=NaN)
 [1] 1233NA
 Levels: 1 2 3

 If you read ?factor it says

   exclude: a vector of values to be excluded when forming the set of
levels. This should be of the same type as 'x', and will be
coerced if necessary.

 and as.integer(NaN) is integer NA.  So  factor(as.integer(x), exclude=NaN)
 is the same as  factor(as.integer(x), exclude=NA).


[rest deleted]

==
Paul Rathouz, Assoc. Professor   ph   773-834-1970
Dept. of Health Studies, Rm. W-264   fax  773-702-1979
University of Chicago[EMAIL PROTECTED]
5841 S. Maryland Ave. MC 2007
Chicago, IL  60637

__
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


Re: [R] NA in table with integer types

2005-04-08 Thread Gabor Grothendieck
On Apr 8, 2005 9:05 AM, Paul Rathouz [EMAIL PROTECTED] wrote:
 
 OK.  Thanks.  So, if you use table() on a factor that contains NA's, but
 for which NA is not a level, is there any way to get table to generate an
 entry for the NAs?  For example, in below, even exclude=NULL will not
 give me an entry for NA on the factor y:
 
  x - c(1,2,3,3,NA)
  y - factor(x)
  y
 [1] 1233NA
 Levels: 1 2 3

summary(y)

__
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


Re: [R] NA in table with integer types

2005-04-08 Thread Prof Brian Ripley
On Fri, 8 Apr 2005, Paul Rathouz wrote:
OK.  Thanks.  So, if you use table() on a factor that contains NA's, but
for which NA is not a level, is there any way to get table to generate an
entry for the NAs?  For example, in below, even exclude=NULL will not
give me an entry for NA on the factor y:
I think this very clear from the help page:
 exclude: values to use in the exclude argument of 'factor' when
  interpreting non-factor objects; if specified, levels to
  remove from all factors in 
 Only when 'exclude' is specified (i.e., not by default), will
 'table' drop levels of factor arguments potentially.
and you cannot remove a level that is not there.
You seem to be persisting in not understanding: 'exclude' is supposed to 
be the same type as x (or its levels), and you have given logical and 
numeric values, not character ones.


x - c(1,2,3,3,NA)
y - factor(x)
y
[1] 1233NA
Levels: 1 2 3
table(y,exclude=NA)
y
1 2 3
1 1 2
table(y,exclude=NaN)
y
1 2 3
1 1 2
table(y,exclude=NULL)
y
1 2 3
1 1 2
On Fri, 8 Apr 2005, Prof Brian Ripley wrote:
NaN only applies to double values: there is no integer NaN (nor Inf nor
-Inf).  The difference is clear from
factor(x, exclude=NaN)
[1] 1233NA
Levels: 1 2 3 NA
factor(as.integer(x), exclude=NaN)
[1] 1233NA
Levels: 1 2 3
If you read ?factor it says
  exclude: a vector of values to be excluded when forming the set of
   levels. This should be of the same type as 'x', and will be
   coerced if necessary.
and as.integer(NaN) is integer NA.  So  factor(as.integer(x), exclude=NaN)
is the same as  factor(as.integer(x), exclude=NA).
[rest deleted]
==
Paul Rathouz, Assoc. Professor   ph   773-834-1970
Dept. of Health Studies, Rm. W-264   fax  773-702-1979
University of Chicago[EMAIL PROTECTED]
5841 S. Maryland Ave. MC 2007
Chicago, IL  60637
==

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


[R] anova with gam?

2005-04-08 Thread Bill Shipley
Hello. In SPLUS I am used to comparing nested models in gam using the
anova function.  When I tried this in R this doesn't work (the error
message says that anova() doesn't recognise the gam fit).  What must I
do to use anova with gam?  To be clear, I want to do the following:

fFit1-gam(y~x,.)

fit1-fam(y~s(x),.)

 

anova(fit2,fit1,test=F)

 

Thanks.

 

Bill Shipley

 


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


Re: [R] NA in table with integer types

2005-04-08 Thread Petr Pikal


On 8 Apr 2005 at 14:20, Prof Brian Ripley wrote:

 On Fri, 8 Apr 2005, Paul Rathouz wrote:
 
 
  OK.  Thanks.  So, if you use table() on a factor that contains NA's,
  but for which NA is not a level, is there any way to get table to
  generate an entry for the NAs?  For example, in below, even
  exclude=NULL will not give me an entry for NA on the factor y:

Hi

Use exclude in factor not in table

 x-sample(1:3, 10, replace=T)
 x[5:6]-NA
 table(x)
x
1 2 3 
5 2 1 
 y-factor(x)
 y
 [1] 1123NA NA 1121   
Levels: 1 2 3
 table(y) # no entry for NA
y
1 2 3 
5 2 1 
 factor(y,exclude=NULL) #make NA a level in factor y
 [1] 1123NA NA 1121   
Levels: 1 2 3 NA

 table(y) # shows you entry for NA
y
   123 NA 
   5212 





 
 I think this very clear from the help page:
 
   exclude: values to use in the exclude argument of 'factor' when
interpreting non-factor objects; if specified, levels to
remove from all factors in 
 
   Only when 'exclude' is specified (i.e., not by default), will
   'table' drop levels of factor arguments potentially.
 
 and you cannot remove a level that is not there.
 
 You seem to be persisting in not understanding: 'exclude' is supposed
 to be the same type as x (or its levels), and you have given logical
 and numeric values, not character ones.
 
 
 
  x - c(1,2,3,3,NA)
  y - factor(x)
  y
  [1] 1233NA
  Levels: 1 2 3
  table(y,exclude=NA)
  y
  1 2 3
  1 1 2
  table(y,exclude=NaN)
  y
  1 2 3
  1 1 2
  table(y,exclude=NULL)
  y
  1 2 3
  1 1 2
 
  On Fri, 8 Apr 2005, Prof Brian Ripley wrote:
 
  NaN only applies to double values: there is no integer NaN (nor Inf
  nor -Inf).  The difference is clear from
 
  factor(x, exclude=NaN)
  [1] 1233NA
  Levels: 1 2 3 NA
  factor(as.integer(x), exclude=NaN)
  [1] 1233NA
  Levels: 1 2 3
 
  If you read ?factor it says
 
exclude: a vector of values to be excluded when forming the set
of
 levels. This should be of the same type as 'x', and will
 be coerced if necessary.
 
  and as.integer(NaN) is integer NA.  So  factor(as.integer(x),
  exclude=NaN) is the same as  factor(as.integer(x), exclude=NA).
 
 
  [rest deleted]
 
  
  == Paul Rathouz, Assoc. Professor   ph   773-834-1970 Dept.
  of Health Studies, Rm. W-264   fax  773-702-1979 University of
  Chicago[EMAIL PROTECTED] 5841 S.
  Maryland Ave. MC 2007 Chicago, IL  60637
  
  ==
 
 
 
 -- 
 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

Petr Pikal
[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


RE: [R] anova with gam?

2005-04-08 Thread John Fox
Dear Bill,

There are anova.gam methods in both the mgcv and gam packages -- perhaps you
have an older version of one of these packages.

I hope this helps,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Bill Shipley
 Sent: Friday, April 08, 2005 8:31 AM
 To: R help list
 Subject: [R] anova with gam?
 
 Hello. In SPLUS I am used to comparing nested models in gam 
 using the anova function.  When I tried this in R this 
 doesn't work (the error message says that anova() doesn't 
 recognise the gam fit).  What must I do to use anova with 
 gam?  To be clear, I want to do the following:
 
 fFit1-gam(y~x,.)
 
 fit1-fam(y~s(x),.)
 
  
 
 anova(fit2,fit1,test=F)
 
  
 
 Thanks.
 
  
 
 Bill Shipley
 
  
 
 
   [[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

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


[R] error on install Rmpi packages

2005-04-08 Thread Marcelo Luiz de Laia
Dear Sir/Madam,
I need to install Rmpi Package on my linux debian like, but I get some 
errors.

I try to instal it using install.packages or after download and save it 
on my local dir and run R CMD INSTALL packagename and, both, I get these 
errors:

checking mpi.h usability... no
checking mpi.h presence... no
checking for mpi.h... no
Try to find mpi.h ...
Cannot find mpi header file.
Please use --with-mpi=/path/to/mpi
ERROR: configuration failed for package 'Rmpi'
I search on archivies help but dont get any issues.
I use Rmpi_0.4-9.tar.gz.
What I to do to fiz it?
Thanks
Marcelo
__
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


Re: [R] /bin/exec/R: No such file or directory

2005-04-08 Thread Uwe Ligges
Jarmila Bohmanova wrote:
Make gives me following error message:
R_HOME_DIR/src/main/array.c:504: undefined reference to `zgemm'
array.o(.text+0x2526): In function `do_matprod':
R_HOME_DIR/src/main/array.c:472: undefined reference to `dsyrk'
array.o(.text+0x2601):R_HOME_DIR/src/main/array.c:487: undefined reference
to `dgemm'
[SNIP]
So this is probably a problem with a BLAS installation choosen by 
./configure.

Uwe Ligges




-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 08, 2005 3:19 AM
To: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] /bin/exec/R: No such file or directory

Jarmila Bohmanova wrote:

I have just installed R-2.0.1 from R-2.0.1.tar.gz on SUSe 9.1 64bit. When
I
am trying to launch R: R_HOME_DIR/bin/R; I am getting following message:
./R: line 151: /R_HOME_DIR/bin/exec/R: No such file or directory
./R: line 151: exec: /R_HOME_DIR/bin/exec/R: cannot execute: No such file
or
directory
I do not have exec directory in bin directory. Does anybody know what went
wrong?

Looks like make failed.
What was the error message from ./configure and/or make?
Uwe Ligges


Thank you.
Jarmila.
Jarmila Bohmanova
University of Georgia
Department of Animal and Dairy Science
Athens, GA
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] restrict namespace inside functions?

2005-04-08 Thread Vivek Rao
Is there a way to exclude from the namespace all
variables other than function arguments and local
variables? For example, I would like the following
code
 
a = 2.0
mult - function(x)
{
   pi = 3.14
   return(pi*a*x)
}
print(mult(10.0))

to say a not found rather than using a = 2.0 inside
function mult. Thanks.
 
Vivek Rao

__
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


Re: [R] restrict namespace inside functions?

2005-04-08 Thread Deepayan Sarkar
On Friday 08 April 2005 09:50, Vivek Rao wrote:
 Is there a way to exclude from the namespace all
 variables other than function arguments and local
 variables? For example, I would like the following
 code

 a = 2.0
 mult - function(x)
 {
pi = 3.14
return(pi*a*x)
 }
 print(mult(10.0))

 to say a not found rather than using a = 2.0 inside
 function mult. Thanks.

Depending on why you want to do this, it might be enough to say

environment(mult) - new.env(parent = NULL)

HTH,

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


[R] DLL Memory Problem

2005-04-08 Thread Brian Habing
Hello,
I have created a .dll file using G77 and MinGW on my PC (Windows 
2000).  After using dyn.load to bring it into R2.0.1, I then call the .dll 
through the function ccprox shown below.  It returns the correct 
values.  If I run it a second time though it returns different values, so 
it seems something is being placed oddly in memory.

If I unload and reload the .dll it works again the first time.
It does the same if I copy the compiled .dll over to my Windows XP machine.
Thank you for any help,
Brian Habing
[EMAIL PROTECTED]
The Fortran subroutine beings with:
subroutine ccprox(nexmn,nitem,respmat2,covmatr,covmatt,
 $   cormatr,cormatt)
!c This subroutine will calculate all the pairwise
!c conditional covariances. An ending r means for
!c rest score, an ending t means for total score.
parameter (maxitem=100,maxexmn=1,maxcats=10,ncells=1001)
!c  ncells must be maxitem*maxcats+1
integer nexmn,nitem,scoretemp,mscore
integer respmat(maxexmn,maxitem)
integer tscore(maxexmn) /maxexmn*0/
integer tstemp(maxexmn) /maxexmn*0/
integer natscore(ncells) /ncells*0/
integer natemp(ncells) /ncells*0/
integer i,j,k,l
integer tcountt,tcountr,tcountt2,tcountr2
real*8 respmat2(maxexmn,maxitem)
real*8 pisum(ncells),plsum(ncells),pilsum(ncells)
real*8 qisum(ncells),qlsum(ncells),qilsum(ncells)   
real*8 pi2sum(ncells),pl2sum(ncells)
real*8 qi2sum(ncells),ql2sum(ncells)
real*8 covmatr(maxitem,maxitem),cormatr(maxitem,maxitem)
real*8 covmatt(maxitem,maxitem),cormatt(maxitem,maxitem)
real*8 sisl
The R function that is calling it is as follows (inputdata is a 400x10 
matrix of 0's and 1's
in the example I have been trying).

ccprox-function(inputdata){
  nexmn-length(inputdata[,1])
  nitem-length(inputdata[1,])
  covmatr-matrix(0,100,100)
  covmatt-matrix(0,100,100)
  cormatr-matrix(0,100,100)
  cormatt-matrix(0,100,100)
  respmat2-matrix(0,nrow=1,ncol=100)
  respmat2[1:nexmn,1:nitem]-as.matrix(inputdata)
  if (is.loaded(ccprox_)==TRUE){
  x-(.C(ccprox_,as.integer(nexmn),as.integer(nitem),respmat2,
  covmatr,covmatt,cormatr,cormatt))
  list(covmatr=x[[4]][1:nitem,1:nitem],covmatt=x[[5]][1:nitem,1:nitem],
  cormatr=x[[6]][1:nitem,1:nitem],cormatt=x[[7]][1:nitem,1:nitem],)
}
  else{
warning(ccprox.dll was not loaded)
NULL
  }
}
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] kunamorph@web.de

2005-04-08 Thread Christfried Kunath
Hello,
how can I use the function cor() with x and y in function 
aggregate() or by()?

The data are like this:
x   y   group
1   4   B
2   4   B
3   5   C
I would like obtain the correlation between x and y for each subset. I 
don't want to use the workaround with the function subset(), because I 
have many groups.

Thanks in advance.
Christfried Kunath KC
__
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


Re: [R] hex format

2005-04-08 Thread Earl F. Glynn
Thomas Lumley [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Yes, and convertColor in R-devel does quite a few of these (XYZ
 tristimulus space; CIE Lab and Luv; sRGB, Apple RGB and roll-your-own
 RGB based on chromaticities of the primaries; and chromatic adaptation for
 changing the white point).  The colorspace package has a more elegant
 implementation of a somewhat different set of color space computations,
 and R-devel also has hcl() for specifying colors based on hue, chroma, and
 luminance (polar coordinates in Luv space).

Thank you for this info.

I struggle to keep up with what is on CRAN and in Bioconductor, so I haven't
looked at the newer packages in R-devel.  Both convertColor and
colorspace look interesting and I'll definitely investigate them.

I see the latest (first?) version of colorspace was introduced in January
2005 and provides functions hex, hex2RGB, readhex and writehex, and these
functions seem to address my color concerns.  But I was using color
manipulations as an example of a need for more general capapabilities in R
to do these hex conversions when needed, and without a special package.

I recently discovered R's writeBin and readBin functions.  readBin, in
particular, looks like an extremely powerful tool for loading external
files.  This might be an easier way to perform some one-time data
manipulations instead of writing a separate C, Perl or Delphi program to
manipulate data before bringing it into R for analysis.

readBin returns a raw data type that looks like an array of bytes that R
displays in hex. That's where my problem begins and why I joined this hex
format thread.

I'd love to manipulate this raw  hex data, but R makes using these hex bytes
quite difficult to use (or more difficult than I think it should be based on
how easy it is in other languages).  I might want to interpret a byte, or a
string of bytes, as characters.  Or, I might want to interpret pairs of
bytes as 2-byte unsigned (or possibly signed) integers.  Or, I might want to
interpret 3-bytes at a time as RGB values (in either RGB or BGR order). Or,
I might want to interpret 8-bytes at a type as a IEEE754 floating point
number.

Every time someone wants to manipulate this raw data in R, as far as I can
tell now, one must start from scratch and do all sorts of manipulations on
these hex byte values to get characters, or integers, or doubles. And
because it's not that easy (but it's not that hard either, more of an
annoyance), I guess many just go back to C to get that job done there and
then return to R.

Perhaps I've missed some R functions that do this conversion, but if not, I
suggest some new functions that take an array of raw bytes like this, and
return either a single value, or an array of values, under a given
interpretation would be a useful addition to R for working with raw data
(like flow cytometery data -- 
http://www.softflow.com/sf_www/fcap/Fcsformt.htm, or even TIFF files, or
other forms of scientific data).


Examples of  writeBin/readBin:
# Integers
 IntegerSize - 4# How do I get this value from R?

 i - -2:2

 i

[1] -2 -1  0  1  2



 writeBin(i, big.bin, endian=big)

 big - readBin(big.bin, raw, length(i)*IntegerSize)

 big

 [1] ff ff ff fe ff ff ff ff 00 00 00 00 00 00 00 01 00 00 00 02

 typeof(big)
[1] raw


 writeBin(i, little.bin, endian=little)

 little - readBin(little.bin, raw, length(i)*IntegerSize)

 little

 [1] fe ff ff ff ff ff ff ff 00 00 00 00 01 00 00 00 02 00 00 00



#Doubles

 DoubleSize - 8

 x - 10^(-2:2)

 x

[1] 1e-02 1e-01 1e+00 1e+01 1e+02



 writeBin(x, big.bin, endian=big)

 big - readBin(big.bin, raw, length(x)*DoubleSize)

 big

 [1] 3f 84 7a e1 47 ae 14 7b 3f b9 99 99 99 99 99 9a 3f f0 00 00 00 00 00 00
40 24 00 00 00 00 00 00 40 59 00 00 00 00 00 00




 writeBin(x, platform.bin, endian=.Platform$endian)

 platform - readBin(platform.bin, raw, length(x)*DoubleSize)

 platform

 [1] 7b 14 ae 47 e1 7a 84 3f 9a 99 99 99 99 99 b9 3f 00 00 00 00 00 00 f0 3f
00 00 00 00 00 00 24 40 00 00 00 00 00 00 59 40

 y - readBin(platform.bin, double, length(x)*DoubleSize)

 y

[1] 1e-02 1e-01 1e+00 1e+01 1e+02





efg

__
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


Re: [R] DLL Memory Problem - Solved

2005-04-08 Thread Brian Habing
At 11:04 AM 4/8/2005, you wrote:
Hello,
I have created a .dll file using G77 and MinGW on my PC (Windows 
2000).  After using dyn.load to bring it into R2.0.1, I then call the .dll 
through the function ccprox shown below.  It returns the correct 
values.  If I run it a second time though it returns different values, so 
it seems something is being placed oddly in memory.

The Fortran subroutine beings with:
integer tscore(maxexmn) /maxexmn*0/
integer tstemp(maxexmn) /maxexmn*0/
integer natscore(ncells) /ncells*0/
integer natemp(ncells) /ncells*0/
These are only reset to zero the first time when its loaded.  Putting the 
reset manually in the Fortran code fixes it.  Thanks to anyone who had been 
thinking about it!

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


Re: [R] axis colors in pairs plot

2005-04-08 Thread Anne York
Thanks Bill and Deepayan for the panel function idea. 

Somehow I've always associated the panel
functions with lattice -- not sure why, but thanks for
pointing out their more universal applicability.

Anne
On Thu, 7 Apr 2005, Deepayan Sarkar wrote:

DS  On Thursday 07 April 2005 17:51, Anne York wrote:
DS   The following command produces red axis line in a pairs
DS   plot:
DS  
DS   pairs(iris[1:4], main = Anderson's Iris Data -- 3 species,
DS   pch = +, col = c(red, green3,  blue)[unclass(iris$Species)])
DS  
DS  
DS   Trying to fool pairs in the following  way  produces the
DS   same plot as above:
DS  
DS   pairs(iris[1:4], main = Anderson's Iris Data -- 3 species,pch =
DS   +, col = c(black, red, green3, blue)[ 1+
DS   unclass(iris$Species)])
DS  
DS   One very kludgy work-around is to define a new level 1, say
DS   foo in the first row of iris:
DS  
DS   iris2=iris
DS   iris2$Species = as.character(iris2$Species)
DS   iris2$Species[1]=foo
DS   iris2$Species = factor(iris2$Species)
DS  
DS   pairs(iris2[1:4], main = Anderson's Iris Data -- 3
DS   species, pch = +,
DS   col = c( black,red, green3,blue)[ unclass(iris2$Species)])
DS  
DS   However, if any other row is redefined, the red-axis
DS   persists. For example:
DS  
DS   iris2=iris
DS   iris2$Species = as.character(iris2$Species)
DS   iris2$Species[3]=foo
DS   iris2$Species = factor(iris2$Species)
DS  
DS  
DS   pairs(iris2[1:4], main = Anderson's Iris Data -- 3
DS   species, pch = +,
DS   col = c( black,red, green3,blue)[ unclass(iris2$Species)])
DS  
DS   I'd appreciate suggestions for a simpler work-around.
DS  
DS  One possibility is something along the lines of
DS  
DS  pairs(iris[1:4], 
DSpanel = function(...)
DSpoints(..., 
DS   col = c(red, green3, blue)
DS   [unclass(iris$Species)]  ))
DS  
DS  Deepayan
DS  
DS 

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


[R] BUG in RODBC with OS X?

2005-04-08 Thread Drew Balazs
This is my second posting on this topic, the first recieved no
replies.  Has anyone successfully used RODBC on the OS X platform? 
I've tested the ODBC drivers I'm using with two other applications and
I've had no problems.  I begining to think the problem is with R/RODBC
and not the drivers.

Here are the specifics:

I'm having a problem connecting to an MS SQL Database via RODBC on OS
X. If I try to connect through the GUI using  chan -
odbcConnect(drewdb, uid=user, pwd =pwd) it simply crashes R with
the following crash report:

Date/Time:  2005-03-28 12:30:48 -0600
OS Version: 10.3.8 (Build 7U16)
Report Version: 2

Command: R
Path:/Applications/R.app/Contents/MacOS/R
Version: 1.01 (1.01)
PID: 507
Thread:  0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x01fc

However, if I try it through an xterm (command line), I get the following:

Warning messages:
1: [RODBC] ERROR: state IM004, code 0, message [iODBC][Driver
Manager]Driver's SQLAllocEnv() failed
2: ODBC connection failed in: odbcDriverConnect(st, case = case,
believeNRows = believeNRows)

I'm reasonably sure the DSN is okay because I can use it to connect to
the DB with other applications.
Any suggestions?

-Drew

Specific Info:
 Machine Model:PowerBook5,6
 CPU Type: PowerPC G4  (1.2)
 Number Of CPUs:   1
 CPU Speed:1.67 GHz
 L2 Cache (per CPU):   512 KB
 Memory:   2 GB
 Bus Speed:167 MHz
 System Version:   Mac OS X 10.3.8 (7U16)
 Kernel Version:   Darwin 7.8.0
 Boot Volume:  Macintosh HD

R : Copyright 2004, The R Foundation for Statistical Computing
Version 2.0.1  (2004-11-15), ISBN 3-900051-07-0

__
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


Re: [R] weird results w/ prcomp-princomp

2005-04-08 Thread ronggui
R2.0.1
 x-matrix(rnorm(44*19),nrow=44)
 princomp(x,cor=TRUE,scores=TRUE)
Call:
princomp(x = x, cor = TRUE, scores = TRUE)

Standard deviations:
   Comp.1Comp.2Comp.3Comp.4Comp.5Comp.6Comp.7Comp.8
1.5874672 1.4652217 1.3088833 1.2339949 1.1697727 1.1402570 1.0774402 1.0458567
   Comp.9   Comp.10   Comp.11   Comp.12   Comp.13   Comp.14   Comp.15   Comp.16
1.0152164 0.9403912 0.8854087 0.8433314 0.7918201 0.7454395 0.6680463 0.6240805
  Comp.17   Comp.18   Comp.19
0.5752994 0.4873633 0.4205193

 19  variables and  44 observations.
 sum(princomp(x,cor=TRUE,scores=TRUE)$sdev^2)
[1] 19

it seems ok. 
On Fri, 08 Apr 2005 11:12:26 +0200
Alessandro Bigi [EMAIL PROTECTED] wrote:

 I am doing a Principal Component Analaysis (PCA) on a 44x19 matrix.
 with
   princomp(x,cor=TRUE,scores=TRUE)
 and
   prcomp(x,scale=TRUE,center=TRUE)
 The resulted eigenv. and rotated matrix are the same (as expected), however 
 the sum of eigenvalues is lower than 19 (number of variables).
 
 With a commercial stat software it worked correctly, with the same dataset.
 Am I doing something wrong?
 Thanks
 Alex
 
 
 
 -- 
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 
 
 
 
 
 -- 
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


correlation by group (was Re: [R] kunamorph@web.de)

2005-04-08 Thread Sundar Dorai-Raj

Christfried Kunath wrote on 4/8/2005 10:39 AM:
Hello,
how can I use the function cor() with x and y in function 
aggregate() or by()?

The data are like this:
x   y   group
1   4   B
2   4   B
3   5   C
I would like obtain the correlation between x and y for each subset. I 
don't want to use the workaround with the function subset(), because I 
have many groups.

Thanks in advance.
Christfried Kunath KC
(Please use an informative subject as the posting guide recommends.)
Your example is not very useful, but perhaps you need something like:
tmp - data.frame(x = rnorm(100), y = rnorm(100),
  group = rep(letters[1:5], each = 20))
sapply(split(tmp, tmp[group]), function(z) cor(z$x, z$y))
# OR
rbind(by(tmp, tmp[group], function(z) cor(z$x, z$y)))
--sundar
__
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


Re: [R] hex format

2005-04-08 Thread Duncan Murdoch
Earl F. Glynn wrote:
I recently discovered R's writeBin and readBin functions.  readBin, in
particular, looks like an extremely powerful tool for loading external
files.  This might be an easier way to perform some one-time data
manipulations instead of writing a separate C, Perl or Delphi program to
manipulate data before bringing it into R for analysis.
readBin returns a raw data type that looks like an array of bytes that R
displays in hex. That's where my problem begins and why I joined this hex
format thread.
 

That's only one possibility.  readBin can return a number of different 
types.

I'd love to manipulate this raw  hex data, but R makes using these hex bytes
quite difficult to use (or more difficult than I think it should be based on
how easy it is in other languages).  I might want to interpret a byte, or a
string of bytes, as characters. 

A simple solution to this would be to implement a raw connection, that 
takes a raw variable and lets you read it using readBin.

Or, I might want to interpret pairs of
bytes as 2-byte unsigned (or possibly signed) integers.  Or, I might want to
interpret 3-bytes at a time as RGB values (in either RGB or BGR order). Or,
I might want to interpret 8-bytes at a type as a IEEE754 floating point
number.
Every time someone wants to manipulate this raw data in R, as far as I can
tell now, one must start from scratch and do all sorts of manipulations on
these hex byte values to get characters, or integers, or doubles. And
because it's not that easy (but it's not that hard either, more of an
annoyance), I guess many just go back to C to get that job done there and
then return to R.
 

Currently you can do it by writing the raw data out to a temporary file 
and reading it back in.  It would be nice to allow this to happen 
without the temporary file.

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


[R] Princomp$Scores

2005-04-08 Thread Ken Termiso
Hi all,
I was hoping that someone could verify this for me-
when I run princomp() on a matrix, it is my understanding that the scores 
slot of the output is a measure of how well each row correlates (for lack of 
a better word) with each principal component.

i.e. say I have a 300x6 log2 scaled matrix, and I run princomp(). I would 
get back a $scores slot that is also 300x6, where each value can be negative 
or positive. I'd assume that the negative values correspond to rows that are 
negatively correlated with that particular PC, and vice-versa for positives.

Thanks in advance for the help,
Ken
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] EEG, ERP, ERF analysis with boot or bootstrap package

2005-04-08 Thread Darren Weber
Does anyone have experience in using boot or bootstrap for ERP data 
analysis?

Event-related potentials (ERPs) are electrical recordings from the human 
scalp during the presentation of stimulus events. They are a timeseries with 
msec resolution. They are essentially a timeseries that are defined relative 
to an event onset. They contain data prior to the event and after the event. 
They might be considered similar to a stock-market timeseries, defined in 
relation to some socio-political event.

I want to evaluate whether a group of points after the event are 
significantly different from all the points before the event. There are 
several publications on using randomization or bootstrap analysis to do 
this. I wonder if the packages in R called boot and bootstrap can be used 
for this purpose.

Best, Darren

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


[R] Using Flexible Discriminant Analysis (fda) in mda

2005-04-08 Thread Joseph Retzer
Greetings everyone,
I was wondering if anyone had experience in using fda (flexible discriminant 
analysis) in the mda package. Specifically, I can run the model but I cant 
locate/produce much of anything beyond the predicted values and confusion 
matrix. I've been searching for more examples or documentation but cant seem to 
locate any specific to the program itself.
I need to be able to find the
   Discriminant function coefficients (DFC) and 
   Correlations between the DFC's and the variables
   (I believe these are referred to as the total canonical structure in 
SAS
 
I ultimately want to graph the total canonical structure coefficients for the 
first 2 discriminant variables along with the groups scores calculated by 
putting in variable means into the discriminant functions. 
 
Any help or advice would be greatly appreciated,
Thanks very much,
Joe Retzer


-

 Show us what our next emoticon should look like. Join the fun.
[[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


[R] subset arg lmList

2005-04-08 Thread Sebastian Luque
I'm having trouble understanding how functions in the subset argument for
lmList search for the objects they need. This trivial example produces
Error in rownames(fakedf) : Object fakedf not found:

library(nlme)

fitbyID - function() {
  fakedf - data.frame(ID = gl(5, 10, 50),
   A = sample(1:100, 50),
   B = rnorm(50))
  mycoefs - lmList(B ~ A | ID,
data = fakedf,
subset = !is.element(rownames(fakedf),
 c(3, 10)))
  coef(mycoefs)
}

fitbyID()


If fakedf is already in the workspace, then the function runs fine, so
rownames seems to be looking for it in the global environment, although
I'd expect it to search locally first. I suspect this shows some gaps in
my understanding of environments and related concepts. I'd be grateful for
some advice on this.

Best wishes,
-- 
Sebastian P. Luque

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


[R] R-generated animation of a polynomiograph

2005-04-08 Thread François Pinard
Hi, people.

Two days ago, I sent to this list a little toy for exploring
polynomiographs (yet, the mathematical formulas were not polynomials
anymore, so the name is not really appropriate).

After studying R calls, expressions and functions a bit more, I gave
myself the homework of producing an animation out of my recent toy.  The
resulting animation, and also the sources, are available at:

http://pinard.progiciels-bpi.ca/plaisirs/nr-anim-01.html

P.S. - My intent was studying R, much more than producing art :-). I'm
sure anyone could do nicer, playing a few hours with this!

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


[R] Plotting principle components against individual variables

2005-04-08 Thread Brett Stansfield
Dear R

I am trying to plot some Principle component scores against the individual
variables that made the first biplot.
First I need to identify some points in the plot as follows
running2 - running[c(USA, New Zealand, Dominican Republic, Western
Samoa, Cook Islands),]

this works fine,
I then ask to do a plot

plot(running$X100m, running.pca$scores[,1])

this works fine also

I then need to specify points to highlight the countries of running2
And this is where I get stuck

points(running2$X100m, running.pca$scores, col=red)
Error in xy.coords(x, y) : x and y lengths differ

What am I doing wrong here

Brett Stansfield

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


[R] Journal of Statistical Software, Volume 12

2005-04-08 Thread Jan de Leeuw
This volume now has extensive documentation on the following R packages.
Issue 8: EbayesTresh (Johnstone/Silverman)
Issue 6: spatstat (Baddeley/Turner)
Issue 5: drc (Ritz/Streibig)
Issue 4: normalp (Mineo/Ruggieri)
Issue 3: R2WinBugs (Sturtz, Ligges, Gelman)
Issue 1: BradleyTerry (Firth)
Package writers are encouraged to submit to JSS.
===
Jan de Leeuw; Distinguished Professor and Chair, UCLA Department of  
Statistics;
Editor: Journal of Multivariate Analysis, Journal of Statistical  
Software
US mail: 8130 Math Sciences Bldg, Box 951554, Los Angeles, CA 90095-1554
phone (310)-825-9550;  fax (310)-206-5658;  email: [EMAIL PROTECTED]
.mac: jdeleeuw ++  aim: deleeuwjan ++ skype: j_deleeuw
homepages: http://gifi.stat.ucla.edu ++ http://www.cuddyvalley.org
  
 
-
  No matter where you go, there you are. --- Buckaroo Banzai
   http://gifi.stat.ucla.edu/sounds/nomatter.au

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


[R] advice on crafting examples for packages

2005-04-08 Thread Peter E. Rossi
Folks-

I have developed a package which I am planning on posting to CRAN.

I include examples for each of the 40 or so functions in the package.
However, since the examples are non-trivial and the package is
using MCMC simulation methods, it takes about 20 minutes to run the complete
set of examples on a 2.8 Ghz windows PC. The R process reaches a high
water mark of about 100 MB of memory as well.

I would appreciate some guidance on this.

many thanks!

peter

 Peter E. Rossi
 [EMAIL PROTECTED]
 WWW: http://ChicagoGsb.edu/fac/peter.rossi
SSRN: http://ssrn.com/author=22862
 QME: http://www.kluweronline.com/issn/1570-7156

__
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