[R] Incompatibility with VGAM

2005-05-29 Thread Kjetil Brinchmann Halvorsen

I just discovered that when the VGAM package (not on CRAN) is loaded,
glm() doesn't work. This is because VGAM defines a family function() 
which gets found

by glm() in place of the family function from stats.
Then VGAM:::family returns an object which doesn't have a $family 
component, (it has a component

$vfamily).

I thought namespaces should protect us from this happening?

Kjetil

--

Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
  --  Mahdi Elmandjra





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

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


RE: [R] Errors in Variables

2005-05-29 Thread John Fox
Dear Spencer,

The reason that I didn't respond to the original posting (I'm the author of
the sem package), that that without additional information (such as the
error variance of x), a model with error in both x and y will be
underidentified (unless there are multiple indicators of x, which didn't
seem to be the case here). I figured that what Jacob had in mind was
something like minimizing the least (orthogonal) distance of the points to
the regression line (implying by the way that x and y are on the same scale
or somehow standardized), which isn't doable with sem as far as I'm aware.

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 Spencer Graves
 Sent: Saturday, May 28, 2005 4:47 PM
 To: Eric-Olivier Le Bigot
 Cc: r-help@stat.math.ethz.ch; Jacob van Wyk
 Subject: Re: [R] Errors in Variables
 
 I'm sorry, I have not followed this thread, but I 
 wonder if you have considered library(sem), structural 
 equations modeling?  Errors in variables problems are the 
 canonical special case.
 
 Also, have you done a search of www.r-project.org 
 - search - R site search for terms like errors in 
 variables regression?  This just led me to ODRpack, which 
 is NOT a CRAN package but is apparently available after a 
 Google search.  If it were my problem, I'd first try to 
 figure out sem;  if that seemed too difficult, I might then 
 look at ODRpack.
 
 Also, have you read the posting guide! 
 http://www.R-project.org/posting-guide.html?  This suggests, 
 among other things, that you provide a toy example that a 
 potential respondant could easily copy from your email, test 
 a few modifications, and prase a reply in a minute or so.  
 This also helps clarify your question so any respondants are 
 more likely to suggest something that is actually useful to 
 you.  Moreover, many people have reported that they were able 
 to answer their own question in the course of preparing a 
 question for this list using the posting guide.
 
 hope this helps.  spencer graves
 
 Eric-Olivier Le Bigot wrote:
 
  I'm interested in this 2D line fitting too!  I've been looking, 
  without success, in the list of R packages.
  
  It might be possible to implement quite easily some of the 
 formalism 
  that you can find in Numerical Recipes (Fortran 77, 2nd ed.), 
  paragraph 15.3.  As a matter of fact, I did this in R but 
 only for a 
  model of the form y ~ x (with a given covariance matrix 
 between x and 
  y).  I can send you the R code (preliminary version: I 
 wrote it yesterday), if you want.
  
  Another interesting reference might be Am. J. Phys. 60, p. 
 66 (1992).  
  But, again, you would have to implement things by yourself.
  
  All the best,
  
  EOL
  
  -- 
  Dr. Eric-Olivier LE BIGOT (EOL)CNRS 
 Associate Researcher
  
 ~~~o~o
 o~o~~~
  Kastler Brossel Laboratory (LKB)   
 http://www.lkb.ens.fr
  Université P.  M. Curie and Ecole Normale Supérieure, Case 74
  4 place Jussieu  75252 Paris CEDEX 05   
   France
  
 ~~~o~o
 o~o~~~
  office  : 01 44 27 73 67 fax: 
 01 44 27 38 45
  ECR room: 01 44 27 47 12  x-ray room: 
 01 44 27 63 00
  home: 01 73 74 61 87  For int'l calls: 33 + number 
 without leading 0
  
  
  On Wed, 25 May 2005, Jacob van Wyk wrote:
  
  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] Incompatibility with VGAM

2005-05-29 Thread Uwe Ligges

Kjetil Brinchmann Halvorsen wrote:

I just discovered that when the VGAM package (not on CRAN) is loaded,
glm() doesn't work. This is because VGAM defines a family function() 
which gets found

by glm() in place of the family function from stats.
Then VGAM:::family returns an object which doesn't have a $family 
component, (it has a component

$vfamily).

I thought namespaces should protect us from this happening?



Yes and no:

Yes: The namespace would protect you if glm would call internally the 
family function such as poisson().


No: Probably you have asked something like glm(., family=poisson()). 
Now the first instance of poisson() in the search path is used. You are 
passing a call to poisson(), and this is not bound to any namespace. Of 
course you can specify tha namespace such as

glm(., family=stats::poisson()).

Uwe Ligges




Kjetil



__
R-help@stat.math.ethz.ch 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] Incompatibility with VGAM

2005-05-29 Thread Gabor Grothendieck
As a workaround you could try detaching and re-attaching vgam 
before and after running glm.

detach(package:vgam)
glm(...whatever...)
library(vgam)

On 5/28/05, Kjetil Brinchmann Halvorsen [EMAIL PROTECTED] wrote:
 I just discovered that when the VGAM package (not on CRAN) is loaded,
 glm() doesn't work. This is because VGAM defines a family function()
 which gets found
 by glm() in place of the family function from stats.
 Then VGAM:::family returns an object which doesn't have a $family
 component, (it has a component
 $vfamily).
 
 I thought namespaces should protect us from this happening?
 
 Kjetil
 
 --
 
 Kjetil Halvorsen.
 
 Peace is the most effective weapon of mass construction.
   --  Mahdi Elmandjra
 
 
 
 
 
 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


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


[R] text-function: adding text in an x,y-plot

2005-05-29 Thread Helmut Kudrnovsky

Hello R-friends,

i have a question to the text-function.

a little test-dataset for better understanding:

-the dataset was imported with read.table(,header=TRUE)
s1-s10 are the samplenames

var1 var2 var3
s1 112
s2 231
s3 223
s4 543
s5 423
s6 632
s7 854
s8 721
s9 932
s10864

-then i´ve performed a pincipal component analysis with prcomp

-for displaying the result in a x,y-graph i transformed out.pca$x into the 
dataframe points

 points - out.pca$x
 points
   PC1 PC2PC3
s1  -4.7055777 -0.14781544 -0.3683602
s2  -3.1854599  0.19661476  1.5212455
s3  -3.2687980  0.78193513 -0.6352458
s4   0.2278948  1.00061498  0.2164108
s5  -1.4382847  0.02500633 -0.9114340
s6   0.6216283 -0.68606440  0.2071083
s7   3.4951878  1.17343675 -0.3266629
s8   1.0153619 -2.37274378  0.1978058
s9   3.3673983 -1.82145761 -0.2071739
s10  3.8706492  1.85047328  0.3063065

- with plot(points$PC1, points$PC2, type=n) i start a graph without 
displaying anything at the x,y-coordinates


- i want now to display the samplenames at the right x,y-coordinate;  i 
generated a dataframe called lab with the samplenames


 lab
V1
1   s1
2   s2
3   s3
4   s4
5   s5
6   s6
7   s7
8   s8
9   s9
10 s10

- i´ve studied the text-helppage and so i tried the following:

text(pca$PC1, pca$PC2, labels=lab)

- in the plot there is now c(1,3,4,5,6,7,8,9,10,2) displayed instead of s1-s10

is out there any idea what i'am doing wrong? is there maybe another way of 
displaying the samplenames at the right x,y-coordinate?


greetings from the sunny tirol with thanks in advance
helli

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

__
R-help@stat.math.ethz.ch 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] text-function: adding text in an x,y-plot

2005-05-29 Thread Uwe Ligges

Helmut Kudrnovsky wrote:


Hello R-friends,

i have a question to the text-function.

a little test-dataset for better understanding:

-the dataset was imported with read.table(,header=TRUE)
s1-s10 are the samplenames

var1 var2 var3
s1 112
s2 231
s3 223
s4 543
s5 423
s6 632
s7 854
s8 721
s9 932
s10864

-then i´ve performed a pincipal component analysis with prcomp

-for displaying the result in a x,y-graph i transformed out.pca$x into 
the dataframe points

 points - out.pca$x
  points
   PC1 PC2PC3
s1  -4.7055777 -0.14781544 -0.3683602
s2  -3.1854599  0.19661476  1.5212455
s3  -3.2687980  0.78193513 -0.6352458
s4   0.2278948  1.00061498  0.2164108
s5  -1.4382847  0.02500633 -0.9114340
s6   0.6216283 -0.68606440  0.2071083
s7   3.4951878  1.17343675 -0.3266629
s8   1.0153619 -2.37274378  0.1978058
s9   3.3673983 -1.82145761 -0.2071739
s10  3.8706492  1.85047328  0.3063065

- with plot(points$PC1, points$PC2, type=n) i start a graph without 
displaying anything at the x,y-coordinates


I think points should be a matrix rather than a list or data.frame, 
hence the code above won't work. Instead:



 plot(points[,PC1], points[,PC2], type=n)


- i want now to display the samplenames at the right x,y-coordinate;  i 
generated a dataframe called lab with the samplenames


  lab
V1
1   s1
2   s2
3   s3
4   s4
5   s5
6   s6
7   s7
8   s8
9   s9
10 s10

- i´ve studied the text-helppage and so i tried the following:
text(pca$PC1, pca$PC2, labels=lab)


Hmm, what is pca ???


 lab - rownames(points)
 text(points[,PC1], points[,PC2], labels=lab)

works for me.


- in the plot there is now c(1,3,4,5,6,7,8,9,10,2) displayed instead of 
s1-s10


Quite probably you lab was a *factor* ...


is out there any idea what i'am doing wrong? is there maybe another way 
of displaying the samplenames at the right x,y-coordinate?


We cannot say what you did wrong when constructing your plot, but we 
know that your descibtion above is wrong, because it does not even work 
to generate the empty plot the way ...


Please read the posting guide and rethink at least one time whether the 
code you are giving us is reproducible. Your code was not.


Uwe Ligges




greetings from the sunny tirol with thanks in advance
helli

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

__
R-help@stat.math.ethz.ch 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] text-function: adding text in an x,y-plot

2005-05-29 Thread John Fox
Dear Helmut,

The problem is that you're implicitly coercing the entire data frame lab to
character, producing

 as.character(lab)
[1] c(1, 3, 4, 5, 6, 7, 8, 9, 10, 2)

The numbers themselves come from the numeric coding of the factor V1 in this
data frame; as.numeric(lab$V1) shows you what's going on.

Instead you could specify labels=lab$V1 in the text() command. But why put
the row names in a data frame in the first place; why not simply use
labels=rownames(out.pca)?

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 Helmut 
 Kudrnovsky
 Sent: Sunday, May 29, 2005 11:08 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] text-function: adding text in an x,y-plot
 
 Hello R-friends,
 
 i have a question to the text-function.
 
 a little test-dataset for better understanding:
 
 -the dataset was imported with read.table(,header=TRUE) 
 s1-s10 are the samplenames
 
  var1 var2 var3
 s1 112
 s2 231
 s3 223
 s4 543
 s5 423
 s6 632
 s7 854
 s8 721
 s9 932
 s10864
 
 -then i´ve performed a pincipal component analysis with prcomp
 
 -for displaying the result in a x,y-graph i transformed 
 out.pca$x into the dataframe points
   points - out.pca$x
   points
 PC1 PC2PC3
 s1  -4.7055777 -0.14781544 -0.3683602
 s2  -3.1854599  0.19661476  1.5212455
 s3  -3.2687980  0.78193513 -0.6352458
 s4   0.2278948  1.00061498  0.2164108
 s5  -1.4382847  0.02500633 -0.9114340
 s6   0.6216283 -0.68606440  0.2071083
 s7   3.4951878  1.17343675 -0.3266629
 s8   1.0153619 -2.37274378  0.1978058
 s9   3.3673983 -1.82145761 -0.2071739
 s10  3.8706492  1.85047328  0.3063065
 
 - with plot(points$PC1, points$PC2, type=n) i start a graph 
 without displaying anything at the x,y-coordinates
 
 - i want now to display the samplenames at the right 
 x,y-coordinate;  i generated a dataframe called lab with the 
 samplenames
 
   lab
  V1
 1   s1
 2   s2
 3   s3
 4   s4
 5   s5
 6   s6
 7   s7
 8   s8
 9   s9
 10 s10
 
 - i´ve studied the text-helppage and so i tried the following:
 
 text(pca$PC1, pca$PC2, labels=lab)
 
 - in the plot there is now c(1,3,4,5,6,7,8,9,10,2) displayed 
 instead of s1-s10
 
 is out there any idea what i'am doing wrong? is there maybe 
 another way of displaying the samplenames at the right x,y-coordinate?
 
 greetings from the sunny tirol with thanks in advance helli
 
 platform i386-pc-mingw32
 arch i386
 os   mingw32 - win xp
 system   i386, mingw32
 status
 major2
 minor1.0
 year 2005
 month04
 day  18
 language R
 
 __
 R-help@stat.math.ethz.ch 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] R GUI for Linux?

2005-05-29 Thread Robert Citek


Hello all,

I noticed that both Windows and OS X version of R have a GUI  
(Rconsole).  Is there a GUI for Linux?  I'm running Debian on which  
the CLI for R works just fine.


Regards,
- Robert

__
R-help@stat.math.ethz.ch 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 GUI for Linux?

2005-05-29 Thread Sander Oom

HI Robert,

Of course Linux already has a console! Just type R in the Terminal 
console and R will start (assuming all is installed correctly). Graphics 
will be launched in separate windows.


If you want more then the Terminal console, try:

http://www.sciviews.org/_rgui/

Good luck,

Sander.

Robert Citek wrote:


Hello all,

I noticed that both Windows and OS X version of R have a GUI  
(Rconsole).  Is there a GUI for Linux?  I'm running Debian on which  the 
CLI for R works just fine.


Regards,
- Robert

__
R-help@stat.math.ethz.ch 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 Sander P. Oom
Animal, Plant and Environmental Sciences,
University of the Witwatersrand
Private Bag 3, Wits 2050, South Africa
Tel (work)  +27 (0)11 717 64 04
Tel (home)  +27 (0)18 297 44 51
Fax +27 (0)18 299 24 64
Email   [EMAIL PROTECTED]
Web www.oomvanlieshout.net/sander

__
R-help@stat.math.ethz.ch 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] Forcing ticks in plot for hclust object outside the limits

2005-05-29 Thread Aleš Žiberna
Thank you very much for your reply and your *dirty* sloution, which does the 
trick for me!


Ale iberna


- Original Message - 
From: Uwe Ligges [EMAIL PROTECTED]

To: Ale iberna [EMAIL PROTECTED]
Cc: R-help r-help@stat.math.ethz.ch
Sent: Saturday, May 28, 2005 7:58 PM
Subject: Re: [R] Forcing ticks in plot for hclust object outside the limits



Ale iberna wrote:

Hello!

I have the following problem.

I would like to plot the hclust object hcd (bellow, at the end of the 
mail) with ticks at seq(0.05,0.25,by=0.05). I tried using the code

plot(hcd)
and
plot(hcd,axes=FALSE)
axis(2,seq(0.05,0.25,by=0.05))

In both cases, the resoult is the same, ticks at 0.05 and 0.25 are not 
printed. I tried changing the ylim argumet in plot, however I got a 
warning parameter ylim couldn't be set in high-level plot() function.


I would like to force those two ticks. Can this be done with axis or 
plot, or should I use lines?



Not easy with the plot method for a hclust object, because 0.05 and 0.25 
are getting clipped, because they are out od the usr coordinated of the 
plot.


Of course you could hack plot.hclust (in Namespace stats) by modifying 
.../R/library/src/stats/R/hclust.R as follows (in order to provide a 
proper ylim argument):


diff hclust.R-orig hclust.R

91c91,92
   sub = NULL, xlab = NULL, ylab = Height, ...)
---
   sub = NULL, xlab = NULL, ylab = Height,
   ylim = NULL, ...)
116c117,120
 .Internal(dend.window(n, merge, height, hang, labels, ...))
---
 height2 - height
 if(!is.null(ylim))
 height2 - c(range(ylim), rep(ylim[1], length(height) - 2))
 .Internal(dend.window(n, merge, height2, hang, labels, ...))


Note that this quick hack is a *dirty* solution.

Uwe Ligges





Thanks in advance for any suggestions!
Ale iberna


hcd -
structure(list(merge = structure(as.integer(c(-4, -5, -1, -7,
-6, -10, -3, -12, -8, -2, 8, 1, -9, -11, 2, 3, -13, 4, 6, 5,
7, 9, 10, 11)), .Dim = as.integer(c(12, 2))), height = 
c(0.0906288626438465,
0.10278145998519, 0.114885217561497, 0.127812745765521, 
0.13237798522,
0.168594637784091, 0.177187802444346, 0.209803430657638, 
0.210361529934791,
0.218946973173863, 0.234000873708654, 0.235702383243089), order = 
as.integer(c(4,
9, 12, 6, 13, 2, 8, 3, 10, 7, 1, 5, 11)), labels = NULL, method = 
single,
   call = quote(hclust(d = d, method = single)), dist.method = NULL), 
.Names = c(merge,
height, order, labels, method, call, dist.method), class = 
hclust)


__
R-help@stat.math.ethz.ch 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] R GUI for Linux?

2005-05-29 Thread Dirk Eddelbuettel

On 29 May 2005 at 12:13, Robert Citek wrote:
| 
| Hello all,
| 
| I noticed that both Windows and OS X version of R have a GUI  
| (Rconsole).  Is there a GUI for Linux?  I'm running Debian on which  
| the CLI for R works just fine.


$ apt-get install r-gnome ## works up until R 2.0.1
$ R --gui=gnome 

That said, as of R 2.1.0, the Gnome UI is no longer shipped with the R
sources. Hence, I no longer provide it in the r-gnome package.  However, the
code is now provided in an add-one package 'gnomeGUI' on CRAN which you could
install directly.

Hope this helps, Dirk

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
 -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'

__
R-help@stat.math.ethz.ch 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 GUI for Linux?

2005-05-29 Thread Gabor Grothendieck
Check out the JGR link on the web page mentioned by Sander below.

On 5/29/05, Sander Oom [EMAIL PROTECTED] wrote:
 HI Robert,
 
 Of course Linux already has a console! Just type R in the Terminal
 console and R will start (assuming all is installed correctly). Graphics
 will be launched in separate windows.
 
 If you want more then the Terminal console, try:
 
 http://www.sciviews.org/_rgui/
 
 Good luck,
 
 Sander.
 
 Robert Citek wrote:
 
  Hello all,
 
  I noticed that both Windows and OS X version of R have a GUI
  (Rconsole).  Is there a GUI for Linux?  I'm running Debian on which  the
  CLI for R works just fine.
 
  Regards,
  - Robert
 
  __
  R-help@stat.math.ethz.ch 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 Sander P. Oom
 Animal, Plant and Environmental Sciences,
 University of the Witwatersrand
 Private Bag 3, Wits 2050, South Africa
 Tel (work)  +27 (0)11 717 64 04
 Tel (home)  +27 (0)18 297 44 51
 Fax +27 (0)18 299 24 64
 Email   [EMAIL PROTECTED]
 Web www.oomvanlieshout.net/sander
 
 __
 R-help@stat.math.ethz.ch 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] get the bug context

2005-05-29 Thread Luke
Hi R-users,

How to get a bug contex? 

My R code ran there for several hours, but a bug crashed it, printing
such message like Error: subscript out of bounds. I want to use
browser() to catch the bug, but I don't know which loop caused the bug
(there are many loops in the code). I even don't know which line of
code caused the bug. Is there any utility or something in R which can
let you know which line of code causes a bug?

Thanks,

-Luke

__
R-help@stat.math.ethz.ch 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] get the bug context

2005-05-29 Thread Uwe Ligges

Luke wrote:

Hi R-users,

How to get a bug contex? 


My R code ran there for several hours, but a bug crashed it, printing
such message like Error: subscript out of bounds. I want to use
browser() to catch the bug, but I don't know which loop caused the bug
(there are many loops in the code). I even don't know which line of
code caused the bug. Is there any utility or something in R which can
let you know which line of code causes a bug?


No, but ...

Have you tried traceback() to see which function is the culprit?

You can also set options(error = recover) to look at the objects at the 
time the error occured. Maybe you see which object is already defined 
and can derive the point of the error that way.


Uwe Ligges




Thanks,

-Luke

__
R-help@stat.math.ethz.ch 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] Errors in Variables

2005-05-29 Thread Spencer Graves

Hi, John:

	  Thanks for the clarification.  I know that the errors in X problem 
requires additional information, most commonly one of the variances or 
the correlation.  The question I saw (below) indicated he had tried 
model of the form y ~ x (with a given covariance matrix ...), which 
made me think of sem.


	  If he wants the least (orthogonal) distance, could he could get it 
indirectly from sem by calling sem repeatedly giving, say, a 
variance for x, then averaging the variances of x and y and trying 
that in sem?


	  Also, what do you know about ODRpack?  It looks like that might 
solve the least (orthogonal) distance.


  Thanks again for your note, John.
  Best Wishes,
  Spencer Graves

John Fox wrote:


Dear Spencer,

The reason that I didn't respond to the original posting (I'm the author of
the sem package), that that without additional information (such as the
error variance of x), a model with error in both x and y will be
underidentified (unless there are multiple indicators of x, which didn't
seem to be the case here). I figured that what Jacob had in mind was
something like minimizing the least (orthogonal) distance of the points to
the regression line (implying by the way that x and y are on the same scale
or somehow standardized), which isn't doable with sem as far as I'm aware.

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

Sent: Saturday, May 28, 2005 4:47 PM
To: Eric-Olivier Le Bigot
Cc: r-help@stat.math.ethz.ch; Jacob van Wyk
Subject: Re: [R] Errors in Variables

	  I'm sorry, I have not followed this thread, but I 
wonder if you have considered library(sem), structural 
equations modeling?  Errors in variables problems are the 
canonical special case.


	  Also, have you done a search of www.r-project.org 
- search - R site search for terms like errors in 
variables regression?  This just led me to ODRpack, which 
is NOT a CRAN package but is apparently available after a 
Google search.  If it were my problem, I'd first try to 
figure out sem;  if that seemed too difficult, I might then 
look at ODRpack.


	  Also, have you read the posting guide! 
http://www.R-project.org/posting-guide.html?  This suggests, 
among other things, that you provide a toy example that a 
potential respondant could easily copy from your email, test 
a few modifications, and prase a reply in a minute or so.  
This also helps clarify your question so any respondants are 
more likely to suggest something that is actually useful to 
you.  Moreover, many people have reported that they were able 
to answer their own question in the course of preparing a 
question for this list using the posting guide.


  hope this helps.  spencer graves

Eric-Olivier Le Bigot wrote:


I'm interested in this 2D line fitting too!  I've been looking, 
without success, in the list of R packages.


It might be possible to implement quite easily some of the 


formalism 

that you can find in Numerical Recipes (Fortran 77, 2nd ed.), 
paragraph 15.3.  As a matter of fact, I did this in R but 


only for a 

model of the form y ~ x (with a given covariance matrix 


between x and 

y).  I can send you the R code (preliminary version: I 


wrote it yesterday), if you want.

Another interesting reference might be Am. J. Phys. 60, p. 


66 (1992).  


But, again, you would have to implement things by yourself.

All the best,

EOL

--
Dr. Eric-Olivier LE BIGOT (EOL)CNRS 


Associate Researcher

~~~o~o
o~o~~~

Kastler Brossel Laboratory (LKB)   


http://www.lkb.ens.fr


Université P.  M. Curie and Ecole Normale Supérieure, Case 74
4 place Jussieu  75252 Paris CEDEX 05   


 France

~~~o~o
o~o~~~

office  : 01 44 27 73 67 fax: 


01 44 27 38 45

ECR room: 01 44 27 47 12  x-ray room: 


01 44 27 63 00

home: 01 73 74 61 87  For int'l calls: 33 + number 


without leading 0



On Wed, 25 May 2005, Jacob van Wyk wrote:



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 

RE: [R] Errors in Variables

2005-05-29 Thread John Fox
Dear Spencer,

 -Original Message-
 From: Spencer Graves [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, May 29, 2005 4:13 PM
 To: John Fox
 Cc: r-help@stat.math.ethz.ch; 'Jacob van Wyk'; 'Eric-Olivier Le Bigot'
 Subject: Re: [R] Errors in Variables
 
 Hi, John:
 
 Thanks for the clarification.  I know that the 
 errors in X problem 
 requires additional information, most commonly one of the 
 variances or the correlation.  The question I saw (below) 
 indicated he had tried model of the form y ~ x (with a given 
 covariance matrix ...), which made me think of sem.
 
 If he wants the least (orthogonal) distance, could 
 he could get it indirectly from sem by calling sem 
 repeatedly giving, say, a variance for x, then averaging 
 the variances of x and y and trying that in sem?
 

I'm not sure how that would work, but seems similar to averaging the
regressions of y on x and x on y.

 Also, what do you know about ODRpack?  It looks 
 like that might solve the least (orthogonal) distance.
 

I'm not familiar with ODRpack, but it seems to me that one could fairly
simply minimize the sum of squared least distances using, e.g., optim.

Regards,
 John

 Thanks again for your note, John.
 Best Wishes,
 Spencer Graves
 
 John Fox wrote:
 
  Dear Spencer,
  
  The reason that I didn't respond to the original posting (I'm the 
  author of the sem package), that that without additional 
 information 
  (such as the error variance of x), a model with error in 
 both x and y 
  will be underidentified (unless there are multiple indicators of x, 
  which didn't seem to be the case here). I figured that what 
 Jacob had 
  in mind was something like minimizing the least 
 (orthogonal) distance 
  of the points to the regression line (implying by the way 
 that x and y 
  are on the same scale or somehow standardized), which isn't 
 doable with sem as far as I'm aware.
  
  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 
 Spencer Graves
 Sent: Saturday, May 28, 2005 4:47 PM
 To: Eric-Olivier Le Bigot
 Cc: r-help@stat.math.ethz.ch; Jacob van Wyk
 Subject: Re: [R] Errors in Variables
 
   I'm sorry, I have not followed this thread, but I 
 wonder if you 
 have considered library(sem), structural equations modeling?  
 Errors in variables problems are the canonical special case.
 
   Also, have you done a search of www.r-project.org 
 - search - R site search for terms like errors in
 variables regression?  This just led me to ODRpack, 
 which is NOT a 
 CRAN package but is apparently available after a Google 
 search.  If it 
 were my problem, I'd first try to figure out sem;  if that seemed 
 too difficult, I might then look at ODRpack.
 
   Also, have you read the posting guide! 
 http://www.R-project.org/posting-guide.html?  This suggests, among 
 other things, that you provide a toy example that a potential 
 respondant could easily copy from your email, test a few 
 modifications, and prase a reply in a minute or so.
 This also helps clarify your question so any respondants are more 
 likely to suggest something that is actually useful to you. 
  Moreover, 
 many people have reported that they were able to answer their own 
 question in the course of preparing a question for this 
 list using the 
 posting guide.
 
   hope this helps.  spencer graves
 
 Eric-Olivier Le Bigot wrote:
 
 
 I'm interested in this 2D line fitting too!  I've been looking, 
 without success, in the list of R packages.
 
 It might be possible to implement quite easily some of the
 
 formalism
 
 that you can find in Numerical Recipes (Fortran 77, 2nd ed.), 
 paragraph 15.3.  As a matter of fact, I did this in R but
 
 only for a
 
 model of the form y ~ x (with a given covariance matrix
 
 between x and
 
 y).  I can send you the R code (preliminary version: I
 
 wrote it yesterday), if you want.
 
 Another interesting reference might be Am. J. Phys. 60, p. 
 
 66 (1992).  
 
 But, again, you would have to implement things by yourself.
 
 All the best,
 
 EOL
 
 -- 
 Dr. Eric-Olivier LE BIGOT (EOL)CNRS 
 
 Associate Researcher
 
 ~~~o~o
 o~o~~~
 
 Kastler Brossel Laboratory (LKB)   
 
 http://www.lkb.ens.fr
 
 Université P.  M. Curie and Ecole Normale Supérieure, Case 74
 4 place Jussieu  75252 Paris CEDEX 05   
 
   France
 
 ~~~o~o
 o~o~~~
 
 office  : 01 44 27 73 67 fax: 
 
 01 44 27 38 45
 
 ECR room: 01 44 27 47 12  x-ray room: 
 
 01 44 27 63 00
 
 home: 

[R] joining files after canonical correlation

2005-05-29 Thread Brett Stansfield
Dear R,
I recently did a canonical correlation analysis on two subsets of data
(location and weather). So I now have canonical scores for location and
weather. but I'd now like to do a scatterplot matrix using the pairs
statement. 

Is there a way to somehow join location.U and weather.V to become a new data
set from which I could undertake a scatterplot matrix of the canonical
variates?

brett


Brett Stansfield 
Environmental Scientist - Water Quality 
Hawke's Bay Regional Council 
102 Vautier Street 
Private Bag 6006 
Napier 
Phone (06) 835-9200 extn 9334 
Fax (06) 835-3601

__
R-help@stat.math.ethz.ch 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] Incompatibility with VGAM

2005-05-29 Thread Thomas Yee

Hello,


It seems that if glm used a namespace then the conflict would be avoided?


FYI, I released VGAM 0.6-3 last Friday which has binomial(), poisson()
etc. removed so that it should no longer conflict with glm().  The
families that work under VGAM are called binomialff(), poissonff() etc.
Also, the Windows zip file for VGAM 0.6-3 was built under R 2.1.0.


cheers


Thomas

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



[R] spatially constrained clustering

2005-05-29 Thread Rob Dunne

Hi List,
does anyone know of an implementation of spatially constrained 
clustering in R?


This is where there is a vector of measurements for points on a plane 
and only neighbors can be clustered together. I have tried implementint 
in myself -- but if someone has alkready done it !


I have searched on the obvios terms spatially constrained clustering 
without any luck.



Bye
Rob

__
R-help@stat.math.ethz.ch 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] Nomogram

2005-05-29 Thread Yongfei Wang

Hi, List:

I heard some where about nomogram function in R, which package include 
this function?


Thanks
Yongfei





__
R-help@stat.math.ethz.ch 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] Nomogram

2005-05-29 Thread Spencer Graves
	  From www.r-project.org - search - R site search, I got 40 hits 
for nomogram.  The first one was for a function nomogram in the 
Design library.  I haven't used it, but other people have, and some of 
the other 39 hits might answer other questions you might have in trying 
to use it.


  hope this helps.
  spencer graves
p.s.  Have you read the posting guide! 
http://www.R-project.org/posting-guide.html;?  It has helped others (a) 
find answers to their own questions, and (b) improve the chances that 
they get useful replies when they do ask questions.


Yongfei Wang wrote:


Hi, List:

I heard some where about nomogram function in R, which package include 
this function?


Thanks
Yongfei





__
R-help@stat.math.ethz.ch 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] trouble with cumsum?

2005-05-29 Thread Makram Talih
Dear R users,

I am using R version 2.0.1 (2004/11/15) on an i386-pc-mingw32 platform. I
encounter the following problem while using cumsum:

 a - rep(0.01, 100)
 b - cumsum(a)
 sum(a) == 1
[1] TRUE
 b[100] == 1
[1] FALSE

Am I missing something? Should cumsum have such an outcome?

Thanks in advance for any clarifications any of you can offer.

Regards,

Makram Talih

--
Makram Talih, Ph.D.
Assistant Professor
Department of Mathematics and Statistics
Hunter College of the City University of New York
695 Park Avenue, Room 905 HE
New York, NY 10021

Website: http://stat.hunter.cuny.edu/talih
E-mail: [EMAIL PROTECTED]
Tel: 212-772-5308
Fax: 212-772-4858

__
R-help@stat.math.ethz.ch 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] Nomogram

2005-05-29 Thread Rob Dunne

Spencer Graves wrote:
  From www.r-project.org - search - R site search, I got 40 hits 
for nomogram.  The first one was for a function nomogram in the 
Design library.  I haven't used it, but other people have, and some of 
the other 39 hits might answer other questions you might have in trying 
to use it.


  hope this helps.
  spencer graves
p.s.  Have you read the posting guide! 
http://www.R-project.org/posting-guide.html;?  It has helped others (a) 
find answers to their own questions, and (b) improve the chances that 
they get useful replies when they do ask questions.




Hi list,
   yes I read the posting guide and looked on R site search 
and searched on spatially constrained clustering


I didnt think to search on nomogram which appears to be a totally 
different thing. See


http://en.wikipedia.org/wiki/Nomogram


Bye
Rob

__
R-help@stat.math.ethz.ch 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] trouble with cumsum?

2005-05-29 Thread Dirk Eddelbuettel

On 29 May 2005 at 20:17, Makram Talih wrote:
| Dear R users,
| 
| I am using R version 2.0.1 (2004/11/15) on an i386-pc-mingw32 platform. I
| encounter the following problem while using cumsum:
| 
|  a - rep(0.01, 100)
|  b - cumsum(a)
|  sum(a) == 1
| [1] TRUE
|  b[100] == 1
| [1] FALSE
| 
| Am I missing something? 

Yes, FAQ section 7.31 entitled Why doesn't R think these numbers are equal?.

| Should cumsum have such an outcome?

 a - rep(0.01, 100)
 b - cumsum(a)
 sum(a) == 1
[1] FALSE
 all.equal(sum(a), 1)
[1] TRUE
 all.equal(b[100], 1)
[1] TRUE
 

On my Linux system with R 2.1.0, the first equality fails whereas it worked
for you. Morale: don't forget about floating-point math ...

Hth, Dirk

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
 -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'

__
R-help@stat.math.ethz.ch 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] trouble with cumsum?

2005-05-29 Thread luan_sheng
 R help document showed us that you should not use == for comparing
objects, and you will use all.equal.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Makram Talih
Sent: Monday, May 30, 2005 8:17 AM
To: r-help@stat.math.ethz.ch
Subject: [R] trouble with cumsum?

Dear R users,

I am using R version 2.0.1 (2004/11/15) on an i386-pc-mingw32 platform. I
encounter the following problem while using cumsum:

 a - rep(0.01, 100)
 b - cumsum(a)
 sum(a) == 1
[1] TRUE
 b[100] == 1
[1] FALSE

Am I missing something? Should cumsum have such an outcome?

Thanks in advance for any clarifications any of you can offer.

Regards,

Makram Talih

--
Makram Talih, Ph.D.
Assistant Professor
Department of Mathematics and Statistics Hunter College of the City
University of New York
695 Park Avenue, Room 905 HE
New York, NY 10021

Website: http://stat.hunter.cuny.edu/talih
E-mail: [EMAIL PROTECTED]
Tel: 212-772-5308
Fax: 212-772-4858

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

__

ÑÅ»¢Ãâ·ÑGÓÊÏ䣭ÖйúµÚÒ»¾øÎÞÀ¬»øÓʼþɧÈų¬´óÓÊÏä

__
R-help@stat.math.ethz.ch 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] Nomogram

2005-05-29 Thread Mulholland, Tom
I don't think Spencer replied to your message. It wasn't addressed to you. He 
was replying to a specific post on nomograms. However you might try being less 
specific as a search on spatial cluster gave back 

[R] mclust - clustering by spatial patterns 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/13474.html

[R] Spatial Clustering 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/19480.html amongst others.

I also did a help.search(spatial cluster) which came up with references to 
the package DCluster


Tom

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Rob Dunne
 Sent: Monday, 30 May 2005 8:44 AM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] Nomogram
 
 
 Spencer Graves wrote:
From www.r-project.org - search - R site search, 
 I got 40 hits 
  for nomogram.  The first one was for a function nomogram in the 
  Design library.  I haven't used it, but other people 
 have, and some of 
  the other 39 hits might answer other questions you might 
 have in trying 
  to use it.
  
hope this helps.
spencer graves
  p.s.  Have you read the posting guide! 
  http://www.R-project.org/posting-guide.html;?  It has 
 helped others (a) 
  find answers to their own questions, and (b) improve the 
 chances that 
  they get useful replies when they do ask questions.
 
 
 Hi list,
 yes I read the posting guide and looked on R 
 site search 
 and searched on spatially constrained clustering
 
 I didnt think to search on nomogram which appears to be a totally 
 different thing. See
 
 http://en.wikipedia.org/wiki/Nomogram
 
 
 Bye
 Rob
 
 __
 R-help@stat.math.ethz.ch 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] sapply following using by with a list of factors

2005-05-29 Thread McClatchie, Sam (PIRSA-SARDI)
Background:
OS: Linux Mandrake 10.1
release: R 2.0.0
editor: GNU Emacs 21.3.2
front-end: ESS 5.2.3
-
Colleagues

I am having some trouble extracting results from the function by, used to
average variables in a data.frame first by one factor (depth) and then by a
second factor (station). The real data.frame is quite large 
 dim(data.2001)
[1] 32049  11

Here is a snippet of code:

## bin density data for each station into 1 m depth bins, containing means
data.2001.test$integer.Depth - as.factor(round(data.2001.test$Depth,
digits=0))
attach(data.2001.test)
binned.data.2001 - by(data.2001.test[,5:11], list(depth=integer.Depth,
station=Station), mean)

and here is a snippet of the data.frame

 dim(data.2001.test)
[1] 150  11
 dump(data.2001.test, file=stdout())
data.2001.test -
structure(list(Cruise = structure(as.integer(c(1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), .Label =
Ngerin01, class = factor), 
Station = structure(as.integer(c(2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
4, 4, 4, 4, 4, 4, 4, 5, 5)), .Label = c(a1, a2, a3, 
a4, a5, a6, a7, a8, a9, b1, b2, b3, b4, 
b5, b6, b7, c1, c2, c3, c4, c5, c6, c7, 
d1, d2, d3, d4, d5, d6, e1, e2, e3, e4, 
e5, e6, e7, f1, f2, f3, f4, f5, f6, f7, 
f8, f9, g1, g10, g11, g2, g3, g4, g5, g6, 
g7, g8, g9, gsvc1, gsvc2, gsvc3, gsvc4, gsvc5, 
gsvc6, gsvc7, gsvc8, gsvc9, gsvd1, gsvd2, gsvd3, 
gsvd4, gsvd5, gsvd6, gsvd7, gsvd8, h1, h11, 
h2, h3, h4, h5, h6, h7, h8, h9, i1, i10, 
i2, i3, i4, i5, i6, i7, i8, i9, j1, j10, 
j2, j3, j4, j5, j6, j7, j8, j9, k1, k10, 
k2, k3, k4, k5, k6, k7, k8, k9, l1, l10, 
l11, l12, l2, l3, l4, l5, l6, l7, l8, l9, 
m1, m10, m11, m2, m3, m4, m5, m6, m7, m8, 
m9, mx, n1, n10, n11, n2, n3, n4, n5, n6, 
n7, n8, n9, nx, o1, o10, o11, o13, o2, 
o3, o4, o5, o6, o7, o8, o9, ox, p10, p11, 
p2, p3, p4, p5, p6, p7, p8, p9, px, q1, 
q10, q11, q12, q13, q2, q3, q4, q5, q6, 
q7, q8, q9, qx, r1, r10, r11, r12, r13, 
r14, r15, r2, r3, r4, r5, r6, r7, r8, r9, 
rx, s1, s10, s11, s12, s13, s14, s15, s16, 
s2, s3, s4, s5, s6, s7, s8, s9, sgc1, sgc2, 
sgc3, sgc4, sgc5, sgc6, sgc7, sx, t1, t10, 
t11, t12, t13, t14, t15, t16, t2, t3, t4, 
t5, t6, t7, t8, t9, tx, u1, u10, u11, u12, 
u13, u14, u15, u2, u3, u4, u5, u6, u7, 
u8, u9, ux, v1, v10, v11, v2, v3, v4, v5, 
v6, v7, v8, v9, vx, w2, w3, w4, w5, w6, 
w7, w8, w9, wx, x2, x3, x4, x5, x6, x7, 
x8), class = factor), Lon = c(138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 138.421, 
138.421, 138.421, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 
138.352, 138.352, 138.352, 138.352, 138.352, 138.352, 138.277, 
138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 
138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 
138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 
138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 
138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 138.277, 
138.277, 138.277, 138.277, 138.277, 138.277, 138.201, 138.201
), Lat = c(-35.766, -35.766, -35.766, -35.766, -35.766, -35.766, 
-35.766, -35.766, -35.766, -35.766, -35.766, -35.766, -35.766, 
-35.766, -35.766, -35.766, -35.766, 

Re: [R] sapply following using by with a list of factors

2005-05-29 Thread Gabor Grothendieck
On 5/29/05, McClatchie, Sam (PIRSA-SARDI)
[EMAIL PROTECTED] wrote:
 Background:
 OS: Linux Mandrake 10.1
 release: R 2.0.0
 editor: GNU Emacs 21.3.2
 front-end: ESS 5.2.3
 -
 Colleagues
 
 I am having some trouble extracting results from the function by, used to
 average variables in a data.frame first by one factor (depth) and then by a
 second factor (station). The real data.frame is quite large
  dim(data.2001)
 [1] 32049  11
 
 Here is a snippet of code:
 
 ## bin density data for each station into 1 m depth bins, containing means
data.2001.test$integer.Depth - as.factor(round(data.2001.test$Depth,
 digits=0))
attach(data.2001.test)
binned.data.2001 - by(data.2001.test[,5:11], list(depth=integer.Depth,
 station=Station), mean)
 
 and here is a snippet of the data.frame
 
  dim(data.2001.test)
 [1] 150  11
  dump(data.2001.test, file=stdout())
 data.2001.test -
 structure(list(Cruise = structure(as.integer(c(1, 1, 1, 1, 1,


Try the following.  To keep this short lets just take a subset
of rows called dd.  Also, we drop the Station levels 
that are not being used since this test only uses 2 levels
and there are 288 Station levels in total.  The function that we apply using
by returns a vector consisting of the integer.Depth, Station
and the column means of columns 5 to 10.  (Asking for just the
mean of those, as in your example, would take all the numbers 
in all the columns passed to mean and give back a grand mean
 rather than a mean per column.)   Finally we rbind it all back together.

 # data.2001.test is your data frame including the integer.Depth column
 dd - data.2001.test[50:60,]
 dd$Station - dd$Station[drop = TRUE]
 dd.bin - by(dd, list(dd$integer.Depth, dd$Station), function(x)
+ c(integer.Depth = x$integer.Depth[1], Station = x$Station[1], 
+ colMeans(x[,5:10])))
 do.call(rbind, dd.bin)
 integer.Depth StationDepth Temperature.oC Salinity Fluoresence.Volts
[1,]20   1 23.90167   17.67420 35.47650  1.107433
[2,]21   1 24.75350   17.33355 35.59050  1.060400
[3,] 1   2  5.19000   19.61510 35.54870  0.726500
[4,] 2   2  5.82950   19.61305 35.55025  0.719200
[5,] 3   2  6.81250   19.61300 35.58345  0.741150
[6,] 4   2  7.55000   19.61180 35.60460  0.754600
 Density.kg.m3 Brunt.Vaisala.Freq.cycl.h
[1,]  25.82400 -5.095467
[2,]  25.99820 16.030975
[3,]  25.30560 -6.261240
[4,]  25.31015  4.051561
[5,]  25.33985  8.893225
[6,]  25.35960 -8.167610

__
R-help@stat.math.ethz.ch 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] Re: Vector Manipulation

2005-05-29 Thread ManojW
OK...x[min(which(x!=0)):length(x)] does the trick!

I guess the coffee is slowly but surely working! . 

Manoj
  - Original Message - 
  From: ManojW 
  To: R-help 
  Sent: Monday, May 30, 2005 2:12 PM
  Subject: Re: Vector Manipulation


  I should clarify that I tried x[cumsum(x)!=0] but the problem is that I might 
have negative numbers in the vector that can potentially make cumsum(x) equal 
to zero somewhere down the line in the vector.

  Manoj
- Original Message - 
From: ManojW 
To: R-help 
Sent: Monday, May 30, 2005 2:00 PM
Subject: Vector Manipulation


Dear All,
For any given vector, I want to extract a sub-vector such that the new 
vector skips all zeros, if any , at the start of vector. Is it possible to 
achieve this w/o looping?

E.G : x= c(0,0,1,2,3,4,5,0,0,8,9)
 y= somefunc(x);
 y 
[1]1 2 3 4 5 0 0 8 9

In the example above, I want to skip the two leading zeroes till I hit 
the non-zero (1 in the above case). I also want to retain all zero after the 
first non-zero digit (again 1 in this case).

Hope I am not confusing you guys. Thanks in advance for your help.

Regards

Manoj




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