Re: [R] input line length in Sweave

2005-05-25 Thread Friedrich . Leisch
 On Tue, 24 May 2005 16:23:31 -0400 (GMT-04:00),
 Woodrow Setzer (WS) wrote:

   I am having trouble in Sweave with input line lengths.  For example, I may 
have in my input file the chunk

[...]

   Is there a way to get Sweave to wrap long input lines better, or
   get it to use my own formatting of the input?  I realize I can
   edit the output tex file, but that is impractical in my
   application (too many).

   I am using R version 2.0.1 Patched (2005-01-26) on a Linux system
   (so, I suppose one possible answer is that this is fixed in 2.1.0;
   I cannot switch right now).

No, no changes in 2.1 with respect to that problem. I have plans for a
solution for this problem, but won't have time for it before summer
break - in 2.2 there should be a fix for it.

Best,
Fritz

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


Re: [R] rotate pie chart

2005-05-25 Thread Katrin Schweitzer


 I think you have to get your hands dirty on this one, but it's not too
 hard.  Here's a function pie90() which is a tiny modification of pie().
   Does that do the trick?


Yes, it works perfectly fine, at least for what I wanted... :)
Thanks a lot, to Lars for asking, and to Paul for getting your hands dirty!

Kati

PS: I know one shouldn't use pie charts at all... :) but if I do so, is 
there a  reason

why they work counter-clockwise in R? Is that convention?
Sorry if its a silly question, my intuition (which might very likely be 
horrible)

just expected them to start at 12 o'clock and fill the pie clockwisely.









 pie90 - function (x, labels = names(x), edges = 200, radius = 0.8,
 density = NULL,
  angle = 45, col = NULL, border = NULL, lty = NULL, main = NULL,
  ...)
 {
  if (!is.numeric(x) || any(is.na(x) | x = 0))
  stop('x' values must be positive.)
  if (is.null(labels))
  labels - as.character(1:length(x))
  x - c(0, cumsum(x)/sum(x))
  dx - diff(x)
  plot.new()
  pin - par(pin)
  xlim - ylim - c(-1, 1)
  if (pin[1]  pin[2])
  xlim - (pin[1]/pin[2]) * xlim
  else ylim - (pin[2]/pin[1]) * ylim
  plot.window(xlim, ylim, , asp = 1)
  nx - length(dx)
  if (is.null(col))
  col - if (is.null(density))
  c(white, lightblue, mistyrose, lightcyan,
  lavender, cornsilk)
  else par(fg)
  col - rep(col, length.out = nx)
  border - rep(border, length.out = nx)
  lty - rep(lty, length.out = nx)
  angle - rep(angle, length.out = nx)
  density - rep(density, length.out = nx)
  for (i in 1:nx) {
  n - max(2, floor(edges * dx[i]))
 # modified line below
  t2p - 2 * pi * seq(x[i], x[i + 1], length = n) + pi/2
  xc - c(cos(t2p), 0) * radius
  yc - c(sin(t2p), 0) * radius
  polygon(xc, yc, density = density[i], angle = angle[i],
  border = border[i], col = col[i], lty = lty[i])
 # modified line below
  t2p - 2 * pi * mean(x[i + 0:1]) + pi/2
  xc - cos(t2p) * radius
  yc - sin(t2p) * radius
  if (!is.na(lab - labels[i])  lab != ) {
  lines(c(1, 1.05) * xc, c(1, 1.05) * yc)
  text(1.1 * xc, 1.1 * yc, lab, xpd = TRUE, adj = ifelse(xc 
  0, 1, 0), ...)
  }
  }
  title(main = main, ...)
  invisible(NULL)
 }


 Paul


 Sean Davis wrote:
  You might want to look at grid graphics and gridBase.  I don't know in
  detail how to go about what you are asking, but grid allows you to
  rotate plots arbitrarily.  Here are a couple of links that I think are
  useful.
 
  http://www.stat.auckland.ac.nz/~paul/grid/grid.html
  http://www.stat.auckland.ac.nz/~paul/grid/doc/rotated.pdf
 
  Sean
 
  On May 24, 2005, at 10:09 AM, Lars wrote:
 
  hey,
 
  about two weeks ago i posted a question concerning the display of two
  piecharts on one plot. after now being able to do so, i need to rotate
  them. the first piece of my pie is suppose to start at 0° but at 90°.
  i tried several things, all failing in the end. anyone out there who
  has an idea?
 
  Lars
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html


 --
 Dr Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 [EMAIL PROTECTED]
 http://www.stat.auckland.ac.nz/~paul/

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



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


[R] Errors in Variables

2005-05-25 Thread Jacob van Wyk
I hope somebody can help.
A student of mine is doing a study on Measurement Error models
(errors-in-variables, total least squares, etc.). I have an old
reference to a multi archive  that contains
leiv3: Programs for best line fitting with errors in both coordinates.
(The date is October 1989, by B.D. Ripley et al.)
I have done a search for something similar in R withour success. Has
this been implemented in a R-package, possibly under some sort of
assumptions about variances. I would lke my student to apply some
regression techniques to data that fit this profile.
Any help is much appreciated.
(If I have not done my search more carefully - my apologies.)
Thanks
Jacob


Jacob L van Wyk
Department of Mathematics and Statistics
University of Johannesburg APK
P O Box 524
Auckland Park 2006
South Africa
Tel: +27-11-489-3080
Fax: +27-11-489-2832

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


Re: [R] How to break an axis?

2005-05-25 Thread Bjørn-Helge Mevik
What about simply using a log scale on the y axis? I.e. plot(..., log=y)

-- 
Bjørn-Helge Mevik

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


Re: [R] R unable to run on Mac OS 10.4 Tiger

2005-05-25 Thread Guillaume Chapron

Dear all,

Thanks for the reply, I solved the issue last night. It appears it is 
was a problem with quicktime library. When I installed Tiger, I dragged 
my Panther quicktime plugin and this was not a good idea. R did not work 
(whatever version) in GUI, but would work in the terminal. I restarted 
the machine and the R would work as GUI, with this error message (at 
least this one, and many times):


2005-05-24 18:42:25.919 R[316] CFLog (21): Error loading 
/Library/QuickTime/DivX 5.component/Contents/MacOS/DivX 5:  error code 
4, error number 0 (Library not loaded: /Library/Application 
Support/DivXNetworks/liblame3.92.dylib
  Referenced from: /Library/QuickTime/DivX 
5.component/Contents/MacOS/DivX 5

  Reason: image not found)

I installed DivX stuff and I now get only this message:

2005-05-25 09:16:31.332 R[4042] CFLog (21): Error loading 
/Library/QuickTime/LiveType.component/Contents/MacOS/LiveType:  error 
code 4, error number 0 (Library not loaded: 
/System/Library/PrivateFrameworks/LiveType.framework/Versions/A/LiveType
  Referenced from: 
/Library/QuickTime/LiveType.component/Contents/MacOS/LiveType

  Reason: image not found)

I suppose i will have to reinstall quicktime 7 and things will be OK. 
But I don't understand why R does need quicktime ??


Thanks
Guillaume


Hi Guillaume,

There is a R-SIG-Mac alias where many of these questions are being  
addressed.


The most likely reason is that you have a .RData file around that its  
trying to load.

It might be missing a library or trying to connect to X11.

Can you check for that 1st in a terminal window (ls -lia). Finder  does 
not show .xxx files.

If you reply to me, we can take it from there or switch to R-Sig-Mac.

Rob


On May 24, 2005, at 9:05 AM, Guillaume Chapron wrote:


Hello,
I'm running a PB G4 with Mac OS 10.4.1. I have downloaded the  latest 
version R-2.1.0a.dmg. It appears that R does not work. It  launches 
itself, but the window never gets ready, there is written  Loading 
R... and a small progress wheel keeps turning indefinitely.

Could someone help or suggest something?
THANKS !!
Guillaume

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







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


[R] Deleting multiple rows from a matrix

2005-05-25 Thread Gottfried Gruber
Hi,

i want to delete multiple rows from a matrix. I know how to delete one by
x=x[,-3]  # deleting 3. column

Is there a quick method how to delete e.g. the 3., 5., 7. and 8. column at 
once?

TiA gg

-- 
---
Gottfried Gruber
mailto:[EMAIL PROTECTED]
www: http://gogo.sehrsupa.net

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


Re: [R] Deleting multiple rows from a matrix

2005-05-25 Thread Sundar Dorai-Raj

Gottfried Gruber wrote:

Hi,

i want to delete multiple rows from a matrix. I know how to delete one by
x=x[,-3]  # deleting 3. column

Is there a quick method how to delete e.g. the 3., 5., 7. and 8. column at 
once?


TiA gg



x[, -c(3, 5, 7, 8)]

--sundar

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


[R] DOING CLUSTERING WITH THE EM ALGORITHM

2005-05-25 Thread Dominique Emmanuel
Hello,

I am looking for documentation (PDF ?) about doing clustering with the EM 
Algorithm on R... I'm sorry for this question which may be trivial...

Thanks...

Dominique

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


RE: [R] Placing A Legend in Titlle of a Plot

2005-05-25 Thread Mulholland, Tom
Without a small example to see what you are doing it is hard to respond. There 
are plenty of examples in the help for legend showing placement all over the 
place. So I am guessing that this might help (The only thing added from the 
help was the par(xpd = TRUE)


 x - 0:64/64
 y - sin(3*pi*x)
 plot(x, y, type=l, col=blue, main = )
 points(x, y, pch=21, bg=white)
 par(xpd = TRUE)
 legend(.4,1.25, sin(c x), pch=21, pt.bg=white, lty=1, col = blue)
 par(xpd = FALSE)

Tom

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Josue Samayoa
 Sent: Wednesday, 25 May 2005 3:20 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Placing A Legend in Titlle of a Plot
 
 
 Hello,
 I am trying to place a legend in the title area of a plot.  I can not 
 seem to find a way to get legend() to do this.  Nor can I use the 
 title() function.  Does anyone know a way to do this?  I 
 would greatly 
 appreciate any advice.
 
 Thanks
 
 
 Josue Samayoa
 Center for Biomolecular Science  Engineering
 School of Engineering
 Division of Physical  Biological Sciences
 University of California Santa Cruz
 (831) 459-1019
   [[alternative text/enriched version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


Re: [R] Placing A Legend in Titlle of a Plot

2005-05-25 Thread Romain Francois

Le 25.05.2005 09:19, Josue Samayoa a écrit :


Hello,
I am trying to place a legend in the title area of a plot.  I can not 
seem to find a way to get legend() to do this.  Nor can I use the 
title() function.  Does anyone know a way to do this?  I would greatly 
appreciate any advice.


Thanks


Josue Samayoa
Center for Biomolecular Science  Engineering
School of Engineering
Division of Physical  Biological Sciences
University of California Santa Cruz
(831) 459-1019
 


Hello,

What kind of plot ? Not easy to know what you tried if you don't tell it.
read the posting guide and then give a short reproductible example of 
what you tried that didn't work.


Romain

--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
 ~ 
~~  Romain FRANCOIS - http://addictedtor.free.fr ~~
Etudiant  ISUP - CS3 - Industrie et Services   
~~http://www.isup.cicrp.jussieu.fr/  ~~
   Stagiaire INRIA Futurs - Equipe SELECT  
~~   http://www.inria.fr/recherche/equipes/select.fr.html~~
 ~ 

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


Re: [R] Deleting multiple rows from a matrix

2005-05-25 Thread Romain Francois

Le 25.05.2005 09:55, Gottfried Gruber a crit :


Hi,

i want to delete multiple rows from a matrix. I know how to delete one by
x=x[,-3]  # deleting 3. column

Is there a quick method how to delete e.g. the 3., 5., 7. and 8. column at 
once?


TiA gg

 


Same way. Only just provide a vector, as in :
x = x[,-c(3,5,7)]

Romain

--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
 ~ 
~~  Romain FRANCOIS - http://addictedtor.free.fr ~~
Etudiant  ISUP - CS3 - Industrie et Services   
~~http://www.isup.cicrp.jussieu.fr/  ~~
   Stagiaire INRIA Futurs - Equipe SELECT  
~~   http://www.inria.fr/recherche/equipes/select.fr.html~~
 ~ 

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


Re: [R] reading multiple files

2005-05-25 Thread Uwe Ligges

Dave Evens wrote:


Dear All,


How do I read in multiple data frames or matrices in a
loop, e.g.

for (i in 1:n) {
   channel - odbcConnectExcel(filenames)
   file[i] - as.data.frame(sqlFetch(channel,
sheet))
}

I would like file[i] to be the name of the data.frame
(i.e. file[1], file[2], file[3],...etc) rather than a
vector.


The terminology you are using re. R objects seems to be rather confused.

Quite probably you want a list of data frames such as using the 
filenames as names for the list elements along the follwoing lines:


library(RODBC)
dataframes - vector(mode=list, length=length(filenames))
names(dataframes) - filenames
for(i in filenames){
  channel - odbcConnectExcel(i)
  dataframes[[i]] - sqlFetch(channel, sheet)
  close(channel)
}


Uwe Ligges




Thanks in advance for any help.

Dave

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


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


Re: [R] plot in a two dimension surface with more than 2 variables

2005-05-25 Thread Uwe Ligges

Amir Safari wrote:

 
 
Dear All ,

How it is possible to trace a plot in a two dimension surface with more than 2 
variables?


Do you want a surface or a point cloud? Do you want to use some sort of 
projection? What is more than 2?

Please specify your question more precisely.

Uwe Ligges



ps: library( rgl) is 3D
 
So many THANKS




-

[[alternative HTML version deleted]]

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


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


Re: [R] DOING CLUSTERING WITH THE EM ALGORITHM

2005-05-25 Thread Christophe Pouzat

Hi,

Check out the docs of the mclust and FlexMix packages:

http://www.stat.washington.edu/mclust/
http://www.ci.tuwien.ac.at/~leisch/FlexMix/

Xtof.


Dominique Emmanuel wrote:


Hello,

I am looking for documentation (PDF ?) about doing clustering with the EM 
Algorithm on R... I'm sorry for this question which may be trivial...

Thanks...

Dominique

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

 




--
A Master Carpenter has many tools and is expert with most of them.If you
only know how to use a hammer, every problem starts to look like a nail.
Stay away from that trap.
Richard B Johnson.
--

Christophe Pouzat
Laboratoire de Physiologie Cerebrale
CNRS UMR 8118
UFR biomedicale de l'Universite Paris V
45, rue des Saints Peres
75006 PARIS
France

tel: +33 (0)1 42 86 38 28
fax: +33 (0)1 42 86 38 30
web: www.biomedicale.univ-paris5.fr/physcerv/C_Pouzat.html

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


Re: [R] DOING CLUSTERING WITH THE EM ALGORITHM

2005-05-25 Thread Sundar Dorai-Raj



Dominique Emmanuel wrote:

Hello,

I am looking for documentation (PDF ?) about doing clustering with the EM 
Algorithm on R... I'm sorry for this question which may be trivial...

Thanks...

Dominique



Your question is a bit vague, but the mclust package might be what 
you're looking for. From ?Mclust:


 Clustering via EM initialized by hierarchical clustering for
 parameterized Gaussian mixture models. The number of clusters and
 the clustering model is chosen to maximize the BIC.

HTH,

--sundar

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


Re: [R] Calling R from R and specifying wait until script is finished

2005-05-25 Thread Uwe Ligges

Don MacQueen wrote:

I don't know about efficient, but here is a way that I find to be 
practical, with around 100 R scripts.


I don't see a reason why your functions are writing character strings 
using cat() into files, and after that processing those files using 
system calls and tools (e.g. grep) which are not available on all 
platforms.


From my point of view the R way is to save the state into R objects 
(e.g. a vector of status codes with one element for each R script).

Then you can easily use R functions to claculate on those objects.

Uwe Ligges




I create a master R script (I call it Runall.r). It begins like this:

## Execute me with  R --save  Runall.r  Runall.log

hc - TRUE
if (hc) sink('Runall.out')

t0runall - Sys.time()
cat('\n')
cat('Running script Runall.r at',format(t0runall),'\n')
cat('\n')

msg - try(source('ae-175.r')) ; rm.trymsg(msg)
msg - try(source('ae-235.r')) ; rm.trymsg(msg)
msg - try(source('ae-251.r')) ; rm.trymsg(msg)
msg - try(source('ae-331.r')) ; rm.trymsg(msg)
msg - try(source('ae-332.r')) ; rm.trymsg(msg)
msg - try(source('ae-491.r')) ; rm.trymsg(msg)
msg - try(source('ae-695.r')) ; rm.trymsg(msg)
msg - try(source('ae-801.r')) ; rm.trymsg(msg)

## and so on, for as many scripts as I want to run
## although I constructed the list of scripts to run by hand, it could 
easily be done

## as a loop, with the script names constructed from the loop index

## the script ends with:

cat('\n')
t1 - Sys.time()
cat('[Runall.r] Elapsed 
time',format(t1-t0runall),attributes(t1-t0runall)$units,'\n')


if (hc) {
  cat('Done\n')
  sink()

  system('grep failed Runall.out  Runall.info')
  cat('\n')
  system('grep succeeded Runall.out  Runall.info')
  cat('\n')

  cat('See files Runall.out and Runall.info\n')
  cat('Done\n')
}


 The function rm.trymsg() is this:

 rm.trymsg - function(msg) {
  if (class(msg)=='try-error') {
cat('',tblid,'failed =\n')
return(FALSE)
  }
  if (data.class(msg)=='list' unlist(msg)[[1]]=='bad.table') {
cat('',tblid,'failed = bad.table ==\n')
return(FALSE)
  }
  cat('=',tblid,'succeeded =\n')
  TRUE
}

## and the purpose of using try() and rm.trymsg() is to let the job 
continue if an error occurs in one of
## the scripts. Note, however, that the text strings bad.table and 
tblid are unique to the task I am doing, and would not

## work in general.

At 8:51 PM -0400 5/21/05, Lapointe, Pierre wrote:


Hello,

Let's say I have 50 R scripts to run.  What would be the most 
efficient way

to run them?

I thought I could do multiple Rterms in a DOS batch file:

Ex:
Rterm 1.R 1.txt
Rterm 2.R 2.txt
...
Rterm 50.R 50.txt

However, I'm afraid they will all open at the same time.   I know I could
pause the batch file with something like:

PING 1.1.1.1 -n 1 -w 6 NUL  (to delay 60 seconds)

But that would require that I know how long each of my scripts take.

Is there an easier way?  Something like calling R from R and 
specifying that

the script has to be finished before continuing.

Thanks

Pierre Lapointe



*** 

AVIS DE NON-RESPONSABILITE:\ Ce document transmis par 
courri...{{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






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


Re: [R] DOING CLUSTERING WITH THE EM ALGORITHM

2005-05-25 Thread Romain Francois

Le 25.05.2005 09:53, Dominique Emmanuel a écrit :


Hello,

I am looking for documentation (PDF ?) about doing clustering with the EM 
Algorithm on R... I'm sorry for this question which may be trivial...

Thanks...

Dominique
 


Hello,

You don't need to shout the subject !
You are looking for the mclust package which is available on CRAN.
Moreover, trying to search 'EM' on the RSiteSeach ( 
http://finzi.psych.upenn.edu/search.html )

leads to it (first hit)
You can even type :
 RSiteSearch('EM')

Romain

--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
 ~ 
~~  Romain FRANCOIS - http://addictedtor.free.fr ~~
Etudiant  ISUP - CS3 - Industrie et Services   
~~http://www.isup.cicrp.jussieu.fr/  ~~
   Stagiaire INRIA Futurs - Equipe SELECT  
~~   http://www.inria.fr/recherche/equipes/select.fr.html~~
 ~ 

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


Re: [R] website reference for building R packages

2005-05-25 Thread Uwe Ligges

Suresh Krishna wrote:



it is the first link if you type making packages into the google 
search box here:


http://maths.newcastle.edu.au/~rking/R/



Yes, please look into the archives as the posting guide asks you to do!



-s.


Laura Holt wrote:


Hi R People:

A few weeks ago, someone put a link to a website for how to for 
building R packages.  It was very nice.



Writing R Extensions is an *complete* and *up to date* documentation for 
this task. Package management is being steadily improved.

Really, I recommend to use Writing R Extensions!

If you are working on Windows, you might want to look into the R 
Administration and Installation manual as well which descibes how to 
collect and set up the required tools...


Uwe Ligges


But of course, I have misplaced the link.  Does anyone still have 
that, please?


It was someone from the University of Chicago, I believe.

Thanks in advance.

Sincerely,
Laura Holt
mailto: [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




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


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


[R] question: corCAR1 in lme

2005-05-25 Thread Sean Connolly
Hello all,

I am trying to use lme to examine how a response variable (Chla) changes 
over time in different treatments (2 Temp  2 Light levels).  Within each 
treatment combination, there are two replicate tanks (each with unique 
TankID) with coral fragments in them.  All tanks are subject to the same 
environment until Time=0, when treatments are imposed, and Chla is measured 
for each tank at six times, including Time 0 just as the experiment 
commences. The model is:

Chla.1 - lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | TankID, 
method=ML)

The reasoning here is that each tank’s intercept (Chla at Time 0) is a 
random draw from a common distribution regardless of treatment, but that 
the trend in Chla over time may vary among treatment combinations.  Based 
on the help files, two separate threads from the archives, and the Pinheiro 
and Bates nlme 3.0 manual, I became confused about which of two ways to 
check for a first-order temporal autocorrelation:

Chla.1b - lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | TankID, 
corr = corCAR1(form = ~Time | TankID), method=ML)

Chla.1c - lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | TankID, 
corr = corCAR1(form = ~1 | TankID), method=ML)

Comparing these fits with inspection of plot(ACF(chla.model1),alpha=0.05) 
suggests to me that there are problems with both of my attempts.  For the 
ACF plot, the correlation at lag 1 is about –0.3, and sticks out beyond the 
confidence limits.  By contrast, the two models' correlation parameters are 
not negative (phi = +0.13 and ~0 respectively), and the log-likelihood 
values are identical to the original model, suggesting no evidence of 
autocorrelation.  Our times are not equally spaced (they vary from 5-8 days 
apart), and I gather than ACF assumes they are, but my troubleshooting 
(summarized below) suggests to me that my problem is bigger than this.  I 
think I have not used corCAR1 properly, and am hoping someone can point me 
in the right direction.

Attempted troubleshooting:

1.  To check whether the discrepancy between ACF and the lme fits was due 
entirely to the unequal spacing of measurements, I created a bogus time 
variable (Time2) that was equally spaced (running from 0 to 5 in steps of 
1).  I then re-fit all of the above models with Time2 replacing Time in the 
function calls, and get the same kinds of problems (phi ~ 0 in the model 
fits, while ACF plot suggests a negative correlation at lag 1).

2.  Still using the bogus equally-spaced time variable, I replaced corCAR1 
with corAR1.  Now, the two different specifications of “form” yield 
identical parameter estimates and MLLs; the estimates of phi agree with 
those from the ACF plot; and the models actually do fit better than the 
equivalent model without autocorrelation.

Any advice would be greatly appreciated.

Sincerely,
Sean Connolly 
[[alternative HTML version deleted]]

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


[R] Problem with systemfit 0.7-3 and transformed variables

2005-05-25 Thread Mikko Pakkanen
The 'systemfit' function in systemfit 0.7-3 CRAN package seems to have a
problem with formulas that contain transformed (eg. log) variables. If I
have my data in a data frame, apparently systemfit doesn't pass the
information of where the variables should be taken to the transforming function.

I'm not entirely sure if this is a bug or just a limitation, I was just
surprised when I attempted to estimate a model, which I'd previously
estimated with OLS using 'lm', with 2SLS using 'systemfit' and it didn't
accept those transformations like 'lm' does.

Here's an example: this is, of course, OK:

 data(kmenta)
 demand - q ~ p + d
 instr - ~ d + f
 fit1 - systemfit(2SLS, eqns=list(demand), inst=instr, data=kmenta)

But, now if I'd like to estimate a model with logarithm of p as a regressor,
an error occurs: 

 demand2 - q ~ log(p) + d
 fit2 - systemfit(2SLS, eqns=list(demand2), inst=instr, data=kmenta)
Error in log(p) : Object p not found

However, estimating the same formula with OLS using the regular 'lm' is OK:
 fit2.ols - lm(demand2, kmenta)

Transforming an instrument causes the same error too:

 instr2 - ~ log(d) + f
 fit3 - systemfit(2SLS, eqns=list(demand), inst=instr2, data=kmenta)
Error in log(d) : Object d not found

One could certainly just create those transformed variables to avoid the
problem, but it would be much more convenient, if it wasn't necessary,
especially if several regressors are involved.

 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major2  
minor1.0
year 2005   
month04 
day  18 
language R 

Regards,

-Mikko Pakkanen

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


Re: [R] colors and palettes and things...

2005-05-25 Thread Uwe Ligges

Jeff D. Hamann wrote:


After trying to find if there was a color picker in the FAQs and the help,
I thought I would send a post here. I was overwhelmed with all the
wonderful color choices R has predefined (discovered after typing in
colors()) but can't figure out what they all (by name) look like. Is there
a color picker or some other method to display all those colors next to
the name?

I think I can put together palettes, but another question I have then
regards the building of palettes (a list of variable length I can select
or create myself other than the ones defined by Palette) so I can pass
these colors into functions instead of having to predefine a bunch of
colors myself or use the predefined colors like terrain.colors(n)?

Are there groups of colors in the colors() that I can group together to
make some nice palettes for drawing barplots, etc?

Thanks,
Jeff.





I'd like to point out some packages or code snippets that might be 
useful for you:


 # base package grDevices:
 ?colorRamp
 example(colorRamp)

 # CRAN package colorspace:
 library(help = colorspace)

 # CRAN package RColorBrewer:
 library(RColorBrewer)
 ?brewer.pal
 example(brewer.pal)

 # see also the last two examples by Martin Maechler in
 # CRAN package scatterplot3d:
 library(scatterplot3d)
 ?scatterplot3d
 example(scatterplot3d)

Uwe Ligges

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


Re: [R] Problem with systemfit 0.7-3 and transformed variables

2005-05-25 Thread Arne Henningsen
On Wednesday 25 May 2005 11:43, Mikko Pakkanen wrote:
 The 'systemfit' function in systemfit 0.7-3 CRAN package seems to have a
 problem with formulas that contain transformed (eg. log) variables. If I
 have my data in a data frame, apparently systemfit doesn't pass the
 information of where the variables should be taken to the transforming
 function.

 I'm not entirely sure if this is a bug or just a limitation, I was just
 surprised when I attempted to estimate a model, which I'd previously
 estimated with OLS using 'lm', with 2SLS using 'systemfit' and it didn't
 accept those transformations like 'lm' does.

 Here's an example: this is, of course, OK:
  data(kmenta)
  demand - q ~ p + d
  instr - ~ d + f
  fit1 - systemfit(2SLS, eqns=list(demand), inst=instr, data=kmenta)

 But, now if I'd like to estimate a model with logarithm of p as a
 regressor,

 an error occurs:
  demand2 - q ~ log(p) + d
  fit2 - systemfit(2SLS, eqns=list(demand2), inst=instr, data=kmenta)

 Error in log(p) : Object p not found

 However, estimating the same formula with OLS using the regular 'lm' is OK:
  fit2.ols - lm(demand2, kmenta)

 Transforming an instrument causes the same error too:
  instr2 - ~ log(d) + f
  fit3 - systemfit(2SLS, eqns=list(demand), inst=instr2, data=kmenta)

 Error in log(d) : Object d not found

 One could certainly just create those transformed variables to avoid the
 problem, but it would be much more convenient, if it wasn't necessary,
 especially if several regressors are involved.

We did not notice this shortcoming of systemfit() so far. Unfortunately, I 
don't have the time in the next few days to look into the code and figure out 
how to enable transformed variables. I suggest that you either create 
transformed variables by hand or you modify the systemfit code to enable this 
and send us the patch. I prefer the second :-) (that's the philosophy of 
open-source software like R: useRs become developeRs).

Best wishes,
Arne

  version

  _
 platform i386-pc-mingw32
 arch i386
 os   mingw32
 system   i386, mingw32
 status
 major2
 minor1.0
 year 2005
 month04
 day  18
 language R

 Regards,

 -Mikko Pakkanen

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

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

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


Re: [R] question: corCAR1 in lme

2005-05-25 Thread Dimitris Rizopoulos

Hi Sean,

As you already guessed and as also the help-page ACF.lme() indicates: 
The autocorrelation function is useful for investigating serial 
correlation models for equally spaced data.


Since you don't have equally spaced time points, you should use: 
corCAR1(form = ~ Time | TankID), which would indicate that Time is 
the position variable and *not* the order of the observations (i.e., 
when you use form = ~ 1 | TankID).


Since you assume continuous time and you also fit a random-intercepts 
model, I think that the correct tool to use is the semi-variogram 
(i.e., look at ?Variogram()) and maybe you could also consider other 
correlation structures such as corExp() or corGaus().


I hope it helps.

Best,
Dimitris


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

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



- Original Message - 
From: Sean Connolly [EMAIL PROTECTED]

To: r-help@stat.math.ethz.ch
Sent: Wednesday, May 25, 2005 11:07 AM
Subject: [R] question: corCAR1 in lme


Hello all,

I am trying to use lme to examine how a response variable (Chla) 
changes
over time in different treatments (2 Temp  2 Light levels).  Within 
each

treatment combination, there are two replicate tanks (each with unique
TankID) with coral fragments in them.  All tanks are subject to the 
same
environment until Time=0, when treatments are imposed, and Chla is 
measured

for each tank at six times, including Time 0 just as the experiment
commences. The model is:

Chla.1 - lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | 
TankID,

method=ML)

The reasoning here is that each tanks intercept (Chla at Time 0) is a
random draw from a common distribution regardless of treatment, but 
that
the trend in Chla over time may vary among treatment combinations. 
Based
on the help files, two separate threads from the archives, and the 
Pinheiro
and Bates nlme 3.0 manual, I became confused about which of two ways 
to

check for a first-order temporal autocorrelation:

Chla.1b - lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | 
TankID,

corr = corCAR1(form = ~Time | TankID), method=ML)

Chla.1c - lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | 
TankID,

corr = corCAR1(form = ~1 | TankID), method=ML)

Comparing these fits with inspection of 
plot(ACF(chla.model1),alpha=0.05)
suggests to me that there are problems with both of my attempts.  For 
the
ACF plot, the correlation at lag 1 is about 0.3, and sticks out 
beyond the
confidence limits.  By contrast, the two models' correlation 
parameters are

not negative (phi = +0.13 and ~0 respectively), and the log-likelihood
values are identical to the original model, suggesting no evidence of
autocorrelation.  Our times are not equally spaced (they vary from 5-8 
days

apart), and I gather than ACF assumes they are, but my troubleshooting
(summarized below) suggests to me that my problem is bigger than this. 
I
think I have not used corCAR1 properly, and am hoping someone can 
point me

in the right direction.

Attempted troubleshooting:

1.  To check whether the discrepancy between ACF and the lme fits was 
due
entirely to the unequal spacing of measurements, I created a bogus 
time
variable (Time2) that was equally spaced (running from 0 to 5 in steps 
of
1).  I then re-fit all of the above models with Time2 replacing Time 
in the
function calls, and get the same kinds of problems (phi ~ 0 in the 
model

fits, while ACF plot suggests a negative correlation at lag 1).

2.  Still using the bogus equally-spaced time variable, I replaced 
corCAR1

with corAR1.  Now, the two different specifications of form yield
identical parameter estimates and MLLs; the estimates of phi agree 
with
those from the ACF plot; and the models actually do fit better than 
the

equivalent model without autocorrelation.

Any advice would be greatly appreciated.

Sincerely,
Sean Connolly
[[alternative HTML version deleted]]

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


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


[R] time-ordered object list

2005-05-25 Thread Robert Kinley
It's often useful to view objects in time order.

In Splus I can do this with 

 objects.summary(order = dataset.date)

which delivers this sort of thing ...

data.class storage.modeextent object.size dataset.date 

  reference  data.frame list25 x 41700 2004.09.13 
15:43
  x  data.frame list15 x 41175 2004.09.13 
15:43
  lower numeric   double   100 841 2004.10.05 
11:10
  upper numeric   double   100 841 2004.10.05 
11:10
barnardfunction function12   20013 2005.04.08 
13:09
   sim7function function 53657 2005.04.14 
15:36
.Last.fixed   charactercharacter 1  52 2005.04.14 
15:38
 runsimfunction function 63952 2005.04.14 
15:38
  last.dumplist list 81186 2005.05.12 
11:57


How can one obtain something similar with  R ?   [ R 2.1.0 / windows 
2000 ]

cheers 
Bob Kinley

[[alternative HTML version deleted]]

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


Re: [R] time-ordered object list

2005-05-25 Thread Uwe Ligges

Robert Kinley wrote:


It's often useful to view objects in time order.

In Splus I can do this with 




objects.summary(order = dataset.date)



which delivers this sort of thing ...

data.class storage.modeextent object.size dataset.date 

  reference  data.frame list25 x 41700 2004.09.13 
15:43
  x  data.frame list15 x 41175 2004.09.13 
15:43
  lower numeric   double   100 841 2004.10.05 
11:10
  upper numeric   double   100 841 2004.10.05 
11:10
barnardfunction function12   20013 2005.04.08 
13:09
   sim7function function 53657 2005.04.14 
15:36
.Last.fixed   charactercharacter 1  52 2005.04.14 
15:38
 runsimfunction function 63952 2005.04.14 
15:38
  last.dumplist list 81186 2005.05.12 
11:57



How can one obtain something similar with  R ?   [ R 2.1.0 / windows 
2000 ]


You cannot. Objects in R do not have any timestamp attributes.

Uwe Ligges



cheers 
Bob Kinley


[[alternative HTML version deleted]]

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


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


[R] No ~ in JGR

2005-05-25 Thread CG Pettersson

R2.1.0
JGR 1.2
W2k

Hello all!
I´ve just installed JGR on my both R-equipped computers and am very 
pleased with the look and functionality.


Except in one, very important, way.

I can´t figure out how to get the ~ sign from the keyboard to the 
console. Copying it from old code works fine. Using the traditional GUI 
works as usual.


I have a Swedish keyboard layout, where ~ shares key with ¨ and ^, all 
reguiring a space after the hit to produce the sign on the screen.


The other signs from the key works, but AltGr + ~ followed by space just 
gives a blank. What do I do wrong?


/CG


--
CG Pettersson MSci. PhD.Stud.
Swedish University of Agricultural Sciences (SLU)
Dep. of Ecology and Crop production sciences (EVP).
http://www.slu.se/
[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


[R] plot 3D

2005-05-25 Thread Navarre Sabine
Is it possible to do a graphic in 3D?
 
This is my source: but this one is on 2D and at moment variables put on other 
variables, so it is difiicult to differentiate them visibly.

plot(corresp(data,nf=2),xlim=c(-1,1),ylim=c(-1,1));

Thanks

Sabine



-

ils, photos et vidéos !

[[alternative HTML version deleted]]

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


[R] R-devel 2.1.0 dependencies for RPMS under Fedora Core 3

2005-05-25 Thread White, Charles E WRAIR-Wash DC
The R-devel RPMS has a number of dependencies on Fedora Core development
tools. When the RPMS is installed, the dependencies are resolved by
automatically downloading and installing the latest version of the
development tools. Looking at the README file in the fc3 directory, I
was surprised by this behavior. I would recommend either changing the
description of the file in the README or the behavior of the RPMS.
Selected text from the README follows:

These RPMS are designed to run on Fedora Core 3 (Heidelberg).  


R-devel: This is a stub package that contains only the documentation
file
 on Writing R Extensions (R-exts.pdf).  You should install
this
 if you wish to compile packages from source.

Chuck White

PS: I've only been using Linux for a couple of weeks; I've used R under
Windows for more than three years. I probably won't use the RPMS again
since I would prefer to use shared libraries.

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


Re: [R] obtaining first and last record for rows with same identifier

2005-05-25 Thread Frank E Harrell Jr

Francisco J. Zagmutt wrote:
If you want to obtain a data frame you can use the functions head and 
tail like:


dat=data.frame(id=rep(1:5,3),num=rnorm(15), num2=rnorm(15))#Creates data 
frame with id
last=do.call(rbind,by(dat,dat$id,tail,1))#Selects the last observation 
for each id
first=do.call(rbind,by(dat,dat$id,head,1))#Selects the first 
observation for each id

newdat=rbind(first,last)#Joins data
newdat=newdat[order(newdat$id),]#sorts data by id

Notice that rownames will give you the original row location of the 
observations selected


I hope this helps

Francisco


. . .

You might also look at section 4.3 of
http://biostat.mc.vanderbilt.edu/twiki/pub/Main/RS/sintro.pdf
--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

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


[R] Can simulation involving random number generation be segmented?

2005-05-25 Thread Dr L. Y Hin

Dear all,
Apologies for this pedantic question that only arise when there is hardware
limitation.
Setting: R 2.1.0 for windows xp sp2.
Scenario:
To generate 1000 samples using rnorm for a simulation activity.
Background:
The simulation activity requires so much memory resources that generating
200 samples
clogs up the PF usage as indicated in the Windows Task Manager.
Therefore, short of implementing the simulation on a computer with more
resources,
the alternative is to generate the 1000 samples in 5 separate runs,
each generating 200 samples, closing the R window and re-opening between
runs.
Question to be addressed:
To maintain consistency and ensure reproducibility of the simulation
results, the 1000 samples
generated in one single run should be indentical to the 5x200 samples
generated on 5 separate
runs.
While such consistency can be ensured using set.seed()  in the case of one
single run, in the case
where 5 separate runs are performed, can we do the following to ensure
identical samples being
generated?
1. In the first run, specify the seed by, say, set.seed(1)

2. At the end of the first run, store the .Random.seed by the following
manner:
saved.seed.1-.Random.seed

3. At the beginning of the second run, assign the saved.seed.1 to
.Random.seed as follows:
.Random.seed-saved.seed.1

4. At the end of the first run, store the new .Random.seed by the following
manner:
saved.seed.2-.Random.seed

5. At the beginning of the second run, assign the saved.seed.2 to
.Random.seed as follows:
.Random.seed-saved.seed.2

This is repeated until 5 runs are completed.

Will the paths of random number generation be identical in these two
approaches? If not, is there
a way to ensure this?

Apologies again for this long-winded inquiry.

Thank you.
Best
Lin

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


[R] Linear system

2005-05-25 Thread Jim Gustafsson

Dear R-help

I have a problem solving a linear system like

353a+45b+29c=79
45a+29b+3c=5
29a+3b+4c=8

Is there any way of doing this in R?

Best Regards
Jim


--
This e-mail and any attachment may be confidential and may also be privileged.
If you are not the intended recipient, please notify us immediately and then
delete this e-mail and any attachment without retaining copies or disclosing
the contents thereof to any other person.
Thank you.
--
[[alternative HTML version deleted]]

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


[R] setting elements of matrix

2005-05-25 Thread Richard Valliant
This is, no doubt, an easy problem, but I need help. I want to set
values in a matrix based on entries in a vector. Here is an example:
 
D is an r x m matrix initilized to all zeroes. r=6, m=5 in the
example.
 
Ro - c(1, 3, 4, 4, 6)
Co - c(1, 2, 3, 4, 5)
 
I want to set D[Ro[j], Co[j] ] to 1. So, D becomes
 
1 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 1 1 0
0 0 0 0 0
0 0 0 0 1
 
A loop works but is slow, which matters since this is being done many
times in a simulation.
 
Thanks,
rv

[[alternative HTML version deleted]]

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


Re: [R] setting elements of matrix

2005-05-25 Thread Sundar Dorai-Raj



Richard Valliant wrote:

This is, no doubt, an easy problem, but I need help. I want to set
values in a matrix based on entries in a vector. Here is an example:
 
D is an r x m matrix initilized to all zeroes. r=6, m=5 in the

example.
 
Ro - c(1, 3, 4, 4, 6)

Co - c(1, 2, 3, 4, 5)
 
I want to set D[Ro[j], Co[j] ] to 1. So, D becomes
 
1 0 0 0 0

0 0 0 0 0
0 1 0 0 0
0 0 1 1 0
0 0 0 0 0
0 0 0 0 1
 
A loop works but is slow, which matters since this is being done many

times in a simulation.
 



How about:

D - matrix(0, 6, 5)
D[cbind(Ro, Co)] - 1

--sundar

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


RE: [R] Linear system

2005-05-25 Thread Doran, Harold
Yes, solving systems of linear equations is a strength of R and is very
easy. Doug Bates has a nice article in a prior version of R News showing
optimal methods for doing this in R. Here is an example using your data:

X - matrix(c(353,45,29,45,29,3,29,3,4), ncol=3)
y - c(79,5,8)

solve(crossprod(X))%*%crossprod(X,y)

See Doug's article at the following link:

http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim Gustafsson
Sent: Wednesday, May 25, 2005 8:31 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Linear system


Dear R-help

I have a problem solving a linear system like

353a+45b+29c=79
45a+29b+3c=5
29a+3b+4c=8

Is there any way of doing this in R?

Best Regards
Jim



--
This e-mail and any attachment may be confidential and may also be
privileged.
If you are not the intended recipient, please notify us immediately and
then delete this e-mail and any attachment without retaining copies or
disclosing the contents thereof to any other person.
Thank you.

--
[[alternative HTML version deleted]]

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

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


Re: [R] Linear system

2005-05-25 Thread Uwe Ligges

Jim Gustafsson wrote:


Dear R-help

I have a problem solving a linear system like

353a+45b+29c=79
45a+29b+3c=5
29a+3b+4c=8



Is there any way of doing this in R?



You already said it yourself (solve):


A - rbind(c(353, 45, 29), c(45, 29, 3), c(29, 3, 4))
solve(A, c(79, 5, 8))
# [1]  0.1784625 -0.1924954  0.8505186

Uwe Ligges




Best Regards
Jim


--
This e-mail and any attachment may be confidential and may also be privileged.
If you are not the intended recipient, please notify us immediately and then
delete this e-mail and any attachment without retaining copies or disclosing
the contents thereof to any other person.
Thank you.
--
[[alternative HTML version deleted]]

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


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


Re: [R] Linear system

2005-05-25 Thread Arne Henningsen
On Wednesday 25 May 2005 14:30, Jim Gustafsson wrote:
 Dear R-help

 I have a problem solving a linear system like

 353a+45b+29c=79
 45a+29b+3c=5
 29a+3b+4c=8

 Is there any way of doing this in R?


You can write this equation system in matrix form:
M * x = y

with 
x = ( a, b, c )
M = ( 353, 45, 29,
   45, 29,  3,
   29,  3,  4 )
y = ( 79, 5, 8 )

you can solve the system by 
x = M^(-1) * y

In R you can do this by
R M = matrix( c( 353, 45, 29, 45, 29,  3, 29,  3,  4 ), 
   ncol = 3, byrow = TRUE )
R y - c( 79, 5, 8 )
R x - solve( M ) %*% y 
or
R x - solve( M, y )

Please read a basic book about linear algebra.

Arne


 Best Regards
 Jim


 ---
--- This e-mail and any attachment may be confidential and may also be
 privileged. If you are not the intended recipient, please notify us
 immediately and then delete this e-mail and any attachment without
 retaining copies or disclosing the contents thereof to any other person.
 Thank you.
 ---
--- [[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

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

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


Re: [R] plot 3D

2005-05-25 Thread Uwe Ligges

Navarre Sabine wrote:


Is it possible to do a graphic in 3D?
 
This is my source: but this one is on 2D and at moment variables put on other variables, so it is difiicult to differentiate them visibly.


It is always the question whether 3D helps, but if you think so, you 
might want to take a look at one of the following packages (functions):


lattice (cloud)
rgl (rgl.speheres)
scatterplot3d (scatterplot3d)
djmrgl (plot3d) - Windows only




plot(corresp(data,nf=2),xlim=c(-1,1),ylim=c(-1,1));


Your code does not help us to help.
What is corresp() (I guess you mean the one from package MASS)? What is 
data? Why is there a ;?
Because of my first two questions, this code is NOT reproducible - the 
posting guide asks you to specify reproducible examples.


Uwe Ligges




Thanks

Sabine



-

ils, photos et vidéos !

[[alternative HTML version deleted]]

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


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


RE: [R] time-ordered object list

2005-05-25 Thread Liaw, Andy
As Uwe said, you can't really do that in R.  S-PLUS can do that because it
stores each object as a separate file on disk, thus you can get time stamp
from the file.  In R everything is in the global environment that can be
saved to a single workspace (.RData by default).

There have been some discussions quite a while ago on how time stamping
objects in R can be done.  You may want to search the archive.  The mbvutils
package has tools for organizing objects, but I don't know if it provides
time stamps.

Andy

 From: Robert Kinley
 
 It's often useful to view objects in time order.
 
 In Splus I can do this with 
 
  objects.summary(order = dataset.date)
 
 which delivers this sort of thing ...
 
 data.class storage.modeextent object.size 
 dataset.date 
 
   reference  data.frame list25 x 4
 1700 2004.09.13 
 15:43
   x  data.frame list15 x 4
 1175 2004.09.13 
 15:43
   lower numeric   double   100 
 841 2004.10.05 
 11:10
   upper numeric   double   100 
 841 2004.10.05 
 11:10
 barnardfunction function12   
 20013 2005.04.08 
 13:09
sim7function function 5
 3657 2005.04.14 
 15:36
 .Last.fixed   charactercharacter 1  
 52 2005.04.14 
 15:38
  runsimfunction function 6
 3952 2005.04.14 
 15:38
   last.dumplist list 8
 1186 2005.05.12 
 11:57
 
 
 How can one obtain something similar with  R ?   [ R 
 2.1.0 / windows 
 2000 ]
 
 cheers 
 Bob Kinley
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


RE: [R] Table Help

2005-05-25 Thread McMurtry, Benjamin G.
I'm slightly confused with aggregate, will I need to loop it until it stops
returning sub lists?  Or would I somehow need to convert my username column
into a unique list and then do FUN=sum??

Please excuse me, I was just introduced to R yesterday to calculate
statistics of over 250 gigs of text we have lol.

Thanks for the reply!

Ben  

-Original Message-
From: Sean Davis
To: McMurtry, Benjamin G. 
Cc: 'r-help@stat.math.ethz.ch'
Sent: 5/24/2005 4:56 PM
Subject: Re: [R] Table Help

see ?aggregate

Sean

On May 24, 2005, at 4:39 PM, McMurtry, Benjamin G. wrote:


 Is there  easy way using a feature like bind to sum all of collumn two

 where
 column 1 is the same?

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


[R] precision problem

2005-05-25 Thread Omar Lakkis
I have prices that I am finding difficult to compare with ==,  and ,
due to precision. For example: the numbers should match, with '==',
but they differ in the magnitude of 1e-14 due to bunch of calculations
that I run on them. Programming with java, I am used to implementing a
function that compares the difference between the numbers to a pre
determined precision factor. This could be very slow when  I have two
matrices of numbers that I could otherwise compare with a simple '==',
''  or '' in R.
What is teh best solution for this problem?
Can I control the precision of ==,  and  without having to
reimplement the operations in a slow way?

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


Re: [R] Contingency tables from data.frames

2005-05-25 Thread Jose Claudio Faria

Gabor Grothendieck wrote:

On 5/24/05, Jose Claudio Faria [EMAIL PROTECTED] wrote:


Dear list,

I'm trying to do a set of generic functions do make contingency tables from
data.frames. It is just running nice (I'm learning R), but I think it can be
better.

I would like to filter the data.frame, i.e, eliminate all not numeric variables.
And I don't know how to make it: please, help me.

Below one of the my functions ('er' is a mention to EasieR, because I'm trying
to do a package for myself and the my students):

#2. Tables from data.frames
#2.1---er.table.df.br (User define breaks and right)
er.table.df.br - function(df,
  breaks = c('Sturges', 'Scott', 'FD'),
  right = FALSE) {

 if (is.data.frame(df) != 'TRUE')
   stop('need data.frame data')

 dim_df - dim(df)

 tmpList - list()

 for (i in 1:dim_df[2]) {

   x - as.matrix(df[ ,i])
   x - na.omit(x)

   k - switch(breaks[1],
   'Sturges' = nclass.Sturges(x),
   'Scott'   = nclass.scott(x),
   'FD'  = nclass.FD(x),
   stop('breaks' must be 'Sturges', 'Scott' or 'FD'))

   tmp  - range(x)
   classIni - tmp[1] - tmp[2]/100
   classEnd - tmp[2] + tmp[2]/100
   R- classEnd-classIni
   h- R/k

   # Absolut frequency
   f - table(cut(x, br = seq(classIni, classEnd, h), right = right))

   # Relative frequency
   fr - f/length(x)

   # Relative frequency, %
   frP - 100*(f/length(x))

   # Cumulative frequency
   fac - cumsum(f)

   # Cumulative frequency, %
   facP - 100*(cumsum(f/length(x)))

   fi   - round(f, 2)
   fr   - round(as.numeric(fr), 2)
   frP  - round(as.numeric(frP), 2)
   fac  - round(as.numeric(fac), 2)
   facP - round(as.numeric(facP),2)

   # Table
   res - data.frame(fi, fr, frP, fac, facP)
   names(res) - c('Class limits', 'fi', 'fr', 'fr(%)', 'fac', 'fac(%)')
   tmpList - c(tmpList, list(res))
 }
 names(tmpList) - names(df)
 return(tmpList)
}

To try the function:

#a) runing nice
y1=rnorm(100, 10, 1)
y2=rnorm(100, 58, 4)
y3=rnorm(100, 500, 10)
mydf=data.frame(y1, y2, y3)
#tbdf=er.table.df.br (mydf, breaks = 'Sturges', right=F)
#tbdf=er.table.df.br (mydf, breaks = 'Scott', right=F)
tbdf=er.table.df.br (mydf, breaks = 'FD', right=F)
print(tbdf)


#b) One of the problems
y1=rnorm(100, 10, 1)
y2=rnorm(100, 58, 4)
y3=rnorm(100, 500, 10)
y4=rep(letters[1:10], 10)
mydf=data.frame(y1, y2, y3, y4)
tbdf=er.table.df.br (mydf, breaks = 'Scott', right=F)
print(tbdf)




Try this:

sapply(my.data.frame, is.numeric)

Also you might want to look up:

?match.arg
?stopifnot
?ncol
?sapply
?lapply



Thanks Gabor, you suggestion solve my basic problem.
I'm working is same basic (but I think useful) functions
for begginiers.

Below you can see the set of functions:

###
#   EasyeR - Package  #
###

# Common function---
er.make.table - function(x,
  classIni,
  classEnd,
  h,
  right) {
  # Absolut frequency
  f - table(cut(x, br = seq(classIni, classEnd, h), right = right))

  # Relative frequency
  fr - f/length(x)

  # Relative frequency, %
  frP - 100*(f/length(x))

  # Cumulative frequency
  fac - cumsum(f)

  # Cumulative frequency, %
  facP - 100*(cumsum(f/length(x)))

  fi   - round(f, 2)
  fr   - round(as.numeric(fr), 2)
  frP  - round(as.numeric(frP), 2)
  fac  - round(as.numeric(fac), 2)
  facP - round(as.numeric(facP),2)

  # Table
  res - data.frame(fi, fr, frP, fac, facP)
  names(res) - c('Class limits', 'fi', 'fr', 'fr(%)', 'fac', 'fac(%)')
  return(res)
}


#1. Tables from vectors
#1.1---er.table.br (User define breaks and right)---
er.table.br - function(x,
breaks = c('Sturges', 'Scott', 'FD'),
right = FALSE) {

  if (is.factor(x) || mode(x) != 'numeric') stop('need numeric data')

  x - na.omit(x)

  k - switch(breaks[1],
  'Sturges' = nclass.Sturges(x),
  'Scott'   = nclass.scott(x),
  'FD'  = nclass.FD(x),
  stop('breaks' must be 'Sturges', 'Scott' or 'FD'))

  tmp  - range(x)
  classIni - tmp[1] - abs(tmp[2])/100
  classEnd - tmp[2] + abs(tmp[2])/100
  R- classEnd-classIni
  h- R/k

  tbl - er.make.table(x, classIni, classEnd, h, right)
  return(tbl)
}


#1.2---er.table.kr (User define the class number (k) and right)-
er.table.kr - function(x,
k,
right = FALSE) {

  if (is.factor(x) || mode(x) != 'numeric') stop('need numeric data')
  if ((k == '') || (k == ' ')) stop('k not defined')

  x - na.omit(x)

  tmp  - range(x)
  classIni - tmp[1] - abs(tmp[2])/100
  classEnd - tmp[2] + abs(tmp[2])/100
  R- classEnd-classIni
  h- R/k

  tbl - er.make.table(x, classIni, classEnd, h, right)
  

Re: [R] precision problem

2005-05-25 Thread Uwe Ligges

Omar Lakkis wrote:


I have prices that I am finding difficult to compare with ==,  and ,
due to precision. For example: the numbers should match, with '==',
but they differ in the magnitude of 1e-14 due to bunch of calculations
that I run on them. Programming with java, I am used to implementing a
function that compares the difference between the numbers to a pre
determined precision factor. This could be very slow when  I have two
matrices of numbers that I could otherwise compare with a simple '==',
''  or '' in R.
What is teh best solution for this problem?
Can I control the precision of ==,  and  without having to
reimplement the operations in a slow way?


The R FAQ Why doesn't R think these numbers are equal? points you to
?all.equal

Uwe Ligges



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


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


Re: [R] precision problem

2005-05-25 Thread Roger Bivand
On Wed, 25 May 2005, Omar Lakkis wrote:

?all.equal, I think

 I have prices that I am finding difficult to compare with ==,  and ,
 due to precision. For example: the numbers should match, with '==',
 but they differ in the magnitude of 1e-14 due to bunch of calculations
 that I run on them. Programming with java, I am used to implementing a
 function that compares the difference between the numbers to a pre
 determined precision factor. This could be very slow when  I have two
 matrices of numbers that I could otherwise compare with a simple '==',
 ''  or '' in R.
 What is teh best solution for this problem?
 Can I control the precision of ==,  and  without having to
 reimplement the operations in a slow way?
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

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


RE: [R] precision problem

2005-05-25 Thread bogdan romocea
This is a FAQ, 7.31.


-Original Message-
From: Omar Lakkis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 25, 2005 10:09 AM
To: r-help@stat.math.ethz.ch
Subject: [R] precision problem


I have prices that I am finding difficult to compare with ==,  and ,
due to precision. For example: the numbers should match, with '==',
but they differ in the magnitude of 1e-14 due to bunch of calculations
that I run on them. Programming with java, I am used to implementing a
function that compares the difference between the numbers to a pre
determined precision factor. This could be very slow when  I have two
matrices of numbers that I could otherwise compare with a simple '==',
''  or '' in R.
What is teh best solution for this problem?
Can I control the precision of ==,  and  without having to
reimplement the operations in a slow way?

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

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


[R] Weird function call problem

2005-05-25 Thread Bela Bauer
Hi,

I'm encountering a very odd problem with calls to anova.mlm() from within a
function.

Consider the following code (data.n is a matrix of numeric values):

mlmfit - lm(data.n ~ 1)
mlmfit0 - lm(data.n ~ 0)
print(mlmfit)
anova(mlmfit,mlmfit0,test=Spherical)

If I run it just like this from the console, it works just fine. If,
however, I call it from within a function, e.g. using

fct - function(data.k) {
 # same code with data.n replaced by data.k
}
fct(data.n)

It gives me
 fct(data.n)

Call:
lm(formula = data.k ~ 1)

Coefficients:
...

Error in anova.mlmlist(object = mlmfit, mlmfit0, test = Spherical) :
Object mlmfit not found

What causes mlmfit to disappear between two lines? I haven't got the
slightest clue where to look for an answer...

Thank you very much for your help.

Bela Bauer

-- 
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl

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


RE: [R] precision problem

2005-05-25 Thread John Fox
Dear Omar,

Perhaps I'm missing something, but why not just subtract one matrix from the
other and test the difference in relation to the precision that you require
for the comparison? E.g., to test near equality, something like, abs(A - B)
 1e-13.

I hope this helps,
 John


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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Omar Lakkis
 Sent: Wednesday, May 25, 2005 9:09 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] precision problem
 
 I have prices that I am finding difficult to compare with ==, 
  and , due to precision. For example: the numbers should 
 match, with '==', but they differ in the magnitude of 1e-14 
 due to bunch of calculations that I run on them. Programming 
 with java, I am used to implementing a function that compares 
 the difference between the numbers to a pre determined 
 precision factor. This could be very slow when  I have two 
 matrices of numbers that I could otherwise compare with a 
 simple '==', ''  or '' in R.
 What is teh best solution for this problem?
 Can I control the precision of ==,  and  without having to 
 reimplement the operations in a slow way?
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html

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


[R] Ternary Plots with continuous data

2005-05-25 Thread Steven K Friedman


Hello 

I have a data base consisting of soil parameters, and tree species 
densities.   The vcd (visualizing categorical data) package includes the 
ternaryplot function which plots the gravitation center of 3 prameters. 

I'd like to find a similar function for use with continuous data rather than 
categorical. 

Does anyone know of a function suitable for this objective? 

Thanks 


Steve Friedman

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


[R]: Aremos TSD files

2005-05-25 Thread Dubé, Eric
Hi 

I try to read Aremos files but with any succes, could you help me please.

Thanks
Eric Dubé


Éric Dubé 
Économiste / Economist 
Groupe économie et stratégie (dép. 657) / Economic  Strategy Team (Dept.
657) 
Financière Banque Nationale / National Bank Financial 
1155 Metcalfe 5e étage / 5th floor 
Montréal H3B 4S9 
(514) 879-2579 
[EMAIL PROTECTED] 




***
 
AVIS DE NON-RESPONSABILITE: 
Ce document transmis par courrier electronique est destine uniquement a la 
personne ou a l'entite a qui il est adresse et peut contenir des 
renseignements confidentiels et assujettis au secret professionnel. La 
confidentialite et le secret professionnel demeurent malgre l'envoi de ce 
document a la mauvaise adresse electronique. Si vous n'etes pas le 
destinataire vise ou la personne chargee de remettre ce document a son 
destinataire, veuillez nous en informer sans delai et detruire ce document 
ainsi que toute copie qui en aurait ete faite.Toute distribution, reproduction 
ou autre utilisation de ce document est 
strictement interdite. De plus, le Groupe Financiere Banque Nationale et ses 
filiales ne peuvent pas etre tenus responsables des dommages pouvant etre 
causes par des virus ou des erreurs de transmission. 

DISCLAIMER: \ This documentation transmitted by electronic...{{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


Re: [R] Table Help

2005-05-25 Thread Sean Davis




On May 25, 2005, at 9:35 AM, McMurtry, Benjamin G. wrote:

I'm slightly confused with aggregate, will I need to loop it until it 
stops
returning sub lists?  Or would I somehow need to convert my username 
column

into a unique list and then do FUN=sum??


Ben,

Generally, it is OK (and encouraged) to post back to the list, just so 
we all learn from each others' posts.


Here is an example:

 a - data.frame(group=rep(letters[1:3],10),values=rnorm(30))
 a
   group   values
1  a -0.146140983
2  b  0.190071267
3  c  0.207708591
4  a -1.126531350
5  b -0.013761243
6  c -0.212028409
7  a  1.012215244
8  b -0.487072132
9  c  0.667999520
10 a  0.276094321
11 b  0.835611948
12 c -1.049264490
13 a  0.399050191
14 b -1.177174650
15 c -1.471944114
16 a -0.410480517
17 b  0.006008521
18 c  1.608219688
19 a -0.120729414
20 b  1.074361542
21 c  1.782826882
22 a  1.336191577
23 b  0.721519413
24 c -0.594837423
25 a  1.120628507
26 b -2.011601905
27 c -0.076464599
28 a -1.512376840
29 b  1.182703732
30 c -1.620904211
 aggregate(a[,2],by=list(a[,1]),sum)
  Group.1  x
1   a  0.8279207
2   b  0.3206665
3   c -0.7586886


Hope that helps.

Sean

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


[R] mixed model

2005-05-25 Thread NATALIA F TCHETCHERINA
 Hello all,
 I have problem with setting up random effects.
 I have a model:
 y=x1+x2+x1*x2+z1+z1*x2
 where x1, x2, x1*x2 are fixed effects
 and z1, z1*x2 are random effects (crossed effects)
 I use library(nlme) 'lme' function.
 My question is: how I should set up random effects?
 I did 
 lme(y~x1+x2+x1:x2, data=DATA, random=~z1+z1:x2, na.action='na.omit')
 but it did not work.

 Sincerely, Natalia.

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


Re: [R] Weird function call problem

2005-05-25 Thread Duncan Murdoch

Bela Bauer wrote:


Hi,

I'm encountering a very odd problem with calls to anova.mlm() from within a
function.

Consider the following code (data.n is a matrix of numeric values):

mlmfit - lm(data.n ~ 1)
mlmfit0 - lm(data.n ~ 0)
print(mlmfit)
anova(mlmfit,mlmfit0,test=Spherical)

If I run it just like this from the console, it works just fine. If,
however, I call it from within a function, e.g. using

fct - function(data.k) {
# same code with data.n replaced by data.k
}
fct(data.n)

It gives me
 


fct(data.n)
   



Call:
lm(formula = data.k ~ 1)

Coefficients:
...

Error in anova.mlmlist(object = mlmfit, mlmfit0, test = Spherical) :
   Object mlmfit not found

What causes mlmfit to disappear between two lines? I haven't got the
slightest clue where to look for an answer...

Thank you very much for your help.
 



This looks like a bug in the anova.mlm or anova.mlmlist functions.  One 
of them is looking in the wrong place for mlmfit.


Duncan Murdoch

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


Re: [R] weighted.mean and tapply (again)

2005-05-25 Thread james . holtman




 x.1 - read.table('clipboard',header=T)
 x.1
   GROUP VALUE FREQUENCY
1  2 278
2  2 340
3  2 416
4  2 5 3
5  2 6 1
6  2 8 1
7  3 319
8  3 410
9  3 519
10 3 6 4
 by(x.1, x.1$GROUP, function(x) weighted.mean(x$VALUE, x$FREQUENCY))
x.1$GROUP: 2
[1] 2.654676
---
x.1$GROUP: 3
[1] 4.153846


Jim
__
James HoltmanWhat is the problem you are trying to solve?
Executive Technical Consultant  --  Office of Technology, Convergys
[EMAIL PROTECTED]
+1 (513) 723-2929



   
  Dan Bolser
   
  [EMAIL PROTECTED]To:   R mailing list 
r-help@stat.math.ethz.ch 
  uk  cc:  
   
  Sent by: Subject:  [R] weighted.mean 
and tapply (again)  
  [EMAIL PROTECTED] 
   
  ath.ethz.ch   
   

   

   
  05/25/2005 11:33  
   

   





I read answers to questions including the words tapply and
weighted.mean, but I didn't understand either the problem (data) or the
solution provided.

Here is my question ...

 dat[1:10,]
  GROUP  VALUE FREQUENCY
1 2  278
2 2  340
3 2  416
4 2  5 3
5 2  6 1
6 2  8 1
7 3  319
8 3  410
9 3  519
1 3  6 4


For each GROUP, I would like to calculate the weighted.mean of VALUE using
the FREQUENCY as the weight, so for the snippet of data shown that would
be...

group.2 - weighted.mean(c(2,3,4,5,6,8),c(78,40,16,3,1,1))
group.3 - weighted.mean(c(3,4,5,6),c(19,10,19,4))

 cbind(rbind(2,3),rbind(group.2,group.3))
[,1] [,2]
group.22 2.654676
group.33 4.153846

I would like to use tapply to automatically do this across the whole
dataset (dat) - which includes lots of other distinct grouping factors,
however, like I said, I couldn't understand (and therefore apply to my
data) any of the other solutions I found, so any help here would be
greatly appreciated!

All the best,
Dan.

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

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


RE: [R] mixed model

2005-05-25 Thread Doran, Harold
I may not follow entirely here, but your random effects structure isn't
correct for lme. Also, nlme cannot handle (at least well) models with
crossed random effects. A better option would be to use the lmer
function. 

Setting up the structure for the random effects in nlme would look
something like:

lme(y~ fixed, data, random~= z1 + z2 |ID)

Where ID is a variable that contains the grouping structure of your
data.

In lmer, which is more appropriate for models with crossed random
effects, you lmer call might be something along the lines of:

lmer(y ~ fixed + (z1|ID) + (z2|ID), data)

See the most recent version of R news for more info on this topic.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of NATALIA F
TCHETCHERINA
Sent: Wednesday, May 25, 2005 11:50 AM
To: r-help@stat.math.ethz.ch
Subject: [R] mixed model

 Hello all,
 I have problem with setting up random effects.
 I have a model:
 y=x1+x2+x1*x2+z1+z1*x2
 where x1, x2, x1*x2 are fixed effects
 and z1, z1*x2 are random effects (crossed effects)  I use library(nlme)
'lme' function.
 My question is: how I should set up random effects?
 I did
 lme(y~x1+x2+x1:x2, data=DATA, random=~z1+z1:x2, na.action='na.omit')
but it did not work.

 Sincerely, Natalia.

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

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


Re: [R] mixed model

2005-05-25 Thread Douglas Bates
NATALIA F TCHETCHERINA wrote:
  Hello all,
  I have problem with setting up random effects.
  I have a model:
  y=x1+x2+x1*x2+z1+z1*x2
  where x1, x2, x1*x2 are fixed effects
  and z1, z1*x2 are random effects (crossed effects)
  I use library(nlme) 'lme' function.
  My question is: how I should set up random effects?
  I did 
  lme(y~x1+x2+x1:x2, data=DATA, random=~z1+z1:x2, na.action='na.omit')
  but it did not work.
 
  Sincerely, Natalia.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

The answer will depend on the types of x1, x2 and z1 (i.e. whether each
of them is numeric or a factor).  Because you use x1:x2 I will assume
that x1, x2 and z1 are all factors.  In that case the formula term x1*x2
is equivalent to x1 + x2 + x1:x2 and you could write the call to lme as

lme(y ~ x1*x2, data = DATA, random = ~1|z1/x1)

For lmer from the lme4 package it would be

lmer(y ~ x1*x2 + (1|z1) + (1|z1:x1), data = DATA)

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


[R] The error while using R2WinBUGS

2005-05-25 Thread Li, Jia
Dear all,
 
I tried to run WinBUGS model in R by using package R2WinBUGS, but I
failed because of the massage : cannot calculate DIC for model in log
file of WinBUGS14. In fact, the model works in WinBUGS and I can get
summaries of the model, such as density, stats..., except DIC , because
DIC may not be appropriate in this kind of model due to some
reasons(according to the manual of WinBUGS14), and WinBUGS cannot
calculate it, but this is allowed in WinBUGS. If I just ran it in
WinBUGS, that would be fine, because my goal is to get the summay not
DIC, but I need to run it in R, and R must have DIC. (the example as
follow). I am wondering what I can do to fix it in R?
 
for exampe: the school example:
the output in R:
 print(schools.sim)
Inference for Bugs model at c:/schools/schools.bug
3 chains, each with 1000 iterations (first 500 discarded)
n.sims = 1500 iterations saved
mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff
theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39
.
theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64
mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35
.
deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170
pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2)
 
Thanks a lot,
 
Jia

[[alternative HTML version deleted]]

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


Re: [R] Problem with systemfit 0.7-3 and transformed variables

2005-05-25 Thread Mikko Pakkanen
 We did not notice this shortcoming of systemfit() so far. Unfortunately,
 I 
 don't have the time in the next few days to look into the code and figure
 out 
 how to enable transformed variables. I suggest that you either create 
 transformed variables by hand or you modify the systemfit code to enable
 this 
 and send us the patch. I prefer the second :-) (that's the philosophy of
 open-source software like R: useRs become developeRs).

Luckily, I had some time to check the code. Debugger revealed that the
problems are caused by the model.frame function which is used to compile the
'$data' data frame. I don't need that data frame so much, so I just
substituted model.frame with model.matrix which apparently doesn't cause
this error with transformed variables. However, I tuned it a bit further, so
that it should still return an identical '$data' data frame, despite the
modification.
I've only tested this with my example and it appears to be OK. Still, I
think this should be considered a quick  dirty fix -there are probably
better ways to do it. But, I hope it gives the idea. Here's my attempt:

[EMAIL PROTECTED] R $ diff -u systemfit.R systemfit-patched.R
--- systemfit.R 2004-11-26 11:17:36.0 +0200
+++ systemfit-patched.R 2005-05-25 18:55:55.568944699 +0300
@@ -624,7 +624,11 @@
 Terms - terms( eqns[[i]], data = data)
 m$formula - Terms
 m - eval(m, parent.frame())
-datai - model.frame(Terms, m)
+resp - model.extract(m, response)
+   ## using model.matrix instead of model.frame, need to get the output
variable separately
+datai - data.frame(cbind(resp, (model.matrix(Terms, m))[,-1]))
+   ## I guess there's a better way to extract the name of the output
variable?
+   names(datai)[1] - as.character(terms(eqns[[i]]))[2]
 if(method==2SLS | method==3SLS) {
   #datai - cbind( datai, model.frame( instl[[i]] ))
   # the following lines have to be substituted for the previous
@@ -634,7 +638,8 @@
   Terms - terms(instl[[i]], data = data)
   m$formula - Terms
   m - eval(m, parent.frame())
-  datai - cbind( datai, model.frame(Terms, m))
+  ## used previously model.frame
+  datai - cbind( datai, as.data.frame((model.matrix(Terms, m))[,-1]))
 }

 if(i==1) {

Regards,

-Mikko.

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


RE: [R] weighted.mean and tapply (again)

2005-05-25 Thread OlsenN
In this simple case you can just coerce directly to a vector like so:

 foo - by(dat, dat$GROUP, function(x) {weighted.mean(x$VALUE,
x$FREQUENCY)})
 bar - as.vector(foo)

but look at the examples for ?by; in particular the use of 'sapply'.

Norm

-Original Message-
From: Dan Bolser [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 25, 2005 9:02 AM
To: [EMAIL PROTECTED]
Subject: RE: [R] weighted.mean and tapply (again)

On Wed, 25 May 2005 [EMAIL PROTECTED] wrote:

I think by will do what you want:

 by(dat, dat$GROUP, function(x) {weighted.mean(x$VALUE, x$FREQUENCY)})

Norm

Thanks Norm and Jim. My question is now...

How do you turn a quote list of class 'by' /quote into a vector of
results (one value per GROUP)?

Cheers guys!

Dan.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dan Bolser
Sent: Wednesday, May 25, 2005 8:34 AM
To: R mailing list
Subject: [R] weighted.mean and tapply (again)


I read answers to questions including the words tapply and 
weighted.mean, but I didn't understand either the problem (data) or 
the solution provided.

Here is my question ...

 dat[1:10,]
  GROUP  VALUE FREQUENCY
1 2  278
2 2  340
3 2  416
4 2  5 3
5 2  6 1
6 2  8 1
7 3  319
8 3  410
9 3  519
1 3  6 4


For each GROUP, I would like to calculate the weighted.mean of VALUE 
using the FREQUENCY as the weight, so for the snippet of data shown 
that would be...

group.2 - weighted.mean(c(2,3,4,5,6,8),c(78,40,16,3,1,1))
group.3 - weighted.mean(c(3,4,5,6),c(19,10,19,4))

 cbind(rbind(2,3),rbind(group.2,group.3))
[,1] [,2]
group.22 2.654676
group.33 4.153846

I would like to use tapply to automatically do this across the whole 
dataset
(dat) - which includes lots of other distinct grouping factors, 
however, like I said, I couldn't understand (and therefore apply to my
data) any of the other solutions I found, so any help here would be 
greatly appreciated!

All the best,
Dan.

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


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


Re: [R-SIG-Mac] Re: [R] R unable to run on Mac OS 10.4 Tiger

2005-05-25 Thread Simon Urbanek

On May 25, 2005, at 3:19 AM, Guillaume Chapron wrote:

I suppose i will have to reinstall quicktime 7 and things will be  
OK. But I don't understand why R does need quicktime ??


Neither R nor R.app does. Chances are that you pretty much broke your  
Tiger, because all R.app does is to link Cocoa which links AppKit. On  
my Tiger machine it doesn't even touch QuickTime, so it must be your  
plugin or whatever you did to poor Tiger ;). Why don't you just  
remove /Library/Quicktime? It's not a part of Tiger. Tiger's  
QuickTime files are in /System/Library.


If you want to understand better who's loading what, set  
DYLD_PRINT_LIBRARIES when running R or R.app.


Cheers,
Simon

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


RE: [R] Can simulation involving random number generation be segm ented?

2005-05-25 Thread Huntsinger, Reid
I don't see why you need to shut R down between runs. Can you just replace
each time you generate a new 200 samples? You might also find gc() helpful
if you generate a lot of intermediate objects in a single run. Delete
objects you no longer need (unless you're going to replace them and can
afford to keep them around), then an explicit request gc() might help keep
you under the wire.

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges
Sent: Wednesday, May 25, 2005 8:56 AM
To: Dr L. Y Hin
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Can simulation involving random number generation be
segmented?


Dr L. Y Hin wrote:

 Dear all,
 Apologies for this pedantic question that only arise when there is
hardware
 limitation.
 Setting: R 2.1.0 for windows xp sp2.
 Scenario:
 To generate 1000 samples using rnorm for a simulation activity.
 Background:
 The simulation activity requires so much memory resources that generating
 200 samples
 clogs up the PF usage as indicated in the Windows Task Manager.
 Therefore, short of implementing the simulation on a computer with more
 resources,
 the alternative is to generate the 1000 samples in 5 separate runs,
 each generating 200 samples, closing the R window and re-opening between
 runs.
 Question to be addressed:
 To maintain consistency and ensure reproducibility of the simulation
 results, the 1000 samples
 generated in one single run should be indentical to the 5x200 samples
 generated on 5 separate
 runs.
 While such consistency can be ensured using set.seed()  in the case of one
 single run, in the case
 where 5 separate runs are performed, can we do the following to ensure
 identical samples being
 generated?
 1. In the first run, specify the seed by, say, set.seed(1)
 
 2. At the end of the first run, store the .Random.seed by the following
 manner:
 saved.seed.1-.Random.seed
 
 3. At the beginning of the second run, assign the saved.seed.1 to
 .Random.seed as follows:
 .Random.seed-saved.seed.1
 
 4. At the end of the first run, store the new .Random.seed by the
following
 manner:
 saved.seed.2-.Random.seed
 
 5. At the beginning of the second run, assign the saved.seed.2 to
 .Random.seed as follows:
 .Random.seed-saved.seed.2
 
 This is repeated until 5 runs are completed.
 
 Will the paths of random number generation be identical in these two
 approaches? 

Yes.

Uwe Ligges

If not, is there
 a way to ensure this?
 
 Apologies again for this long-winded inquiry.
 
 Thank you.
 Best
 Lin
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html

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

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


RE: [R] weighted.mean and tapply (again)

2005-05-25 Thread Berton Gunter
 
 In this simple case you can just coerce directly to a vector like so:
 
  foo - by(dat, dat$GROUP, function(x) {weighted.mean(x$VALUE,
 x$FREQUENCY)})
  bar - as.vector(foo)
 
 but look at the examples for ?by; in particular the use of 'sapply'.
 
 Norm

As a general practice, I believe unlist() is preferable. ?unlist explains
why.

Cheers,
Bert Gunter

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


Re: [R] The error while using R2WinBUGS

2005-05-25 Thread Uwe Ligges
I don't know if I understand you correctly, but I think you missed to 
read ?bugs carefully enough:


   bugs(., DIC = FALSE)

should disable calculation of DIC statistics. If your example still 
fails, please specify a reproducible example in a private message.


Asking the package maintainer / authors would have been a better idea 
for such a specialized question.



Uwe Ligges

BTW: You might want to try out the new CRAN package BRugs, which 
provides an interface to the (included) OpenBUGS (the next version of 
WinBUGS). Currenty, it only works on Windows, though.








Li, Jia wrote:


Dear all,
 
I tried to run WinBUGS model in R by using package R2WinBUGS, but I

failed because of the massage : cannot calculate DIC for model in log
file of WinBUGS14. In fact, the model works in WinBUGS and I can get
summaries of the model, such as density, stats..., except DIC , because
DIC may not be appropriate in this kind of model due to some
reasons(according to the manual of WinBUGS14), and WinBUGS cannot
calculate it, but this is allowed in WinBUGS. If I just ran it in
WinBUGS, that would be fine, because my goal is to get the summay not
DIC, but I need to run it in R, and R must have DIC. (the example as
follow). I am wondering what I can do to fix it in R?
 
for exampe: the school example:

the output in R:


print(schools.sim)


Inference for Bugs model at c:/schools/schools.bug
3 chains, each with 1000 iterations (first 500 discarded)
n.sims = 1500 iterations saved
mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff
theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39
.
theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64
mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35
.
deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170
pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2)
 
Thanks a lot,
 
Jia


[[alternative HTML version deleted]]

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


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


[R] Rounding fractional numbers to nearest fraction

2005-05-25 Thread Ken Termiso

Hi all,

I've got a matrix of fractional data that is all positive and greater than 
zero that I would like to loosely classify, for lack of a better word. It 
looks something like this :


1.07   1.11   1.27   1.59   0.97   0.76
2.23   0.98   0.71   0.88   1.19   1.02


What I'm looking for is a way to round these numbers to the nearest 0.25, 
i.e. the above matrix would be transformed to :


1.00   1.00   1.25   1.50   1.00   0.75
2.25   1.00   0.75   1.00   1.25   1.00


Anyone have a clever way to do this??

Thanks in advance,
Ken

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


RE: [R] Rounding fractional numbers to nearest fraction

2005-05-25 Thread bogdan romocea
Multiply by 4, round and divide by 4.
a - c(1.15,5.82)
round(a*4,digits=0)/4



-Original Message-
From: Ken Termiso [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 25, 2005 1:27 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Rounding fractional numbers to nearest fraction


Hi all,

I've got a matrix of fractional data that is all positive and greater than 
zero that I would like to loosely classify, for lack of a better word. It 
looks something like this :

1.07   1.11   1.27   1.59   0.97   0.76
2.23   0.98   0.71   0.88   1.19   1.02


What I'm looking for is a way to round these numbers to the nearest 0.25, 
i.e. the above matrix would be transformed to :

1.00   1.00   1.25   1.50   1.00   0.75
2.25   1.00   0.75   1.00   1.25   1.00


Anyone have a clever way to do this??

Thanks in advance,
Ken

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

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


Re: [R] Rounding fractional numbers to nearest fraction

2005-05-25 Thread Ken Termiso

Thx for the help...

mdiv - function(dec)
{
dec - dec * 4
dec - round(dec, 0)
dec - dec / 4
dec
}

where m is a matrix --

m1 - apply(m, 1, mdiv)

...but it looks like as.integer(x.1*4)/4 or (round(x.1*4,0))/4 might be 
easier...


thx again,
ken


From: [EMAIL PROTECTED]
To: Ken Termiso [EMAIL PROTECTED]
Subject: Re: [R] Rounding fractional numbers to nearest fraction
Date: Wed, 25 May 2005 14:30:44 -0400





 x.1
 [1] 1.07 1.11 1.27 1.59 0.97 0.76 2.23 0.98 0.71 0.88 1.19 1.02
 as.integer(x.1*4)/4
 [1] 1.00 1.00 1.25 1.50 0.75 0.75 2.00 0.75 0.50 0.75 1.00 1.00


Jim
__
James HoltmanWhat is the problem you are trying to solve?
Executive Technical Consultant  --  Convergys Labs
[EMAIL PROTECTED]
+1 (513) 723-2929



  Ken Termiso
  [EMAIL PROTECTED]To:   
r-help@stat.math.ethz.ch

  om  cc:
  Sent by: Subject:  [R] Rounding 
fractional numbers to nearest fraction

  [EMAIL PROTECTED]
  ath.ethz.ch


  05/25/2005 13:27





Hi all,

I've got a matrix of fractional data that is all positive and greater than
zero that I would like to loosely classify, for lack of a better word. It

looks something like this :

1.07   1.11   1.27   1.59   0.97   0.76
2.23   0.98   0.71   0.88   1.19   1.02


What I'm looking for is a way to round these numbers to the nearest 0.25,
i.e. the above matrix would be transformed to :

1.00   1.00   1.25   1.50   1.00   0.75
2.25   1.00   0.75   1.00   1.25   1.00


Anyone have a clever way to do this??

Thanks in advance,
Ken

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




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


RE: [R] Rounding fractional numbers to nearest fraction

2005-05-25 Thread Liaw, Andy
 From: Ken Termiso
 
 Thx for the help...
 
 mdiv - function(dec)
 {
   dec - dec * 4
   dec - round(dec, 0)
   dec - dec / 4
   dec
 }
 
 where m is a matrix --
 
 m1 - apply(m, 1, mdiv)

You don't need the apply():

 m - matrix(runif(6), 2, 3)
 m
  [,1]  [,2]  [,3]
[1,] 0.6885473 0.4598892 0.2738169
[2,] 0.2393461 0.8863284 0.7891100
 round(m * 4) / 4
 [,1] [,2] [,3]
[1,] 0.75  0.5 0.25
[2,] 0.25  1.0 0.75
 
 ...but it looks like as.integer(x.1*4)/4 or 
 (round(x.1*4,0))/4 might be 
 easier...

Be careful: as.integer() trucate the fractional part (so as.integer(1.999)
is 1 intead of 2), which may not be what you want.

Andy

 
 thx again,
 ken
 
 From: [EMAIL PROTECTED]
 To: Ken Termiso [EMAIL PROTECTED]
 Subject: Re: [R] Rounding fractional numbers to nearest fraction
 Date: Wed, 25 May 2005 14:30:44 -0400
 
 
 
 
 
   x.1
   [1] 1.07 1.11 1.27 1.59 0.97 0.76 2.23 0.98 0.71 0.88 1.19 1.02
   as.integer(x.1*4)/4
   [1] 1.00 1.00 1.25 1.50 0.75 0.75 2.00 0.75 0.50 0.75 1.00 1.00
  
 
 Jim
 __
 James HoltmanWhat is the problem you are trying to solve?
 Executive Technical Consultant  --  Convergys Labs
 [EMAIL PROTECTED]
 +1 (513) 723-2929
 
 
 
Ken Termiso
[EMAIL PROTECTED]To:   
 r-help@stat.math.ethz.ch
om  cc:
Sent by: Subject: 
  [R] Rounding 
 fractional numbers to nearest fraction
[EMAIL PROTECTED]
ath.ethz.ch
 
 
05/25/2005 13:27
 
 
 
 
 
 Hi all,
 
 I've got a matrix of fractional data that is all positive 
 and greater than
 zero that I would like to loosely classify, for lack of a 
 better word. It
 
 looks something like this :
 
 1.07   1.11   1.27   1.59   0.97   0.76
 2.23   0.98   0.71   0.88   1.19   1.02
 
 
 What I'm looking for is a way to round these numbers to the 
 nearest 0.25,
 i.e. the above matrix would be transformed to :
 
 1.00   1.00   1.25   1.50   1.00   0.75
 2.25   1.00   0.75   1.00   1.25   1.00
 
 
 Anyone have a clever way to do this??
 
 Thanks in advance,
 Ken
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
 
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


[R] cor vs cor.test

2005-05-25 Thread Michael Grant
Using Windows System, R 2.1.0

d is a data frame, 48 rows, 10 columns
cor(d) works properly providing all pairwise Pearson correlation
coefficients among columns
cor.test(d) gives error message Error in cor.test.default(d) : argument
y is missing, with no default

Why?

Thanks,
MCG

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


Re: [R] Can simulation involving random number generation be segmented?

2005-05-25 Thread A.J. Rossini
You might consider the rlecuyer package, which provides parallel
streams and avoids the potential worst case scenario from arbitrary
seed setting.

On 5/25/05, Dr L. Y Hin [EMAIL PROTECTED] wrote:
 Dear all,
 Apologies for this pedantic question that only arise when there is hardware
 limitation.
 Setting: R 2.1.0 for windows xp sp2.
 Scenario:
 To generate 1000 samples using rnorm for a simulation activity.
 Background:
 The simulation activity requires so much memory resources that generating
 200 samples
 clogs up the PF usage as indicated in the Windows Task Manager.
 Therefore, short of implementing the simulation on a computer with more
 resources,
 the alternative is to generate the 1000 samples in 5 separate runs,
 each generating 200 samples, closing the R window and re-opening between
 runs.
 Question to be addressed:
 To maintain consistency and ensure reproducibility of the simulation
 results, the 1000 samples
 generated in one single run should be indentical to the 5x200 samples
 generated on 5 separate
 runs.
 While such consistency can be ensured using set.seed()  in the case of one
 single run, in the case
 where 5 separate runs are performed, can we do the following to ensure
 identical samples being
 generated?
 1. In the first run, specify the seed by, say, set.seed(1)
 
 2. At the end of the first run, store the .Random.seed by the following
 manner:
 saved.seed.1-.Random.seed
 
 3. At the beginning of the second run, assign the saved.seed.1 to
 .Random.seed as follows:
 .Random.seed-saved.seed.1
 
 4. At the end of the first run, store the new .Random.seed by the following
 manner:
 saved.seed.2-.Random.seed
 
 5. At the beginning of the second run, assign the saved.seed.2 to
 .Random.seed as follows:
 .Random.seed-saved.seed.2
 
 This is repeated until 5 runs are completed.
 
 Will the paths of random number generation be identical in these two
 approaches? If not, is there
 a way to ensure this?
 
 Apologies again for this long-winded inquiry.
 
 Thank you.
 Best
 Lin
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 


-- 
best,
-tony

Commit early,commit often, and commit in a repository from which we can easily
roll-back your mistakes (AJR, 4Jan05).

A.J. Rossini
[EMAIL PROTECTED]

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


Re: [R] website reference for building R packages

2005-05-25 Thread roger bos
I used this tutorial and completed steps 1-6 without errors, but on
step 7 I tried to run R CMD check on my package called 'ram' directory
one level above the 'ram' folder and I got the following error?

I:\R_HOMER CMD check ram
* checking for working latex ...Error: environment variable TMPDIR not set (or s
et to unusable value) and no default available.
 at c:\R\rw2010\share\perl/R/Utils.pm line 72

Can anyone help me with this?

Thanks,

Roger



On 5/25/05, Uwe Ligges [EMAIL PROTECTED] wrote:
 Suresh Krishna wrote:
 
 
  it is the first link if you type making packages into the google
  search box here:
 
  http://maths.newcastle.edu.au/~rking/R/
 
 
 Yes, please look into the archives as the posting guide asks you to do!
 
 
  -s.
 
 
  Laura Holt wrote:
 
  Hi R People:
 
  A few weeks ago, someone put a link to a website for how to for
  building R packages.  It was very nice.
 
 
 Writing R Extensions is an *complete* and *up to date* documentation for
 this task. Package management is being steadily improved.
 Really, I recommend to use Writing R Extensions!
 
 If you are working on Windows, you might want to look into the R
 Administration and Installation manual as well which descibes how to
 collect and set up the required tools...
 
 Uwe Ligges
 
 
  But of course, I have misplaced the link.  Does anyone still have
  that, please?
 
  It was someone from the University of Chicago, I believe.
 
  Thanks in advance.
 
  Sincerely,
  Laura Holt
  mailto: [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
 
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


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


[R] Any ideas on how to add a dotted line to a box plot to indicate a specific value?

2005-05-25 Thread BJ
Basically, i want to create a boxplot from population data, with a solid 
line for the median, and then a dotted line for a specific persons 
value. Is there a way to artificially introduce another line or mark of 
some kind in a box plot? Thanks again for all of yoru help. Hopefully 
soon I wont have to keep bugging you all. ~Erithid :-p


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


Re: [R] cor vs cor.test

2005-05-25 Thread Suresh Krishna


From:

?cor.test

Arguments:

x, y: numeric vectors of data values.  'x' and 'y' must have the
  same length.

-s.

Michael Grant wrote:

Using Windows System, R 2.1.0

d is a data frame, 48 rows, 10 columns
cor(d) works properly providing all pairwise Pearson correlation
coefficients among columns
cor.test(d) gives error message Error in cor.test.default(d) : argument
y is missing, with no default

Why?

Thanks,
MCG

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



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


[R] aggregate and stack

2005-05-25 Thread Paulo Brando
Dear All,

I have tried to calculate tree mean growth but I think the structure I used 
below (growthresumo) is not the most elegant, even though it worked. The only 
problem I had in this first part was that  I cannot use 'summary', just 'mean' 
(sorry but 'R' is pretty new for me).

growthresumo - 
aggregate(growth[,c(16,19,23,27,31,35,39,43,47,52,56,60,64,68,72,76,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,
141,145,149,153,157,161,165,169,173,177,181,185,189,194,197,201,205,209,213,217,221,225,229,233,237,241)],
by=(growth[,c(3,8)]),MEAN,na.rm=TRUE)

#after growth is calculated, I want to stack the results in just one colunm.  

growthvertical - c(growthresumo[,3],...,growthresumo[,50]) # this is very 
time consuming though

Parcel - c(C9,S8...C9,S8) # 50 items

date  c(DATE1DATE50)

growthpermonth - data.frame(Parcel, Date, growthvertical)

Thank you very much!

Paulo

Paulo Brando
Inst. de Pesquisa Ambiental da Amazônia (IPAM)
Rua Rui Barbosa,136.
68.005.080 Santarém, PA, Brasil.
Fone/Fax ++ 55 93 522 5538
www.ipam.org.br
[[alternative HTML version deleted]]

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


[R] global normalization

2005-05-25 Thread NATALIA F TCHETCHERINA
Hello all,
I have question about global normalization.
I have data from big experement(two-color cDNA arrays) where used three
different layouts but the same set of genes. 
I used limma package for within array normalization.
My question is: how I can do between array normalization (global) if arrays have
different layout(different location and different number technical replicates
(number of spots of a gene on an array))?  

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

RE: [R] global normalization

2005-05-25 Thread Berton Gunter
Please address this question to the appropriate BioConductor or other
microarray list (or to the limma package author, as the Posting Guide asks).
It is not appropriate for R-Help.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 NATALIA F TCHETCHERINA
 Sent: Wednesday, May 25, 2005 3:33 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] global normalization
 
 Hello all,
 I have question about global normalization.
 I have data from big experement(two-color cDNA arrays) where 
 used three
 different layouts but the same set of genes. 
 I used limma package for within array normalization.
 My question is: how I can do between array normalization 
 (global) if arrays have
 different layout(different location and different number 
 technical replicates
 (number of spots of a gene on an array))?  
 
 Sincerely, Natalia.


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


RE: [R] Basic matematical functions with NAs

2005-05-25 Thread Alexander.Herr

Conceptually your assumption is wrong: If you have the traps out and don't 
catch fruit in the trap than you have 0 captures. NA would come for example 
from a trap not functioning properly at a certain day.

To get R to recognize NA you need to define your variables as numeric or 
factors. Quickest I find to produce the data in a spreadsheet/database and have 
NAs defined as -9. Than import into R via CSV format and replace -9 
with NA. Do read the R documentation on http://www.r-project.org/. Introduction 
to R is most helpful...

Herry

---
Alexander Herr - Herry
Northern Futures
Davies Laboratory, CSIRO
PMB, Aitkenvale, QLD 4814
Phone (07) 4753 8510
Fax   (07) 4753 8650
Home: http://herry.ausbats.org.au
Webadmin ABS: http://ausbats.org.au
Sustainable Ecosystems: http://www.cse.csiro.au/


Original messageX
Message: 19
Date: Tue, 24 May 2005 10:22:53 -0700
From: Paulo Brando [EMAIL PROTECTED]
Subject: [R] Basic matematical functions with NAs
To: r-help@stat.math.ethz.ch
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain

Dear All,

I've tried to sum columns -- different species of flowers, fruits plus twigs -- 
with NAs to get litterfall/trap, and then after use litterfall to calculate 
production (litterfall (grams)/ hectare/ day. But R 'sees' litterfall/trap as a 
string. 

My question: How to use basic mathematical functions to deal with NAs in data 
management. 

Example (as you can note I have many missing values -- no fruit  fell in the 
trap.


  area ponto date pseco psaco pliquido florg1 flor1 florg2 flor2 florg3 
flor3 frutog1 fruto1 frutog2 fruto2 frutog3 fruto3 frutog4 fruto4 frutog5 
fruto5 frutog6 fruto6 frutog7 fruto7 frutog8 fruto8 twigs  
  A A 1 38233 17.7 1.6 7.1 0.266 1   
  A AA 1 38233 12.5 8.7 3.8 
  A AB 1 38233 13.9 1.7 3.2   0.421 3 
  A B 1 38233 12.1 1.6 1.5   0.248 2 0.435 7 0.16 1 
  A BORDA 1 38233
  A C 1 38233 15.6 1.7 4.9   0.374 2 0.298 3 0.231 1 
  A F 1 38233 14 1.5 3.5 0.366 45 0.153 1 0.15 1   



Paulo Brando
Inst. de Pesquisa Ambiental da Amazônia (IPAM)
Rua Rui Barbosa,136.
68.005.080 Santarém, PA, Brazil.
Fone/Fax ++ 55 93 522 5538
www.ipam.org.br
[[alternative HTML version deleted]]



-
 

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


Re: [R] Problem with systemfit 0.7-3 and transformed variables

2005-05-25 Thread Arne Henningsen
On Wednesday 25 May 2005 18:25, Mikko Pakkanen wrote:
  We did not notice this shortcoming of systemfit() so far. Unfortunately,
  I
  don't have the time in the next few days to look into the code and figure
  out
  how to enable transformed variables. I suggest that you either create
  transformed variables by hand or you modify the systemfit code to enable
  this
  and send us the patch. I prefer the second :-) (that's the philosophy of
  open-source software like R: useRs become developeRs).

 Luckily, I had some time to check the code. Debugger revealed that the
 problems are caused by the model.frame function which is used to compile
 the '$data' data frame. I don't need that data frame so much, so I just
 substituted model.frame with model.matrix which apparently doesn't cause
 this error with transformed variables. However, I tuned it a bit further,
 so that it should still return an identical '$data' data frame, despite the
 modification.
 I've only tested this with my example and it appears to be OK. Still, I
 think this should be considered a quick  dirty fix -there are probably
 better ways to do it. But, I hope it gives the idea. Here's my attempt:

 [EMAIL PROTECTED] R $ diff -u systemfit.R systemfit-patched.R
 --- systemfit.R 2004-11-26 11:17:36.0 +0200
 +++ systemfit-patched.R 2005-05-25 18:55:55.568944699 +0300
 @@ -624,7 +624,11 @@
  Terms - terms( eqns[[i]], data = data)
  m$formula - Terms
  m - eval(m, parent.frame())
 -datai - model.frame(Terms, m)
 +resp - model.extract(m, response)
 +   ## using model.matrix instead of model.frame, need to get the
 output variable separately
 +datai - data.frame(cbind(resp, (model.matrix(Terms, m))[,-1]))
 +   ## I guess there's a better way to extract the name of the output
 variable?
 +   names(datai)[1] - as.character(terms(eqns[[i]]))[2]
  if(method==2SLS | method==3SLS) {
#datai - cbind( datai, model.frame( instl[[i]] ))
# the following lines have to be substituted for the previous
 @@ -634,7 +638,8 @@
Terms - terms(instl[[i]], data = data)
m$formula - Terms
m - eval(m, parent.frame())
 -  datai - cbind( datai, model.frame(Terms, m))
 +  ## used previously model.frame
 +  datai - cbind( datai, as.data.frame((model.matrix(Terms, m))[,-1]))
  }

  if(i==1) {

Thank you very much for the patch. I have uploaded a patched version of 
systemfit (version 0.7-4) to CRAN. It is also available on my website now:
   http://www.uni-kiel.de/agrarpol/ahenningsen/index-e.html 

Best wishes,
Arne

 Regards,

 -Mikko.

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

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

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


Re: [R] Any ideas on how to add a dotted line to a box plot to indicate a specific value?

2005-05-25 Thread Paul Murrell

Hi


BJ wrote:
Basically, i want to create a boxplot from population data, with a solid 
line for the median, and then a dotted line for a specific persons 
value. Is there a way to artificially introduce another line or mark of 
some kind in a box plot? Thanks again for all of yoru help. Hopefully 
soon I wont have to keep bugging you all. ~Erithid :-p



Do you mean something like this ... ?

with(ToothGrowth,
 {
   boxplot(len ~ supp)
   # boxplots horizontally centred at 1 and 2
   # 0.6, 1.4 come from default boxwex of 0.8
   #   (1 +/- boxwex/2)
   # 18 I made up
   lines(c(0.6, 1.4), c(18, 18),
 lty=dashed, col=red)
 })

Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

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


Re: [R] Plot: Distance between tick and tick label on y-axis

2005-05-25 Thread Paul Murrell

Hi

You might have more luck with par(mgp), for example, ...

par(las=1)
plot(runif(50), type=l,xaxt=n,yaxt=n,ylab=, bty=l)
axis(2, mgp=c(3, .5, 0))
axis(1, mgp=c(3, .3, 0))

Paul


Lapointe, Pierre wrote:

Hello,

I want to reduce the distance between my ticks and their labels.   I managed
to do it for the x-axis, but the y-axis puzzles me.  Here's an example where
there is no space between the x-asix ticks and labels.

par(las=1)
plot(runif(50), type=l,xaxt=n,yaxt=n,ylab=, bty=l)
axis(2)
axis(1,padj=-1.5)

#However, 
axis(2,padj=-1.5) #does not work


I understand from ?axis that padj will take its direction from the par(las).
In this case, padj will move labels up and down for both x-axis and y-axis.
I want my y-axis labels to be horizontal.

I can I reduce the distance between y-axis ticks and labels? 



Regards,

Pierre Lapointe
Assistant Market Strategist



*** 
AVIS DE NON-RESPONSABILITE:\ Ce document transmis par courri...{{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



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

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


[R] PAN: Need Help for Multiple Imputation Package

2005-05-25 Thread AC
Hello all.  I am trying to run PAN, multilevel
multiple imputation program, in R to impute missing
data in a longitudinal dataset.  I could successfully
run the multiple imputation when I only imputed one
variable.  However, when I tried to impute a
time-varying covariate as well as a response variable,
I received an error message, “Error: subscript out of
bounds.”  Can anyone tell if my commands contain any
mistakes?

First I imported SAS dataset ‘sim’ which includes a
response variable ‘MIY1’, a time-varying covariate
‘TCOV1’, TIME, GROUP (0 or 1), and ID.  200
participants were included and measurement occurred
six times.  Approximately 25% of participants dropped
out at end.  

 sim - read.xport('c:\\xptds.dat')
 
 int - rep(1,1200)
 y - cbind(sim$MIY1,sim$TCOV1)
 subj - sim$ID
 pred - cbind(int, sim$TIME, sim$GROUP)  
 
 xcol - 1:3
 zcol - 1

 prior - list(a=2,Binv=4,c=2,Dinv=4)

 result -
pan(y,subj,pred,xcol,zcol,prior,seed=13579,iter=1000)
Error: subscript out of bounds


By the way, I also received the same error message
when I tried to include intercept and time in Zcol, a
matrix for random effect specification.  I used
command “ zcol - 1:2”.  Does anybody know if this
error is due to sample size/proportion of missing data
or due to command mistake?

I truly appreciate any feedbacks.
Best regards,
Eishi

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


RE: [R] precision problem

2005-05-25 Thread John Fox
Dear Omar,

It wasn't clear to me from your original question that you wanted to test
that *all* the corresponding entries were equal, as opposed to each
individual entry.

In any event, I don't think that you'll find a similar function for testing
inequality, so you can do as you suggest, but of course without abs().

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 Omar Lakkis
 Sent: Wednesday, May 25, 2005 10:08 AM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] precision problem
 
 all.equal is helpful when I am comparing equality of two matrices.
 However, when I am comparing two individual number with  or 
  is my best bet doing if( abs(x - y)  tolerence) or is 
 there a function like all.equal that has the same default tolerence?
 
 On 5/25/05, Omar Lakkis [EMAIL PROTECTED] wrote:
  Thank you all.
  all.equal is very helpful since I am also interested in finding the 
  mismatched prices.
  
  On 5/25/05, John Fox [EMAIL PROTECTED] wrote:
   Dear Omar,
  
   Perhaps I'm missing something, but why not just subtract 
 one matrix 
   from the other and test the difference in relation to the 
 precision 
   that you require for the comparison? E.g., to test near equality, 
   something like, abs(A - B)  1e-13.
  
   I hope this helps,
John
  
   
   John Fox
   Department of Sociology
   McMaster University
   Hamilton, Ontario
   Canada L8S 4M4
   905-525-9140x23604
   http://socserv.mcmaster.ca/jfox
   
  
-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
 Omar Lakkis
Sent: Wednesday, May 25, 2005 9:09 AM
To: r-help@stat.math.ethz.ch
Subject: [R] precision problem
   
I have prices that I am finding difficult to compare with ==,
 and , due to precision. For example: the numbers should
match, with '==', but they differ in the magnitude of 
 1e-14 due to 
bunch of calculations that I run on them. Programming 
 with java, I 
am used to implementing a function that compares the difference 
between the numbers to a pre determined precision factor. This 
could be very slow when  I have two matrices of numbers that I 
could otherwise compare with a simple '==', ''  or '' in R.
What is teh best solution for this problem?
Can I control the precision of ==,  and  without having to 
reimplement the operations in a slow way?
   
__
R-help@stat.math.ethz.ch mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
  
  
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html

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


[R] Useful tip: Use Google to find R scripts

2005-05-25 Thread Lapointe, Pierre
Hello,

Ever wondered how people use a particular function in their programs?  Use
Google to find actual scripts:

filetype:R boxplot

will return real R scripts using the boxplot function.

Regards,

Pierre Lapointe
Assistant Market Strategist



***
 
AVIS DE NON-RESPONSABILITE:\ Ce document transmis par courri...{{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


Re: [R] aggregate and stack

2005-05-25 Thread Stephen D. Weigand

Dear Paulo,

On May 25, 2005, at 8:01 PM, Paulo Brando wrote:


Dear All,

I have tried to calculate tree mean growth but I think the structure I  
used below (growthresumo) is not the most elegant, even though it  
worked. The only problem I had in this first part was that  I cannot  
use 'summary', just 'mean' (sorry but 'R' is pretty new for me).




In case you didn't notice, help(aggregate) indicates that 'FUN'
should be a scalar function, so summary won't work for that reason.

growthresumo -  
aggregate(growth[,c(16,19,23,27,31,35,39,43,47,52,56,60,64,68,72,76,81 
,85,89,93,97,101,105,109,113,117,121,125,129,133,137,
141,145,149,153,157,161,165,169,173,177,181,185,189,194,197,201,205,209 
,213,217,221,225,229,233,237,241)],

by=(growth[,c(3,8)]),MEAN,na.rm=TRUE)



It's hard to know where 'growth' came from. Is it your own data.frame,
or from a package? It's better to provide a reproducible or toy example
(as you'll often read here).

#after growth is calculated, I want to stack the results in just one  
colunm.


growthvertical - c(growthresumo[,3],...,growthresumo[,50]) # this is  
very time consuming though




This comes to my mind:

as.vector(as.matrix(growthresumo[,3:50]))

but look up the help on stack() because it's a very powerful tool that
is aptly named (and might do everything you want).


Parcel - c(C9,S8...C9,S8) # 50 items




rep() could help with the above.


date  c(DATE1DATE50)




paste() will help with this.


growthpermonth - data.frame(Parcel, Date, growthvertical)


Thank you very much!


Good luck with R!

Stephen

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


[R] estimating p values bootstrap regression

2005-05-25 Thread Roberto Edmundo Munguia Steyer
Dear R-users:

I have a basic question.

I am trying to estimate the gradients of sexual selection on the males of a 
waterbug species.I performed a bootstrap analysis on a multiple regression 
using library boot and obtained the estimated coefficents and their respective 
standard errors. 

eri-read.table(D:/efi/er2.txt,header=T)
grad1-eri
grad1$fit-fitted(gradi)
grad1$res-resid(gradi)
grad.fit-function(data){
mod-lm(data$huevrel~data$slongitud*data$sabdomen*data$saparcap, 
weights=data$presencia, data=eri)
c(coef(mod),
summary(mod)$coef[,2]^2)}

gmodfun-function(d,i){
d$huevrel-d$fit+d$res[i]
grad.fit(d)}
grandi-boot(grad1,gmodfun, R=999)
grandi


I was wondering if there is a way to estimate p-values in order to know wich 
independent variables are significant. Would be correct to add the bias to the 
regression coefficients and divide with de SE to obtain a t value and use pt 
function eg (1 - pt(abs(1.51),211))*2 in order to get the p values? 

Thanks a lot for your help.

Roberto
I use R 2.1, Windows XP.
 

Departamento de Biologia Evolutiva
Instituto de Ecología, A.C.
Km 2.5 Carretera antigua a Coatepec
Ap. Postal 63 (excepto mensajería)
Xalapa, Veracruz 91000
MEXICO
Tel. (52)(228)8421800 ext.3009


 


-
Instituto de Ecología, A. C.
http://www.ecologia.edu.mx

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