[R] Segmentation fault/buffer overflow with fix() in Fedora Core 5 from Extras repository

2006-10-19 Thread Paul Johnson
The Fedora Extras update of R found its way onto my systems today and
I noted that fix() and edit() no longer work. There is a program crash
that closes up R, but it does not leave a core file.   I've tested by
turning off SELinux, it had no effect.

Do you see it too?  What do you think?  It happens on both systems
I've tested. As far as I know, both of these systems are up-to-date.

I restarted with R -d gdb to try to get a backtrace, but gdb says
the debugging symbols have been removed and I don't see the
debuginfo package on the Extras archive.  I'm attaching the gdb info
later, but  I don't think it helps much without line numbers..

I think my next step will be to re-build R on these systems and see if
the problem disappears. Right? If it still crashes, I'll make sure I
have debugging symbols and give you a full backtrace.  If it does not
crash, I'll let you know as well


Here's the session that crashes


 library(car)
 data(Chile)
 edit(Chile)
*** buffer overflow detected ***: /usr/lib/R/bin/exec/R terminated
=== Backtrace: =
/lib/libc.so.6(__chk_fail+0x29)[0xa8079d]
/lib/libc.so.6[0xa8195d]
/usr/lib/R/modules//R_X11.so[0x7c094a]
/usr/lib/R/modules//R_X11.so[0x7c20dd]
/usr/lib/R/modules//R_X11.so[0x7c3428]
/usr/lib/R/modules//R_X11.so(RX11_dataentry+0xa25)[0x7c4b15]
/usr/lib/R/lib/libR.so[0x2bf4c5]
/usr/lib/R/lib/libR.so[0x1dfd26]
/usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
/usr/lib/R/lib/libR.so[0x1b4d28]
/usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
/usr/lib/R/lib/libR.so[0x1b1887]
/usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
/usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0x1b2f67]
/usr/lib/R/lib/libR.so[0x1e146f]
/usr/lib/R/lib/libR.so(Rf_usemethod+0x609)[0x1e28d9]
/usr/lib/R/lib/libR.so[0x1e30ae]
/usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
/usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0x1b2f67]
/usr/lib/R/lib/libR.so(Rf_eval+0x2f4)[0x1b07e4]
/usr/lib/R/lib/libR.so(Rf_ReplIteration+0x311)[0x1d01b1]
/usr/lib/R/lib/libR.so[0x1d03c1]
/usr/lib/R/lib/libR.so(run_Rmainloop+0x60)[0x1d0710]
/usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0x1d073c]
/usr/lib/R/bin/exec/R(main+0x46)[0x8048696]
/lib/libc.so.6(__libc_start_main+0xc6)[0x9c41fe]
/usr/lib/R/bin/exec/R[0x8048591]
=== Memory map: 
0011-00329000 r-xp  08:05 553625 /usr/lib/R/lib/libR.so
00329000-00336000 rwxp 00219000 08:05 553625 /usr/lib/R/lib/libR.so
00336000-003cd000 rwxp 00336000 00:00 0
003cd000-003d5000 r-xp  08:05 683486 /lib/libnss_files-2.4.90.so
003d5000-003d6000 r-xp 7000 08:05 683486 /lib/libnss_files-2.4.90.so
003d7000-003f5000 r-xp  08:05 1045723
/usr/lib/R/library/grDevices/libs/grDevices.so
003f5000-003f6000 rwxp 0001d000 08:05 1045723
/usr/lib/R/library/grDevices/libs/grDevices.so
003f6000-003fc000 r-xp  08:05 1046746
/usr/lib/R/library/methods/libs/methods.so
003fc000-003fd000 rwxp 5000 08:05 1046746
/usr/lib/R/library/methods/libs/methods.so
003fd000-0040 r-xp  08:05 1050384
/usr/lib/R/library/tools/libs/tools.so
0040-00401000 rwxp 2000 08:05 1050384
/usr/lib/R/library/tools/libs/tools.so
00413000-0043d000 r-xp  08:05 553410 /usr/lib/R/lib/libRblas.so
0043d000-0043e000 rwxp 00029000 08:05 553410 /usr/lib/R/lib/libRblas.so
0043e000-004b9000 r-xp  08:05 2868184/usr/lib/libgfortran.so.1.0.0
004b9000-004ba000 rwxp 0007b000 08:05 2868184/usr/lib/libgfortran.so.1.0.0
004ba000-0050b000 r-xp  08:05 1049782
/usr/lib/R/library/stats/libs/stats.so
0050b000-0050d000 rwxp 0005 08:05 1049782
/usr/lib/R/library/stats/libs/stats.so
0051-00511000 r-xp 0051 00:00 0  [vdso]
00511000-0060a000 r-xp  08:05 2868912/usr/lib/libX11.so.6.2.0
0060a000-0060e000 rwxp 000f9000 08:05 2868912/usr/lib/libX11.so.6.2.0
00664000-0067b000 r-xp  08:05 683622 /lib/libpcre.so.0.0.1
0067b000-00692000 rwxp 00017000 08:05 683622 /lib/libpcre.so.0.0.1
007bb000-007d4000 r-xp  08:05 1050764/usr/lib/R/modules/R_X11.so
007d4000-007d5000 rwxp 00018000 08:05 1050764/usr/lib/R/modules/R_X11.so
007d5000-007e1000 rwxp 007d5000 00:00 0
00896000-008eb000 r-xp  08:05 2876525/usr/lib/libXt.so.6.0.0
008eb000-008ef000 rwxp 00054000 08:05 2876525/usr/lib/libXt.so.6.0.0
0099-009a7000 r-xp  08:05 683431 /lib/ld-2.4.90.so
009a7000-009a8000 r-xp 00017000 08:05 683431 /lib/ld-2.4.90.so
009a8000-009a9000 rwxp 00018000 08:05 683431 /lib/ld-2.4.90.so
009ab000-00acf000 r-xp  08:05 683432 /lib/libc-2.4.90.so
00acf000-00ad1000 r-xp 00124000 08:05 683432 /lib/libc-2.4.90.so
00ad1000-00ad2000 rwxp 00126000 08:05 683432 /lib/libc-2.4.90.so
00ad2000-00ad5000 rwxp 00ad2000 00:00 0
00ad7000-00afc000 r-xp  08:05 683433 /lib/libm-2.4.90.so
00afc000-00afd000 r-xp 00024000 08:05 683433 /lib/libm-2.4.90.so
00afd000-00afe000 rwxp 00025000 08:05 683433 /lib/libm-2.4.90.so
00b0-00b02000 r-xp  08:05 683435   

Re: [R] Segmentation fault/buffer overflow with fix() in Fedora Core 5 from Extras repository

2006-10-19 Thread Prof Brian Ripley
Is this in a UTF-8 locale?  If so, this is covered by Ei-ji Nakama's 
posting to both R-help and R-devel yesterday: see

https://stat.ethz.ch/pipermail/r-devel/2006-October/039792.html

You have three choices:

1) Use a single-byte locale.
2) Compile with the standard CFLAGS and not the extra flags used by FC.
3) Use R-patched, which has this fixed.

As my dept still sets Linux boxes up in en_GB and not en_GB.utf8, I am 
using workaround 1 and so took a while to work out what the problem might 
be.

What is happening is that FC sets CFLAGS to something other than the R 
default.  This enables extra checks on buffer overflow and stack-smashing, 
but unfortunately removes the flag -std=gnu99 that is needed to allow C99 
features to be used.  Those extra checks are triggered by a few places in 
the MBCS code that Mr Nakama contributed, and some of those were patched 
prior to the release of 2.4.0.  AFAIK the problems are not new but the 
detection has got more efficient.

It is very helpful to include a concise description of your environment. 
You only mentioned the OS in the subject line, never the architecture, 
exact version of R (let alone the exact RPM) nor the locale. 
sessionInfo() provides such information in a compact form.


On Thu, 19 Oct 2006, Paul Johnson wrote:

 The Fedora Extras update of R found its way onto my systems today and
 I noted that fix() and edit() no longer work. There is a program crash
 that closes up R, but it does not leave a core file.   I've tested by
 turning off SELinux, it had no effect.

 Do you see it too?  What do you think?  It happens on both systems
 I've tested. As far as I know, both of these systems are up-to-date.

 I restarted with R -d gdb to try to get a backtrace, but gdb says
 the debugging symbols have been removed and I don't see the
 debuginfo package on the Extras archive.  I'm attaching the gdb info
 later, but  I don't think it helps much without line numbers..

 I think my next step will be to re-build R on these systems and see if
 the problem disappears. Right? If it still crashes, I'll make sure I
 have debugging symbols and give you a full backtrace.  If it does not
 crash, I'll let you know as well


 Here's the session that crashes


 library(car)
 data(Chile)
 edit(Chile)
 *** buffer overflow detected ***: /usr/lib/R/bin/exec/R terminated
 === Backtrace: =
 /lib/libc.so.6(__chk_fail+0x29)[0xa8079d]
 /lib/libc.so.6[0xa8195d]
 /usr/lib/R/modules//R_X11.so[0x7c094a]
 /usr/lib/R/modules//R_X11.so[0x7c20dd]
 /usr/lib/R/modules//R_X11.so[0x7c3428]
 /usr/lib/R/modules//R_X11.so(RX11_dataentry+0xa25)[0x7c4b15]
 /usr/lib/R/lib/libR.so[0x2bf4c5]
 /usr/lib/R/lib/libR.so[0x1dfd26]
 /usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
 /usr/lib/R/lib/libR.so[0x1b4d28]
 /usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
 /usr/lib/R/lib/libR.so[0x1b1887]
 /usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
 /usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0x1b2f67]
 /usr/lib/R/lib/libR.so[0x1e146f]
 /usr/lib/R/lib/libR.so(Rf_usemethod+0x609)[0x1e28d9]
 /usr/lib/R/lib/libR.so[0x1e30ae]
 /usr/lib/R/lib/libR.so(Rf_eval+0x483)[0x1b0973]
 /usr/lib/R/lib/libR.so(Rf_applyClosure+0x2a7)[0x1b2f67]
 /usr/lib/R/lib/libR.so(Rf_eval+0x2f4)[0x1b07e4]
 /usr/lib/R/lib/libR.so(Rf_ReplIteration+0x311)[0x1d01b1]
 /usr/lib/R/lib/libR.so[0x1d03c1]
 /usr/lib/R/lib/libR.so(run_Rmainloop+0x60)[0x1d0710]
 /usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0x1d073c]
 /usr/lib/R/bin/exec/R(main+0x46)[0x8048696]
 /lib/libc.so.6(__libc_start_main+0xc6)[0x9c41fe]
 /usr/lib/R/bin/exec/R[0x8048591]
 === Memory map: 
 0011-00329000 r-xp  08:05 553625 /usr/lib/R/lib/libR.so
 00329000-00336000 rwxp 00219000 08:05 553625 /usr/lib/R/lib/libR.so
 00336000-003cd000 rwxp 00336000 00:00 0
 003cd000-003d5000 r-xp  08:05 683486 /lib/libnss_files-2.4.90.so
 003d5000-003d6000 r-xp 7000 08:05 683486 /lib/libnss_files-2.4.90.so
 003d7000-003f5000 r-xp  08:05 1045723
 /usr/lib/R/library/grDevices/libs/grDevices.so
 003f5000-003f6000 rwxp 0001d000 08:05 1045723
 /usr/lib/R/library/grDevices/libs/grDevices.so
 003f6000-003fc000 r-xp  08:05 1046746
 /usr/lib/R/library/methods/libs/methods.so
 003fc000-003fd000 rwxp 5000 08:05 1046746
 /usr/lib/R/library/methods/libs/methods.so
 003fd000-0040 r-xp  08:05 1050384
 /usr/lib/R/library/tools/libs/tools.so
 0040-00401000 rwxp 2000 08:05 1050384
 /usr/lib/R/library/tools/libs/tools.so
 00413000-0043d000 r-xp  08:05 553410 /usr/lib/R/lib/libRblas.so
 0043d000-0043e000 rwxp 00029000 08:05 553410 /usr/lib/R/lib/libRblas.so
 0043e000-004b9000 r-xp  08:05 2868184/usr/lib/libgfortran.so.1.0.0
 004b9000-004ba000 rwxp 0007b000 08:05 2868184/usr/lib/libgfortran.so.1.0.0
 004ba000-0050b000 r-xp  08:05 1049782
 /usr/lib/R/library/stats/libs/stats.so
 0050b000-0050d000 rwxp 0005 08:05 1049782
 /usr/lib/R/library/stats/libs/stats.so
 0051-00511000 

[R] Re : CI

2006-10-19 Thread justin bem
Get the the package fortunes in the CRAN and try 
fortune(Harrell) for experience of and advance R-user. For the second 
question, the binomial distribution converge to normal distribution 
asymptomaticaly. You can not expect get the same result by using the two 
approximations on a finite sample. Watching a football macth in a TV screen is 
not the same thing that see the game in a staduim.

 
Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé.
Tél (00237)9597295.



- Message d'origine 
De : Ethan Johnsons [EMAIL PROTECTED]
À : Liaw, Andy [EMAIL PROTECTED]
Cc : r-help@stat.math.ethz.ch
Envoyé le : Jeudi, 19 Octobre 2006, 5h43mn 36s
Objet : Re: [R] CI


Thx so much.

I just got into R world for my small research.
I thought that R is free so doesn't have many features, but it seems I
was wrong.

Why do these two return different values?

0.2666456 0.6133544
0.2698531 0.6213784

I think the diff is ignorable, but would ask.

ej

On 10/19/06, Liaw, Andy [EMAIL PROTECTED] wrote:
 You did ask for CI of mean, so that's what you got.  If you want CI for
 proportion, here are two (non-bootstrap) ways:

 R confint(lm(I(x == 1) ~ 1), level=.9)
   5 %  95 %
 (Intercept) 0.2666456 0.6133544
 R binom.test(sum(x == 1), length(x), conf.level=.9)

 Exact binomial test

 data:  sum(x == 1) and length(x)
 number of successes = 11, number of trials = 25, p-value = 0.69
 alternative hypothesis: true probability of success is not equal to 0.5
 90 percent confidence interval:
  0.2698531 0.6213784
 sample estimates:
 probability of success
   0.44

 I hope these are not HW problems?

 Andy

 From: Ethan Johnsons
 
  Thank you so much for the feedback.
 
  The random numbers are working great.  I have tried
  non-random numbers, and the outcome is not correct with confint.
 
  Is there a way to compute i.e. a 90% confidence interval for
  percent of 1?
 
  i.e. where 1 = apple; 2 = orange
 
   x
   [1] 2 2 2 2 2 1 1 2 2 1 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2
   table (x)
  x
   1  2
  11 14
 
   x =11
   confint(lm(x~1), level=0.90)
  5 % 95 %
  (Intercept) NaN  NaN
 
  ej
 
  On 10/18/06, Liaw, Andy [EMAIL PROTECTED] wrote:
   Here's one way:
  
   R x - c(6,11,5,14,30,11,17,3,9,3,8,8) confint(lm(x~1), level=.9)
5 %95 %
   (Intercept) 6.546834 14.2865
  
   Andy
  
   From: Ethan Johnsons
   
I have a quick question, please.
   
Does R have function to compute i.e. a 90% confidence
  interval for
the mean for these numbers?
   
 mean (6,11,5,14,30,11,17,3,9,3,8,8)
[1] 6
   
I thought pt or qt would give me the interval, but it seems not.
   
thx much.
   
ej
   
__
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, contains
   information of Merck  Co., Inc. (One Merck Drive,
  Whitehouse Station,
   New Jersey, USA 08889), and/or its affiliates (which may be known
   outside the United States as Merck Frosst, Merck Sharp 
  Dohme or MSD
   and in Japan, as Banyu - direct contact information for
  affiliates is
   available at http://www.merck.com/contact/contacts.html)
  that may be
   confidential, proprietary copyrighted and/or legally
  privileged. It is
   intended solely for the use of the individual or entity
  named on this
   message. If you are not the intended recipient, and have
  received this
   message in error, please notify us immediately by reply e-mail and
   then delete it from your system.
  
  
  --
   
  
 
 
 


 --
 Notice:  This e-mail message, together with any attachment...{{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.






___ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 


[[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] creating bins for a plot

2006-10-19 Thread Dieter Menne
Jeffrey Stratford stratja at auburn.edu writes:

 
 I'm trying to plot the ratio of used versus unused bird houses
 (coded 1 or 0) versus a continuous environmental gradient (proportion of
  urban cover [purban2]) that I would like to convert into bins (0 -
 0.25, 0.26 - 0.5, 0.51 - 0.75, 0.76 - 1.0) and I'm not having much luck
 figuring this out.  I ran a logistic regression and purban2 ends up
 driving the probability of a box being occupied so it would be nice to
 show this relationship.  I'm also plotting the fitted values vs. purban2
 but that's done.  
 
Check the example under predict.glm. It does not use binning, though.

--- Code below added because gmane complains about too much quoted text.

## example from Venables and Ripley (2002, pp. 190-2.)
ldose - rep(0:5, 2)
numdead - c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex - factor(rep(c(M, F), c(6, 6)))
SF - cbind(numdead, numalive=20-numdead)
budworm.lg - glm(SF ~ sex*ldose, family=binomial)
summary(budworm.lg)



Dieter

__
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] Nested source() errors

2006-10-19 Thread Dieter Menne
Pierce, Ken ken.pierce at oregonstate.edu writes:

 
 Does anyone know of any issues with nesting source() calls within
 multiple scripts? I have at least one script which always finds errors
 when I source it but runs fine when run on its own. It containd source()
 calls to other scripts and it seems to fail during the first nested
 source() command.
 
This could happen when the last line in one of the files has no linefeed 
appended. But probably better take Andy's advice.

Dieter

__
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] Getting group size in a data frame

2006-10-19 Thread Ulrik Stervbo
Hi all,

I have a data frame with some measured values of some animals. Sometimes the
measurement failed, resulting in a NA for a measurement and sometimes the
animal died, resulting in NA for all measurements.

I have several groups of animals. How do I find the size of each group with
only alive animals? And how do I find the size of the groups for each
measurement?

An example:
l1 - list(factor=c(24,24,24), val1=c(2, 3, NA), val2=c(4, NA, NA))
df - as.data.frame(l1)
df$factor - factor(df$factor)

The size of factors should be 2 and not 3.  The number of measurement in
val1 should be 2 and the number of measurements in val2 should be 1

Thanks in advance for any help and suggestions
Ulrik

[[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] creating bins for a plot

2006-10-19 Thread Ingmar Visser
Jeffrey,
not sure what you mean by showing the relationship between the prob and
purban2, but something like this could work:

library(gtools)
#inverse logit
fl - function(x,beta){inv.logit(beta[1]+beta[2]*x)}
# for beta fill in your intercept and the coefficient of purban2
flb-function(x,beta=c(-0.09,3.65)){fl(x,beta)}
# plot over the range of purban2 by:
plot(flb,0,1)

hth, Ingmar

On 10/19/06 12:24 AM, Jeffrey Stratford [EMAIL PROTECTED] wrote:

 Hi.  I'm trying to plot the ratio of used versus unused bird houses
 (coded 1 or 0) versus a continuous environmental gradient (proportion of
  urban cover [purban2]) that I would like to convert into bins (0 -
 0.25, 0.26 - 0.5, 0.51 - 0.75, 0.76 - 1.0) and I'm not having much luck
 figuring this out.  I ran a logistic regression and purban2 ends up
 driving the probability of a box being occupied so it would be nice to
 show this relationship.  I'm also plotting the fitted values vs. purban2
 but that's done.  Any suggestions would be appreciated.
 
 Many thanks,
 
 Jeff
 
 
 Data sample:
 
 box use purbank purban2
 1 1 0.003813435 0.02684564
 2 1 0.04429451 0.1610738
 3 1 0.04458785 0.06040268
 4 1 0.06072162 0.2080537
 5 0 0.6080962 0.6979866
 6 1 0.6060428 0.6107383
 7 1 0.3807568 0.4362416
 8 0 0.3649164 0.3154362
 9 0 0.3505427 0.2483221
 10 0 0.3476093 0.1409396
 11 0 0.3719566 0.3020134
 12 1 0.09238011 0.1342282
 13 0 0.08616111 0.1073826
 14 0 0.07388724 0.04026845
 15 1 0.07046477 0.03355705
 .
 .
 .
 
 
 
 Jeffrey A. Stratford, Ph.D.
 Postdoctoral Associate
 331 Funchess Hall
 Department of Biological Sciences
 Auburn University
 Auburn, AL 36849
 334-329-9198
 FAX 334-844-9234
 http://www.auburn.edu/~stratja
 
 __
 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.

-- 
Ingmar Visser
Department of Psychology, University of Amsterdam
Roetersstraat 15, 1018 WB Amsterdam
The Netherlands
http://users.fmg.uva.nl/ivisser/
tel: +31-20-5256735

__
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] Adding locfit confidence intervals in trelis xyplot

2006-10-19 Thread Dieter Menne
Deepayan Sarkar deepayan.sarkar at gmail.com writes:

 
 On 10/18/06, juan f poyatos jpoyatos at cnio.es wrote:
  Dear all,
  I am trying to include confidence intervals in a xyplot.
 
...
 
 Well, panel.locfit doesn't have any options to draw confidence bands,
 so you'll have to write a panel function that does. Shouldn't be hard
 to extend panel.locfit if you know how to extract that information
 from a locfit object.

plot.locfit has bands. I think Juan mixed trellis and standard plot 
documentation.


x - rnorm(100)
y - dnorm(x) + rnorm(100) / 5
plot(locfit(y~x), band=global)

__
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] Adding locfit confidence intervals in trelis xyplot

2006-10-19 Thread juan f poyatos

But it is *within* a trellis plot when I cannot plot the bands!

Building up on Dieter's example:

x - rnorm(100)
y - dnorm(x) + rnorm(100) / 5
plot(locfit(y~x), band=global)

Plots two nice confidence bands. 

But try this
z - dnorm(y) + rnorm(100) / 3
Z - equal.count(z, number = 4, overlap = .1)
xyplot(z ~ y|Z, alpha = 1,band = global,panel = panel.locfit)

and you will not see the bands,

indeed band is completely ignored as
xyplot(z ~ y|Z, alpha = 1,band = rubbish,panel = panel.locfit)

works fine but without the bands!!

- juan


On Thu, 2006-10-19 at 07:49 +, Dieter Menne wrote:
 Deepayan Sarkar deepayan.sarkar at gmail.com writes:
 
  
  On 10/18/06, juan f poyatos jpoyatos at cnio.es wrote:
   Dear all,
   I am trying to include confidence intervals in a xyplot.
  
 ...
  
  Well, panel.locfit doesn't have any options to draw confidence bands,
  so you'll have to write a panel function that does. Shouldn't be hard
  to extend panel.locfit if you know how to extract that information
  from a locfit object.
 
 plot.locfit has bands. I think Juan mixed trellis and standard plot 
 documentation.
 
 
 x - rnorm(100)
 y - dnorm(x) + rnorm(100) / 5
 plot(locfit(y~x), band=global)
 
 __
 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.
-- 
Juan F. Poyatos
Structural and Computational Biology Programme
Spanish National Cancer Centre (CNIO)
Melchor Fernandez Almagro, 3/E-28029 Madrid SPAIN
Phone:+34 912 246 900/Fax: +34 912 246 980

http://bioinfo.cnio.es/~jpoyatos/




**NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{dropped}}

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


Re: [R] Redhat compilers and lme4 with R-2.4.0

2006-10-19 Thread Stefan Grosse
Prof Brian Ripley schrieb:

 Not surprising: you have not compiled R with -std=gnu99 to allow C99 
 features, as recommended in the R-admin manual, and selected by 
 default. (Comment to Doug Bates: it is probably better still to write 
 in C90 if you can.)

 This seems to be a problem with the flags used to build the FC5 RPMs.
 I think you can circumvent it by adding

 PKG_CFLAGS=-std=gnu99

 to lme4/src/Makevars.



I am having the same problem on Fedora Core 5 with the 2.4.0 rpm from 
CRAN. Update from lme4 0.9975-3 to lme4 0.9975-6 failed due to exactly 
the same error message. I would have expected the cran rpm is compiled 
according to the R-admin guide...?

message (the german version ;-) ):
* Installing *source* package 'lme4' ...
** libs
gcc -I/usr/lib/R/include -I/usr/lib/R/include  -I/usr/local/include 
-I/usr/lib/R/library/Matrix/include   -fpic  -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
-fasynchronous-unwind-tables -c glmer.c -o glmer.o
In file included from lmer.h:4,
 from glmer.h:4,
 from glmer.c:1:
lme4_utils.h: In Funktion »internal_symmetrize«:
lme4_utils.h:82: Fehler: Anfangsdeklaration in »for«-Schleife außerhalb 
C99-Modus verwendet
lme4_utils.h:83: Fehler: Anfangsdeklaration in »for«-Schleife außerhalb 
C99-Modus verwendet
lme4_utils.h: In Funktion »internal_make_named«:
lme4_utils.h:105: Fehler: Anfangsdeklaration in »for«-Schleife außerhalb 
C99-Modus verwendet
lme4_utils.h: In Funktion »internal_getElement«:
lme4_utils.h:124: Fehler: Anfangsdeklaration in »for«-Schleife außerhalb 
C99-Modus verwendet
glmer.c: In Funktion »random_effects_deviance«:
glmer.c:433: Fehler: Anfangsdeklaration in »for«-Schleife außerhalb 
C99-Modus verwendet
glmer.c: In Funktion »glmer_init«:
glmer.c:583: Fehler: Anfangsdeklaration in »for«-Schleife außerhalb 
C99-Modus verwendet
make: *** [glmer.o] Fehler 1
ERROR: compilation failed for package 'lme4'

__
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] extract arguments from a list

2006-10-19 Thread jessica . gervais
Hi,

I would like to know how to extract the arguments from a list :

For example, I have a list of charchacter x
x- 
c(Bentazone,Atrazine,Epoxiconazol,Metolachlor,Epoxiconazol,Atrazine 
desethyl,Fenpropimorph,Epoxiconazol,Metolachlor,Simazine,Atrazine 
desethyl,Epoxiconazol,Atrazine 
desethyl,Atrazine,Epoxiconazol,Metolachlor,Epoxiconazol,Atrazine 
desethyl,Fenpropimorph,Epoxiconazol,Metolachlor,Simazine)
 
and I am searching for a (basic) function which would return arguments of 
the list x, aphabeticaly reordered like this :
 (Atrazine,Atrazine 
desethyl,Bentazone,Epoxiconazol,Fenpropimorph,Metolachlor,Simazine).


Can anyone help me ?


Thanks by advance

Jessica



 
[[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] Re : extract arguments from a list

2006-10-19 Thread justin bem
If you want to sort see ?sort 
If you want to get subsample see ?subset 
 
Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé.
Tél (00237)9597295.



- Message d'origine 
De : [EMAIL PROTECTED] [EMAIL PROTECTED]
À : r-help@stat.math.ethz.ch
Envoyé le : Jeudi, 19 Octobre 2006, 10h13mn 46s
Objet : [R] extract arguments from a list


Hi,

I would like to know how to extract the arguments from a list :

For example, I have a list of charchacter x
x- 
c(Bentazone,Atrazine,Epoxiconazol,Metolachlor,Epoxiconazol,Atrazine 
desethyl,Fenpropimorph,Epoxiconazol,Metolachlor,Simazine,Atrazine 
desethyl,Epoxiconazol,Atrazine 
desethyl,Atrazine,Epoxiconazol,Metolachlor,Epoxiconazol,Atrazine 
desethyl,Fenpropimorph,Epoxiconazol,Metolachlor,Simazine)

and I am searching for a (basic) function which would return arguments of 
the list x, aphabeticaly reordered like this :
(Atrazine,Atrazine 
desethyl,Bentazone,Epoxiconazol,Fenpropimorph,Metolachlor,Simazine).


Can anyone help me ?


Thanks by advance

Jessica




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






___ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 


[[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] extract arguments from a list

2006-10-19 Thread David Barron
First, that isn't what is called a list in R, it is a character vector.

Second, to get what you want, try

 sort(unique(x))
[1] Atrazine  Atrazine desethyl Bentazone
[4] Epoxiconazol  Fenpropimorph Metolachlor
[7] Simazine

On 19/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 I would like to know how to extract the arguments from a list :

 For example, I have a list of charchacter x
 x-
 c(Bentazone,Atrazine,Epoxiconazol,Metolachlor,Epoxiconazol,Atrazine
 desethyl,Fenpropimorph,Epoxiconazol,Metolachlor,Simazine,Atrazine
 desethyl,Epoxiconazol,Atrazine
 desethyl,Atrazine,Epoxiconazol,Metolachlor,Epoxiconazol,Atrazine
 desethyl,Fenpropimorph,Epoxiconazol,Metolachlor,Simazine)

 and I am searching for a (basic) function which would return arguments of
 the list x, aphabeticaly reordered like this :
  (Atrazine,Atrazine
 desethyl,Bentazone,Epoxiconazol,Fenpropimorph,Metolachlor,Simazine).


 Can anyone help me ?


 Thanks by advance

 Jessica




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



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

__
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] Rug-like density plots on margins of figure

2006-10-19 Thread Alex Brown
Hi everyone,

I'm trying to plot density curves on the axes of a plot, in a  
similar way to the 'rug' function.

I have had a look at a few approaches and libraries, including:

* layout http://addictedtor.free.fr/graphiques/RGraphGallery.php? 
graph=78
* fancygraph http://addictedtor.free.fr/graphiques/RGraphGallery.php? 
graph=81
* ggplot - gave up since it needs R 2.3.0 and today I need to run on  
less than that
* grid - probably powerful, good approach, but too much effort for a  
midnight hack
* rug - since it does something similar
* lattice - it has multiple graphs, but I think they may need to be  
homogeneous
* plot + lines
* plot + plot

And here is the solution I am using at the moment, based upon layout.

Can anyone suggest a better way to do this?

-Alex Brown


# some data

x1 = rnorm(100)
y1 = rnorm(100)

# setup the layout
opar = par(no.readonly=TRUE)
omar = par(mar)
l = layout(matrix(c(2,0,1,3),2),c(1,4),c(4,1))
par(cex=1,bty=n)

# first plot : main plot
par(mar=omar * c(0,0,1,1)) # just top and right margins
plot(x1, y1, axes=FALSE, main=Density Margins,
  xlab=, ylab=
)

# vars
usepoly - TRUE
plott = ifelse(usepoly,n,l)
par(col=blue)

# second plot : y axis density
par(mar=omar * c(0,1,1,0))
par(xpd=NA)
yd = density(y1,from=min(y1),to=max(y1))
ydd= data.frame(x=-yd$y, y=yd$x)
plot(ydd, xaxt=n,xlim=c(0,min(ydd$x)),type= plott,bty=n,ylab=y  
(density),xlab=)

if(usepoly) {
ydd=rbind(ydd, c(0,max(ydd$y)), c(0,min(ydd$y)))
polygon(ydd,col=grey,border=NA)
}

# third plot : x axis density
par(mar=omar * c(1,0,0,1))
par(xpd=NA)
xd = density(x1,from=min(y1),to=max(y1))
xdd= data.frame(x=xd$x, y=-xd$y)
plot(xdd, yaxt=n,ylim=c(0,min(xdd$y)),type= plott,xlab=x  
(density),ylab=)

if(usepoly) {
xdd=rbind(xdd,c(max(xdd$x),0), c(min(xdd$x),0))
polygon(xdd,col=grey,border=NA)
}

par(opar)


[[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] Redhat compilers and lme4 with R-2.4.0

2006-10-19 Thread Patrick Connolly
On Wed, 18-Oct-2006 at 09:35AM +0100, Prof Brian Ripley wrote:

| There are no known problems with 'RedHat compilers' and lme4.
| 
| You do need to have installed an up-to-date Matrix prior to lme4, and the 
| command-line you show indicates that you have not done so (or that it is 
| not in a library known to R_LIBS).

I did Matrix immediately before trying lme4 but because I wasn't
putting it in the default library, Dealing with that issue is
different on the two machines, but they are essentially the same
problem.

Thank you for adding some wisdom to the information errors.  Fairly
obvious once you know, of course.



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] Labels for Points- 2 character labels?

2006-10-19 Thread David Barron
Is this what you want?

 plot(e,n)
 text(e,n,labels=e_order,pos=4)


On 18/10/06, ableape [EMAIL PROTECTED] wrote:
 I would like to be able to label each point in a scatter plot with
 the numeric order of that point. for example, I create the following plot:

 plot(e,n)
 #
 # now I go back and create my labels
 #
 for(i in 1:length(e)) {# lets say e 10
 pc - as.character(e_order[i])   # e_order has an
 integer array 1,4,3,2... which is the order of e
 points(e15[i], n15[i],pch=pc)# this will plot
 0-9 as data labels

   }
 #
 The above works for single characters.  Now if the length of e[] is
 greater than 9, the character string converted by as.character will
 yield more than one digit. At this point, my labeling trick fails:-(

 1) is there a way to create two character labels for a plot?
 2) Or even better, is there a way to do what I am trying to
 do.  Label each point by its numeric order?

 Thanks for your help.

 Renaldo

 __
 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

__
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] Redhat compilers and lme4 with R-2.4.0

2006-10-19 Thread Prof Brian Ripley
On Thu, 19 Oct 2006, Stefan Grosse wrote:

 Prof Brian Ripley schrieb:
 
 Not surprising: you have not compiled R with -std=gnu99 to allow C99 
 features, as recommended in the R-admin manual, and selected by default. 
 (Comment to Doug Bates: it is probably better still to write in C90 if you 
 can.)
 
 This seems to be a problem with the flags used to build the FC5 RPMs.
 I think you can circumvent it by adding
 
 PKG_CFLAGS=-std=gnu99
 
 to lme4/src/Makevars.
 
 

 I am having the same problem on Fedora Core 5 with the 2.4.0 rpm from CRAN. 
 Update from lme4 0.9975-3 to lme4 0.9975-6 failed due to exactly the same 
 error message. I would have expected the cran rpm is compiled according to 
 the R-admin guide...?

But it is not, as you can check by looking at R_HOME/etc/Makeconf.  (That 
seems like basic homework to be done _before_ posting: I can only know 
that because I happen to have that RPM installed on my own machine.)

My understanding is that rpmbuild is overridding the R defaults, and needs 
to be overridden in turn. I've copied in Martyn Plummer, who will know for 
sure what happens and what needs to be done about this.

From offline correspondence, I gathered that the next lme4 revision will 
revert to C90, which would resolve this.

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

__
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 get multiple Correlation Coefficients

2006-10-19 Thread Kum-Hoe Hwang
Hi

I have used a polycor package for categorical correlation coefficients.
I run the following script. But there were no results.

Could you tell me how to correct the script?

Thanks in advance,

vars - names(sdi)
for (i in 1:length(vars)) {
for (j in 1:length(vars)) {
  paste(vars[i], and , vars[j])
  polychor(vars[i], vars[j])
  # corr
}
}



-- 
Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [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] spectral analysis of time series

2006-10-19 Thread Peter Dalgaard
Thomas Hoffmann [EMAIL PROTECTED] writes:

 Dear List-Members,
 
 I would like to draw the amplitudes of different frequencies from a
 time series as shown in the attached figure. Does anybody has an idea
 how to do it?

Have a look at

par(ask=T) ; example(spectrum)
help(spectrum)

-- 
   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] CTRL-C behaviour with RODBC on Solaris2.8

2006-10-19 Thread Prof Brian Ripley
This is nothing to do with RODBC, and not reproducible on any of my 
systems.

Investigate your unstated ODBC driver manager and driver for possible 
causes.  Something other than R has uninstalled the signal handler for 
SIGINT, and a rogue shared library is the likely cause.

And please learn to give credit where it is due, instead of blame where it 
is not.  (RODBC attracts far too many careless attributions of blame, this 
being the second just today.  Yet words of thanks are very, very thin on 
the ground.)


On Tue, 17 Oct 2006, [EMAIL PROTECTED] wrote:

 After loading the RODBC package version 1.1-7, Ctrl-C changes its
 behaviour and is quitting R and returning to the (unix-)command prompt
 on the solaris2.8 platform here. Here's what happened before and after
 loading RODBC

 for (i in 1:10^5) rnorm(10)
 ^C
 library(RODBC)
 for (i in 1:10^5) rnorm(10)
 ^C
 bash-3.00$


 platform   sparc-sun-solaris2.8
 arch   sparc
 os solaris2.8
 system sparc, solaris2.8
 status
 major  2
 minor  3.1
 year   2006
 month  06
 day01
 svn rev38247
 language   R
 version.string Version 2.3.1 (2006-06-01)

 This version of R was built with gcc-3.3 (too old?) and ODBC_INCLUDE,
 ODBC_LIBS pointing to non-standard locations
 /quant/temp/jagat/usr/local/include, /quant/temp/jagat/usr/local/lib,
 respectively. Will be glad to provide further details.

 Any ideas on how to correct this would be greatly appreciated.

 Thanks

 --
 Jagat K. Sheth
 Prepayment Modeling and Economics
 Wells Fargo Home Mortgage
 7911 Forsyth Boulevard
 Suite 500, M5001-061
 Clayton, MO 63105

 Tel: (314)-726-4496
 Fax: (314)-726-4483
 [EMAIL PROTECTED]



-- 
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] How to get multiple Correlation Coefficients

2006-10-19 Thread David Barron
Oh, and of course you need to use an explicit print inside a for loop.
 So, the line would be:

  print( polychor(sdi[,i], sdi[,j]))

On 19/10/06, David Barron [EMAIL PROTECTED] wrote:
 The problem is that in the expression  polychor(vars[i], vars[j]),
 vars[i] and vars[j] refer to the names of the variables, not the
 variables themselves.  So, use sdi[,i] and sdi[,j] instead.

 On 19/10/06, Kum-Hoe Hwang [EMAIL PROTECTED] wrote:
  Hi
 
  I have used a polycor package for categorical correlation coefficients.
  I run the following script. But there were no results.
 
  Could you tell me how to correct the script?
 
  Thanks in advance,
 
  vars - names(sdi)
  for (i in 1:length(vars)) {
  for (j in 1:length(vars)) {
paste(vars[i], and , vars[j])
polychor(vars[i], vars[j])
# corr
  }
  }
 
 
 
  --
  Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [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.
 


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



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

__
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] cluster in R

2006-10-19 Thread Christian Hennig
On Wed, 18 Oct 2006, Weiwei Shi wrote:

 Dear Chris:

 I tried to use cor+1 but it still gives me sil width  0 for average.

Well, then it seems that the clustering is not that good.
I don't know your data and there is no theoretical reason why it has to 
be positive. You should read the Kaufman and Rousseeuw book to understand 
the average silhouette width better.

Best wishes,
Christian


 set.seed(1000)
 t9 - cor(t(x), method=pearson)+1 # here i add 1
 t8 - as.dist(t9)
 t7 - cutree(hclust(t8), 4)
 cluster.stats(t8, t7)$avg.silwidth
 [1] -0.008750826
 set.seed(1000)
 t9 - cor(t(x), method=pearson) # here I did not add 1
 t8 - as.dist(t9)
 t7 - cutree(hclust(t8), 4)
 cluster.stats(t8, t7)$avg.silwidth
 [1] -0.09543089

 On 10/18/06, Weiwei Shi [EMAIL PROTECTED] wrote:
 Dear Chris:
 
 thanks for the prompt reply!
 
 You are right, dist from pearson has negatives there, which I should
 use cor+1 in my case (since negatively correlated genes should be
 considered farthest). Thanks.
 
 as to the ?cluster.stats, I double-checked it and I found I need to
 restart my JGR, until then the help page function starts to accept
 newly loaded package, like fpc for this case.
 
 sorry for the confusion,
 
 weiwei
 
 On 10/18/06, Christian Hennig [EMAIL PROTECTED] wrote:
  Dear Weiwei,
 
   btw, ?cluster.stats does not work on my Mac machine.
   version
_
   platform   i386-apple-darwin8.6.1
   arch   i386
   os darwin8.6.1
   system i386, darwin8.6.1
   status
   major  2
   minor  3.1
   year   2006
   month  06
   day01
   svn rev38247
   language   R
   version.string Version 2.3.1 (2006-06-01)
 
  Because I don't have access to a Mac, I can't tell you anything about
  this, unfortunately.
  I always thought that my package should work on all platforms if it 
 passes
  all the standard tests for packages?
  (Is there anyone else who could comment on this please?)
 
   I have a sample like this
   dim(dd.df)
   [1] 142  28
  
   and I want to cluster rows;
   first of all, I followed the examples for cluster.stats() by
   d.dd - dist(dd.df) # use Euclidean
   d.4 - cutree(hclust(d.dd), 4) # 4 clusters I tried
   cluster.stats(d.dd, d.4) # gives me some results like this:
  
   $cluster.size
   [1] 133   5   2   2
  
   $avg.silwidth
   [1] 0.9857916
  
   but when I tried to use pearson dist here, by visualization, i think 4
   or 5 clusters are good for pearson dist, but it gave me a very bad
   avg.siqlwidth
  
   d.dd - as.dist(cor(t(x),method=pearson)) # is This correct?
   $cluster.size
   [1] 86 31  6 19
  
   $avg.silwidth
   [1] -0.09543089
 
  cor can give negative values, which doesn't fit the usual definition
  of a distance. I don't know what as.dist does in this case, but I think
  that, depending on your application, you should rather use the absolute
  value of the correlation, or 1+cor.
 
   btw, what's $seperation? where can I find the detailed explanation on
   the output from cluster.stats?
 
  This is documented on the cluster.stats help page:
 
  separation: vector of clusterwise minimum distances of a point in the
 cluster to a point of another cluster.
 
  Best regards,
  Christian
 
 
  *** --- ***
  Christian Hennig
  University College London, Department of Statistical Science
  Gower St., London WC1E 6BT, phone +44 207 679 1698
  [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche
 
 
 
 --
 Weiwei Shi, Ph.D
 Research Scientist
 GeneGO, Inc.
 
 Did you always know?
 No, I did not. But I believed...
 ---Matrix III
 


 -- 
 Weiwei Shi, Ph.D
 Research Scientist
 GeneGO, Inc.

 Did you always know?
 No, I did not. But I believed...
 ---Matrix III


*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
[EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche

__
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] Getting group size in a data frame

2006-10-19 Thread Alex Brown

I can't quite tell what you are looking for, but try the following:

measurecols = c(val1,val2)
df2 - df[!apply(is.na(df[1:nrow(df),measuredcols]),1,all),]

to remove rows which have no measurements in.

a simple count of the rows (nrow) will then give you the number of  
animals that didn't die, and then

table(df2$factor)

will tell you how many per group didn't die

table(df2$factor[!is.na(df2$val1)]

and

names(measurecols) = measurecols

lapply(measurecols, function(x)table(df2$factor[!is.na(df2[,x])]))

will tell you for each measurement, how many of each group you got.

-Alex

On 19 Oct 2006, at 08:37, Ulrik Stervbo wrote:

 Hi all,

 I have a data frame with some measured values of some animals.  
 Sometimes the
 measurement failed, resulting in a NA for a measurement and  
 sometimes the
 animal died, resulting in NA for all measurements.

 I have several groups of animals. How do I find the size of each  
 group with
 only alive animals? And how do I find the size of the groups for each
 measurement?

 An example:
 l1 - list(factor=c(24,24,24), val1=c(2, 3, NA), val2=c(4, NA, NA))
 df - as.data.frame(l1)
 df$factor - factor(df$factor)

 The size of factors should be 2 and not 3.  The number of  
 measurement in
 val1 should be 2 and the number of measurements in val2 should be 1

 Thanks in advance for any help and suggestions
 Ulrik

   [[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] creating bins for a plot

2006-10-19 Thread Alex Brown
I suggest you look at the functions cut and tapply.

for instance:

breaks = 0:40 / 40
bucket - cut(purban2, breaks)
used.c = tapply(used, bucket, sum)
unused.c = tapply(1 - used, bucket, sum)
used.c[is.na(used.c)] = 0
unused.c[is.na(unused.c)] = 0
plot(breaks[-length(breaks)], used.c / unused.c)

-Alex Brown

On 18 Oct 2006, at 23:24, Jeffrey Stratford wrote:

 Hi.  I'm trying to plot the ratio of used versus unused bird houses
 (coded 1 or 0) versus a continuous environmental gradient  
 (proportion of
  urban cover [purban2]) that I would like to convert into bins (0 -
 0.25, 0.26 - 0.5, 0.51 - 0.75, 0.76 - 1.0) and I'm not having much  
 luck
 figuring this out.  I ran a logistic regression and purban2 ends up
 driving the probability of a box being occupied so it would be nice to
 show this relationship.  I'm also plotting the fitted values vs.  
 purban2
 but that's done.  Any suggestions would be appreciated.

 Many thanks,

 Jeff


 Data sample:

 box   use purbank purban2
 1 1   0.003813435 0.02684564
 2 1   0.04429451  0.1610738
 3 1   0.04458785  0.06040268
 4 1   0.06072162  0.2080537
 5 0   0.6080962   0.6979866
 6 1   0.6060428   0.6107383
 7 1   0.3807568   0.4362416
 8 0   0.3649164   0.3154362
 9 0   0.3505427   0.2483221
 100   0.3476093   0.1409396
 110   0.3719566   0.3020134
 121   0.09238011  0.1342282
 130   0.08616111  0.1073826
 140   0.07388724  0.04026845
 151   0.07046477  0.03355705
 .
 .
 .


 
 Jeffrey A. Stratford, Ph.D.
 Postdoctoral Associate
 331 Funchess Hall
 Department of Biological Sciences
 Auburn University
 Auburn, AL 36849
 334-329-9198
 FAX 334-844-9234
 http://www.auburn.edu/~stratja

 __
 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 the ROracle package with Oracle 10 ?

2006-10-19 Thread Ram Dessau
Hi,

The ROracle package works very well reasonable easy R-code, 
the documention for ROracle is very usefull.
Thank you for this contribution to R !
 
A tip for complex SQL: 
I did however find difficulties to handle complex sql statements in an Oracle 
script 
(something with handling of spaces and line feeds)
This problem was solved by instead creating  views in oracle to 
do the complex sql and then only using simple SQL statement in R 
e.g. select * from viewname

Window binary for ROracle 10 ?
Is there anyone who could help with a version of ROracle for windows
which is compatible with Oracle 10 or more general just uses the default-home
The available (not officially released) version only supports Oracle 9

I work in a clinical microbiology laboratory.
We try to develop the Roracle functionality to retrieve current data 
from the laboratory information system to generate
graphics for epidemiologic surveillance and controlcharts for ELISA robots.


Greetings

Ram Dessau,
Naestved Denmark



Ram Dessau
Overlæge
Klinisk Mikrobiologisk afdeling
Storstrømmens sygehus, Næstved
Ringstedgade 61
4700 Næstved
tel. 5572 9000 tone 4148 el. 4141
fax. 5572 6024

BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Dessau, Ram
TEL;WORK:4148
ORG:;Klinisk Mikrobiologisk afd.
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Dessau;Ram
TITLE:Overlæge
END:VCARD

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


Re: [R] How to get multiple Correlation Coefficients

2006-10-19 Thread David Barron
The problem is that in the expression  polychor(vars[i], vars[j]),
vars[i] and vars[j] refer to the names of the variables, not the
variables themselves.  So, use sdi[,i] and sdi[,j] instead.

On 19/10/06, Kum-Hoe Hwang [EMAIL PROTECTED] wrote:
 Hi

 I have used a polycor package for categorical correlation coefficients.
 I run the following script. But there were no results.

 Could you tell me how to correct the script?

 Thanks in advance,

 vars - names(sdi)
 for (i in 1:length(vars)) {
 for (j in 1:length(vars)) {
   paste(vars[i], and , vars[j])
   polychor(vars[i], vars[j])
   # corr
 }
 }



 --
 Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [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.



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

__
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] spectral analysis of time series

2006-10-19 Thread Gavin Simpson
On Thu, 2006-10-19 at 11:59 +0200, Thomas Hoffmann wrote:
 Dear List-Members,
 
 I would like to draw the amplitudes of different frequencies from a time 
 series as shown in the attached figure. Does anybody has an idea how to 
 do it?
 
 
 Best wishes
 Thomas

Thomas,

If your data are really like those (Foram derived \delta^{18}O
measurements?) palaeoceanographic data and are irregular in time, then
the nuSpectral package may be useful. It isn't on CRAN, but the files
and a paper in JSS about the package are available here:

http://www.jstatsoft.org/index.php?vol=11

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC  ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@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] Writing a script for multiplying a progressively larger lists of items

2006-10-19 Thread Fabio Sanchez
Hi, I would like to get guidance as to how to write code in R that can 
deal with the following situation:

v1 is a vector containing a sequence of numbers (Ex. 1:10)
I want to store the sequence of numbers resulting from multiplying the 
first and the second element in the vector, then the product of the 
1st, 2nd and 3rd, then 1st,2nd,3rd and 4th and so forth until all the 
elements in the vector are multiplied.

Many thanks,

Fabio


Fabio Sánchez, MD, MSc, PhD
Molecular Dermatology
Department of Medicine
Karolinska Institute
SE-17176 Karolinska University Hospital
Tel: +46 8 51772158

__
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] GHK Simulator for Ordered Probit

2006-10-19 Thread Werner Wernersen
Hi,

I am wondering if anybody has already written a GHK
Simulator function for an ordered probit model in R?
We have a system of three equations where the
variables can take ordered categorial values.

Thanks a million,
  Pensi

__
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] Writing a script for multiplying a progressively larger listsof items

2006-10-19 Thread Dimitris Rizopoulos
probably you're looking for ?cumprod(), e.g.,

cumprod(1:10)


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: Fabio Sanchez [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Thursday, October 19, 2006 1:49 PM
Subject: [R] Writing a script for multiplying a progressively larger 
listsof items


Hi, I would like to get guidance as to how to write code in R that can
deal with the following situation:

v1 is a vector containing a sequence of numbers (Ex. 1:10)
I want to store the sequence of numbers resulting from multiplying the
first and the second element in the vector, then the product of the
1st, 2nd and 3rd, then 1st,2nd,3rd and 4th and so forth until all the
elements in the vector are multiplied.

Many thanks,

Fabio


Fabio Sánchez, MD, MSc, PhD
Molecular Dermatology
Department of Medicine
Karolinska Institute
SE-17176 Karolinska University Hospital
Tel: +46 8 51772158

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


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] Getting group size in a data frame [Broadcast]

2006-10-19 Thread Liaw, Andy
Is this sort of what you want?

R aggregate(df[2:3], df[1], function(x) sum(!is.na(x)))
  factor val1 val2
1 2421

Andy 

From: Ulrik Stervbo
 
 Hi all,
 
 I have a data frame with some measured values of some 
 animals. Sometimes the
 measurement failed, resulting in a NA for a measurement and 
 sometimes the
 animal died, resulting in NA for all measurements.
 
 I have several groups of animals. How do I find the size of 
 each group with
 only alive animals? And how do I find the size of the groups for each
 measurement?
 
 An example:
 l1 - list(factor=c(24,24,24), val1=c(2, 3, NA), val2=c(4, NA, NA))
 df - as.data.frame(l1)
 df$factor - factor(df$factor)
 
 The size of factors should be 2 and not 3.  The number of 
 measurement in
 val1 should be 2 and the number of measurements in val2 should be 1
 
 Thanks in advance for any help and suggestions
 Ulrik
 
   [[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.


Re: [R] CTRL-C behaviour with RODBC on Solaris2.8

2006-10-19 Thread Jagat.K.Sheth
The ODBC driver manager is unixODBC-2.2.11. 

I will continue investigating other causes and am extremely grateful for
the time you took to see if the problem was reproducible on any of your
systems. The lack of reproducibility is valuable information to me. 

Thanks very much again for the time you took to investigate and reply.
Thank you very much also to the R project and all the great things it
has done. I wouldn't be here without you!

Best wishes,
Jagat

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 19, 2006 5:23 AM
To: Sheth, Jagat K
Cc: [EMAIL PROTECTED]
Subject: Re: CTRL-C behaviour with RODBC on Solaris2.8

This is nothing to do with RODBC, and not reproducible on any of my
systems.

Investigate your unstated ODBC driver manager and driver for possible
causes.  Something other than R has uninstalled the signal handler for
SIGINT, and a rogue shared library is the likely cause.

And please learn to give credit where it is due, instead of blame where
it is not.  (RODBC attracts far too many careless attributions of blame,
this being the second just today.  Yet words of thanks are very, very
thin on the ground.)


On Tue, 17 Oct 2006, [EMAIL PROTECTED] wrote:

 After loading the RODBC package version 1.1-7, Ctrl-C changes its 
 behaviour and is quitting R and returning to the (unix-)command prompt

 on the solaris2.8 platform here. Here's what happened before and after

 loading RODBC

 for (i in 1:10^5) rnorm(10)
 ^C
 library(RODBC)
 for (i in 1:10^5) rnorm(10)
 ^C
 bash-3.00$


 platform   sparc-sun-solaris2.8
 arch   sparc
 os solaris2.8
 system sparc, solaris2.8
 status
 major  2
 minor  3.1
 year   2006
 month  06
 day01
 svn rev38247
 language   R
 version.string Version 2.3.1 (2006-06-01)

 This version of R was built with gcc-3.3 (too old?) and ODBC_INCLUDE, 
 ODBC_LIBS pointing to non-standard locations 
 /quant/temp/jagat/usr/local/include, /quant/temp/jagat/usr/local/lib, 
 respectively. Will be glad to provide further details.

 Any ideas on how to correct this would be greatly appreciated.

 Thanks

 --
 Jagat K. Sheth
 Prepayment Modeling and Economics
 Wells Fargo Home Mortgage
 7911 Forsyth Boulevard
 Suite 500, M5001-061
 Clayton, MO 63105

 Tel: (314)-726-4496
 Fax: (314)-726-4483
 [EMAIL PROTECTED]



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

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


[R] Problem Reading from .txt

2006-10-19 Thread Bill Wyatt
I apologize that I've asked a similar question before, but being new to 
R I don't think I did a very good job of formating the question.


I've included a text file since the date set is somewhat large.

What I have is a huge string of numbers in a text file. The numbers are 
all separated by comma's and the groups are separated by a semicolon. 
What I would like to do is read each group in as a single column.


I had hoped that I could just do something like

a-cbind(c(big string of numbers))

However I receive several syntax errors when I do that.

Included in the text document are two lines that represent the first 
point that error occurs in the included data set.


If I run line one it works. Line two is identical I just selected one 
more number from the data set and it will not work.


If anyone could tell me why this is happening, and possibly some way to 
read these large strings into a single column I would be grateful.


Bill Wyatt
Associate Instructor
Ergonomics Graduate Student
Department of Kinesiology
School of Health, Physical Education, and Recreation
Indiana University
O:(812)856-5924
[EMAIL PROTECTED]





//working line

b1x-cbind(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-132.5,-132.5,-132.5,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-133.6,-133.6,-133.05,-133.05,-131.35,-131.35,-129.7,-129.7,-126.9,-126.9,-124.7,-124.7,-121.35,-121.35,-118,-118,-114.7,-114.7,-110.8,-110.8,-106.9,-106.9,-102.45,-102.45,-98,-98,-92.95,-92.95,-87.95,-87.95,-82.95,-82.95,-77.95,-77.95,-72.35,-67.3
 5,-67.35,-61.8,-61.8,-55.65))


//non-working line

b1x-cbind(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-132.5,-132.5,-132.5,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-133.6,-133.6,-133.05,-133.05,-131.35,-131.35,-129.7,-129.7,-126.9,-126.9,-124.7,-124.7,-121.35,-121.35,-118,-118,-114.7,-114.7,-110.8,-110.8,-106.9,-106.9,-102.45,-102.45,-98,-98,-92.95,-92.95,-87.95,-87.95,-82.95,-82.95,-77.95,-77.95,-72.35,-67.3
 5,-67.35,-61.8,-61.8,-55.65,-55.65))


//output from non-working line
 b1x-cbind(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-132.5,-132.5,-132.5,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-134.15,-133.6,-133.6,-133.05,-133.05,-131.35,-131.35,-129.7,-129.7,-126.9,-126.9,-124.7,-124.7,-121.35,-121.35,-118,-118,-114.7,-114.7,-110.8,-110.8,-106.9,-106.9,-102.45,-102.45,-98,-98,-92.95,-92.95,-87.95,-87.95,-82.95,-82.95,-77.95,-77.95,-72.35,-67
 .35,-67.35,-61.8,-61.8,-55.65,-55.
+ 5))
Error: syntax error
 


//one group in orginal data set

//I would like to do this

Re: [R] How to get multiple Correlation Coefficients

2006-10-19 Thread John Fox
Dear David and Kum-Hoe Hwang,

David has pointed out to me that polychor() will incorrectly return a
polychoric correlation when its arguments are length-one character vectors:

 polychor(a, b)
[1] 0.1055909

Actually, the problem is more general, since polychor() will erroneously
compute a polychoric correlation in any event when the contingency table for
the data contains only one cell:

 polychor(1, 2)
[1] 0.1055909
 polychor(rep(a, 100), rep(b, 100))
[1] 0.1055909

I've fixed this bug so that polychor() and polyserial() report an error when
a categorical variable has just one level. I'll upload the new version of
the package to CRAN shortly.

Regards,
 John


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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of David Barron
 Sent: Thursday, October 19, 2006 5:54 AM
 To: Kum-Hoe Hwang; r-help
 Subject: Re: [R] How to get multiple Correlation Coefficients
 
 The problem is that in the expression  polychor(vars[i], 
 vars[j]), vars[i] and vars[j] refer to the names of the 
 variables, not the variables themselves.  So, use sdi[,i] and 
 sdi[,j] instead.
 
 On 19/10/06, Kum-Hoe Hwang [EMAIL PROTECTED] wrote:
  Hi
 
  I have used a polycor package for categorical correlation 
 coefficients.
  I run the following script. But there were no results.
 
  Could you tell me how to correct the script?
 
  Thanks in advance,
 
  vars - names(sdi)
  for (i in 1:length(vars)) {
  for (j in 1:length(vars)) {
paste(vars[i], and , vars[j])
polychor(vars[i], vars[j])
# corr
  }
  }
 
 
 
  --
  Kum-Hoe Hwang, Ph.D.Phone : 82-31-250-3516Email : [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.
 
 
 
 --
 =
 David Barron
 Said Business School
 University of Oxford
 Park End Street
 Oxford OX1 1HP
 
 __
 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] Re : Writing a script for multiplying a progressively larger lists of items

2006-10-19 Thread justin bem
multi-function(x0) {
result-rep(0,length(x0))
for ( i in 1:length(x0)) result[i]-prod(x0[1:i])
result  
}
 
Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé.
Tél (00237)9597295.



- Message d'origine 
De : Fabio Sanchez [EMAIL PROTECTED]
À : r-help@stat.math.ethz.ch
Envoyé le : Jeudi, 19 Octobre 2006, 12h49mn 12s
Objet : [R] Writing a script for multiplying a progressively larger lists of 
items


Hi, I would like to get guidance as to how to write code in R that can 
deal with the following situation:

v1 is a vector containing a sequence of numbers (Ex. 1:10)
I want to store the sequence of numbers resulting from multiplying the 
first and the second element in the vector, then the product of the 
1st, 2nd and 3rd, then 1st,2nd,3rd and 4th and so forth until all the 
elements in the vector are multiplied.

Many thanks,

Fabio


Fabio Sánchez, MD, MSc, PhD
Molecular Dermatology
Department of Medicine
Karolinska Institute
SE-17176 Karolinska University Hospital
Tel: +46 8 51772158

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






___ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 


[[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] out.format for chron

2006-10-19 Thread Denis Chabot
Dear R users,

Do you know of a way to precise an out.format for a chron object that  
would use numbers for months and yet 4 digits for the year?

I have tried out.format=c(d-m-year) (note the m instead of either  
mon or month) but got 27-Feb-1992.

Also, the help for chron tells us how to define an out.format when we  
create a chron object, but how can you change the out.format of an  
existing chron object?

Thanks in advance,

Denis

__
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] Indexing a loop-created list

2006-10-19 Thread Nicolas Prune
Hello,

I create a certain number (n*m) matrices, that I would like to store. These
matrices have different dimensions. As far as I know, for matrices of different
dimensions, there's no alternative to a list.

Here's how I store them on the fly :

my_list - NULL

for (i in 1:n)
{for (j in (i+1):m)
{my_list - list(my_list,i_create_a_matrix(i,j)))
}
}

But the indexation of the result is horrible ! (see below a simplified version,
with no matrices created but i*10+j added to the list instead). Is there a
cleaner way to get the same result ?

Any help will be very welcomed.
Nicolas

[[1]]
[[1]][[1]]
[[1]][[1]][[1]]
[[1]][[1]][[1]][[1]]
[[1]][[1]][[1]][[1]][[1]]
[[1]][[1]][[1]][[1]][[1]][[1]]
NULL

[[1]][[1]][[1]][[1]][[1]][[2]]
[1] 12


[[1]][[1]][[1]][[1]][[2]]
[1] 13


[[1]][[1]][[1]][[2]]
[1] 14


[[1]][[1]][[2]]
[1] 23


[[1]][[2]]
[1] 24


[[2]]
[1] 34

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


Re: [R] Re : CI

2006-10-19 Thread Ethan Johnsons
Great analogy!
Thanks much for the explanantion.

ej

On 10/19/06, justin bem [EMAIL PROTECTED] wrote:


 Get the the package fortunes in the CRAN and try
 fortune(Harrell) for experience of and advance R-user. For the second
 question, the binomial distribution converge to normal distribution
 asymptomaticaly. You can not expect get the same result by using the two
 approximations on a finite sample. Watching a football macth in a TV screen
 is not the same thing that see the game in a staduim.

  Justin BEM
 Elève Ingénieur Statisticien Economiste
 BP 294 Yaoundé.
 Tél (00237)9597295.



 - Message d'origine 
 De : Ethan Johnsons [EMAIL PROTECTED]
 À : Liaw, Andy [EMAIL PROTECTED]
 Cc : r-help@stat.math.ethz.ch
 Envoyé le : Jeudi, 19 Octobre 2006, 5h43mn 36s
 Objet : Re: [R] CI


 Thx so much.

 I just got into R world for my small research.
 I thought that R is free so doesn't have many features, but it seems I
 was wrong.

 Why do these two return different values?

 0.2666456 0.6133544
 0.2698531 0.6213784

 I think the diff is ignorable, but would ask.

 ej

 On 10/19/06, Liaw, Andy [EMAIL PROTECTED] wrote:
  You did ask for CI of mean, so that's what you got.  If you want CI for
  proportion, here are two (non-bootstrap) ways:
 
  R confint(lm(I(x == 1) ~ 1), level=.9)
5 %  95 %
  (Intercept) 0.2666456 0.6133544
  R binom.test(sum(x == 1), length(x), conf.level=.9)
 
  Exact binomial test
 
  data:  sum(x == 1) and length(x)
  number of successes = 11, number of trials = 25, p-value = 0.69
  alternative hypothesis: true probability of success is not equal to 0.5
  90 percent confidence interval:
   0.2698531 0.6213784
  sample estimates:
  probability of success
0.44
 
  I hope these are not HW problems?
 
  Andy
 
  From: Ethan Johnsons
  
   Thank you so much for the feedback.
  
   The random numbers are working great.  I have tried
   non-random numbers, and the outcome is not correct with confint.
  
   Is there a way to compute i.e. a 90% confidence interval for
   percent of 1?
  
   i.e. where 1 = apple; 2 = orange
  
x
[1] 2 2 2 2 2 1 1 2 2 1 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2
table (x)
   x
1  2
   11 14
  
x =11
confint(lm(x~1), level=0.90)
   5 % 95 %
   (Intercept) NaN  NaN
  
   ej
  
   On 10/18/06, Liaw, Andy [EMAIL PROTECTED] wrote:
Here's one way:
   
R x - c(6,11,5,14,30,11,17,3,9,3,8,8) confint(lm(x~1), level=.9)
 5 %95 %
(Intercept) 6.546834 14.2865
   
Andy
   
From: Ethan Johnsons

 I have a quick question, please.

 Does R have function to compute i.e. a 90% confidence
   interval for
 the mean for these numbers?

  mean (6,11,5,14,30,11,17,3,9,3,8,8)
 [1] 6

 I thought pt or qt would give me the interval, but it seems not.

 thx much.

 ej

 __
 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, contains
information of Merck  Co., Inc. (One Merck Drive,
   Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp 
   Dohme or MSD
and in Japan, as Banyu - direct contact information for
   affiliates is
available at
 http://www.merck.com/contact/contacts.html)
   that may be
confidential, proprietary copyrighted and/or legally
   privileged. It is
intended solely for the use of the individual or entity
   named on this
message. If you are not the intended recipient, and have
   received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.
   
   
  
 --

   
  
  
  
 
 
 
 --
  Notice:  This e-mail message, together with any attachment...{{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.

  
  Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions
 ! Demandez à ceux qui savent sur Yahoo! Questions/Réponses.

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

[R] Tukey-Kramer test

2006-10-19 Thread A.R. Criswell
Hello All,

I found the TukeyHSD() function. Is there a Tukey-Kramer test for
unbalanced data?

Andrew

__
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] write data to pdf

2006-10-19 Thread Franco Mendolia
Hello!

Is there a possibility in R to save data in pdf-format?
I do not want to save a plot but some lines of simple text.

Regards,

Franco Mendolia

__
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] out.format for chron

2006-10-19 Thread Gabor Grothendieck
As discussed the Help Desk article in R News 4/1, the 2 vs 4 year
length is controlled by the chron.year.abb option,  e.g.

   options(chron.year.abb = FALSE)
   chron(20)

however, as also discussed there its not really recommended that
you use this option so try this instead:

   ddmm - function( x )
 with( month.day.year( x ), sprintf( %02.f-%02.f-%04.f, day,
month, year) )
   chron( 20, out.format = ddmm )




On 10/19/06, Denis Chabot [EMAIL PROTECTED] wrote:
 Dear R users,

 Do you know of a way to precise an out.format for a chron object that
 would use numbers for months and yet 4 digits for the year?

 I have tried out.format=c(d-m-year) (note the m instead of either
 mon or month) but got 27-Feb-1992.

 Also, the help for chron tells us how to define an out.format when we
 create a chron object, but how can you change the out.format of an
 existing chron object?

 Thanks in advance,

 Denis

 __
 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] out.format for chron

2006-10-19 Thread Gabor Grothendieck
For your second question:

x - chron(1)
x - chron(x, out.format = ddmm)

using the ddmm from below.

On 10/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 As discussed the Help Desk article in R News 4/1, the 2 vs 4 year
 length is controlled by the chron.year.abb option,  e.g.

   options(chron.year.abb = FALSE)
   chron(20)

 however, as also discussed there its not really recommended that
 you use this option so try this instead:

   ddmm - function( x )
 with( month.day.year( x ), sprintf( %02.f-%02.f-%04.f, day,
 month, year) )
   chron( 20, out.format = ddmm )




 On 10/19/06, Denis Chabot [EMAIL PROTECTED] wrote:
  Dear R users,
 
  Do you know of a way to precise an out.format for a chron object that
  would use numbers for months and yet 4 digits for the year?
 
  I have tried out.format=c(d-m-year) (note the m instead of either
  mon or month) but got 27-Feb-1992.
 
  Also, the help for chron tells us how to define an out.format when we
  create a chron object, but how can you change the out.format of an
  existing chron object?
 
  Thanks in advance,
 
  Denis
 
  __
  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] write data to pdf

2006-10-19 Thread Stefano Calza
Give a look at Sweave

library(tools)
?Sweave

or RNews 2002 vol 2 number 3 and 2003 vol 3 number 2

Stefano

On Thu, Oct 19, 2006 at 04:09:56PM +0200, Franco Mendolia wrote:
FrancoHello!
Franco
FrancoIs there a possibility in R to save data in pdf-format?
FrancoI do not want to save a plot but some lines of simple text.
Franco
FrancoRegards,
Franco
FrancoFranco Mendolia
Franco
Franco__
FrancoR-help@stat.math.ethz.ch mailing list
Francohttps://stat.ethz.ch/mailman/listinfo/r-help
FrancoPLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
Francoand 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] Indexing a loop-created list

2006-10-19 Thread Romain Lorrilliere

__
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] predict.Arima question

2006-10-19 Thread Felipe Santos
Hi,

I am trying to forecast a model using predict.Arima

I found arima model for a data set: x={x1,x2,x3,...,x(t)}

arima_model = arima(x,order=c(1,0,1))

I am forecasting the next N lags using predict:

arima_pred = predict(arima_model,n.ahead = N, se.fit=T)

If I have one more point in my series, let's say x(t+1). I do not want to
recalibrate themodel, I just want to forecast the next N-1 lags  using the
same model for x={x1,x2,...x(t)} but without recalibrate arima.

How to do it using arima + predict.Arima ?

My problem is that I am trying to fit arima models by brute force ( trying
lots of combinations for p and q and chosing the best model by AIC and BIC )
I have a big time series and I am running calibration for some sub-sequence
and I trying to forecast some points. I repeat this process for the next
contiguous subsequence and try to forecast again, until the big series end.

Thanks
Felipe

[[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] write data to pdf

2006-10-19 Thread Alex Brown
One possible option is the sweave package, available on CRAN.  This  
package allows you to generate reports including static text, inlined  
and pretty printed data frames, plots, etc.

-Alex

On 19 Oct 2006, at 15:57, Franco Mendolia wrote:

 Hi Alex!

 I'll try to explain.

 I am writing a tool to simulate the lifetime of special machines.
 When finisched with simulating I display the results in a GUI  
 written with the tcltk-package.

 It looks somehow like this:

 Lifetime
 mean :   7 years
 variance:1
 standard deviation:  1
 xyz: abc
  ..
  ..
  ..

 I now would like to save the results in a pdf-file in the same  
 format as above and add one or two plots.
 In R the results are written in a data frame.

 Franco Mendolia

  Original-Nachricht 
 Von: Alex Brown [EMAIL PROTECTED]
 An: Franco Mendolia [EMAIL PROTECTED]
 Betreff: Re:[R] write data to pdf
 Datum: 19.10.2006 16:38

 Hi Franco
 There are several possible answers to this.
 To get the best answer, it would help if you could describe what  
 you actually want, and why.
 Even better, give an example of what you would like to write in R,  
 and the output you expect.
 -Alex Brown
 On 19 Oct 2006, at 15:09, Franco Mendolia wrote:
 Hello!

 Is there a possibility in R to save data in pdf-format?
 I do not want to save a plot but some lines of simple text.

 Regards,

 Franco Mendolia

 __
 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] Indexing a loop-created list

2006-10-19 Thread Romain Lorrilliere

  hi,

 try this:

 my_list - NULL

 for (i in 1:n)
   {for (j in (i+1):m)
   {my_list - c(my_list,list(i_create_a_matrix(i,j)))
   }
 }

   

 Best,

 Romain


 Romain Lorrillière

  

 UMR 8079 Laboratoire Ecologie, Systématique et Evolution

 Bât. 362

 Université Paris-Sud

 91405 Orsay cedex

 France

  

 tel : 01 69 15 56 85

 fax : 01 69 15 56 96

 mobile : 06 81 70 90 70

  

 email : [EMAIL PROTECTED]

  



 Nicolas Prune a écrit :
 Hello,

 I create a certain number (n*m) matrices, that I would like to store. These
 matrices have different dimensions. As far as I know, for matrices of 
 different
 dimensions, there's no alternative to a list.

 Here's how I store them on the fly :

 my_list - NULL

 for (i in 1:n)
  {for (j in (i+1):m)
  {my_list - list(my_list,i_create_a_matrix(i,j)))
  }
 }

 But the indexation of the result is horrible ! (see below a simplified 
 version,
 with no matrices created but i*10+j added to the list instead). Is there a
 cleaner way to get the same result ?

 Any help will be very welcomed.
 Nicolas

 [[1]]
 [[1]][[1]]
 [[1]][[1]][[1]]
 [[1]][[1]][[1]][[1]]
 [[1]][[1]][[1]][[1]][[1]]
 [[1]][[1]][[1]][[1]][[1]][[1]]
 NULL

 [[1]][[1]][[1]][[1]][[1]][[2]]
 [1] 12


 [[1]][[1]][[1]][[1]][[2]]
 [1] 13


 [[1]][[1]][[1]][[2]]
 [1] 14


 [[1]][[1]][[2]]
 [1] 23


 [[1]][[2]]
 [1] 24


 [[2]]
 [1] 34

 __
 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] write data to pdf

2006-10-19 Thread Dieter Menne
Franco Mendolia franco.mendolia at gmx.de writes:

 
 Is there a possibility in R to save data in pdf-format?
 I do not want to save a plot but some lines of simple text.

I remember that about 4  years ago there was a thread on the subject, but I
could not find it any more. But, maybe, it's anyway better to think the other
way round, asking How can I generate nice pdf tables with R. For that, you
should have a look at Sweave (latex), or package odfWeave if you prefer Open
Office output.

Dieter

__
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] binom.test

2006-10-19 Thread Ethan Johnsons
R-experts:

A quick question, please.

From a lab exp, I got 12 positives out of 50.
To get 90% CI for this , I think binom.test might be the one to be used.
Is there a better way or function to calculate this?

 binom.test(x=12, n=50, p=12/50, conf.level = 0.90)

Exact binomial test

data:  12 and 50
number of successes = 12, number of trials = 50, p-value = 1
alternative hypothesis: true probability of success is not equal to 0.24
90 percent confidence interval:
 0.1447182 0.3596557
sample estimates:
probability of success
  0.24

thx much

ej

__
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] out.format for chron

2006-10-19 Thread Denis Chabot
Got it Gabor,

Thank you very much.

Denis

Le 06-10-19 à 10:38, Gabor Grothendieck a écrit :

 For your second question:

 x - chron(1)
 x - chron(x, out.format = ddmm)

 using the ddmm from below.

 On 10/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 As discussed the Help Desk article in R News 4/1, the 2 vs 4 year
 length is controlled by the chron.year.abb option,  e.g.

   options(chron.year.abb = FALSE)
   chron(20)

 however, as also discussed there its not really recommended that
 you use this option so try this instead:

   ddmm - function( x )
 with( month.day.year( x ), sprintf( %02.f-%02.f-%04.f, day,
 month, year) )
   chron( 20, out.format = ddmm )




 On 10/19/06, Denis Chabot [EMAIL PROTECTED] wrote:
  Dear R users,
 
  Do you know of a way to precise an out.format for a chron object  
 that
  would use numbers for months and yet 4 digits for the year?
 
  I have tried out.format=c(d-m-year) (note the m instead of either
  mon or month) but got 27-Feb-1992.
 
  Also, the help for chron tells us how to define an out.format  
 when we
  create a chron object, but how can you change the out.format of an
  existing chron object?
 
  Thanks in advance,
 
  Denis
 
  __
  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] Time conversion from Win32 64bit FILETIME?

2006-10-19 Thread Derek Eder
Windows-32 has a time structure called FILETIME, a 64-bit value 
representing the number of 100-nanosecond intervals since January 1, 
1601 (UTC).   That is not a typo, the year is 1601. 

Does anyone have a clue(or algorhithm)for how this is converted to 
something a little more POSIX-like ?

Thank you,

Derek

-- 
Derek N. Eder

Gothenburg University 
VINKLA - Vigilance and Neurocognition laboratory 

SU/Sahlgrenska
Utvecklingslab 1, Med
Gröna stråket 8
SE 413 45 Göteborg (Gothenburg)
Sverige (Sweden)

+46 (031)* 342 8261 (28261 inom Sahlgrenska)
+46 0704 915 714 (mobile)
+46 (031) 25 97 07 (home)

* omit the 0 when calling from outside Sweden

personal web page:  www.derek-eder.org

__
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] write data to pdf

2006-10-19 Thread Mark Lyman
Franco Mendolia franco.mendolia at gmx.de writes:

 
 Hello!
 
 Is there a possibility in R to save data in pdf-format?
 I do not want to save a plot but some lines of simple text.
 
 Regards,
 
 Franco Mendolia


You could also use pdf() and textplot() in the gplots package

Mark Lyman

__
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] write data to pdf

2006-10-19 Thread Barry Rowlingson
Franco Mendolia wrote:
 Hello!
 
 Is there a possibility in R to save data in pdf-format?
 I do not want to save a plot but some lines of simple text.

Howabout:

  R - RSPython[1] - ReportLab[2] - PDF

[1] http://www.omegahat.org/RSPython/
[2] http://www.reportlab.org/

ReportLab is a very nice PDF generator library, closer integration with 
R would be useful... But no I dont have time to do it :(

Barry

__
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] binom.test

2006-10-19 Thread Chuck Cleland
Ethan Johnsons wrote:
 R-experts:
 
 A quick question, please.
 
From a lab exp, I got 12 positives out of 50.
 To get 90% CI for this , I think binom.test might be the one to be used.
 Is there a better way or function to calculate this?
 
 binom.test(x=12, n=50, p=12/50, conf.level = 0.90)
 
 Exact binomial test
 
 data:  12 and 50
 number of successes = 12, number of trials = 50, p-value = 1
 alternative hypothesis: true probability of success is not equal to 0.24
 90 percent confidence interval:
  0.1447182 0.3596557
 sample estimates:
 probability of success
   0.24

You might consider binconf() in the Hmisc package too:

library(Hmisc)
binconf(12, 50, method=all)
   PointEstLowerUpper
Exact  0.24 0.130610 0.381691
Wilson 0.24 0.142974 0.374127
Asymptotic 0.24 0.121621 0.358379

 thx much
 
 ej
 
 __
 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.

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

__
R-help@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] binom.test

2006-10-19 Thread Ted Harding
On 19-Oct-06 Ethan Johnsons wrote:
 R-experts:
 
 A quick question, please.
 
From a lab exp, I got 12 positives out of 50.
 To get 90% CI for this , I think binom.test might be
 the one to be used.
 Is there a better way or function to calculate this?

What do you mean by better? For a symmetrical 2-sided
exact binomial confidence interval, binom.test gives the
result quickly and, to within the precision of pbinom,
correctly (as I've just verified by hand!).

And you can get 1-sided CIs by setting the 'alternative'
option, or asymmetrical CI's by finding the two 1-sided
CIs (e.g. for conf.level = 0.03 and 0.07) that you want.

What do you want to improve on?

 binom.test(x=12, n=50, p=12/50, conf.level = 0.90)
 
 Exact binomial test
 
 data:  12 and 50
 number of successes = 12, number of trials = 50, p-value = 1
 alternative hypothesis: true probability of success is not equal to
 0.24
 90 percent confidence interval:
  0.1447182 0.3596557

  r-12 ; n-50

  1-pbinom(r-1,n, 0.14471815)
  [1] 0.0499

  1-pbinom(r-1,n, 0.14471816)
  [1] 0.0501


  pbinom(r,n, 0.35965569)
  [1] 0.0501

  pbinom(r,n, 0.35965570)
  [1] 0.05

  pbinom(r,n, 0.35965571)
  [1] 0.0498


 sample estimates:
 probability of success
   0.24
 
 thx much
 
 ej

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 19-Oct-06   Time: 16:53:19
-- XFMail --

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


[R] CI with sd

2006-10-19 Thread Ethan Johnsons
Please let me ask you another quick question.
I have results for e coli, and am trying to get 95% CI with the sd (1.783956).
I got the result from another tool as (1.21, 3.42).
But, I like to verify it with R.  What function do you use for this?

 e.coli=c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
 sd(e.coli, na.rm = FALSE)
[1] 1.783956

Sorry for the newbie question.

thx much

ej

__
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] Indexing a loop-created list

2006-10-19 Thread Richard M. Heiberger
m - 2
n - 3

matlist - matrix(vector(list), m, n)

for (i in 1:m)
  for (j in 1:n)
matlist[[i,j]] - matrix(sample(12), 3, 4)

matlist[[1,2]] ## access with double[[ subscripts

__
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] Time conversion from Win32 64bit FILETIME?

2006-10-19 Thread jim holtman
One way might be to convert the number to POSIXct by scaling it based
that POSIXct is from 1970 and your number is from 1601.  So if you
subtract the difference between 1601 and 1970 then you should have a
compliant number for R:

# read your number
x - 12345678901234567890  # big number (your 64-bit time)
x.sec - x / 10^9 # convert to seconds
xBase - unclass(as.POSIXct('1601-1-1'))  # your time base, relative to 1970
x.sec - x.sec - abs(xBase)  # scale to 1970
x.time - structure(x.sec, class=c(POSIXt, POSIXct))  # convert to POSIXct


On 10/19/06, Derek Eder [EMAIL PROTECTED] wrote:
 Windows-32 has a time structure called FILETIME, a 64-bit value
 representing the number of 100-nanosecond intervals since January 1,
 1601 (UTC).   That is not a typo, the year is 1601.

 Does anyone have a clue(or algorhithm)for how this is converted to
 something a little more POSIX-like ?

 Thank you,

 Derek

 --
 Derek N. Eder

 Gothenburg University
 VINKLA - Vigilance and Neurocognition laboratory

 SU/Sahlgrenska
 Utvecklingslab 1, Med
 Gröna stråket 8
 SE 413 45 Göteborg (Gothenburg)
 Sverige (Sweden)

 +46 (031)* 342 8261 (28261 inom Sahlgrenska)
 +46 0704 915 714 (mobile)
 +46 (031) 25 97 07 (home)

 * omit the 0 when calling from outside Sweden

 personal web page:  www.derek-eder.org

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


Re: [R] Time conversion from Win32 64bit FILETIME?

2006-10-19 Thread Prof Brian Ripley
On Thu, 19 Oct 2006, Derek Eder wrote:

 Windows-32 has a time structure called FILETIME, a 64-bit value
 representing the number of 100-nanosecond intervals since January 1,
 1601 (UTC).   That is not a typo, the year is 1601.

 Does anyone have a clue(or algorhithm)for how this is converted to
 something a little more POSIX-like ?

ISOdatetime(1601, 1, 1, 0, 0, UTC) + x/1e7

looks about right, although you won't manage to get the full 64-bit time 
into R.  However, you can also use Windows system calls such as 
FileTimeToSystemTime to do 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] binom.test

2006-10-19 Thread Ethan Johnsons
Thx much for the feedback.
It is a big help.

ej

On 10/19/06, Ted Harding [EMAIL PROTECTED] wrote:
 On 19-Oct-06 Ethan Johnsons wrote:
  R-experts:
 
  A quick question, please.
 
 From a lab exp, I got 12 positives out of 50.
  To get 90% CI for this , I think binom.test might be
  the one to be used.
  Is there a better way or function to calculate this?

 What do you mean by better? For a symmetrical 2-sided
 exact binomial confidence interval, binom.test gives the
 result quickly and, to within the precision of pbinom,
 correctly (as I've just verified by hand!).

 And you can get 1-sided CIs by setting the 'alternative'
 option, or asymmetrical CI's by finding the two 1-sided
 CIs (e.g. for conf.level = 0.03 and 0.07) that you want.

 What do you want to improve on?

  binom.test(x=12, n=50, p=12/50, conf.level = 0.90)
 
  Exact binomial test
 
  data:  12 and 50
  number of successes = 12, number of trials = 50, p-value = 1
  alternative hypothesis: true probability of success is not equal to
  0.24
  90 percent confidence interval:
   0.1447182 0.3596557

   r-12 ; n-50

   1-pbinom(r-1,n, 0.14471815)
   [1] 0.0499

   1-pbinom(r-1,n, 0.14471816)
   [1] 0.0501


   pbinom(r,n, 0.35965569)
   [1] 0.0501

   pbinom(r,n, 0.35965570)
   [1] 0.05

   pbinom(r,n, 0.35965571)
   [1] 0.0498


  sample estimates:
  probability of success
0.24
 
  thx much
 
  ej

 Best wishes,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 19-Oct-06   Time: 16:53:19
 -- XFMail --


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


[R] A question regarding Wireframe in Package Lattice

2006-10-19 Thread Saptarshi Guha
Hello,
The following code produces a quadrilateral:

q-matrix(c(1,3,1,2,3,1,2,4,2,1,4,2),nrow=4,byrow=T)
qc-xyz.coords(q)
wireframe(z~y*x,qc)
I have 2 questions
1) How can i remove the bounding box i.e the cube encompassing the  
quadrilateral?
2) Is there any function to get the 2D coordinates of the  
quadrilateral actually used in the final plot   ? I could manually  
calculate the 2D co-ordinates of the projection of the quad if I knew  
the sequnce of 3D transformations 'wireframe' performed upto the  
final step before plotting.

Thanks
Saptarshi



Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha



[[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] predict.Arima question

2006-10-19 Thread Prof Brian Ripley
On Thu, 19 Oct 2006, Felipe Santos wrote:

 Hi,

 I am trying to forecast a model using predict.Arima

 I found arima model for a data set: x={x1,x2,x3,...,x(t)}

 arima_model = arima(x,order=c(1,0,1))

 I am forecasting the next N lags using predict:

 arima_pred = predict(arima_model,n.ahead = N, se.fit=T)

 If I have one more point in my series, let's say x(t+1). I do not want to
 recalibrate themodel, I just want to forecast the next N-1 lags  using the
 same model for x={x1,x2,...x(t)} but without recalibrate arima.

 How to do it using arima + predict.Arima ?

The short answer is that you cannot.  However, these are built on top of a 
Kalman filter implementation, and you could use the underlying C code.
It would be easier to make use of a modification of predict.arima0, 
though.

[...]

-- 
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] binom.test

2006-10-19 Thread Francisco J. Zagmutt
You can also plot an uncertainty distribution of p, using an uninformed 
prior (uniform(0,1)), using beta(s+1, n-s+1)  i.e.

x - seq(0.091, 0.469, length=100)
plot(x, dbeta(.x, shape1=13, shape2=39), xlab=x, ylab=Density, 
main=Uncertainy distribution for p: beta(a = 12+1, b = 50-12+1), type=l)

Cheers,

Francisco


Dr. Francisco J. Zagmutt
College of Veterinary Medicine and Biomedical Sciences
Colorado State University



From: Chuck Cleland [EMAIL PROTECTED]
To: Ethan Johnsons [EMAIL PROTECTED]
CC: r-help@stat.math.ethz.ch
Subject: Re: [R] binom.test
Date: Thu, 19 Oct 2006 11:27:35 -0400

Ethan Johnsons wrote:
  R-experts:
 
  A quick question, please.
 
 From a lab exp, I got 12 positives out of 50.
  To get 90% CI for this , I think binom.test might be the one to be used.
  Is there a better way or function to calculate this?
 
  binom.test(x=12, n=50, p=12/50, conf.level = 0.90)
 
  Exact binomial test
 
  data:  12 and 50
  number of successes = 12, number of trials = 50, p-value = 1
  alternative hypothesis: true probability of success is not equal to 0.24
  90 percent confidence interval:
   0.1447182 0.3596557
  sample estimates:
  probability of success
0.24

You might consider binconf() in the Hmisc package too:

library(Hmisc)
binconf(12, 50, method=all)
PointEstLowerUpper
Exact  0.24 0.130610 0.381691
Wilson 0.24 0.142974 0.374127
Asymptotic 0.24 0.121621 0.358379

  thx much
 
  ej
 
  __
  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.

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

__
R-help@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.

_
Stay in touch with old friends and meet new ones with Windows Live Spaces

__
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] CI with sd

2006-10-19 Thread Chuck Cleland
Ethan Johnsons wrote:
 Please let me ask you another quick question.
 I have results for e coli, and am trying to get 95% CI with the sd (1.783956).
 I got the result from another tool as (1.21, 3.42).
 But, I like to verify it with R.  What function do you use for this?
 
 e.coli=c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
 sd(e.coli, na.rm = FALSE)
 [1] 1.783956
 
 Sorry for the newbie question.

e.coli - c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
library(nlme)
mod1 - gls(e.coli ~ 1)
intervals(mod1)

Approximate 95% confidence intervals

 Coefficients:
   lower est.upper
(Intercept) 24.16206 25.5 26.90460
attr(,label)
[1] Coefficients:

 Residual standard error:
   lower est.upper
1.204986 1.783956 3.417651

 thx much
 
 ej
 
 __
 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.

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

__
R-help@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] binom.test

2006-10-19 Thread Kevin E. Thorpe
See also the binconf function in the Hmisc package.

Ethan Johnsons wrote:
 R-experts:
 
 A quick question, please.
 
From a lab exp, I got 12 positives out of 50.
 To get 90% CI for this , I think binom.test might be the one to be used.
 Is there a better way or function to calculate this?
 
 binom.test(x=12, n=50, p=12/50, conf.level = 0.90)
 
 Exact binomial test
 
 data:  12 and 50
 number of successes = 12, number of trials = 50, p-value = 1
 alternative hypothesis: true probability of success is not equal to 0.24
 90 percent confidence interval:
  0.1447182 0.3596557
 sample estimates:
 probability of success
   0.24
 
 thx much
 
 ej
 


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [EMAIL PROTECTED]  Tel: 416.946.8081  Fax: 416.946.3297

__
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] CI with sd

2006-10-19 Thread Ethan Johnsons
Thx so much, Chuck.

R is a reallt sweet tool to use..

I can try many things with i.e. intervals (gls(e.coli ~ 1), level=0.90).
It is a great help.

ej

On 10/19/06, Chuck Cleland [EMAIL PROTECTED] wrote:
 Ethan Johnsons wrote:
  Please let me ask you another quick question.
  I have results for e coli, and am trying to get 95% CI with the sd 
  (1.783956).
  I got the result from another tool as (1.21, 3.42).
  But, I like to verify it with R.  What function do you use for this?
 
  e.coli=c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
  sd(e.coli, na.rm = FALSE)
  [1] 1.783956
 
  Sorry for the newbie question.

 e.coli - c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
 library(nlme)
 mod1 - gls(e.coli ~ 1)
 intervals(mod1)

 Approximate 95% confidence intervals

  Coefficients:
lower est.upper
 (Intercept) 24.16206 25.5 26.90460
 attr(,label)
 [1] Coefficients:

  Residual standard error:
lower est.upper
 1.204986 1.783956 3.417651

  thx much
 
  ej
 
  __
  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.

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



__
R-help@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 random sampling in R

2006-10-19 Thread tom soyer
Hi,

I looked up the help file on sample(), but didn't find the info I was
looking for.

When sample() is used to resample from a distribution, e.g., bootstrap, how
does it do it? Does it use an uniform distribution, e.g., runif(), or
something else? And, when the help file says:sample(x) generates a random
permutation of the elements of x (or 1:x), would I be correct if I
translate the statement as follows: it means that the order of
sequence, which was generated from a uniform distribution, would look like a
random normal distribution.

Thanks,

Tom

[[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] Indexing a loop-created list

2006-10-19 Thread Alberto Monteiro
Romain Lorrilliere wrote:

 try this:

 my_list - NULL

 for (i in 1:n)
   {for (j in (i+1):m)
   {my_list - c(my_list,list(i_create_a_matrix(i,j)))
   }
 }

Why it does not work as expected in this case?

  my_list - NULL

  for (i in 1:10)
my_list - c(my_list, function(x) x^i)

  f - my_list[[2]]
  f(10)

[1] 1e+10

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] Problem Reading from .txt

2006-10-19 Thread chao gai
Bill,

It looks like you are having from some source a hard return in your string. 
When that hard return is in the middle of a number, R sees this as two 
numbers, not separated by a comma (,) and throws an error. Like this:
 c(13,12
+ .3)
Error: syntax error in:
c(13,12
.3
When the hard return is next to a comma (,) it is valid R, so it passes.
In your case it might be around 990th character that the hard occurs.

However, the txt file you added had some additional hard returns so my 
observations might be wrong.

Kees

On Thursday 19 October 2006 15:06, Bill Wyatt wrote:
 I apologize that I've asked a similar question before, but being new to
 R I don't think I did a very good job of formating the question.

 I've included a text file since the date set is somewhat large.

 What I have is a huge string of numbers in a text file. The numbers are
 all separated by comma's and the groups are separated by a semicolon.
 What I would like to do is read each group in as a single column.

 I had hoped that I could just do something like

 a-cbind(c(big string of numbers))

 However I receive several syntax errors when I do that.

 Included in the text document are two lines that represent the first
 point that error occurs in the included data set.

 If I run line one it works. Line two is identical I just selected one
 more number from the data set and it will not work.

 If anyone could tell me why this is happening, and possibly some way to
 read these large strings into a single column I would be grateful.
 
 Bill Wyatt
 Associate Instructor
 Ergonomics Graduate Student
 Department of Kinesiology
 School of Health, Physical Education, and Recreation
 Indiana University
 O:(812)856-5924
 [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] CI with sd

2006-10-19 Thread Ethan Johnsons
I thought of another interesting scenario, and I would just go ahead
and ask this.
I have a mean (i.e. 26.2) where the number of e coli samples is 250.
The mean is already calculated, so it is a discrete value, not series.

What fucntion can be used for the calc with CI i.e. 90%?

thx much,

ej

On 10/19/06, Chuck Cleland [EMAIL PROTECTED] wrote:
 Ethan Johnsons wrote:
  Please let me ask you another quick question.
  I have results for e coli, and am trying to get 95% CI with the sd 
  (1.783956).
  I got the result from another tool as (1.21, 3.42).
  But, I like to verify it with R.  What function do you use for this?
 
  e.coli=c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
  sd(e.coli, na.rm = FALSE)
  [1] 1.783956
 
  Sorry for the newbie question.

 e.coli - c(27.5,24.6,25.3,28.7,23,26.8,24.7,24.3,24.9)
 library(nlme)
 mod1 - gls(e.coli ~ 1)
 intervals(mod1)

 Approximate 95% confidence intervals

  Coefficients:
lower est.upper
 (Intercept) 24.16206 25.5 26.90460
 attr(,label)
 [1] Coefficients:

  Residual standard error:
lower est.upper
 1.204986 1.783956 3.417651

  thx much
 
  ej
 
  __
  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.

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



__
R-help@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] Time conversion from Win32 64bit FILETIME?

2006-10-19 Thread Alberto Monteiro
Derek Eder wrote:

 Windows-32 has a time structure called FILETIME, a 64-bit value 
 representing the number of 100-nanosecond intervals since January 1, 
 1601 (UTC).   That is not a typo, the year is 1601.

It could be worse. VAX/VMS used an internal time that was the
number of seconds since 1858-11-17 multiplied by 10,000,000 -
I don't know what they were smoking when they came to this number.
 
 Does anyone have a clue(or algorhithm)for how this is converted to 
 something a little more POSIX-like ?
 
I would try to get the meaningful FILETIME for some recent
date [like 2001-01-01] and then do a simple arithmetic. The
real problem is that there is no _unique_ definition of
1601-01-01, because the Gregorian reform of the calendar
was established some years before that, but Redmond didn't change
to Gregorian until some date after that. So, there's no way
to know if 1601-01-01 is Gregorian or Julian calendar.

If it's Gregorian, then a simple calculation gives that
2001-01-01 would correspond to FILETIME =
((365 * 400) + 100 - 3) * 24 * 60 * 60 * (1e9 / 100)

where:

365 * 400 = number of normal (non-Feb-29) days
100 = number of _Julian_ calendar Feb-29 days
-3 = take this off, because 1700, 1800 and 1900 were not leap years

And now I think the problem is much simpler.

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] bi-directional sockets

2006-10-19 Thread Grateful Frog
Hello R-helpers!

I am new to R, but having a rough time with the socketConnection function. I
cannot seem to get bi-directional communication to work. I have tried loads
of possible ways, based on the manual's examples, but the result is always
one or the other process hanging.

Could anyone give me a working example of R code that:
- creates a socket,
- listens for data ,
- reads the data,
- writes a reply.

Without hanging or causing the sending process to hang.

I would greatly appreciate any help.

thanks,
gf: http://gratefulfrog.net

[[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] Adding locfit confidence intervals in trelis xyplot

2006-10-19 Thread Deepayan Sarkar
On 10/19/06, juan f poyatos [EMAIL PROTECTED] wrote:

 But it is *within* a trellis plot when I cannot plot the bands!

 Building up on Dieter's example:

 x - rnorm(100)
 y - dnorm(x) + rnorm(100) / 5
 plot(locfit(y~x), band=global)

 Plots two nice confidence bands.

 But try this
 z - dnorm(y) + rnorm(100) / 3
 Z - equal.count(z, number = 4, overlap = .1)
 xyplot(z ~ y|Z, alpha = 1,band = global,panel = panel.locfit)

 and you will not see the bands,

 indeed band is completely ignored as
 xyplot(z ~ y|Z, alpha = 1,band = rubbish,panel = panel.locfit)

 works fine but without the bands!!

And why does that come as a surprise to you?

Since you seem to have missed the point of the previous replies, let
me spell it out for you. A function does what it is instructed to do,
not what you _want_ it to do. The most reliable way to figure out what
those instructions are is to look at the source code of that function.
Since this is not very user friendly, R also requires that all
functions be documented, and specifically, that the documentation for
any function, say foo, can be accessed by typing help(foo). Since you
are using the function panel.locfit, you are supposed to look at
help(panel.locfit), which does not claim to have any support for
bands.

In this case, the source of panel.locfit is actually simpler:

panel.locfit
function (x, y, subscripts, z, xyz.labs, xyz.axes, xyz.mid, xyz.minmax,
xyz.range, col.regions, at, drape, contour, region, groups,
...)
{
   panel.xyplot(x, y, ...)
args - list(x = x, y = y, ...)
ok - names(formals(locfit.raw))
llines.locfit(do.call(locfit.raw, args[ok[ok %in% names(args)]]))
}

(removing the irrelevant part)

-Deepayan


 - juan


 On Thu, 2006-10-19 at 07:49 +, Dieter Menne wrote:
  Deepayan Sarkar deepayan.sarkar at gmail.com writes:
 
  
   On 10/18/06, juan f poyatos jpoyatos at cnio.es wrote:
Dear all,
I am trying to include confidence intervals in a xyplot.
   
  ...
 
   Well, panel.locfit doesn't have any options to draw confidence bands,
   so you'll have to write a panel function that does. Shouldn't be hard
   to extend panel.locfit if you know how to extract that information
   from a locfit object.
 
  plot.locfit has bands. I think Juan mixed trellis and standard plot
  documentation.
 
 
  x - rnorm(100)
  y - dnorm(x) + rnorm(100) / 5
  plot(locfit(y~x), band=global)
 
  __
  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.
 --
 Juan F. Poyatos
 Structural and Computational Biology Programme
 Spanish National Cancer Centre (CNIO)
 Melchor Fernandez Almagro, 3/E-28029 Madrid SPAIN
 Phone:+34 912 246 900/Fax: +34 912 246 980

 http://bioinfo.cnio.es/~jpoyatos/




 **NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{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.





-- 
http://www.stat.wisc.edu/~deepayan/

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


Re: [R] Question about random sampling in R

2006-10-19 Thread Liaw, Andy
When sampling with replacement (like ordinary bootstrap), each draw is
done independently, and in each draw every point has equal probability
of being drawn.  When sampling without replacement (random permutation),
all possible sequences (permutations) have equal probability of
occurring.  E.g., if the data is 1:2, then (1, 2) has the same
probability of occurring as (2, 1).

Andy

From: tom soyer
 
 Hi,
 
 I looked up the help file on sample(), but didn't find the 
 info I was looking for.
 
 When sample() is used to resample from a distribution, e.g., 
 bootstrap, how does it do it? Does it use an uniform 
 distribution, e.g., runif(), or something else? And, when the 
 help file says:sample(x) generates a random permutation of 
 the elements of x (or 1:x), would I be correct if I 
 translate the statement as follows: it means that the order 
 of sequence, which was generated from a uniform distribution, 
 would look like a random normal distribution.
 
 Thanks,
 
 Tom
 
   [[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.


Re: [R] bi-directional sockets

2006-10-19 Thread Gabor Grothendieck
Check out these packages:
- Ryacas (on omegahat) -- sockets between R and yacas
- mimR (on CRAN) -- sockets between R and mim (Windows only)


On 10/19/06, Grateful Frog [EMAIL PROTECTED] wrote:
 Hello R-helpers!

 I am new to R, but having a rough time with the socketConnection function. I
 cannot seem to get bi-directional communication to work. I have tried loads
 of possible ways, based on the manual's examples, but the result is always
 one or the other process hanging.

 Could anyone give me a working example of R code that:
 - creates a socket,
 - listens for data ,
 - reads the data,
 - writes a reply.

 Without hanging or causing the sending process to hang.

 I would greatly appreciate any help.

 thanks,
 gf: http://gratefulfrog.net

[[alternative HTML version deleted]]

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


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


Re: [R] Question about random sampling in R

2006-10-19 Thread Marc Schwartz
On Thu, 2006-10-19 at 12:07 -0500, tom soyer wrote:
 Hi,
 
 I looked up the help file on sample(), but didn't find the info I was
 looking for.
 
 When sample() is used to resample from a distribution, e.g., bootstrap, how
 does it do it? Does it use an uniform distribution, e.g., runif(), or
 something else? And, when the help file says:sample(x) generates a random
 permutation of the elements of x (or 1:x), would I be correct if I
 translate the statement as follows: it means that the order of
 sequence, which was generated from a uniform distribution, would look like a
 random normal distribution.
 
 Thanks,
 
 Tom

In the simplest case, where you have not specified a set of probability
weights, sample() uses a uniform distribution, such that each element
has an equal probability of being selected.

In the case of sampling WITHOUT replacement (the default), each element
in the vector has an equal probability of being selected. Once selected,
that element is removed from the sampling space and the process is
repeated with the remaining elements until all elements have been
selected.

So:

 sample(10)
 [1]  3  8  5  9  7  1  4  2 10  6

yields a random permutation of 1:10.

In the case of 'replace = TRUE', which is sampling WITH replacement,
after an element is selected it is retained in the sampling space, thus
can be selected multiple times.

So:

 sample(10, replace = TRUE)
 [1] 1 4 1 8 7 8 6 7 5 9


If you specify a set of probability weights from the sampling vector,
then the probability for each element in being selected is affected
accordingly.

In the case of bootstrapping, sampling WITH replacement is used. You
might find the following post helpful in this scenario:

  http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67421.html


If you want to investigate further, you can review the C source code for
the relevant R functions in random.c in the R source tarball. The file
will be in ../src/main.

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] hit return key before next gaph appears

2006-10-19 Thread Leeds, Mark \(IED\)
i am looping and creating plots which are coming to the screen. i am in
linux and remember ( in a previopus life ) i used to use a command so
that the next graph n + 1 didn't appear on the screen until
i hit the return key after graph n appeared. i thought i remeber using
the command unix but when i type unix at the r prompt, it gices me
system. it's probably a deprecated
command then but i still don't remember what i did to make the next
graph not appear until i hit the return key. or maybe it was any key for
that matter. 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.


Re: [R] hit return key before next gaph appears

2006-10-19 Thread Chuck Cleland
Leeds, Mark (IED) wrote:
 i am looping and creating plots which are coming to the screen. i am in
 linux and remember ( in a previopus life ) i used to use a command so
 that the next graph n + 1 didn't appear on the screen until
 i hit the return key after graph n appeared. i thought i remeber using
 the command unix but when i type unix at the r prompt, it gices me
 system. it's probably a deprecated
 command then but i still don't remember what i did to make the next
 graph not appear until i hit the return key. or maybe it was any key for
 that matter. thanks a lot.

par(ask=TRUE)
plot(rnorm(10))

 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 vi
a !
  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.

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

__
R-help@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] hit return key before next gaph appears

2006-10-19 Thread Marc Schwartz
On Thu, 2006-10-19 at 14:23 -0400, Leeds, Mark (IED) wrote:
 i am looping and creating plots which are coming to the screen. i am in
 linux and remember ( in a previopus life ) i used to use a command so
 that the next graph n + 1 didn't appear on the screen until
 i hit the return key after graph n appeared. i thought i remeber using
 the command unix but when i type unix at the r prompt, it gices me
 system. it's probably a deprecated
 command then but i still don't remember what i did to make the next
 graph not appear until i hit the return key. or maybe it was any key for
 that matter. thanks a lot.
  
 
 
 mark

Mark,

It is par(ask).  See ?par for more information.

 par(ask = TRUE)

 plot(1:10)

 par(ask = FALSE)

HTH,

Marc Schwartz

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


Re: [R] Question about random sampling in R

2006-10-19 Thread Ted Harding
On 19-Oct-06 tom soyer wrote:
 Hi,
 
 I looked up the help file on sample(), but didn't find the
 info I was looking for.
 
 When sample() is used to resample from a distribution, e.g.,
 bootstrap, how does it do it? Does it use an uniform distribution,
 e.g., runif(), or something else?

I don't know the details of the algorithm, but since sample()
has flexible options it may be helpful to describe the effect
of sample() in different cases.

1. sample(x,r) where x is a vector of length n
In effect, the index values (1:n) of x are sampled from
without replacement (default) with a uniform probability
distribution over the available elements at all stages.
Hence, i1 is sampled from (1:n) with probability 1/n for
each possibility. Then i2 is sampled from the remainder
with probability 1/(n-1) for each, and so on until r items
(all distinct) have been sampled. If the resulting indices
are {i1,i2,...,ir} then the result is x[i1],x[i2],...,x[ir].
Thus, if some of the values in x[1],...,x[n] are equal,
you can get 2 or more items in the sample which are equal
even though the sampling is done without replacement (since
it is the indices which are sampled).
[NB I'm describing the *effect* here, not saying that this
is how the algorithm operates]

2. sample(x, replace=TRUE)
Similar to [1], except that the sampled index is returned
to the pool and is available to be sampled again, so at each
stage the probability of any value being chosen is 1/n.

3. sample(x, replace=TRUE, prob=p) where p is a vector of
   probability weights (which must not all be 0, and none
   negative).
First, p is converted into a probability distribution
(summing to 1) (in effect by dividing by the sum).
Then an index i1 is sampled from (1:n) with probability
p[i] that i is chosen. This is repeated (with previously
sampled i's still available) until r index values have been
sampled -- i1,...,ir. The result is x[i1],...,x[ir].

4. sample(x, prob=p) [without replacement]
First p is scaled to sum to 1, then i1 is sampled as in [3].
The remaining p-values are rescaled so as to sum to 1,
and i2 is sampled from the remaining i's; and so on.

These are the essential variants of the use of sample().

runif() can be used to sample i1 from (1:n) with equal
probabilities by selecting i if runif() is = i and  (i-1)
for i = 1:n.

Similarly runif() can be used to sample i1 from (1:n)
with probabilities p1,...,pn by selecting i if

  p[1] + ... + p[i-1]  runif() = p[1] + ... + p[i]

[LHS=0 if i=0], since the probability of this happening is p[i].

 And, when the help file
 says:sample(x) generates a random permutation of the elements
 of x (or 1:x),

Since the default value of r (size of sample) is the length
of x, say n, sample(x) (see [1] above) will sample n elements
without replacement from the n elements of x with uniform
probabilities at each stage. In effect, n elements i1,i2,...,in
will be sampled without replacement from (1:n), giving a
random permutation of (1:n), so the result x[i1],...,x[in]
will be a random permutation of x[1],...,x[n] (though
different random permutations may look identical if there
are equal values in x[1],...,x[n]).

 would I be correct if I translate the statement
 as follows: it means that the order of sequence, which was
 generated from a uniform distribution, would look like a
 random normal distribution.

No. A normal distribution has nothing to do with it!

*Unless* the values x[1],...,x[n] already loooked like values
which had already been sampled from a normal distribution (but
were, say, in increasing order of size). Then sample(x) would
shuffle them into random order so the result could then look
like a real sample according ot eh order in which the data
came in.

Hoping this helps!
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 19-Oct-06   Time: 19:34:13
-- XFMail --

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


Re: [R] Time conversion from Win32 64bit FILETIME?

2006-10-19 Thread Alberto Monteiro
Jim Holtman wrote:

 One way might be to convert the number to POSIXct by scaling it based
 that POSIXct is from 1970 and your number is from 1601.  So if you
 subtract the difference between 1601 and 1970 then you should have a
 compliant number for R:
 
 # read your number
 x - 12345678901234567890  # big number (your 64-bit time)
 x.sec - x / 10^9 # convert to seconds

No, it's not the number of ms, it's the number of 100ns, so
the way to convert is

x.sec - x / 1000 # 10 million - I hope I didn't place an extra 0
# BTW: is there a number format with thousand separators?
x.sec - x / 10e7 # better to write this way :-)

 xBase - unclass(as.POSIXct('1601-1-1'))  # your time base, relative 
 to 1970
 x.sec - x.sec - abs(xBase)  # scale to 1970
 x.time - structure(x.sec, class=c(POSIXt, POSIXct))  # convert 
 to POSIXct
 
I would do it in a simpler way:

  win.xp.filetime - (400 * 365 + 100 - 3) * 10e7 # 2001-01-01
  x - as.Date(1601-01-01) + win.xp.filetime / 10e7
  x

[1] 2001-01-01

This supposes, of course, that Windows is compliant with
the Gregorian Calendar [until a few years ago, Excel did
consider 1900 a leap year, so care must be taken here].

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] Question about random sampling in R

2006-10-19 Thread Francisco J. Zagmutt
To add to the nice explanation by Marc, you can access the source directly 
from the web at https://svn.r-project.org/R/trunk/src/main/random.c

If you prefer to look directly in the source tarball, notice the file is 
called random.c


Francisco

Dr. Francisco J. Zagmutt
College of Veterinary Medicine and Biomedical Sciences
Colorado State University




From: Marc Schwartz [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: tom soyer [EMAIL PROTECTED]
CC: r-help r-help@stat.math.ethz.ch
Subject: Re: [R] Question about random sampling in R
Date: Thu, 19 Oct 2006 13:10:20 -0500

On Thu, 2006-10-19 at 12:07 -0500, tom soyer wrote:
  Hi,
 
  I looked up the help file on sample(), but didn't find the info I was
  looking for.
 
  When sample() is used to resample from a distribution, e.g., bootstrap, 
how
  does it do it? Does it use an uniform distribution, e.g., runif(), or
  something else? And, when the help file says:sample(x) generates a 
random
  permutation of the elements of x (or 1:x), would I be correct if I
  translate the statement as follows: it means that the order of
  sequence, which was generated from a uniform distribution, would look 
like a
  random normal distribution.
 
  Thanks,
 
  Tom

In the simplest case, where you have not specified a set of probability
weights, sample() uses a uniform distribution, such that each element
has an equal probability of being selected.

In the case of sampling WITHOUT replacement (the default), each element
in the vector has an equal probability of being selected. Once selected,
that element is removed from the sampling space and the process is
repeated with the remaining elements until all elements have been
selected.

So:

  sample(10)
  [1]  3  8  5  9  7  1  4  2 10  6

yields a random permutation of 1:10.

In the case of 'replace = TRUE', which is sampling WITH replacement,
after an element is selected it is retained in the sampling space, thus
can be selected multiple times.

So:

  sample(10, replace = TRUE)
  [1] 1 4 1 8 7 8 6 7 5 9


If you specify a set of probability weights from the sampling vector,
then the probability for each element in being selected is affected
accordingly.

In the case of bootstrapping, sampling WITH replacement is used. You
might find the following post helpful in this scenario:

   http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67421.html


If you want to investigate further, you can review the C source code for
the relevant R functions in random.c in the R source tarball. The file
will be in ../src/main.

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-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] A question regarding Wireframe in Package Lattice

2006-10-19 Thread Deepayan Sarkar
On 10/19/06, Saptarshi Guha [EMAIL PROTECTED] wrote:
 Hello,
 The following code produces a quadrilateral:

 q-matrix(c(1,3,1,2,3,1,2,4,2,1,4,2),nrow=4,byrow=T)
 qc-xyz.coords(q)
 wireframe(z~y*x,qc)
 I have 2 questions
 1) How can i remove the bounding box i.e the cube encompassing the
 quadrilateral?

wireframe(z~y*x, qc, par.settings = list(box.3d = list(col = transparent))

Add
scales = list(col = transparent)
or
scales = list(draw = FALSE)
to remove the arrows/ticks as well.

One warning though: I eventually plan to separate box.3d into two
sets, one for the lines in front, one for the `hidden' ones.
Hopefully, by that time there will be better documentation for
settings.

 2) Is there any function to get the 2D coordinates of the
 quadrilateral actually used in the final plot   ? I could manually
 calculate the 2D co-ordinates of the projection of the quad if I knew
 the sequnce of 3D transformations 'wireframe' performed upto the
 final step before plotting.

There are two things you need to know:

(1) The range of the bounding box in the 3D space is not the range
of the data. Usually, it is [-0.5, 0.5]^3, but that can change if
aspect is not c(1, 1). The data are scaled to fit into this box
(actually, xlim, ylim and zlim are scaled to fit into this box). This
is mostly to ensure that the origin is in the middle of the box, which
makes the projection calculations simpler. Inside 'panel.3d.wireframe'
(see ?panel.3dwire), where you should be doing any additional
calculations, these limits are available as the [xyz]lim.scaled
arguments.

(2) Modulo the above, what you want is described in ?utilities.3d.
Extending your example, and making use of the fact that you are using
the defaults for most arguments, we can do:

sq - scale(q, center = apply(q, 2, function(x) mean(range(x))),
scale = apply(q, 2, function(x) diff(range(x
rot.mat - ltransform3dMatrix(screen = list(z = 40, x = -60))
ans - ltransform3dto3d(t(sq), rot.mat, dist = 0.2)
rot.mat
ans

wireframe(z~x*y, qc, par.settings = list(box.3d = list(col = transparent)),
  scales = list(draw = FALSE),
  xlab = , ylab = , zlab = )
trellis.focus(panel, 1, 1)
panel.points(ans[1, ], ans[2, ])

Note that in the wireframe call I've changed z~y*x to the more natural
z~x*y. Otherwise some reordering of the columns of sq would be
involved.

-Deepayan

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


Re: [R] hit return key before next gaph appears

2006-10-19 Thread Jan T. Kim
On Thu, Oct 19, 2006 at 02:28:01PM -0400, Chuck Cleland wrote:
 Leeds, Mark (IED) wrote:
  i am looping and creating plots which are coming to the screen. i am in
  linux and remember ( in a previopus life ) i used to use a command so
  that the next graph n + 1 didn't appear on the screen until
  i hit the return key after graph n appeared. i thought i remeber using
  the command unix but when i type unix at the r prompt, it gices me
  system. it's probably a deprecated
  command then but i still don't remember what i did to make the next
  graph not appear until i hit the return key. or maybe it was any key for
  that matter. thanks a lot.
 
 par(ask=TRUE)
 plot(rnorm(10))

As a somewhat more advanced variant, it's also possible to manually
engineer the waiting for the return key. I sometimes do this in loops,
as in

hitReturn - function(msg)
{
  invisible(readline(sprintf(%s -- hit return, msg)));
}

plotAllColumns - function(dframe, waitFunc = hitReturn)
{
  for (n in colnames(dframe))
  {
plot(dframe[[n]]);
waitFunc(n);
  }
}

# demo:
dframe - data.frame(x = runif(10), y = rnorm(10), z = rexp(10));
plotAllColumns(dframe);

I find this useful to keep track of what the current plot actually is
displaying. Furthermore, it's possible to run a simplistic kind of
animation, as in

plotAllColumns(dframe, function(msg) { print(msg); Sys.sleep(3); });

Best regards, Jan
-- 
 +- Jan T. Kim ---+
 | email: [EMAIL PROTECTED]   |
 | WWW:   http://www.cmp.uea.ac.uk/people/jtk |
 *-=  hierarchical systems are for files, not for humans  =-*

__
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-pkgs] New package CreditMetrics

2006-10-19 Thread Andreas Wittmann
Dear R useRs,

A new package 'CreditMetrics' is now available on CRAN. It is mainly a 
set of
functions for computing the CreditMetrics risk model.

This is the first version of the package and it is also my first try to
build a package for R.

The canonical reference is:
Glasserman, Paul, Monte Carlo Methods in Financial Engineering, Springer 
2004


Suggestions, bug reports and other comments are very welcome.


enjoy and best regards
Andreas

___
R-packages mailing list
R-packages@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] incorrect result for Matrix() %*% Diagonal()

2006-10-19 Thread Gerald Jansen
I'm exploring pedigree() in lme4 and found some strange results trying
to multiply a dtCMatrix by a diag() matrix using %*%. Studying the 
Matrix documentation, I stumbled upon the following error in the 
example on the ddiMatrix-class {Matrix} help page. I wonder if my
problem could be related to this.

 matrix(cbind(1, 2:4),3,2) %*% diag(c(10,1)) # OK
 [,1] [,2]
[1,]   102
[2,]   103
[3,]   104

 Matrix(cbind(1, 2:4)) %*% Diagonal(x=c(10,1)) # KO
3 x 2 Matrix of class dgeMatrix
 [,1] [,2]
[1,]   102
[2,]1   30
[3,]   104

===
 sessionInfo()
R version 2.4.0 (2006-10-03) 
x86_64-pc-linux-gnu 

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

other attached packages:
  lme4 Matrixlattice 
0.9975-4 0.9975-3   0.14-9 
==

Thanks in advance
Gerald Jansen

__
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 remove the empty element in the vector

2006-10-19 Thread Yanqin Yang
Hello,
   
  Would anyone kindly tell me how to remove the empty element in the vector 
object?
  For example, 
   x
[1] a c c c d
 unique(x)
[1] a   c d
How could I get the output like: a,c,d? 
   
  Thanks,
   
  Yanqin
   


-
Get your email and more, right on the  new Yahoo.com 
[[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] ROracle error in Windows. Memory could not be read.

2006-10-19 Thread Adrian Dragulescu

I've seen from earlier posts that other people had problems installing
ROracle under Windows.  I run R-2.3.1.

I got the Windows binaries for ROracle from
http://stat.bell-labs.com/RS-DBI/download/index.html

Here is my session:
 require(ROracle)
Loading required package: ROracle
Loading required package: DBI
[1] TRUE
 drv - dbDriver(Oracle)
 drv
OraDriver:(1648)
 con - dbConnect(drv, user=USER, password=PASS, dbname=TEST)

A window pops up, with the message:  The instruction at 0x6260c621
referenced memory at 0x4a280ae2.  The memory could not be read.  And R
freezes.

Something is working, because I get to establish an Oracle driver.

Any ideas would be much appreciated.

Thank you,
Adrian

__
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] bi-directional sockets

2006-10-19 Thread Grateful Frog
Thanks for your answer, but I wasn't able to find anything that looked like
an example of sockets in either of those packages. I guess I must be even
dumber than I previously thought!

Any help would still be welcome.

On 10/19/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 Check out these packages:
 - Ryacas (on omegahat) -- sockets between R and yacas
 - mimR (on CRAN) -- sockets between R and mim (Windows only)


 On 10/19/06, Grateful Frog [EMAIL PROTECTED] wrote:
  Hello R-helpers!
 
  I am new to R, but having a rough time with the socketConnection
 function. I
  cannot seem to get bi-directional communication to work. I have tried
 loads
  of possible ways, based on the manual's examples, but the result is
 always
  one or the other process hanging.
 
  Could anyone give me a working example of R code that:
  - creates a socket,
  - listens for data ,
  - reads the data,
  - writes a reply.
 
  Without hanging or causing the sending process to hang.
 
  I would greatly appreciate any help.
 
  thanks,
  gf: http://gratefulfrog.net
 
 [[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.
 


[[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] how to remove the empty element in the vector

2006-10-19 Thread Marc Schwartz
On Thu, 2006-10-19 at 12:23 -0700, Yanqin Yang wrote:
 Hello,

   Would anyone kindly tell me how to remove the empty element in the vector 
 object?
   For example, 
x
 [1] a c c c d
  unique(x)
 [1] a   c d
 How could I get the output like: a,c,d? 

   Thanks,

   Yanqin


It depends upon what you mean by removing the empty elements.

If you want to just get the set of values that are not :

 x[x != ]
[1] a c c c d


If you want the output exactly as you have it above, which is
eliminating the repeated values:

 unique(x[x != ])
[1] a c d


See ?Extract, ?Comparison and ?Syntax for more information.

HTH,

Marc Schwartz

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


Re: [R] how to remove the empty element in the vector

2006-10-19 Thread Roger D. Peng
How about

x[-c(2, 3)]

-roger

Yanqin Yang wrote:
 Hello,

   Would anyone kindly tell me how to remove the empty element in the vector 
 object?
   For example, 
x
 [1] a c c c d
 unique(x)
 [1] a   c d
 How could I get the output like: a,c,d? 

   Thanks,

   Yanqin

 
   
 -
 Get your email and more, right on the  new Yahoo.com 
   [[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.
 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/

__
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] randomize a matrix

2006-10-19 Thread Guenther, Cameron
Hello everyone,

If I have an incidence matrix of 0 and 1's 

P=[1 1 1 1 1 1
   1 1 1 1 0 0 
   1 1 1 0 0 0
   1 1 1 0 0 0
   1 1 0 0 0 0]

I want to create a new uniform random matrix [a] that is filled with 0's
and 1's but constrained so that the row and column sums are the same as
in [P].  Does anyone know how to accomplish this?

Thanks in advance  

Cameron Guenther, Ph.D. 
Associate Research Scientist
FWC/FWRI, Marine Fisheries Research
100 8th Avenue S.E.
St. Petersburg, FL 33701
(727)896-8626 Ext. 4305
[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] Question about random sampling in R

2006-10-19 Thread Alberto Monteiro
Tom Soyer wrote:
 
 I looked up the help file on sample(), but didn't find the info I was
 looking for.
 
 When sample() is used to resample from a distribution, e.g., 
 bootstrap, how does it do it? Does it use an uniform distribution, 
 e.g., runif(), or something else? And, when the help file 
 says:sample(x) generates a random permutation of the elements of x 
 (or 1:x), would I be correct if I translate the statement as 
 follows: it means that the order of sequence, which was generated 
 from a uniform distribution, would look like a random normal distribution.

I think it's clear that sample (without repetition) simulates
what you would get if you wrote every element in a card, shuffled
the card, and extracted a sample.

In other words, take some number n, another m = n, 
let x - 1:n and then simulate y - sample(x, m). If you
do it many times, y[1] (or y[2], or y[m]) will have the
discrete distribution given by Probability(y[1] = 1) = 1/n,
Prob(y[1] = 2) = 1/n, ..., Prob(y[1] = n) = 1/n. The same,
of course, is valid for y[2], etc.

Ok, too much talking, let's run an example:

  x - 1:10
  y3.hist - NULL
  for (i in 1:1) {
y - sample(x, 5)
y3.hist[i] - y[3]
  }
  hist(y3.hist)

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] Newbie: Selecting data

2006-10-19 Thread Zembower, Kevin
I've been working with R for all of about 8 hours, so anyone with more
experience than this should be able to help me. General comments about
my methods of work are also welcomed.

I have a table that I've imported thusly:
 w - read.table(woodford.data, header=T)
 w
   start thermsgas KWHs  elect temp days
1  10-Jun-98  9  16.84  613  63.80   75   40
2  20-Jul-98  6  15.29  721  74.21   76   29
3  18-Aug-98  7  15.73  597  62.22   76   29
4  16-Sep-98 42  35.81  460  43.98   70   33
5  19-Oct-98105  77.28  314  31.45   57   29
6  17-Nov-98106  77.01  342  33.86   48   30
snip

[This is real data on my house.] 'days' is number of days in bill,
'temp' is average temperature in Fahrenheit. I'd like to see if there is
a relationship between the gas burned (therms) and the number of heating
degree days.

I compute therms per day and heating degree days like this:
 thermsperday - w[,2]/w[,7]
 hdd - (w[,6] -65)*w[,7]

However, I only want the data for the months in which the average
temperature is less than 65 (otherwise, it's a cooling degree day). I
tried ifelse, but couldn't get it to work. What simple technique am I
overlooking?

Thanks so much for your help and suggestions, especially for your
patience with a newbie.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139

__
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

2006-10-19 Thread Weiwei Shi
hi,

how could I let the colname be the numbers instead of X plus numbers
when I use read.table. Or there is an alternative way?

thanks

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

Did you always know?
No, I did not. But I believed...
---Matrix III

__
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] unique sets of factors

2006-10-19 Thread Tony Long
All:

I have a matrix, X, with a LARGE number of rows.  Consider the 
following three rows of that matrix:

1 1 1 1 2 2 3 3
1 1 1 1 3 3 2 2
3 3 2 2 1 1 1 1

I wish to fit many one-way ANOVAs to some response variable using 
each row as a set of factors.  For example, for each row above I will 
do something like anova(lm(Y~as.factor(X[1,]))).  My problem is that 
in the above example, I do not want to fit models for both rows 1 and 
2 as they are essentially duplicates in terms of the ANOVA model. 
Clearly row 3, although it has the same number of 1's, 2's, and 3's, 
is a different model.

Is there some computationally efficient way to remove such factor 
duplicates from my large matrix?  I have been banging my head 
against the wall all morning.

Thanks!!

Tony
-- 
###

Tony Long

Ecology and Evolutionary Biology
Steinhaus Hall
University of California at Irvine
Irvine, CA
92697-2525

Tel:  (949) 824-2562   (office)
Tel:  (949) 824-5994   (lab)
Fax: (949) 824-2181

email:  [EMAIL PROTECTED]
http://hjmuller.bio.uci.edu/~labhome/

__
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

2006-10-19 Thread Marc Schwartz
On Thu, 2006-10-19 at 16:10 -0400, Weiwei Shi wrote:
 hi,
 
 how could I let the colname be the numbers instead of X plus numbers
 when I use read.table. Or there is an alternative way?
 
 thanks

Sounds like you have imported the data, perhaps using 'header = TRUE'
either without an actual header row of column names or perhaps an
incomplete or improper (not syntactically valid) header row. 

If you are getting X's (and not V's) pre-pended to the column names,
that sounds like the result of make.names() on your data. 

See ?make.names

If you don't have a header row in the imported data set, you can use the
'colnames' argument in read.table() to explicitly provide them. Just be
sure to set 'header = FALSE'.

If there is a header row, but it is problematic, set 'header = FALSE'
AND 'skip = 1', which will skip over the first row in the incoming file.

See ?read.table

HTH,

Marc Schwartz

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


Re: [R] read.table

2006-10-19 Thread Weiwei Shi
thanks. i know how to go around it but i feel read.table should have
something like that to disable the process of adding X to the header
:)

On 10/19/06, Marc Schwartz [EMAIL PROTECTED] wrote:
 On Thu, 2006-10-19 at 16:10 -0400, Weiwei Shi wrote:
  hi,
 
  how could I let the colname be the numbers instead of X plus numbers
  when I use read.table. Or there is an alternative way?
 
  thanks

 Sounds like you have imported the data, perhaps using 'header = TRUE'
 either without an actual header row of column names or perhaps an
 incomplete or improper (not syntactically valid) header row.

 If you are getting X's (and not V's) pre-pended to the column names,
 that sounds like the result of make.names() on your data.

 See ?make.names

 If you don't have a header row in the imported data set, you can use the
 'colnames' argument in read.table() to explicitly provide them. Just be
 sure to set 'header = FALSE'.

 If there is a header row, but it is problematic, set 'header = FALSE'
 AND 'skip = 1', which will skip over the first row in the incoming file.

 See ?read.table

 HTH,

 Marc Schwartz





-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

Did you always know?
No, I did not. But I believed...
---Matrix III

__
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

2006-10-19 Thread Marc Schwartz
On Thu, 2006-10-19 at 17:06 -0400, Weiwei Shi wrote:
 thanks. i know how to go around it but i feel read.table should have
 something like that to disable the process of adding X to the header
 :)

You could try setting 'check.names = FALSE' to see what you end up with
in terms of column names. That will effectively disable the use of
make.names() to validate/adjust the incoming column names.

The risk here is unknown depending upon the root etiology of the
problem.

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] [Q] How to fit data to a straight line

2006-10-19 Thread Young-Jin Lee
Dear R users

I have a question about how to fit data to a straight line.
I tried nls to do it, but it didn't work.

The reason I want to fit data to a straight line is that I need to compare
AIC or BIC values of the two models (a straight line model vs a nonlinear
curve model). Fitting data to a nonlinear curve is straightforward, but I
could not figure out how to fit the data to a straight line and therefore, I
could not get the AIC/BIC values of this simple model. If I can get the
AIC/BIC value of the straight line fit without actually doing a fit, that is
also fine.

Thanks in advance.

Young-Jin

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


  1   2   >