[R] [R-SIG-Finance] regarding bootstrapping... REVISITED

2006-10-10 Thread gyadav

hi Thomas/All,

I went through the thread(
https://stat.ethz.ch/pipermail/r-sig-finance/2006q1/000682.html which 
concerns with swaps). Yeah it is correct that i would like to quote both 
David and Krishna that the curve interpolation may vary considerably (for 
e.g. any polynomial/parametric fit is very different from and curve 
fitting whether it is free hand or by NURBS ( complex version of Basis 
Splines ZZZzzz). My problem is that i want to know how can i generate spot 
curve using bootstrap methodin R.Further, even if you do not have fixed 
maturity bonds i.e. when you need to create fictitious or virtual paper of 
varied fixed maturities like 1 month, 6 month, 1 year, 5 year, 10 year 
. so that you can create a spot curve from the traded points which may 
be like as follows for e.g.

Price,Residual Maturity, Coupon, Frequency, Redemption, Basis
98.45,0.53,5%,2,100,4
100.15,1.54,8%,2,100,4
99.56,8.5,4%,1,100,4
and
97.65,20.6,10%,2,100,4

thanks to all
with warm regards
-gaurav





Thomas Steiner [EMAIL PROTECTED] 
09-10-06 09:18 PM

To
[EMAIL PROTECTED] [EMAIL PROTECTED]
cc
[EMAIL PROTECTED]
Subject
Re: [R-SIG-Finance] regarding bootstrapping






Gaurav,

some time ago I asked a very similar question. I got some very helpful
answers and some lines of code. Perhaps you want to read this (after
consulting Hull and the others):
https://stat.ethz.ch/pipermail/r-sig-finance/2006q1/000682.html

If you want to see some of my present code, just let me know.

Yours,
Thomas




DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{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] Goodness of fit measures for model with autocorrelation?

2006-10-10 Thread Wilson, Andrew
I wonder if anyone can help me with this query?

I am undertaking textual content analyses which result in time series
data (i.e., relative frequency counts of word categories in successive
segments of a larger text or in successive individual texts in a
temporal order).  In regard to the content category that interests me,
previous research has suggested an underlying five-stage psychological
process and has proposed a fifth-degree polynomial as a general model
for this in texts:

cat_freq ~ I(time) + I(time^2) + I(time^3) + I(time^4) + I(time^5)

I want to test the adequacy of this model on new data.

If I fit the model using lm, I get two measures of goodness of fit: RSq
and the significance of the ANOVA.  However, autocorrelation is normally
present in these data, so I should instead be using gls with an
appropriate autocorrelation process such as cor(AR1).  However, gls in R
does not offer the RSq and ANOVA measures.

Is there any way of getting these measures for a gls fit, or is there
perhaps even a better way of testing the theoretical model on new data?

Many thanks,

Andrew Wilson

Email: [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.


Re: [R] Problem building a DLL from Fortran 90 source under Windows (with solution)

2006-10-10 Thread Prof Brian Ripley
On Mon, 9 Oct 2006, Mstislav Elagin wrote:

 Hi, All,

 I have come across a problem building a DLL from .f90 source (R 2.3.1,
 Windows XP). When using the R CMD SHLIB procedure, the DLL itself was
 being built, but its export table was empty.

 Among the output from R CMD SHLIB the following message appeared:

 c:\mingw\bin\nm.exe: 'a.out': No such file

 The reason is the empty list of dependencies in the pattern rule for
 DLLs contained in the file MkRules:

 %.dll:
   @$(ECHO) EXPORTS  $*.def
   @$(NM) $^ | $(SED) -n 's/^ [BCDRT] _/ /p'  $*.def

 The dependencies list is constructed in the MakeDll file that contains
 the following:

 CFSOURCES=$(wildcard -f *.c *.f *.f90 *.f95)
 CSOURCES=$(wildcard -f *.c)
 CXXSOURCES=$(wildcard -f *.cc *.cpp *.C)
 FSOURCES=$(wildcard -f *.f)
 FCSOURCES=$(wildcard -f *.f90 *.f95)
 OBJSA=$(foreach i,$(CSOURCES) $(FSOURCES) $(CXXSOURCES),$(basename $i).o)

 Observe that the neither CFSOURCES nor FCSOURCES in included in OBJSA,
 i.e. an object file made from a f90 source never becomes part of
 dependencies. If I add $(FCSOURCES) to OBJSA, the DLL gets built
 correctly.

 I wonder whether there is a reason for not including .f90 (and .f95)
 sources in the list of dependencies or this can be considered a bug in
 R.

Please use a current version of R (as the posting guide asks). From the 
CHANGES file for 2.3.1 patched:

   Objects from Fortran 9X sources no longer need to be declared to R CMD
   SHLIB/INSTALL via OBJS in Makevars.win.


-- 
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] File Encoding Warnings during package installs

2006-10-10 Thread Prof Brian Ripley
On Fri, 29 Sep 2006, Sarosh Jamal wrote:

 I've been getting the following warning on each package update/install (Rv2.4 
 on SunOS9):

Each?  This only applies to a few packages, and is only a warning.

 Warning message:
 'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible.

 This was the case on R2.3 and now on R2.4 as well - any insight would be much 
 appreciated.

Most likely you need to install libiconv and rebuild R: Solaris's (I think 
you mean Solaris 9 or SunOS 5.9) iconv is not adequate for recent versions 
of R (in particular, for UTF-8 locales or packages).

-- 
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] Rank Function

2006-10-10 Thread David Barron
 y-round(c(0.68,0.95,b,c,d),2)
 rank(y)
[1] 3.5 5.0 1.0 2.0 3.5


On 10/10/06, Li Zhang [EMAIL PROTECTED] wrote:

 Does anyone know why the two rank functions gives
 different results? I need to use the rank function in
 a for loop, so the sequence to be ranked is given
 values in the form of part (1). How can I use
 assignment like in part (1) to get correct ranks as in
 part (2)?

 Thank You



 Part (1)
 i-1.94
 b-0.95-i
 c-1.73-i
 d-2.62-i

 y-c(0.68,0.95,b,c,d)

 y
 0.68  0.95 -0.99 -0.21  0.68

 rank(y)
 3 5 1 2 4

 Part(2)
 rank(c(0.68,0.95,-0.99,-0.21,0.68))
 3.5 5.0 1.0 2.0 3.5

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




-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

[[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] Rank Function

2006-10-10 Thread Gabor Grothendieck
Because y[1] and y[5] are not the same in Part1 but are in Part2:

 # using y from Part1
 y[5] - y[1]
[1] 1.110223e-16

You could round your numbers to 2 digits, say:

 rank(round(100*y)) # y is from Part1
[1] 3.5 5.0 1.0 2.0 3.5


On 10/10/06, Li Zhang [EMAIL PROTECTED] wrote:
 Does anyone know why the two rank functions gives
 different results? I need to use the rank function in
 a for loop, so the sequence to be ranked is given
 values in the form of part (1). How can I use
 assignment like in part (1) to get correct ranks as in
 part (2)?

 Thank You



 Part (1)
 i-1.94
 b-0.95-i
 c-1.73-i
 d-2.62-i

 y-c(0.68,0.95,b,c,d)

 y
 0.68  0.95 -0.99 -0.21  0.68

 rank(y)
 3 5 1 2 4

 Part(2)
 rank(c(0.68,0.95,-0.99,-0.21,0.68))
 3.5 5.0 1.0 2.0 3.5

 __
 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] Rank Function

2006-10-10 Thread Roger Bivand
On Tue, 10 Oct 2006, Gabor Grothendieck wrote:

 Because y[1] and y[5] are not the same in Part1 but are in Part2:
 
  # using y from Part1
  y[5] - y[1]
 [1] 1.110223e-16

Yes, this is FAQ 7.31: Why doesn't R think these numbers are equal?

 i-1.94
 d-2.62-i
 print(0.68, digits=16)
[1] 0.68
 print(d, digits=16)
[1] 0.6802
 identical(d, 0.68)
[1] FALSE
 all.equal(d, 0.68)
[1] TRUE

with the internal rank function ignoring numeric fuzz.

 
 You could round your numbers to 2 digits, say:
 
  rank(round(100*y)) # y is from Part1
 [1] 3.5 5.0 1.0 2.0 3.5
 
 
 On 10/10/06, Li Zhang [EMAIL PROTECTED] wrote:
  Does anyone know why the two rank functions gives
  different results? I need to use the rank function in
  a for loop, so the sequence to be ranked is given
  values in the form of part (1). How can I use
  assignment like in part (1) to get correct ranks as in
  part (2)?
 
  Thank You
 
 
 
  Part (1)
  i-1.94
  b-0.95-i
  c-1.73-i
  d-2.62-i
 
  y-c(0.68,0.95,b,c,d)
 
  y
  0.68  0.95 -0.99 -0.21  0.68
 
  rank(y)
  3 5 1 2 4
 
  Part(2)
  rank(c(0.68,0.95,-0.99,-0.21,0.68))
  3.5 5.0 1.0 2.0 3.5
 
  __
  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.
 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [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] compiling error R-2.4.0

2006-10-10 Thread David Ruau
Hi there,

I am trying to install from the source R-2.4.0 on my mac (osx 10.4.8  
G5 DP)

The error imply Tcl/Tk.
I install it by all the way I know: darwinport, the Tcl/Tk package
from the dmg available from CRAN but without success.
The PATH is correct.
tclConfig.sh is localised in /opt/local/lib and have those permission:
-rw-r--r-- 2 root  admin7K Oct  9 09:49 tclConfig.sh

Here is the error produce by ./configure CFLAGS='-O3 -faltivec -fgcse- 
sm -funroll-loops -fstrict-aliasing -fsched-interblock -falign- 
loops=16 -falign-jumps=16 -falign-functions=16 -malign-natural - 
freorder-blocks -freorder-blocks-and-partition -mpowerpc-gfxopt - 
mpowerpc-gpopt -fstrict-aliasing -ftree-vectorize -mtune=G5 -mcpu=G5'  
FFLAGS='-O3 -faltivec -fgcse-sm -funroll-loops -fstrict-aliasing - 
fsched-interblock -falign-loops=16 -falign-jumps=16 -falign- 
functions=16 -malign-natural -freorder-blocks -freorder-blocks-and- 
partition -mpowerpc-gfxopt -mpowerpc-gpopt -fstrict-aliasing -ftree- 
vectorize -mtune=G5 -mcpu=G5'
[...]
checking for tclConfig.sh... /opt/local/lib/tclConfig.sh
checking for tkConfig.sh... no
checking for tkConfig.sh in library (sub)directories... /usr/local/
lib/tkConfig.sh
checking /opt/local/include/tcl8.4/generic/tcl.h usability... no
checking /opt/local/include/tcl8.4/generic/tcl.h presence... no
checking for /opt/local/include/tcl8.4/generic/tcl.h... no
checking /opt/local/include/tcl8.4/tcl.h usability... no
checking /opt/local/include/tcl8.4/tcl.h presence... no
checking for /opt/local/include/tcl8.4/tcl.h... no
checking /opt/local/include/tcl.h usability... yes
checking /opt/local/include/tcl.h presence... yes
checking for /opt/local/include/tcl.h... yes
checking /usr/local/include/tk8.4/generic/tk.h usability... no
checking /usr/local/include/tk8.4/generic/tk.h presence... no
checking for /usr/local/include/tk8.4/generic/tk.h... no
checking /usr/local/include/tk8.4/tk.h usability... no
checking /usr/local/include/tk8.4/tk.h presence... no
checking for /usr/local/include/tk8.4/tk.h... no
checking /usr/local/include/tcl8.4/tk.h usability... no
checking /usr/local/include/tcl8.4/tk.h presence... no
checking for /usr/local/include/tcl8.4/tk.h... no
checking /usr/local/include/tk.h usability... no
checking /usr/local/include/tk.h presence... yes
configure: WARNING: /usr/local/include/tk.h: present but cannot be
compiled
configure: WARNING: /usr/local/include/tk.h: check for missing
prerequisite headers?
configure: WARNING: /usr/local/include/tk.h: see the Autoconf
documentation
configure: WARNING: /usr/local/include/tk.h: section Present But
Cannot Be Compiled
configure: WARNING: /usr/local/include/tk.h: proceeding with the
preprocessor's result
configure: WARNING: /usr/local/include/tk.h: in the future, the
compiler will take precedence
configure: WARNING: ## --- ##
configure: WARNING: ## Report this to [EMAIL PROTECTED] ##
configure: WARNING: ## --- ##
checking for /usr/local/include/tk.h... yes
checking whether compiling/linking Tcl/Tk code works... no
[...]

Then after it goes all right until the end and then produce a error
in the make step:

make[4]: `libintl.a' is up to date.
gcc -I. -I../../src/include -I../../src/include -I/usr/local/include -
DHAVE_CONFIG_H   -fPIC  -O3 -faltivec -fgcse-sm -funroll-loops -
fstrict-aliasing -fsched-interblock -falign-loops=16 -falign-jumps=16
-falign-functions=16 -malign-natural -freorder-blocks -freorder-
blocks-and-partition -mpowerpc-gfxopt -mpowerpc-gpopt -fstrict-
aliasing -ftree-vectorize -mtune=G5 -mcpu=G5 -c cpoly.c -o cpoly.o
cpoly.c: In function 'fxshft':
cpoly.c:292: error: expected identifier or '(' before 'unsigned'
[...]
make[3]: *** [cpoly.o] Error 1
make[2]: *** [R] Error 2
make[1]: *** [R] Error 1
make: *** [R] Error 1

I try lot of things but I run out of idea.
Any idea would be really helpful...

David

__
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] Haplo.Stats: error (recursive default argument reference)

2006-10-10 Thread M.J. Bos
Dear colleagues,

I face a problem doing haplotype analyses with haplostats: when I use 
the haplo.em function, the programme gives an error message because of 
'recursive default argument reference.' I am not able to figure out what 
this means. Could you perhaps help me?

The full output is the following:
  library(haplo.stats)
  datafile.dat-read.table(datafile.dat,header=TRUE)
  attach(datafile.dat)
  names(datafile.dat)
 [1] SEXE AGE OUTCOME1  OUTCOME2 OUTCOME3 OUTCOME4
 [7] OUTCOME5 SNP1X SNP1Y SNP2X SNP2Y SNP3X
[13] SNP3Y SNP4X SNP4Y SNP5X SNP5Y SNP6X
[19] SNP6Y SNP7X SNP7Y
  block1-datafile.dat[,c(8:21)]
  loci-c(1,2,3,4,5,6,7)
  em-haplo.em(geno=block1,locus.label=loci,miss.val=c(0,NA))
Error in .Call(R_lazyLoadDBfetch, key, file, compressed, hook, PACKAGE 
= base) :
recursive default argument reference

Thank you very much in advance!
Michiel Bos

-- 

Michiel J. Bos, MD MSc
PhD-student Neuro-epidemiology
Erasmus MC
Dept. of Epidemiology and Biostatistics
Room Ee2130
PO Box 1738
3000 DR Rotterdam
tel: +31 (0)10-4087478
fax: +31 (0)10-4089382
E-mail: [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.


Re: [R] copula

2006-10-10 Thread Dominique Katshunga
Dear R-helper,
Is there any thing that I am doing wrong in the following codes:
 norm.cop - normalCopula(0.5)
 persp(norm.cop, dcopula)
The last command produces what follows

Error in persp(x, y, z, xlim, ylim, zlim, theta, phi, r, d, scale,
expand,  : 
invalid 'x' argument
In addition: Warning messages:
1: no non-missing arguments to min; returning Inf 
2: no non-missing arguments to max; returning -Inf 
3: no non-missing arguments to min; returning Inf 
4: no non-missing arguments to max; returning -Inf 
5: is.na() applied to non-(list or vector) in: is.na(x) 
6: no non-missing arguments to min; returning Inf 
7: no non-missing arguments to max; returning -Inf
I remember that I tried the same two commands exactly the way they
appear above and I had the surface drawn properly. Does anyone have an
idea what this could possibly mean? 
thanks,
Dominique

__
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] Rank Function

2006-10-10 Thread Jim Lemon
Li Zhang wrote:
 Does anyone know why the two rank functions gives
 different results? I need to use the rank function in
 a for loop, so the sequence to be ranked is given
 values in the form of part (1). How can I use
 assignment like in part (1) to get correct ranks as in
 part (2)?
 
 Thank You
 
 
 
 Part (1)
 i-1.94
 b-0.95-i
 c-1.73-i
 d-2.62-i
 
 y-c(0.68,0.95,b,c,d)
 
 y
 0.68  0.95 -0.99 -0.21  0.68
 
 rank(y)
 3 5 1 2 4
 
 Part(2)
 rank(c(0.68,0.95,-0.99,-0.21,0.68))
 3.5 5.0 1.0 2.0 3.5
 
You have specified the exact numbers in part(2). Try part(1) with the 
following:

rank(zapsmall(y))

zapsmall removes tiny floating point errors that are not visible with 
the default representation of numbers.

Jim

__
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] Surfaceplot3D with wireframe

2006-10-10 Thread Gustaf Granath
Hi,
I want to make a surface3D plot of a landscape. I have cordinates (x, y, z)
recorded with a GPS. The datapoints are not evenly distributed within the
rectangular area.

To do a fast 3D plot I used following.

 library(grid)
 library(lattice)
 v - read.table(clipboard)
 names(v) - c(x, y, z)
 wireframe(z ~ x * y, data = v)

However I just get an empty box with no 3D grid. I have tried with other data
and then it usually works. But I cant get it to work with my data.
Here is a sample of my data (x, y, z). I think there is something in my data set
that wireframe doesnt like. Any ideas?? Are there better commands to use? 
(I have tried to change the magnitude of the numbers but that doesnt help)
 y   xz  
6659592.078 1585162.959 59.229
6659591.348 1585164.402 59.159
6659590.494 1585163.294 59.205
6659589.466 1585158.968 59.290
6659589.229 1585159.390 59.246
6659588.963 1585158.895 59.201
6659589.475 1585158.617 59.199
6659589.808 1585159.206 59.135
6659592.361 1585161.707 59.447
6659592.387 1585161.319 59.437
6659592.590 1585161.871 59.217
6659591.989 1585162.156 59.163
6659591.934 1585161.489 59.358
6659590.340 1585158.060 59.352
6659590.228 1585157.714 59.138
6659590.957 1585157.947 59.145
6659590.422 1585158.344 59.214
6659589.904 1585158.024 59.175
6659589.877 1585162.033 59.346
6659589.967 1585161.674 59.197
6659590.109 1585162.062 59.205
6659589.778 1585162.572 59.152
6659589.591 1585161.876 59.187
6659591.783 1585156.210 59.561
6659592.164 1585156.764 59.266
6659590.352 1585156.154 59.339
6659590.890 1585154.720 59.278
6659592.520 1585155.023 59.250
6659593.127 1585166.690 59.217

Regards,
Gustaf
_
Gustaf Granath (PhD student)
Dept of Plant Ecology
Evolutionary Biology Centre (EBC)
Uppsala University
Villavägen 14, SE - 752 36 Uppsala, Sweden

Tel: +46 (0)18-471 76 88 
Fax: 018 55 34 19
Email: [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] read.table() and scientific notation

2006-10-10 Thread January Weiner
Dear all,

I am having troubles importing values written as scientific notation
using read.table(). I'm sure this is a frequent problem, as many
people in my lab have this problem as well, so I'm sure that I just
have troubles googling for the right solution.

The problem is, that, given a file like that:

a 1 2e-4
b 2 3e-8
...

the third column gets imported as a factor, or a string if I set the
as.is parameter of read.table to TRUE for this column. However, I just
want a simple numeric vector :-) I'm sure there is a simple trick for
this. If you can point me to the right function, or manual, I think I
should be able to find out the details myself.

Thanks in advance,
January

-- 
 January Weiner 3  -+---
Division of Bioinformatics, University of Muenster  |  Schloßplatz 4
(+49)(251)8321634   |  D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/|  Germany

__
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] r 2.4.0

2006-10-10 Thread Dominique Katshunga

Can someone help interprete the error message below? i was trying to
load the package copula from the R command prompt.

 Error in loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = 
 keep.source) : 
in 'copula' methods specified for export, but none defined: show,
summary, persp, contour
Error: package/namespace load failed for 'copula'
Thanks,
Dominique

__
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] factor levels with umlauts

2006-10-10 Thread Prof Brian Ripley

On Fri, 6 Oct 2006, Christian Bieli wrote:


Hi all

I have to generate some test data for import in an sql database. The
database is meant for web-based data entry in a study taking place in a
german speaking region, so factor levels of the variables include umlauts.
The variables in the dataframe t.muster are generated e.g. like this:

t.muster$screening - rep(ausgefüllt,50)

and exported to a .csv file by:

write.table(t.muster,MakeMuster041006/MusterDaten.csv,
   col.names=FALSE,row.names=FALSE,na=,sep=;)

After export the factor level including an umlaut of t.muster$screening
look like this in the sql-database as well as in an excel spreadsheet:

ausgefüllt


I think the problem is rather how you imported them.  That is the UTF-8 
representation of the ausgefüllt viewed in a single-byte locale.  R on 
Windows does not handle UTF-8, so something else has done the conversion.


[...]

--
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] solaris 64 build?

2006-10-10 Thread Prof Brian Ripley
Which Solaris is this?  I am not seeing any problems with our Solaris 8 
systems.  Was the compiler built on that exact system?  What gcc options 
were used (-std=gnu99, as recommended, for instance)?

It looks like a system header problem: __builtin_isnan ought to be 
built in, not an external entry point.  Since R does not use it, you need 
to trace through the headers to see why isnan is expanding to it.

On Thu, 5 Oct 2006, roger koenker wrote:

 We have a solaris/sparc machine that has been running an old version
 of R-devel:  Version 2.2.0 Under development (unstable) (2005-06-04
 r34577)
 which was built as m64 from sources.  Attempting to upgrade to 2.4.0
 the configure step
 goes ok, but I'm getting early on from make:

 gcc -m64  -L/opt/sfw/lib/sparcv9  -L/usr/lib/sparcv9
 -L/usr/openwin/lib/sparcv9  -L/usr/local/lib -o R.bin Rmain.o
 CConverters.o CommandLineArgs.o  Rdynload.o Renviron.o RNG.o  apply.o
 arithmetic.o apse.o array.o attrib.o  base.o bind.o builtin.o
 character.o coerce.o colors.o complex.o connections.o context.o  cov.o
 cum.o  dcf.o datetime.o debug.o deparse.o deriv.o  dotcode.o dounzip.o
 dstruct.o duplicate.o  engine.o envir.o errors.o eval.o  format.o
 fourier.o  gevents.o gram.o gram-ex.o graphics.o  identical.o
 internet.o
 iosupport.o  lapack.o list.o localecharset.o logic.o  main.o mapply.o
 match.o memory.o model.o  names.o  objects.o optim.o optimize.o
 options.o  par.o paste.o pcre.o platform.o  plot.o plot3d.o plotmath.o
 print.o printarray.o printvector.o printutils.o qsort.o  random.o
 regex.o registration.o relop.o rlocale.o  saveload.o scan.o seq.o
 serialize.o size.o sort.o source.o split.o  sprintf.o startup.o
 subassign.o subscript.o subset.o summary.o sysutils.o  unique.o util.o
 version.o vfonts.o xxxpr.o  mkdtemp.o ../unix/libunix.a
 ../appl/libappl.a ../nmath/libnmath.a -L../../lib -lRblas
 -L/usr/local/encap/gf7764-3.4.3+2/lib/gcc/sparc64-sun-solaris2.9/3.4.3
 -L/usr/ccs/bin/sparcv9 -L/usr/ccs/bin -L/usr/ccs/lib
 -L/usr/local/encap/gf7764-3.4.3+2/lib/sparcv9
 -L/usr/local/encap/gf7764-3.4.3+2/lib -lg2c -lm -lgcc_s
 ../extra/zlib/libz.a  ../extra/bzip2/libbz2.a ../extra/pcre/libpcre.a
 ../extra/intl/libintl.a  -lreadline -ltermcap -lnsl -lsocket -ldl -lm


 Undefined   first referenced
 symbol in file
 __builtin_isnan arithmetic.o
 ld: fatal: Symbol referencing errors. No output written to R.bin
 collect2: ld returned 1 exit status

 I've tried to look at the difference in outcomes in the old R-devel
 version --  if I touch arithmetic.c  there and then type make I get a
 something
 almost the same as above except for the following  bits that are new
 to 2.4.0
 (this diff is after replacing spaces with linebreaks obviously.)

 ysidro.econ.uiuc.edu% diff t0 t1
 54a55
  localecharset.o
 81a83
  rlocale.o
 101a104
  mkdtemp.o
 104a108,109
  -L../../lib
  -lRblas


 Has there been some change in the way that Rblas is used, or in
 isnan?  It didn't seem so from a look at arithmetic.c, but this is well
 beyond me.

 I hope that someone sees something suspicious, or could point me
 toward a better diagnostic.  Thanks,

 Roger


 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820

 __
 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] read.table() and scientific notation

2006-10-10 Thread Gabor Grothendieck
Your example does not exhibit that behavior when I try it (below).
Can you provide a reproducible example following the style
shown here:

 Lines - a 1 2e-4
+ b 2 3e-8

 DF - read.table(textConnection(Lines))
 str(DF)
'data.frame':   2 obs. of  3 variables:
 $ V1: Factor w/ 2 levels a,b: 1 2
 $ V2: int  1 2
 $ V3: num  2e-04 3e-08
 R.version.string # Windows XP
[1] R version 2.4.0 (2006-10-03)


On 10/10/06, January Weiner [EMAIL PROTECTED] wrote:
 Dear all,

 I am having troubles importing values written as scientific notation
 using read.table(). I'm sure this is a frequent problem, as many
 people in my lab have this problem as well, so I'm sure that I just
 have troubles googling for the right solution.

 The problem is, that, given a file like that:

 a 1 2e-4
 b 2 3e-8
 ...

 the third column gets imported as a factor, or a string if I set the
 as.is parameter of read.table to TRUE for this column. However, I just
 want a simple numeric vector :-) I'm sure there is a simple trick for
 this. If you can point me to the right function, or manual, I think I
 should be able to find out the details myself.

 Thanks in advance,
 January

 --
  January Weiner 3  -+---
 Division of Bioinformatics, University of Muenster  |  Schloßplatz 4
 (+49)(251)8321634   |  D48149 Münster
 http://www.uni-muenster.de/Biologie.Botanik/ebb/|  Germany

 __
 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] read.table() and scientific notation

2006-10-10 Thread Prof Brian Ripley
On FC5 Linux:

gannet% cat  foo.dat
a 1 2e-4
b 2 3e-8
gannet% R
...
 read.table(foo.dat)
   V1 V2V3
1  a  1 2e-04
2  b  2 3e-08
 sapply(read.table(foo.dat), class)
V1V2V3
  factor integer numeric

so please tell us your environment and give a reproducible example.  (This 
is using the OS function strtod, so it might be a deficiency in your OS's 
implementation of ISO C.)

On Tue, 10 Oct 2006, January Weiner wrote:

 Dear all,

 I am having troubles importing values written as scientific notation
 using read.table(). I'm sure this is a frequent problem, as many
 people in my lab have this problem as well, so I'm sure that I just
 have troubles googling for the right solution.

 The problem is, that, given a file like that:

 a 1 2e-4
 b 2 3e-8
 ...

 the third column gets imported as a factor, or a string if I set the
 as.is parameter of read.table to TRUE for this column. However, I just
 want a simple numeric vector :-) I'm sure there is a simple trick for
 this. If you can point me to the right function, or manual, I think I
 should be able to find out the details myself.

 Thanks in advance,
 January



-- 
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] factor levels with umlauts

2006-10-10 Thread Christian Bieli
Thanks for your answer.
I went round the problem by directly connect to the sql-database instead 
of generating a .csv file and then upload it.
This works perfectly with the RODBC package and is much more suitable, too.

Kind regards
Christian

Prof Brian Ripley schrieb:
 On Fri, 6 Oct 2006, Christian Bieli wrote:

 Hi all

 I have to generate some test data for import in an sql database. The
 database is meant for web-based data entry in a study taking place in a
 german speaking region, so factor levels of the variables include 
 umlauts.
 The variables in the dataframe t.muster are generated e.g. like this:

 t.muster$screening - rep(ausgefüllt,50)

 and exported to a .csv file by:

 write.table(t.muster,MakeMuster041006/MusterDaten.csv,
col.names=FALSE,row.names=FALSE,na=,sep=;)

 After export the factor level including an umlaut of t.muster$screening
 look like this in the sql-database as well as in an excel spreadsheet:

 ausgefüllt

 I think the problem is rather how you imported them.  That is the 
 UTF-8 representation of the ausgefüllt viewed in a single-byte 
 locale.  R on Windows does not handle UTF-8, so something else has 
 done the conversion.

 [...]


__
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] r 2.4.0

2006-10-10 Thread Uwe Ligges


Dominique Katshunga wrote:
 Can someone help interprete the error message below? i was trying to
 load the package copula from the R command prompt.
 
 Error in loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = 
 keep.source) : 
 in 'copula' methods specified for export, but none defined: show,
 summary, persp, contour
 Error: package/namespace load failed for 'copula'
 Thanks,
 Dominique


You have to reinstall all packages depending on methods after upgrade 
to R-2.4.0.

For convenience, type:

update.packages(checkBuilt = TRUE)

Uwe Ligges


 __
 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] read.table() and scientific notation

2006-10-10 Thread January Weiner
Oh, thanks, that was hint enough :-) I see it now. I turns that R does
not understand

e-10

...which stands for 1e-10 and is produced by some of the bioinformatic
applications that I use (notably BLAST). However, R instead of being
verbose on that just assumes that the whole column is a string.

Is there a way to enforce a specific conversion in R (for example, to
be able to see where the errors are?).

January

-- 
 January Weiner 3  -+---
Division of Bioinformatics, University of Muenster  |  Schloßplatz 4
(+49)(251)8321634   |  D48149 Münster
http://www.uni-muenster.de/Biologie.Botanik/ebb/|  Germany

__
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] read.table() and scientific notation

2006-10-10 Thread Martin C. Martin
I think the colClasses argument to read.table() is what you need. 
Either that, or explicitly cast columns in the data.frame that's 
returned by read.table().  That's how you get data types that aren't 
directly supported by read.table(), like various date formats.

- Martin

January Weiner wrote:
 Oh, thanks, that was hint enough :-) I see it now. I turns that R does
 not understand
 
 e-10
 
 ...which stands for 1e-10 and is produced by some of the bioinformatic
 applications that I use (notably BLAST). However, R instead of being
 verbose on that just assumes that the whole column is a string.
 
 Is there a way to enforce a specific conversion in R (for example, to
 be able to see where the errors are?).
 
 January


__
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] read.table() and scientific notation

2006-10-10 Thread Prof Brian Ripley
On Tue, 10 Oct 2006, January Weiner wrote:

 Oh, thanks, that was hint enough :-) I see it now. I turns that R does
 not understand

 e-10

 ...which stands for 1e-10 and is produced by some of the bioinformatic
 applications that I use (notably BLAST).

And that is not standard C notation.

 However, R instead of being
 verbose on that just assumes that the whole column is a string.

 Is there a way to enforce a specific conversion in R (for example, to
 be able to see where the errors are?).

Please study ?read.table, especially 'colClasses'.

-- 
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] bimodal / trimodal

2006-10-10 Thread Ingmar Visser
Hi,
If you want parametric modes you could fit mixtures with different numbers
of components and select the best model with your favourite model-selection
criterion. Various packages such as mclust and fitdistr may be helpful in
doing this, the cluster task view has many more:
http://cran.at.r-project.org/src/contrib/Views/Cluster.html
I am not aware of non-parametric mode testing routines in R, which ones were
you thinking of?
Hth, Ingmar


 From: array chip [EMAIL PROTECTED]
 Date: Mon, 9 Oct 2006 14:28:32 -0700 (PDT)
 To: r-help@stat.math.ethz.ch
 Subject: [R] bimodal / trimodal
 
 Hi, is there any package/function that can tell if a
 numeric vector (continuous data) has a bimodal or
 trimodal distribution and caluclate the location of
 the corresponding modes?
 
 Thanks
 
 __
 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] read.table() and scientific notation

2006-10-10 Thread Alex Brown
A cheeky solution by subverting the coerce mechanism and read.table:

# install a coerce function which can fix the e+10 syntax for an  
imaginary class myDouble:

  setAs(character, myDouble, function(from)as.double(sub('^(-?) 
e','\\11e',from)))
Warning message:
in the method signature for function 'coerce' no definition for  
class: “myDouble” in: matchSignature(signature, fdef, where)

# load some data:

  Lines - scan(sep=\n, what=)
a 1 3e-8
b 2 1e+10
c 3 e-10
d 4 e+3
e 5 e+1

# process it without using the imaginary class - use a real double  
instead to see what happens:
# Note I've used textConnection(Lines) here, where your filename  
would go

  T - read.table(textConnection(Lines), colClasses=list 
(character, integer, double))
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,  
na.strings,  :
scan() expected 'a real', got 'e-10'

# process it, specifying the imaginary class myDouble.

  T - read.table(textConnection(Lines), colClasses=list 
(character, integer, myDouble))
  T
   V1 V2V3
1  a  1 3e-08
2  b  2 1e+10
3  c  3 1e-10
4  d  4 1e+03
5  e  5 1e+01

  lapply(T, class)
$V1
[1] character

$V2
[1] integer

$V3
[1] numeric


Someone's bound to shoot me down for hackery here :-)

-Alex

On 10 Oct 2006, at 11:43, January Weiner wrote:

 Dear all,

 I am having troubles importing values written as scientific notation
 using read.table(). I'm sure this is a frequent problem, as many
 people in my lab have this problem as well, so I'm sure that I just
 have troubles googling for the right solution.

 The problem is, that, given a file like that:

 a 1 2e-4
 b 2 3e-8
 ...

 the third column gets imported as a factor, or a string if I set the
 as.is parameter of read.table to TRUE for this column. However, I just
 want a simple numeric vector :-) I'm sure there is a simple trick for
 this. If you can point me to the right function, or manual, I think I
 should be able to find out the details myself.

 Thanks in advance,
 January

 -- 
  January Weiner 3  -+---
 Division of Bioinformatics, University of Muenster  |  Schloßplatz 4
 (+49)(251)8321634   |  D48149 Münster
 http://www.uni-muenster.de/Biologie.Botanik/ebb/|  Germany

 __
 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] Fwd: read.table() and scientific notation

2006-10-10 Thread Alex Brown
note: this e-mail is supposed to precede my coerce hack one.

As an example of the other posters mentioning colClasses, with some  
debugging notes:

# create a pretend file for this example

  Lines - scan(sep=\n, what=)
a 1 3e-8
b 2 1e+10
c 3 e-10
d 4 e+3

  file - textConnection(Lines)

# import as you would a file, and specify the column types.
  T - read.table(file, colClasses=list(character, integer,  
double))
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,  
na.strings,  :
scan() expected 'a real', got 'e-10'

# decide that's not very helpful.  let's just import everything as  
character:
# restarting the file.
 file - textConnection(Lines)
 T - read.table(file, colClasses=character)
 lapply(T, mode)
$V1
[1] character

$V2
[1] character

$V3
[1] character


  T
   V1 V2V3
1  a  1  3e-8
2  b  2 1e+10
3  c  3  e-10
4  d  4   e+3

# try the conversion to double:

  (D-as.double(T$V3))
[1] 3e-08 1e+10NANA
Warning message:
NAs introduced by coercion

# let's see which are bad:
  T[is.na(D),]
   V1 V2   V3
3  c  3 e-10
4  d  4  e+3



-Alex



On 10 Oct 2006, at 12:17, January Weiner wrote:

 Oh, thanks, that was hint enough :-) I see it now. I turns that R does
 not understand

 e-10

 ...which stands for 1e-10 and is produced by some of the bioinformatic
 applications that I use (notably BLAST). However, R instead of being
 verbose on that just assumes that the whole column is a string.

 Is there a way to enforce a specific conversion in R (for example, to
 be able to see where the errors are?).

 January

 -- 
  January Weiner 3  -+---
 Division of Bioinformatics, University of Muenster  |  Schloßplatz 4
 (+49)(251)8321634   |  D48149 Münster
 http://www.uni-muenster.de/Biologie.Botanik/ebb/|  Germany

 __
 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] Survival Sample Size package / function

2006-10-10 Thread Edison Iglesias de Oliveira Vidal
Hi,

My name is Edison and this is the first time I write to this list. I have 
been trying without success to find a package or function in R that 
calculates sample sizes for multiple events survival models. Does anyone 
have an advice that could help me?

best regards,

edison

_
O Windows Live Spaces é seu espaço na internet com fotos (500 por mês), blog 
e agora com rede social http://spaces.live.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] cokriging

2006-10-10 Thread ali bilgili


Hi,


when using the script file for cokriging, is there any way to fit  cross 
variogram other than linear, I mean  what other options can I put in place 
of fit.lmc

I ll be very appreciated if somebody who know the answer  can response to me

thanks

__
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] Block comments in R?

2006-10-10 Thread Duncan Murdoch
On 10/9/2006 10:06 AM, hadley wickham wrote:
 Current .Rd documentation has some obvious problems:

 - the parser strips comments out of examples when it runs them
 - there's no way to put images into the documentation
 - the keywords aren't much use
 - there's isn't a definition anywhere of what the format really is, so
 it's hard to know
 whether something will work other than by trying it -- and it may break
 with the next release.
 - there's no way to link from a help man page to a vignette or other
 form of documentation.
 
 The main thing I don't like about the current system is the amount of
 duplication - you have to supply a lot of information in the
 documentation that is also encoded in the function (ie. everything in
 the codoc check).  This makes it unnecessarily painful when updating
 documentation to reflect minor changes.  The large distance between
 code and documentation also makes it easy to forget to update the
 documentation when changing the code.  These are things that are
 helped by inline documentation (which I am using)

Inline documentation isn't the only way to achieve what you want: 
better editing tools would help too.  I don't know if ESS helps with 
this, but I could imagine a smart editor would be able to help with the 
updates in each direction.

The big problem with this solution is that there is such a variety of 
editors in use, and most people are convinced that everyone else has 
made a big mistake in choosing theirs.

However, there was talk in the summer about adding more keywords to .Rd 
files, to expand in various ways.  A keyword that expanded to the arg 
list of a function might be a nice way to avoid duplication.  If we had 
a way to put argument descriptions into the R file it could do a better 
job, but it would be tricky:  e.g. what if the file arg in two objects 
to be documented in the same .Rd had different descriptions?  I agree 
with Richard that we don't want to force separate man pages for every 
documented object.

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] eps embedded fonts again

2006-10-10 Thread Yury Yuryev
Dear friends,

I am sorry, I again rise that boring question about font embedding in
EPS figure.

I found some discussions on this topic but there were no strait solution.

The publisher (AIP) demands submission of separate EPS file
for each figure with all fonts embedded in it (even the standard
14 Adobe fonts).

As I understand the R does not do this embedding. It inserts only
comments what font resources are needed. Then I should use some other
software to do this task. Is there a solution for problem within open
source environment (without using of proprietary software)? My system is
Debian GNU/Linux (testing).

The second picture format that AIP journals accept is TIFF, but
R has no tiff device to produce that pictures. Does someone know a strait way
to convert the EPS file into the high resolution high quality TIFF figure?


-- 
Sincerely yours,
Yury Yuryev.

__
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] generate random numbers that sum up to 1

2006-10-10 Thread sun
I am trying to generate a vector of random numbers with the constraint that 
they have to sum up to one with uniform distribution.

eg. {0.1,0.7,0.2 }

any function to do this? Thanks.

__
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] generate random numbers that sum up to 1

2006-10-10 Thread Rolf Turner

As I have previously asked, in response to a similar
question:  Is this a homework problem?

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] eps embedded fonts again

2006-10-10 Thread Prof Brian Ripley
On Tue, 10 Oct 2006, Yury Yuryev wrote:

 Dear friends,

 I am sorry, I again rise that boring question about font embedding in
 EPS figure.

It gives us an opportunity to point you to the solution included in R 
2.4.0.

 I found some discussions on this topic but there were no strait solution.

 The publisher (AIP) demands submission of separate EPS file
 for each figure with all fonts embedded in it (even the standard
 14 Adobe fonts).

 As I understand the R does not do this embedding. It inserts only
 comments what font resources are needed.

Yes, that's the EPS standard.

 Then I should use some other software to do this task. Is there a 
 solution for problem within open source environment (without using of 
 proprietary software)? My system is Debian GNU/Linux (testing).

ghostscript: see the R-News 6/2 article for an R wrapper function 
embedFonts() to help you with this.

 The second picture format that AIP journals accept is TIFF, but
 R has no tiff device to produce that pictures. Does someone know a strait way
 to convert the EPS file into the high resolution high quality TIFF figure?

ghostscript, ImageMagick.

-- 
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] generate random numbers that sum up to 1

2006-10-10 Thread Peter Dalgaard
Rolf Turner [EMAIL PROTECTED] writes:

 As I have previously asked, in response to a similar
 question:  Is this a homework problem?

If so, he has a pretty nasty teacher...

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

__
R-help@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] generate random numbers that sum up to 1

2006-10-10 Thread Peter Dalgaard
sun [EMAIL PROTECTED] writes:

 I am trying to generate a vector of random numbers with the constraint that 
 they have to sum up to one with uniform distribution.
 
 eg. {0.1,0.7,0.2 }
 
 any function to do this? Thanks.

Depending on what you mean by uniform, this may be a solution

 x-runif(3)
 x/sum(x)
[1] 0.1130642 0.4098608 0.4770750

What you can't have is the individual components uniform and
identically distributed because the sum of the means would be 1.5 and
equal to the mean of the sum which is 1...

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

__
R-help@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] generate random numbers that sum up to 1

2006-10-10 Thread Ben Fairbank
 
The trick is in defining random in the face of the three apparently
incompatible constraints that the numbers be random, that they sum to 1,
and that they be uniformly distributed.  Tell us more.  Perhaps extend
Peter D's solution by first deciding (at random) how many components
each solution will have.

Ben Fairbank

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of sun
Sent: Tuesday, October 10, 2006 8:28 AM
To: r-help@stat.math.ethz.ch
Subject: [R] generate random numbers that sum up to 1

I am trying to generate a vector of random numbers with the constraint
that they have to sum up to one with uniform distribution.

eg. {0.1,0.7,0.2 }

any function to do this? Thanks.

__
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] 2 linux/R environment questions

2006-10-10 Thread Leeds, Mark \(IED\)
I was working on windows xp for a while and now i am back to linux ( not
sure which kind but I can find out if that helps ) and i just have two
questions that are
really environment R questions rather than R code questions.
 
1) i use emacs ( or xemacs if need be ) and i vaguely being able to cut
a line or a region in an emacs window and then paste it at my R prompt
so that it ran. Could I be mistaken 
or is there an  option I need to set in my environment to be able to do
this. It doesn't seem to work and I would prefer to avoid learning ESS.
 
2) I can make my linux window ( where i am working in R )  quite wide
but if i do a print or a head on a dataframe of say 8 columns , it
doesn't know that there is all this extra space 
in the window and it ends  up putting the columns on top of each other
instead of straight across and it's hard to read the data this way ? Is
there a way to make it know that it has a lot more room than it is
using.
 
 
Thanks a lot.
 
 
 
Mark


This is not an offer (or solicitation of an offer) to buy/sell the 
securities/instruments mentioned or an official confirmation.  Morgan Stanley 
may deal as principal in or own or act as market maker for 
securities/instruments mentioned or may advise the issuers.  This is not 
research and is not from MS Research but it may refer to a research 
analyst/research report.  Unless indicated, these views are the author's and 
may differ from those of Morgan Stanley research or others in the Firm.  We do 
not represent this is accurate or complete and we may not update this.  Past 
performance is not indicative of future returns.  For additional information, 
research reports and important disclosures, contact me or see 
https://secure.ms.com/servlet/cls.  You should not use e-mail to request, 
authorize or effect the purchase or sale of any security or instrument, to send 
transfer instructions, or to effect any other transactions.  We cannot 
guarantee that any such requests received via !
 e-mail will be processed in a timely manner.  This communication is solely for 
the addressee(s) and may contain confidential information.  We do not waive 
confidentiality by mistransmission.  Contact me if you do not wish to receive 
these communications.  In the UK, this communication is directed in the UK to 
those persons who are market counterparties or intermediate customers (as 
defined in the UK Financial Services Authority's rules).

[[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] find weighted group mean

2006-10-10 Thread Young Cho
HI,

I am trying to figure out an efficient way to calculate group means and
associate each entry with it. I made up an example:

 A = rep(rep(0:1,each=2),3)
 B = rep(rep(0:1,4),3)
 C = rep(rep(c(0,0,1,1),2),3)
 X =cbind(rnorm(24,0,1),runif(24,0,1),A,B,C)
  A B C
 [1,] -1.92926469 0.32213127 0 0 0
 [2,] -0.83935617 0.77794096 0 1 0
 [3,] -1.27799751 0.26276934 1 0 1

Suppose I want to compute a weighted mean of X[,1] by for each group, which
is defined by unique vector (A,B,C) with weights are X[,2]. And then add a
column for the weighted group mean. How can I do this ?  My matrix is fairly
large (few thousands) but, luckily, I have only a few factors (10).

Thanks a lot,

Young.

[[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] 2 linux/R environment questions

2006-10-10 Thread Dirk Eddelbuettel

On 10 October 2006 at 10:51, Leeds, Mark \(IED\) wrote:
| 1) i use emacs ( or xemacs if need be ) and i vaguely being able to cut
| a line or a region in an emacs window and then paste it at my R prompt
| so that it ran. Could I be mistaken 
| or is there an  option I need to set in my environment to be able to do
| this. It doesn't seem to work and I would prefer to avoid learning ESS.

All three questions in section 6 in the R FAQ details R and (X)Emacs.  And
yes, you do want to learn ESS as that is how (X)Emacs and R play together.

| 2) I can make my linux window ( where i am working in R )  quite wide
| but if i do a print or a head on a dataframe of say 8 columns , it
| doesn't know that there is all this extra space 
| in the window and it ends  up putting the columns on top of each other
| instead of straight across and it's hard to read the data this way ? Is
| there a way to make it know that it has a lot more room than it is
| using.

Put 

options(width=160)   # or whatever nb of columns you want

into ~/.Rprofile.  You may want to set other preferences too, see

help(options)
help(Startup)

Good luck,  Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
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] generate random numbers that sum up to 1

2006-10-10 Thread Duncan Murdoch
On 10/10/2006 9:53 AM, Peter Dalgaard wrote:
 sun [EMAIL PROTECTED] writes:
 
 I am trying to generate a vector of random numbers with the constraint that 
 they have to sum up to one with uniform distribution.
 
 eg. {0.1,0.7,0.2 }
 
 any function to do this? Thanks.
 
 Depending on what you mean by uniform, this may be a solution
 
 x-runif(3)
 x/sum(x)
 [1] 0.1130642 0.4098608 0.4770750
 
 What you can't have is the individual components uniform and
 identically distributed because the sum of the means would be 1.5 and
 equal to the mean of the sum which is 1...
 

Another definition of uniform is to have equal density for all possible 
vectors; the Dirichlet distribution with parameters (1,1,1) would give 
you that.  RSiteSearch finds at least a couple of packages (VGAM, 
MCMCpack) that provide simulations from the Dirichlet.

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] find weighted group mean

2006-10-10 Thread Alex Brown

You can do it directly from the X matrix like so:

  by(X, as.list(as.data.frame(X[,3:5])), function(R)weighted.mean(R 
[1], R[2]))
A: 0
B: 0
C: 0
[1] 0.4912458

A: 1
B: 0
C: 0
[1] NA

A: 0
B: 1
C: 0
[1] -0.2694550

A: 1
B: 1
C: 0
[1] NA

A: 0
B: 0
C: 1
[1] NA

A: 1
B: 0
C: 1
[1] 0.01102718

A: 0
B: 1
C: 1
[1] NA

A: 1
B: 1
C: 1
[1] -0.5622041


Or you can poke about a bit with it first:

  Z = as.data.frame(X)
  names(Z) = c(x, w, A, B, C)
  by(Z[,c(x, w)], list(paste(A, Z$A, B, Z$B, C, Z$C)),  
function(R)weighted.mean(R$x, R$w))
: A 0 B 0 C 0
[1] 0.4912458

: A 0 B 1 C 0
[1] -0.2694550

: A 1 B 0 C 1
[1] 0.01102718

: A 1 B 1 C 1
[1] -0.5622041

-Alex

On 10 Oct 2006, at 16:13, Young Cho wrote:

 HI,

 I am trying to figure out an efficient way to calculate group means  
 and
 associate each entry with it. I made up an example:

  A = rep(rep(0:1,each=2),3)
  B = rep(rep(0:1,4),3)
  C = rep(rep(c(0,0,1,1),2),3)
  X =cbind(rnorm(24,0,1),runif(24,0,1),A,B,C)
   A B C
  [1,] -1.92926469 0.32213127 0 0 0
  [2,] -0.83935617 0.77794096 0 1 0
  [3,] -1.27799751 0.26276934 1 0 1

 Suppose I want to compute a weighted mean of X[,1] by for each  
 group, which
 is defined by unique vector (A,B,C) with weights are X[,2]. And  
 then add a
 column for the weighted group mean. How can I do this ?  My matrix  
 is fairly
 large (few thousands) but, luckily, I have only a few factors (10).

 Thanks a lot,

 Young.

   [[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] find weighted group mean

2006-10-10 Thread Gabor Grothendieck
Here are two ways:


f1 - function(i) weighted.mean(X[i,1], X[i,2])
aggregate(list(wmean = 1:nrow(X)), as.data.frame(X[,3:5]), f1)

f2 - function(x) data.frame(wmean = weighted.mean(x[,1], x[,2]), x[1, 3:5])
do.call(rbind, by(X, as.data.frame(X[,3:5]), f2))

Also you check out the na.rm= argument in ?weighted.mean which
may or may not be relevant to you.

On 10/10/06, Young Cho [EMAIL PROTECTED] wrote:
 HI,

 I am trying to figure out an efficient way to calculate group means and
 associate each entry with it. I made up an example:

  A = rep(rep(0:1,each=2),3)
  B = rep(rep(0:1,4),3)
  C = rep(rep(c(0,0,1,1),2),3)
  X =cbind(rnorm(24,0,1),runif(24,0,1),A,B,C)
  A B C
  [1,] -1.92926469 0.32213127 0 0 0
  [2,] -0.83935617 0.77794096 0 1 0
  [3,] -1.27799751 0.26276934 1 0 1

 Suppose I want to compute a weighted mean of X[,1] by for each group, which
 is defined by unique vector (A,B,C) with weights are X[,2]. And then add a
 column for the weighted group mean. How can I do this ?  My matrix is fairly
 large (few thousands) but, luckily, I have only a few factors (10).

 Thanks a lot,

 Young.

[[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] update.default evaluating in wrong environment?

2006-10-10 Thread Martin C. Martin
Hi all,

update.default, which is the method used to update lm objects (among
others), extracts the call element from it's first argument, updates
it, then evaluates it in the parent.frame().  Shouldn't it be evaluated
in environment(formula(object)), if that's non-NULL?

I ask because I call lm from within a function, and the data argument
is a local variable of that function.  After that, I can't update the
model any more, since the new lm() call (the one evaled in
parent.frame()) can't find the data.

Best,
Martin

__
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] .arch.uni in function call in arch test of vars package

2006-10-10 Thread Joe Byers
I have been reviewing the arch test of vars package that is based on 
Engle's paper.  R-metrics has this as a wants/todo item.  I need an arch 
test and thought I might accomplish two things at once or at least try.

The arch test requires a varest object and I am trying to write one that 
will use R-metrics arima, arch, Garch objects, or at least a vector. 
Also the arch function has the following line of code that I can not 
find the function anywhere

archs.resids - apply(resids, 2, function(x) .arch.uni(x,
 lags.single = lags.single))

does any one know about the function .arch.uni?

Thank you
Joe

__
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] Surfaceplot3D with wireframe

2006-10-10 Thread Deepayan Sarkar
On 10/10/06, Gustaf Granath [EMAIL PROTECTED] wrote:
 Hi,
 I want to make a surface3D plot of a landscape. I have cordinates (x, y, z)
 recorded with a GPS. The datapoints are not evenly distributed within the
 rectangular area.

 To do a fast 3D plot I used following.

  library(grid)
  library(lattice)
  v - read.table(clipboard)
  names(v) - c(x, y, z)
  wireframe(z ~ x * y, data = v)

 However I just get an empty box with no 3D grid. I have tried with other data
 and then it usually works. But I cant get it to work with my data.
 Here is a sample of my data (x, y, z). I think there is something in my data 
 set
 that wireframe doesnt like.

Yes, and you have already stated what that is, namely that The
datapoints are not evenly distributed within the rectangular area. As
it says in the first multiple-sentence paragraph in help page for
wireframe:

  ... In the case of 'wireframe',
  calculations are based on the assumption that the 'x' and 'y'
  values are evaluated on a rectangular grid defined by their
  unique values.  The grid points need not be equally spaced.

You need to use your favorite smoothing method to evaluate z values on
a grid. ?levelplot has an example using loess (the akima package is
also popular, although I'm not personally familiar with it).

Another alternative is using some form of triangulation (e.g. voronoi
tesselation). This should be possible, but is not trivial.

-Deepayan

 Any ideas?? Are there better commands to use?
 (I have tried to change the magnitude of the numbers but that doesnt help)
  y   xz
 6659592.078 1585162.959 59.229
 6659591.348 1585164.402 59.159
 6659590.494 1585163.294 59.205
 6659589.466 1585158.968 59.290
 6659589.229 1585159.390 59.246
 6659588.963 1585158.895 59.201
 6659589.475 1585158.617 59.199
 6659589.808 1585159.206 59.135
 6659592.361 1585161.707 59.447
 6659592.387 1585161.319 59.437
 6659592.590 1585161.871 59.217
 6659591.989 1585162.156 59.163
 6659591.934 1585161.489 59.358
 6659590.340 1585158.060 59.352
 6659590.228 1585157.714 59.138
 6659590.957 1585157.947 59.145
 6659590.422 1585158.344 59.214
 6659589.904 1585158.024 59.175
 6659589.877 1585162.033 59.346
 6659589.967 1585161.674 59.197
 6659590.109 1585162.062 59.205
 6659589.778 1585162.572 59.152
 6659589.591 1585161.876 59.187
 6659591.783 1585156.210 59.561
 6659592.164 1585156.764 59.266
 6659590.352 1585156.154 59.339
 6659590.890 1585154.720 59.278
 6659592.520 1585155.023 59.250
 6659593.127 1585166.690 59.217

 Regards,
 Gustaf

__
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] update.default evaluating in wrong environment?

2006-10-10 Thread Gabor Grothendieck
As a workaround use evaluate=FALSE argument to update and
evaluate it yourself fetching the environment from the innards
of the lm structure:

f - function() {
   DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
   lm(y ~ x1, DF)
}

f.lm - f()
e - attr(terms(f.lm), .Environment)
eval(update(f.lm, formula = y ~ x2, evaluate = FALSE), e)


On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:
 Hi all,

 update.default, which is the method used to update lm objects (among
 others), extracts the call element from it's first argument, updates
 it, then evaluates it in the parent.frame().  Shouldn't it be evaluated
 in environment(formula(object)), if that's non-NULL?

 I ask because I call lm from within a function, and the data argument
 is a local variable of that function.  After that, I can't update the
 model any more, since the new lm() call (the one evaled in
 parent.frame()) can't find the data.

 Best,
 Martin

 __
 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] update.default evaluating in wrong environment?

2006-10-10 Thread Martin C. Martin


Gabor Grothendieck wrote:
 As a workaround use evaluate=FALSE argument to update and
 evaluate it yourself fetching the environment from the innards
 of the lm structure:
 
 f - function() {
   DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
   lm(y ~ x1, DF)
 }
 
 f.lm - f()
 e - attr(terms(f.lm), .Environment)
 eval(update(f.lm, formula = y ~ x2, evaluate = FALSE), e)

Thanks, or even just:

e - environment(formula(f.lm))

But this was more of a bug report.  Is update.default wrong?  Should it 
be changed?  I don't see how evaluating in update's parent environment 
would ever be better default behavior than the formula's environment.

- Martin
 
 
 On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:
 Hi all,

 update.default, which is the method used to update lm objects (among
 others), extracts the call element from it's first argument, updates
 it, then evaluates it in the parent.frame().  Shouldn't it be evaluated
 in environment(formula(object)), if that's non-NULL?

 I ask because I call lm from within a function, and the data argument
 is a local variable of that function.  After that, I can't update the
 model any more, since the new lm() call (the one evaled in
 parent.frame()) can't find the data.

 Best,
 Martin

 __
 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] 2 linux/R environment questions

2006-10-10 Thread Joe Byers
Mark,

you could also try rkward a gui for R from
http://rkward.sourceforge.net/
or JGR.  I have experimented with both because like you I have been 
avoiding learning ESS, and emacs just confuses me.

rkward seems fine with a few quirks that I need to report as problems, 
like the object browser not showing the r session objects, and a couple 
of package functions not working correctly.  I hope these are just 
because I have a RHEL 4 linux system.

JGR, when I manually compiled it for my system by specifying my location 
of java 1.5.0_06, worked fairly nicely.  The autoinstall does not find 
my installation of this java version since Redhat EL4 does not support 
it.  Redhat EL5 will in the near future.  Maybe JGR will autoinstall then.

These are just GUI/programming options that I have tried.

Good Luck
Joe

Leeds, Mark (IED) wrote:
 I was working on windows xp for a while and now i am back to linux ( not
 sure which kind but I can find out if that helps ) and i just have two
 questions that are
 really environment R questions rather than R code questions.
  
 1) i use emacs ( or xemacs if need be ) and i vaguely being able to cut
 a line or a region in an emacs window and then paste it at my R prompt
 so that it ran. Could I be mistaken 
 or is there an  option I need to set in my environment to be able to do
 this. It doesn't seem to work and I would prefer to avoid learning ESS.
  
 2) I can make my linux window ( where i am working in R )  quite wide
 but if i do a print or a head on a dataframe of say 8 columns , it
 doesn't know that there is all this extra space 
 in the window and it ends  up putting the columns on top of each other
 instead of straight across and it's hard to read the data this way ? Is
 there a way to make it know that it has a lot more room than it is
 using.
  
  
 Thanks a lot.
  
  
  
 Mark
 
 
 This is not an offer (or solicitation of an offer) to buy/sell the 
 securities/instruments mentioned or an official confirmation.  Morgan Stanley 
 may deal as principal in or own or act as market maker for 
 securities/instruments mentioned or may advise the issuers.  This is not 
 research and is not from MS Research but it may refer to a research 
 analyst/research report.  Unless indicated, these views are the author's and 
 may differ from those of Morgan Stanley research or others in the Firm.  We 
 do not represent this is accurate or complete and we may not update this.  
 Past performance is not indicative of future returns.  For additional 
 information, research reports and important disclosures, contact me or see 
 https://secure.ms.com/servlet/cls.  You should not use e-mail to request, 
 authorize or effect the purchase or sale of any security or instrument, to 
 send transfer instructions, or to
   effect any other transactions.  We cannot guarantee that any such requests 
 received via !
  e-mail will be processed in a timely manner.  This communication is solely 
 for the addressee(s) and may contain confidential information.  We do not 
 waive confidentiality by mistransmission.  Contact me if you do not wish to 
 receive these communications.  In the UK, this communication is directed in 
 the UK to those persons who are market counterparties or intermediate 
 customers (as defined in the UK Financial Services Authority's rules).
 
   [[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] update.default evaluating in wrong environment?

2006-10-10 Thread Gabor Grothendieck
It does seem strange to me too.  I guess what one could say
is that from an oo viewpoint the internal environment within f
is the object space and update needs to be a method of it which
could be arranged by including update in your lm object:

f - function() {
   DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
   f.lm - lm(y ~ x1, DF)
   f.lm$update - function(object = f.lm, ...) update(object, ...)
   f.lm
}

f.lm - f()
f.lm$update(formula = y ~ x2)


On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:


 Gabor Grothendieck wrote:
  As a workaround use evaluate=FALSE argument to update and
  evaluate it yourself fetching the environment from the innards
  of the lm structure:
 
  f - function() {
DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
lm(y ~ x1, DF)
  }
 
  f.lm - f()
  e - attr(terms(f.lm), .Environment)
  eval(update(f.lm, formula = y ~ x2, evaluate = FALSE), e)

 Thanks, or even just:

 e - environment(formula(f.lm))

 But this was more of a bug report.  Is update.default wrong?  Should it
 be changed?  I don't see how evaluating in update's parent environment
 would ever be better default behavior than the formula's environment.

 - Martin
 
 
  On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:
  Hi all,
 
  update.default, which is the method used to update lm objects (among
  others), extracts the call element from it's first argument, updates
  it, then evaluates it in the parent.frame().  Shouldn't it be evaluated
  in environment(formula(object)), if that's non-NULL?
 
  I ask because I call lm from within a function, and the data argument
  is a local variable of that function.  After that, I can't update the
  model any more, since the new lm() call (the one evaled in
  parent.frame()) can't find the data.
 
  Best,
  Martin
 
  __
  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] Interval pls

2006-10-10 Thread Dirk De Becker
Hey R-helpers,

Does anybody know of an implementation of interval PLS in R?

Thx,

Dirk

-- 
Dirk De Becker
Work: Kasteelpark Arenberg 30
  3001 Heverlee
  phone: ++32(0)16/32.14.44
  fax: ++32(0)16/32.85.90
Home: Waversebaan 90
  3001 Heverlee
  phone: ++32(0)16/23.36.65
[EMAIL PROTECTED]
mobile phone: ++32(0)498/51.19.86


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
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] update.default evaluating in wrong environment?

2006-10-10 Thread Thomas Lumley
On Tue, 10 Oct 2006, Martin C. Martin wrote:
 Thanks, or even just:

 e - environment(formula(f.lm))

 But this was more of a bug report.  Is update.default wrong?  Should it
 be changed?  I don't see how evaluating in update's parent environment
 would ever be better default behavior than the formula's environment.


This is deliberate (although that doesn't necessarily imply that it is 
optimal). There already is a bug report (PR#1861) on this issue, so 
another one certainly isn't appropriate.

The comments for this bug report give an example taken from the scripts 
for MASS chapter 6, doing a bootstrap of a linear model
ph.fun - function(data, i) {
   d - data
   d$calls - d$fitted + d$res[i]
   coef(update(fit, data=d))
}

This is not uncommon for resampling and other perturbations of a model and 
requires looking in the calling frame of update().

For other uses such as yours the right place would be the frame where the 
model was created. Neither the environment of the formula nor the calling 
frame of update() is guaranteed to be the right place and it is easy to 
come up with examples where each works and the other doesn't.

There really isn't a trivial solution to this.

-thomas

__
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] update.default evaluating in wrong environment?

2006-10-10 Thread Martin C. Martin
Great; thanks for the detailed explanation!

- Martin

Thomas Lumley wrote:
 On Tue, 10 Oct 2006, Martin C. Martin wrote:
 Thanks, or even just:

 e - environment(formula(f.lm))

 But this was more of a bug report.  Is update.default wrong?  Should it
 be changed?  I don't see how evaluating in update's parent environment
 would ever be better default behavior than the formula's environment.

 
 This is deliberate (although that doesn't necessarily imply that it is 
 optimal). There already is a bug report (PR#1861) on this issue, so 
 another one certainly isn't appropriate.
 
 The comments for this bug report give an example taken from the scripts 
 for MASS chapter 6, doing a bootstrap of a linear model
 ph.fun - function(data, i) {
   d - data
   d$calls - d$fitted + d$res[i]
   coef(update(fit, data=d))
 }
 
 This is not uncommon for resampling and other perturbations of a model 
 and requires looking in the calling frame of update().
 
 For other uses such as yours the right place would be the frame where 
 the model was created. Neither the environment of the formula nor the 
 calling frame of update() is guaranteed to be the right place and it is 
 easy to come up with examples where each works and the other doesn't.
 
 There really isn't a trivial solution to this.
 
 -thomas

__
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 assign a rank to a range of values..

2006-10-10 Thread Thomas P. Colson
From the following:

basin.map - readAsciiGrid(c:/temp/area.asc, colname=area) 

I have a SpatialGridDataFrame which has the x and y cordinate of a cell, and
the drainage area of that cell. There are many cells with a low drainage
area (in my case, 33000 with an area of 37.16) and one cell with the highest
drainage area (again, in my case, a drainage area of of 80). 

What I'd like to do, is to rank the drainage area cells based upon the
number of times they occur, with a rank of 100 going to the cells with
area=37.16, and 1 going to the cell(s) with area=80). There are 6,000
different drainage areas out of 180,000 cells in this grid, so the ranks
would have values like 100, 99.01, 57.34, 20, 1.08, 1 and so forth. 


I have been struggeling with the split, length and rank commands in R, but
can't seem to figure out how to attach a new column (or make a new
dataset) that has a colums of ranks, or how to calculate the rank. 

Thanks for any help. 



Thomas Colson
North Carolina State University
Department of Forestry and Environmental Resources
(919)624-6329
(919)515 3434
[EMAIL PROTECTED]

Schedule: www4.ncsu.edu/~tpcolson

__
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] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Alberto Monteiro
The following code works fine:

# g is the function that returns the square of a number
g - function(y) y^2

# f1 is a function that takes one function
# as argument, and returns another function
f1 - function(f) function(x) f(x+1) - f(x)

# h(x) is g(x+1) - g(x) or 2x + 1
h - f1(g)

# h(1) = 3
# h(2) = 5
# h(3) = 7

So far, so good. But why:

h

shows:

function(x) f(x+1)-f(x)
environment: 0264BE84

I don't get it. h should show function(x) g(x+1)-g(x)
or something like that.

Alberto Monteiro

__
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] update.default evaluating in wrong environment?

2006-10-10 Thread Duncan Murdoch
On 10/10/2006 1:32 PM, Martin C. Martin wrote:
 
 Gabor Grothendieck wrote:
 As a workaround use evaluate=FALSE argument to update and
 evaluate it yourself fetching the environment from the innards
 of the lm structure:
 
 f - function() {
   DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
   lm(y ~ x1, DF)
 }
 
 f.lm - f()
 e - attr(terms(f.lm), .Environment)
 eval(update(f.lm, formula = y ~ x2, evaluate = FALSE), e)
 
 Thanks, or even just:
 
 e - environment(formula(f.lm))
 
 But this was more of a bug report.  Is update.default wrong?  Should it 
 be changed?  I don't see how evaluating in update's parent environment 
 would ever be better default behavior than the formula's environment.

This is pretty old code:  I think the particular line causing the 
problem you see was put there in 2000, but it was a workalike for code 
that was there already in 1998.  This isn't to say that old code is 
necessarily right, but changing it could have lots of unwanted side 
effects.  It's also likely that whatever was in the mind of whoever 
wrote the original shows up in other places, so tracking things down to 
make a consistent change would be a lot of work.  You'd probably want to 
read the referenced 1992 Statistical Models definition of the expected 
behaviour here pretty closely (and recognize that the 1992 book is about 
S, not R, so we might not want to follow it exactly), etc., etc., etc.

All of which is to say that I wouldn't pick up this bug fix unless I was 
personally bitten by it:  it looks like an awful lot of work.  But there 
are others who may want to tackle it.

Duncan Murdoch

 
 - Martin
 
 
 On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:
 Hi all,

 update.default, which is the method used to update lm objects (among
 others), extracts the call element from it's first argument, updates
 it, then evaluates it in the parent.frame().  Shouldn't it be evaluated
 in environment(formula(object)), if that's non-NULL?

 I ask because I call lm from within a function, and the data argument
 is a local variable of that function.  After that, I can't update the
 model any more, since the new lm() call (the one evaled in
 parent.frame()) can't find the data.

 Best,
 Martin

 __
 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] update.default evaluating in wrong environment?

2006-10-10 Thread Gabor Grothendieck
Perhaps the evaluate= argument could be extended to
allow an environment or an object for which
environment(object) yields an environment, e.g.

update(y ~ x2, evaluate = formula(f.lm))


On 10/10/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
 On 10/10/2006 1:32 PM, Martin C. Martin wrote:
 
  Gabor Grothendieck wrote:
  As a workaround use evaluate=FALSE argument to update and
  evaluate it yourself fetching the environment from the innards
  of the lm structure:
 
  f - function() {
DF - data.frame(y = 1:12, x1 = gl(2, 1, 12), x2 = gl(2,6))
lm(y ~ x1, DF)
  }
 
  f.lm - f()
  e - attr(terms(f.lm), .Environment)
  eval(update(f.lm, formula = y ~ x2, evaluate = FALSE), e)
 
  Thanks, or even just:
 
  e - environment(formula(f.lm))
 
  But this was more of a bug report.  Is update.default wrong?  Should it
  be changed?  I don't see how evaluating in update's parent environment
  would ever be better default behavior than the formula's environment.

 This is pretty old code:  I think the particular line causing the
 problem you see was put there in 2000, but it was a workalike for code
 that was there already in 1998.  This isn't to say that old code is
 necessarily right, but changing it could have lots of unwanted side
 effects.  It's also likely that whatever was in the mind of whoever
 wrote the original shows up in other places, so tracking things down to
 make a consistent change would be a lot of work.  You'd probably want to
 read the referenced 1992 Statistical Models definition of the expected
 behaviour here pretty closely (and recognize that the 1992 book is about
 S, not R, so we might not want to follow it exactly), etc., etc., etc.

 All of which is to say that I wouldn't pick up this bug fix unless I was
 personally bitten by it:  it looks like an awful lot of work.  But there
 are others who may want to tackle it.

 Duncan Murdoch

 
  - Martin
 
 
  On 10/10/06, Martin C. Martin [EMAIL PROTECTED] wrote:
  Hi all,
 
  update.default, which is the method used to update lm objects (among
  others), extracts the call element from it's first argument, updates
  it, then evaluates it in the parent.frame().  Shouldn't it be evaluated
  in environment(formula(object)), if that's non-NULL?
 
  I ask because I call lm from within a function, and the data argument
  is a local variable of that function.  After that, I can't update the
  model any more, since the new lm() call (the one evaled in
  parent.frame()) can't find the data.
 
  Best,
  Martin
 
  __
  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] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Duncan Murdoch
On 10/10/2006 3:53 PM, Alberto Monteiro wrote:
 The following code works fine:
 
 # g is the function that returns the square of a number
 g - function(y) y^2
 
 # f1 is a function that takes one function
 # as argument, and returns another function
 f1 - function(f) function(x) f(x+1) - f(x)
 
 # h(x) is g(x+1) - g(x) or 2x + 1
 h - f1(g)
 
 # h(1) = 3
 # h(2) = 5
 # h(3) = 7
 
 So far, so good. But why:
 
 h
 
 shows:
 
 function(x) f(x+1)-f(x)
 environment: 0264BE84
 
 I don't get it. h should show function(x) g(x+1)-g(x)
 or something like that.

But you defined the result of f1 to be function(x) f(x+1) - f(x), so 
what it is showing you is correct.  This will be evaluated in 
environment: 0264BE84, where f is defined to be function(y) y^2, which 
is why h gives the right answers.

Remember that R isn't a macro language, function calls aren't text 
substitutions.

Duncan Murdoch

 
 Alberto Monteiro
 
 __
 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] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Deepayan Sarkar
On 10/10/06, Alberto Monteiro [EMAIL PROTECTED] wrote:
 The following code works fine:

 # g is the function that returns the square of a number
 g - function(y) y^2

 # f1 is a function that takes one function
 # as argument, and returns another function
 f1 - function(f) function(x) f(x+1) - f(x)

 # h(x) is g(x+1) - g(x) or 2x + 1
 h - f1(g)

 # h(1) = 3
 # h(2) = 5
 # h(3) = 7

 So far, so good. But why:

 h

 shows:

 function(x) f(x+1)-f(x)
 environment: 0264BE84

Presumably, 'f' takes the value 'g' in this environment, and indeed

 environment(h)$f
function(y) y^2

 I don't get it. h should show function(x) g(x+1)-g(x)
 or something like that.

Not that I know much about functions and environments, but printing is
ultimately a matter of aesthetics. What do you think should happen
when

h - f1(function(y) y^2)

and you try to print h ?

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


[R] Including time in a zoo

2006-10-10 Thread Horace Tso
dear list,

I have these hourly price data over a 20 year period. Among other things, I 
want to plot them with time on the x-axis. The data is in a data frame,

 head(OWI.SE.all)
   Record_Number   Name Condition  Time_PeriodPrice
1312 WECC-OWI SouthEast   All 1/1/2012 Hour: 1 41.21383
2827 WECC-OWI SouthEast   All 1/1/2012 Hour: 2 38.38091
4342 WECC-OWI SouthEast   All 1/1/2012 Hour: 3 39.97879
5857 WECC-OWI SouthEast   All 1/1/2012 Hour: 4 40.14156
7372 WECC-OWI SouthEast   All 1/1/2012 Hour: 5 38.21092
8887 WECC-OWI SouthEast   All 1/1/2012 Hour: 6 40.09152

And the date-times are in a POSIX object dte1,

 class(dte1)
[1] POSIXt  POSIXlt

When I tried to create a zoo with dte1 as the index, I got an error,

 zoo(OWI.SE.all, dte1) 
Error in order(x, ..., na.last = na.last, decreasing = decreasing) : 
unimplemented type 'list' in 'orderVector1'

I guess that's saying the index of a zoo can't have a time component. Am I 
correct? If so, is there a way to include an hour component in a zoo object.

Second question: 

If I just attach this dte1 to my data frame as a column named Date and try 
plotting it as,

 plot(OWI.SE.all$Date, OWI.SE.all$Price, type=l)

I got non-sensical result. How do I plot hourly data in general? 

TIA.

Horace W. Tso

__
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] rarefy a matrix of counts

2006-10-10 Thread Brian Frappier
Hi all,

I have a matrix of counts for objects (rows) by samples (columns).  I aimed
for about 500 counts in each sample (I have about 80 samples) and would now
like to rarefy these down to 100 counts in each sample using simple random
sampling without replacement.  I plan on rarefying several times for each
sample.  I could do the tedious looping task of making a list of all objects
(with its associated identifier) in each sample and then use the wonderful
sampling package to select a sub-sample of 100 for each sample and thereby
get a logical vector of inclusions.  I would then regroup the resulting
logical vector into a vector of counts by object, rinse and repeat several
times for each sample.

Alternately, using the same list, I could create a random index of integers
between 1 and the number of objects for a sample (without repeats) and then
select those objects from the list.  Again, rinse and repeat several time
for each sample.

Is there a way to directly rarefy a matrix of counts without having to
create a list of objects first?  I am trying to switch to R from Matlab and
am trying to pick up good programming habits from the start.

Much appreciation!

[[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] Data manipulation in columns (with apply?)

2006-10-10 Thread Bret Collier
R Users,
I have written a small simulation model in R which outputs a datafile 
consisting of ending population sizes for each simulation run (year).  The data 
(see short data example below) is labeled by NUM (simulation run), sim (year) 
and N (yearly count).   After searching the help files and coming up empty 
(probably because I used the wrong terms) I am appealing for some help for 
working with the output dataset. 

What I want to do is for each of the i simulation runs (NUM) I want to 

1) take N(t+1)/N(t)=lambda(t) for each year (where in the below example 
t=1,...,10--total years of the simulation)
2) Sum lambda(t) and divide by t (e.g., output both the mean/se of lambda for 
each simulation run)
3) Take the mean of the mean(lambda's) (and associated stddev, min, max) over 
all NUM

I think I have to write a function for use within an apply statement, but I am 
not quite there yet on the learning curve so most of my recent attempts in R 
have been useful learning experiences of what not to do...

Any suggestions/direction is greatly appreciated.

Bret Collier
TX AM

NUM sim N
1 1  466
1 2  450
1 3  473
1 4  531
1 5  515
1 6  502
1 7  471
1 8  460
1 9  458
1 10 434
2 1  289
2 2  356
2 3 387
2 4 440
2 5 457
2 6 466
2 7 467
2 8 449
2 9 387
2 10 394
3 1 367
3 2 400
3 3 476
3 4 508
3 5 478
3 6 501
3 7 513
3 8 505
3 9 492
3 10 465

platform   i386-pc-mingw32   
arch   i386  
os mingw32   
system i386, mingw32 
status   
major  2 
minor  3.0   
year   2006  
month  04
day24
svn rev37909 
language   R 
version.string Version 2.3.0 (2006-04-24) (yeah, I need to update)

__
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] r 2.4.0

2006-10-10 Thread victor
Uwe Ligges wrote:
 
 Dominique Katshunga wrote:
 Can someone help interprete the error message below? i was trying to
 load the package copula from the R command prompt.

 Error in loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = 
 keep.source) : 
 in 'copula' methods specified for export, but none defined: show,
 summary, persp, contour
 Error: package/namespace load failed for 'copula'
 Thanks,
 Dominique

 
 You have to reinstall all packages depending on methods after upgrade 
 to R-2.4.0.
 
 For convenience, type:
 
 update.packages(checkBuilt = TRUE)
 
 Uwe Ligges
 

Quite similar(?) problem occured after updating to 2.4.0 in a case of 
flexmix package. The error message:

  library(flexmix)
Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
 internal error in R_decompress1
Error: package/namespace load failed for 'flexmix'

I was using as you recommended 'update.packages(checkBuilt = TRUE)' and 
the error still occures. Have any an idea what to do in this case?

Thanks!

victor


 
 __
 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] Including time in a zoo

2006-10-10 Thread Gabor Grothendieck
Its saying you are trying to pass a list to zoo (a data frame is a list);
however, from ?zoo we see zoo takes a first argument of:
a numeric vector, matrix or a factor.

On 10/10/06, Horace Tso [EMAIL PROTECTED] wrote:
 dear list,

 I have these hourly price data over a 20 year period. Among other things, I 
 want to plot them with time on the x-axis. The data is in a data frame,

  head(OWI.SE.all)
   Record_Number   Name Condition  Time_PeriodPrice
 1312 WECC-OWI SouthEast   All 1/1/2012 Hour: 1 41.21383
 2827 WECC-OWI SouthEast   All 1/1/2012 Hour: 2 38.38091
 4342 WECC-OWI SouthEast   All 1/1/2012 Hour: 3 39.97879
 5857 WECC-OWI SouthEast   All 1/1/2012 Hour: 4 40.14156
 7372 WECC-OWI SouthEast   All 1/1/2012 Hour: 5 38.21092
 8887 WECC-OWI SouthEast   All 1/1/2012 Hour: 6 40.09152

 And the date-times are in a POSIX object dte1,

  class(dte1)
 [1] POSIXt  POSIXlt

 When I tried to create a zoo with dte1 as the index, I got an error,

  zoo(OWI.SE.all, dte1)
 Error in order(x, ..., na.last = na.last, decreasing = decreasing) :
unimplemented type 'list' in 'orderVector1'

 I guess that's saying the index of a zoo can't have a time component. Am I 
 correct? If so, is there a way to include an hour component in a zoo object.

 Second question:

 If I just attach this dte1 to my data frame as a column named Date and try 
 plotting it as,

  plot(OWI.SE.all$Date, OWI.SE.all$Price, type=l)

 I got non-sensical result. How do I plot hourly data in general?

 TIA.

 Horace W. Tso

 __
 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] Data manipulation in columns (with apply?)

2006-10-10 Thread jim holtman
Does this start to do what you want?

 x - NUM sim N
+ 1 1  466
+ 1 2  450
+ 1 3  473
+ 1 4  531
+ 1 5  515
+ 1 6  502
+ 1 7  471
+ 1 8  460
+ 1 9  458
+ 1 10 434
+ 2 1  289
+ 2 2  356
+ 2 3 387
+ 2 4 440
+ 2 5 457
+ 2 6 466
+ 2 7 467
+ 2 8 449
+ 2 9 387
+ 2 10 394
+ 3 1 367
+ 3 2 400
+ 3 3 476
+ 3 4 508
+ 3 5 478
+ 3 6 501
+ 3 7 513
+ 3 8 505
+ 3 9 492
+ 3 10 465
 a - read.table(textConnection(x), header=T)
 lambda - by(a, a$NUM, function(x) x$N[-1] / x$N[-length(x$N)])
 lambda
a$NUM: 1
[1] 0.9656652 1.051 1.1226216 0.9698682 0.9747573 0.9382470
0.9766454 0.9956522 0.9475983
--
a$NUM: 2
[1] 1.2318339 1.0870787 1.1369509 1.0386364 1.0196937 1.0021459
0.9614561 0.8619154 1.0180879
--
a$NUM: 3
[1] 1.0899183 1.190 1.0672269 0.9409449 1.0481172 1.0239521
0.9844055 0.9742574 0.9451220
 # sum of lambdas
 sapply(lambda, sum)
   123
8.942166 9.357799 9.263944
 # mean
 sapply(lambda, mean)
   123
0.993574 1.039755 1.029327
 # sd
 sapply(lambda, sd)
 1  2  3
0.05822850 0.10525335 0.08004527





On 10/10/06, Bret Collier [EMAIL PROTECTED] wrote:
 R Users,
 I have written a small simulation model in R which outputs a datafile 
 consisting of ending population sizes for each simulation run (year).  The 
 data (see short data example below) is labeled by NUM (simulation run), sim 
 (year) and N (yearly count).   After searching the help files and coming up 
 empty (probably because I used the wrong terms) I am appealing for some help 
 for working with the output dataset.

 What I want to do is for each of the i simulation runs (NUM) I want to

 1) take N(t+1)/N(t)=lambda(t) for each year (where in the below example 
 t=1,...,10--total years of the simulation)
 2) Sum lambda(t) and divide by t (e.g., output both the mean/se of lambda for 
 each simulation run)
 3) Take the mean of the mean(lambda's) (and associated stddev, min, max) over 
 all NUM

 I think I have to write a function for use within an apply statement, but I 
 am not quite there yet on the learning curve so most of my recent attempts in 
 R have been useful learning experiences of what not to do...

 Any suggestions/direction is greatly appreciated.

 Bret Collier
 TX AM

 NUM sim N
 1 1  466
 1 2  450
 1 3  473
 1 4  531
 1 5  515
 1 6  502
 1 7  471
 1 8  460
 1 9  458
 1 10 434
 2 1  289
 2 2  356
 2 3 387
 2 4 440
 2 5 457
 2 6 466
 2 7 467
 2 8 449
 2 9 387
 2 10 394
 3 1 367
 3 2 400
 3 3 476
 3 4 508
 3 5 478
 3 6 501
 3 7 513
 3 8 505
 3 9 492
 3 10 465

 platform   i386-pc-mingw32
 arch   i386
 os mingw32
 system i386, mingw32
 status
 major  2
 minor  3.0
 year   2006
 month  04
 day24
 svn rev37909
 language   R
 version.string Version 2.3.0 (2006-04-24) (yeah, I need to update)

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



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

What is the problem you are trying to solve?

__
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] R 2.4.0 can not work in Chinese windows

2006-10-10 Thread liu, jcheng
Dear list,
 R 2.4.0 can not work in Chinese windows. it's a bug?
Thanks!

-- 

Sincerely yours,

Liu, jcheng

__
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] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Alberto Vieira Ferreira Monteiro
Deepayan Sarkar wrote:

 # f1 is a function that takes one function
 # as argument, and returns another function
 f1 - function(f) function(x) f(x+1) - f(x)

 # h(x) is g(x+1) - g(x) or 2x + 1
 h - f1(g)

 h

 function(x) f(x+1)-f(x)
 environment: 0264BE84

 Presumably, 'f' takes the value 'g' in this environment, and indeed

 environment(h)$f

 function(y) y^2

Ok, so it's possible to recover the meaning of h. It might then
be possible to write something like simplify, that would
take a function and try to rewrite it using simpler blocks.

In this case, simplify h would return the function h1
equal to function(x) (x+1)^2 - x^2.

 Not that I know much about functions and environments, but printing is
 ultimately a matter of aesthetics. What do you think should happen
 when

 h - f1(function(y) y^2)

 and you try to print h ?

Yesterday, I would expect function(y) (y+1)^2 - y^2, but today I expect
the same as above.

Alberto Monteiro

__
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] Accessing R from Java

2006-10-10 Thread fuad
 

Hello All,

 

I am Fuad from Indonesia. I am doing a research using R. I need to access R
from Java. 

Here are my computer specifications :

1.   Windows XP

2.   Java 1.4.0

3.   R 2.2.1

4.   rJava_0.4.3.zip ; I download the binary from CRAN

5.   Rserve_0.4 ; I download the exe from Rosuda

6.   JRI_0.3.5.tar.gz from Rosuda too

 

I have successfully install and try a little code in R. 

I have install packages rJava from RGUI and it was successful.

But when I try to load packages using library(rJava) I have error : unable
to load shared library rJava.dll. There is no Jvm.dll.

So I copied jvm.dll from JAVA_HOME\bin to R_HOME\bin, and it seems done well
until I try to wake up Java Virtual Machine using .jinit() I received error
: cannot create JVM. 

 

Is there anyway I can call R inside Java code ?

Please help me. Thank you

 

Best regards,

 

Fuad

 


[[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] R 2.4.0 can not work in Chinese windows

2006-10-10 Thread Duncan Murdoch
On 10/10/2006 8:30 PM, liu, jcheng wrote:
 Dear list,
  R 2.4.0 can not work in Chinese windows. it's a bug?

Yes, the translations were mislabelled.  R-patched fixes it.

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 error of non-numeric argument to binary operator

2006-10-10 Thread Yulei Gong
Hi,
I have the following data and there is no binary operator contained,
however, I still receive the error message when running unitrootTest
function, could someone give me a guidance on it??

readClipboard()
  [1] 245246261.5  275.5  307284.5  289313.5
323.75 334 312.5  325305.5  322.5  317310.5
 [17] 302301305287277.5  271 271.5  278.5
279271263262262271262257
 [33] 251.5  258 252.5  254.5  253251.5  255
253253243238.5  234229.5  230.5   237.5  
235.5
 [49] 238225227.5  233236.5  236.5  231.5
225221.5  221.5   221.5  221.5  221.5  221.25 221
206
 [65] 207.5  196192.5  193.5  186 197.5  193.5
201195183185.5  181.5  179177173
169.5
 [81] 173178169173167 158.5  169.5
164145127.5  132131131120120.5  
120.25
 [97] 120 112.5  114.5  106113111113118.5
131131146.5  133.5  128132 130.5  122
[113] 122.5  123.5  126140132140143
148168162.5   152.5  148144144150.5
151
[129] 156156156152156 153.5  137
135140135138.5  139130131125
125
[145] 121.5   125.5  128128129.5  133129.5
140154.5  167.5  156179 178.5  174188
214
[161] 197.5  181.5  181.5  197.5  191.5  179189.5
184.5  183182
182.5  177191198191180.5
[177] 182183.5  183182 189.5  195208
203194176.5  173173174165.5  163
162.5
[193] 159162.5  171168.5  164158147
149149.5  144141 138.5  138136138
140
[209] 135132.5  130.75 129129.5  126127 128.5
127.5  124117119120.5  122129133
[225] 136137133133127123122
117122126126133 127.5  129130
125
[241] 122126.5  136148147150.5  143.5
138.5  134135
135.75 136.5  132129127.5  118.5
 x-readClipboard()
 unitrootTest(x)
Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] :
non-numeric argument to binary operator

I also try to do simple code with it, and getting error message as
well, such as
for(j in 1:length(x)){w-x/1}
Error in x/1 : non-numeric argument to binary operator

Thanks for your help!

Yulei

[[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 error of non-numeric argument to binary operator

2006-10-10 Thread Marc Schwartz
On Tue, 2006-10-10 at 22:35 -0400, Yulei Gong wrote:
 Hi,
 I have the following data and there is no binary operator contained,
 however, I still receive the error message when running unitrootTest
 function, could someone give me a guidance on it??
 
 readClipboard()
   [1] 245246261.5  275.5  307284.5  289313.5
 323.75 334 312.5  325305.5  322.5  317310.5
  [17] 302301305287277.5  271 271.5  278.5
 279271263262262271262257
  [33] 251.5  258 252.5  254.5  253251.5  255
 253253243238.5  234229.5  230.5   237.5  
 235.5
  [49] 238225227.5  233236.5  236.5  231.5
 225221.5  221.5   221.5  221.5  221.5  221.25 221
 206
  [65] 207.5  196192.5  193.5  186 197.5  193.5
 201195183185.5  181.5  179177173
 169.5
  [81] 173178169173167 158.5  169.5
 164145127.5  132131131120120.5  
 120.25
  [97] 120 112.5  114.5  106113111113118.5
 131131146.5  133.5  128132 130.5  122
 [113] 122.5  123.5  126140132140143
 148168162.5   152.5  148144144150.5
 151
 [129] 156156156152156 153.5  137
 135140135138.5  139130131125
 125
 [145] 121.5   125.5  128128129.5  133129.5
 140154.5  167.5  156179 178.5  174188
 214
 [161] 197.5  181.5  181.5  197.5  191.5  179189.5
 184.5  183182
 182.5  177191198191180.5
 [177] 182183.5  183182 189.5  195208
 203194176.5  173173174165.5  163
 162.5
 [193] 159162.5  171168.5  164158147
 149149.5  144141 138.5  138136138
 140
 [209] 135132.5  130.75 129129.5  126127 128.5
 127.5  124117119120.5  122129133
 [225] 136137133133127123122
 117122126126133 127.5  129130
 125
 [241] 122126.5  136148147150.5  143.5
 138.5  134135
 135.75 136.5  132129127.5  118.5
  x-readClipboard()
  unitrootTest(x)
 Error in r[i1] - r[-length(r):-(length(r) - lag + 1)] :
 non-numeric argument to binary operator
 
 I also try to do simple code with it, and getting error message as
 well, such as
 for(j in 1:length(x)){w-x/1}
 Error in x/1 : non-numeric argument to binary operator
 
 Thanks for your help!
 
 Yulei

Your 'x' is a character vector, not numeric. The tip is that the values
are surrounded by double quotes.  Thus, you are trying to use operators
intended for numerics on characters.

For example:

 x - c(122, 126.5, 136, 148, 147, 150.5, 143.5)

 x
[1] 122   126.5 136   148   147   150.5 143.5

 x / 1
Error in x/1 : non-numeric argument to binary operator

 is.numeric(x)
[1] FALSE

 is.character(x)
[1] TRUE


It's not clear from your post how you read in the data originally.  You
should review that process or alternatively, coerce 'x' to numeric:

 x.num - as.numeric(x)

 x.num
[1] 122.0 126.5 136.0 148.0 147.0 150.5 143.5

 x.num / 1
[1] 122.0 126.5 136.0 148.0 147.0 150.5 143.5


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.


[R] during fitting of successive datasets, stall crashes iterations

2006-10-10 Thread Warren
Hi all,
I am trying to do fitting of large sets of timeseries data, and error
messages derail the process when I encounter a dataset that doesn't fit. I'd
like to ignore those misfits and try another equation or move to the next
dataset. Any ideas?  (piece of code below)

Thanks,--Warren

##The code looks something like this:
attach(zf)
x - hours
n-length(zf[,2])
for (i in 2:n)
{y - zf[,i]
plot(y ~ x, xlab = Time (h), ylab = Lumi, pch = 15)
# fitting algorithm  looks like this:
sine- nls (y ~ baseline + trend*x + amplitude*(sin(2*pi*(x+phase)/period)),
  start=list(baseline=4000, amplitude=4000, phase=0, period=24, trend=0),
  trace=TRUE)
...
}




-- 
Warren G. Lewis
[EMAIL PROTECTED]

[[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] during fitting of successive datasets, stall crashes iterations

2006-10-10 Thread Gabor Grothendieck
See ?try or ?tryCatch. The basic idiom is given here:

https://stat.ethz.ch/pipermail/r-help/2005-May/072035.html

On 10/10/06, Warren [EMAIL PROTECTED] wrote:
 Hi all,
 I am trying to do fitting of large sets of timeseries data, and error
 messages derail the process when I encounter a dataset that doesn't fit. I'd
 like to ignore those misfits and try another equation or move to the next
 dataset. Any ideas?  (piece of code below)

 Thanks,--Warren

 ##The code looks something like this:
 attach(zf)
 x - hours
 n-length(zf[,2])
 for (i in 2:n)
 {y - zf[,i]
 plot(y ~ x, xlab = Time (h), ylab = Lumi, pch = 15)
 # fitting algorithm  looks like this:
 sine- nls (y ~ baseline + trend*x + amplitude*(sin(2*pi*(x+phase)/period)),
  start=list(baseline=4000, amplitude=4000, phase=0, period=24, trend=0),
  trace=TRUE)
 ...
 }




 --
 Warren G. Lewis
 [EMAIL PROTECTED]

[[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] Using integrate() with vectors as boundaries rather than scalars

2006-10-10 Thread Tobias

Hi all

my apologies if above title is misleading, but here is my problem anyways:

I need to evaluate an integral n times. Since I can't get my head around
vectorization as of yet, I have coded it up in a loop, i.e.:

for (i in 1:n)

{

z[i] - integrate(dnorm,x[i],Inf)

}

Since n is quite large in my operation, ~4, I would rather stack all the
elements of x into a vector and then evaluate the integral for each vector
element in x up to infinity. So that the operation would look something like
this:

z - integrate(dnorm,x,Inf)

I am not sure if this works, as I am new to R, however managed the
equivalent in MatLab. Is this possible at all? If yes, your input would be
highly appreciated.

Regards

Tobias
-- 
View this message in context: 
http://www.nabble.com/Using-integrate%28%29-with-vectors-as-boundaries-rather-than-scalars-tf2421074.html#a6749926
Sent from the R help mailing list archive at Nabble.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] Accessing R from Java [Broadcast]

2006-10-10 Thread Wiener, Matthew
I've had good luck with Rserve.  http://stats.math.uni-augsburg.de/Rserve/
Hope this helps,
Matt 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of fuad
Sent: Tuesday, October 10, 2006 9:58 PM
To: R-help@stat.math.ethz.ch
Subject: [R] Accessing R from Java [Broadcast]

 

Hello All,

 

I am Fuad from Indonesia. I am doing a research using R. I need to access R
from Java. 

Here are my computer specifications :

1.   Windows XP

2.   Java 1.4.0

3.   R 2.2.1

4.   rJava_0.4.3.zip ; I download the binary from CRAN

5.   Rserve_0.4 ; I download the exe from Rosuda

6.   JRI_0.3.5.tar.gz from Rosuda too

 

I have successfully install and try a little code in R. 

I have install packages rJava from RGUI and it was successful.

But when I try to load packages using library(rJava) I have error : unable
to load shared library rJava.dll. There is no Jvm.dll.

So I copied jvm.dll from JAVA_HOME\bin to R_HOME\bin, and it seems done well
until I try to wake up Java Virtual Machine using .jinit() I received error
: cannot create JVM. 

 

Is there anyway I can call R inside Java code ?

Please help me. Thank you

 

Best regards,

 

Fuad

 


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




--
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] for loop not working in function

2006-10-10 Thread Dale Steele
I'm trying to write a small function (below) to compute Box  Cox 
transformations of x for arbitrary values of lambda.  I'd like to 
specify a range of values for lamba (min,max,step) and am having trouble 
getting the for loop to work.  Suggestions?

Any pointers to resources for learning to write functions in R for 
neophyte programmers?  Thanks.  --Dale


boxcox - function(x,min,max,step) {
lambda - seq(min,max,step)
s - length(lambda)
for (lambda in 1:s)
n - nrow(x)
if(lambda ==0) xL - log(x) else
xL - ((x^lambda) - 1)/lambda
xLbar - mean(xL)
t1 - (-n/2)* log((1/n)*sum((xL -  xLbar)^2))
t2 - (lambda - 1)*sum(log(x))
l= t1 + t2
l
}

__
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] Using integrate() with vectors as boundaries rather than scalars

2006-10-10 Thread Tobias

I think I have figured it out myself, would however like to know the opinion
of more experienced coders. Is this a good way of approaching this:

cumdnorm1 - function(x) {integrate(dnorm,x,Inf)}

evalvec - function(x) {lapply(x,cumdnorm1)}

It does return the desired result. 



Tobias wrote:
 
 Hi all
 
 my apologies if above title is misleading, but here is my problem anyways:
 
 I need to evaluate an integral n times. Since I can't get my head around
 vectorization as of yet, I have coded it up in a loop, i.e.:
 
 for (i in 1:n)
 
 {
 
 z[i] - integrate(dnorm,x[i],Inf)
 
 }
 
 Since n is quite large in my operation, ~4, I would rather stack all
 the elements of x into a vector and then evaluate the integral for each
 vector element in x up to infinity. So that the operation would look
 something like this:
 
 z - integrate(dnorm,x,Inf)
 
 I am not sure if this works, as I am new to R, however managed the
 equivalent in MatLab. Is this possible at all? If yes, your input would be
 highly appreciated.
 
 Regards
 
 Tobias
 

-- 
View this message in context: 
http://www.nabble.com/Using-integrate%28%29-with-vectors-as-boundaries-rather-than-scalars-tf2421074.html#a6750170
Sent from the R help mailing list archive at Nabble.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] How to solve Different Correlation Results

2006-10-10 Thread Kum-Hoe Hwang
Howdy Gurus !

I have a different correlation result from the same data. The corridor1
string variable is expressed
as a number like the corridor2 number variable.
--
 levels(corridor1)
[1] A   B   C   D E   F
 levels(as.factor(corridor2))
[1] 0 1 2 3 4

--
I have the correlation results followings using cor() function.
--
 cor(jh1_1, as.factor(corridor1))
[1] 0.01528538
 cor(jh1_1, as.factor(corridor2))
[1] -0.4972571
--
I donot know why the above correlation coefficients used the same data are
different.
They are 0.015 from as.factor(corridor1), -0.497 from as,factor(corridor2).
The string variable corridor1 is the same catergory data with the variable
corridor2.
The difference is that A is replaced with 0, B with 1, C with 2,
.

Could you tell me why they are different, and which correlation coefficient
is correct?

Thank in advance,

-- 
Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [EMAIL PROTECTED]

[[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] Using integrate() with vectors as boundaries rather than scalars

2006-10-10 Thread Gabor Grothendieck
Or just:

   lapply(x, integrate, f = dnorm, upper = Inf)



On 10/11/06, Tobias [EMAIL PROTECTED] wrote:

 I think I have figured it out myself, would however like to know the opinion
 of more experienced coders. Is this a good way of approaching this:

 cumdnorm1 - function(x) {integrate(dnorm,x,Inf)}

 evalvec - function(x) {lapply(x,cumdnorm1)}

 It does return the desired result.



 Tobias wrote:
 
  Hi all
 
  my apologies if above title is misleading, but here is my problem anyways:
 
  I need to evaluate an integral n times. Since I can't get my head around
  vectorization as of yet, I have coded it up in a loop, i.e.:
 
  for (i in 1:n)
 
  {
 
  z[i] - integrate(dnorm,x[i],Inf)
 
  }
 
  Since n is quite large in my operation, ~4, I would rather stack all
  the elements of x into a vector and then evaluate the integral for each
  vector element in x up to infinity. So that the operation would look
  something like this:
 
  z - integrate(dnorm,x,Inf)
 
  I am not sure if this works, as I am new to R, however managed the
  equivalent in MatLab. Is this possible at all? If yes, your input would be
  highly appreciated.
 
  Regards
 
  Tobias
 

 --
 View this message in context: 
 http://www.nabble.com/Using-integrate%28%29-with-vectors-as-boundaries-rather-than-scalars-tf2421074.html#a6750170
 Sent from the R help mailing list archive at Nabble.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] rarefy a matrix of counts

2006-10-10 Thread Petr Pikal
Hi

I am not experienced in Matlab and from your explanation I do not 
understand what exactly do you want. It seems that you want randomly 
choose a sample of 100 rows from your martix, what can be achived by 
sample.

DF-data.frame(rnorm(100), 1:100, 101:200, 201:300)
DF[sample(1:100, 10),]

If you want to do this several times, you need to save your result 
and than it depends on what you want to do next. One suitable form is 
list of matrices the other is array and you can use for loop for 
completing it.

HTH
Petr


On 10 Oct 2006 at 17:40, Brian Frappier wrote:

Date sent:  Tue, 10 Oct 2006 17:40:47 -0400
From:   Brian Frappier [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] rarefy a matrix of counts

 Hi all,
 
 I have a matrix of counts for objects (rows) by samples (columns).  I
 aimed for about 500 counts in each sample (I have about 80 samples)
 and would now like to rarefy these down to 100 counts in each sample
 using simple random sampling without replacement.  I plan on rarefying
 several times for each sample.  I could do the tedious looping task of
 making a list of all objects (with its associated identifier) in each
 sample and then use the wonderful sampling package to select a
 sub-sample of 100 for each sample and thereby get a logical vector of
 inclusions.  I would then regroup the resulting logical vector into a
 vector of counts by object, rinse and repeat several times for each
 sample.
 
 Alternately, using the same list, I could create a random index of
 integers between 1 and the number of objects for a sample (without
 repeats) and then select those objects from the list.  Again, rinse
 and repeat several time for each sample.
 
 Is there a way to directly rarefy a matrix of counts without having to
 create a list of objects first?  I am trying to switch to R from
 Matlab and am trying to pick up good programming habits from the
 start.
 
 Much appreciation!
 
  [[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.

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
and provide commented, minimal, self-contained, reproducible code.