[R] Trouble compiling XML package

2007-05-18 Thread Wiener, Matthew

Dear Prof. Lang  - 

I am trying to install the XML library on a 64-bit SUSE linux system
(version info below) running 2.4.1.

I have gcc version 3.3.3, and libxml2 version 2.6.7.  I know this is not
current, but I'm on a machine used and administered by others, and
updating libxml2 would require updating libc, and things get pretty
complicated from there.

Trying to install through R (1.9-0), I eventually get the error:
XMLTree.c: In function `xmlBufferWrite': 
XMLTree.c:729: error: void value not ignored as it ought to be 
make: *** [XMLTree.o] Error 1 

I manually downloaded version 1.8-0 and got the same problem.  I took a
look at that part of the code, but do not understand enough to start
tinkering with it.  I was able to install an earlier version a couple of
years ago, and it was extremely useful (thanks!) but the relevant
machine has been decommissioned.

Can you make any suggestions about which component of my system this
might indicate needs to be changed?  I checked the mailing list
archives, but didn't find anything.  I'm hoping there's an alternative
to changing libxml2, with all the cascading requirements that would
bring (and no guarantee, with what I know now, that that's the problem).

Thanks,

Matt Wiener

 version
   _
platform   x86_64-unknown-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)

--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] Trouble compiling XML package [Broadcast]

2007-05-18 Thread Wiener, Matthew
Oops - I see I was unclear.  I'm using R-2.4.1 to install; 1.9.0 is the
version of XML I was trying to load.  I'll try your change - I'm really
using this for reading XML.

Thanks,
Matt

-Original Message-
From: Duncan Temple Lang [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 18, 2007 4:18 PM
To: Wiener, Matthew
Cc: R-help
Subject: Re: [R] Trouble compiling XML package [Broadcast]



Wiener, Matthew wrote:
 Dear Prof. Lang  - 
 
 I am trying to install the XML library on a 64-bit SUSE linux system
 (version info below) running 2.4.1.
 
 I have gcc version 3.3.3, and libxml2 version 2.6.7.  I know this is
not
 current, but I'm on a machine used and administered by others, and
 updating libxml2 would require updating libc, and things get pretty
 complicated from there.
 
 Trying to install through R (1.9-0), 

Wow, that's really old!


 I eventually get the error:
 XMLTree.c: In function `xmlBufferWrite': 
 XMLTree.c:729: error: void value not ignored as it ought to be 
 make: *** [XMLTree.o] Error 1 
 


You might try changing the routine xmlBufferWrite to

static int
xmlBufferWrite (void * context, const char * buffer, int len) {
  xmlBufferAdd((xmlBufferPtr) context, (const xmlChar *) buffer,len);
  return(len);
}

That will work if there are no errors when adding to the buffer.
But this is used when generating XML in a particular way, i.e. using
internal nodes.  So let's just hope that you don't invoke
this code and if you do, that there are no errors.


 I manually downloaded version 1.8-0 and got the same problem.  I took
a
 look at that part of the code, but do not understand enough to start
 tinkering with it.  I was able to install an earlier version a couple
of
 years ago, and it was extremely useful (thanks!) but the relevant
 machine has been decommissioned.
 
 Can you make any suggestions about which component of my system this
 might indicate needs to be changed?  I checked the mailing list
 archives, but didn't find anything.  I'm hoping there's an alternative
 to changing libxml2, with all the cascading requirements that would
 bring (and no guarantee, with what I know now, that that's the
problem).
 
 Thanks,
 
 Matt Wiener
 
 version
_
 platform   x86_64-unknown-linux-gnu
 arch   x86_64
 os linux-gnu
 system x86_64, linux-gnu
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)
 


--
 Notice:  This e-mail message, together with any
attachments,...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] count the # of appearances... [Broadcast]

2007-03-01 Thread Wiener, Matthew
Take a look at table.
Hope this helps,
Matt 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of bunny ,
lautloscrew.com
Sent: Thursday, March 01, 2007 9:20 AM
To: r-help@stat.math.ethz.ch
Subject: [R] count the # of appearances... [Broadcast]

Hi there,

is there a possibility to count the number of appearances of an  
element in a vector ?
i mean of any given element.. deliver all elements which are exactly  
xtimes in this vector ?

thx in advance !!

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




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] problem with throwing lines out of matrix [Broadcast]

2007-03-01 Thread Wiener, Matthew
You didn't' actually tell us what forfact is.  You could try something like 
(untested)

My.matrix - my.matrix[!(my.matrix[, 1] %in% remove.values), , drop = FALSE]

Also, reading some of the introductory R manuals you can find on CRAN in the 
documentation section will really give you a leg up on some of these things.

Hope this helps.

Matt Wiener


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bunny , 
lautloscrew.com
Sent: Thursday, March 01, 2007 2:09 PM
To: r-help@stat.math.ethz.ch
Subject: [R] problem with throwing lines out of matrix [Broadcast]

Dear all,

again i have a problem with special case of dropping lines out of a  
matrix.

i tried the following, where throwout is a vector of length 18 with  
simple id values that should be compared to any

for (k in 1:length(throwout))
{
mymatrix=matrix(mymatrix[-(forfact[k]),],ncol=4)
}


this didnt work and i tried the following to find the error:

mymatrix[,1][mymatrix[,1]==throwout[7]]
this returned me a nice value - everything fine...
but other same other values for throwout didnt work - because the  
throwout value simply is not in this matrix.
but i need the same throwout vector for different matrices - so i  
need to use it.

does anybody have an idea how i can throw out all lines in every of  
my 5 matrices that contain values of the throwout in their first  
column ?
and how to deal with the problem that not every matrix contains all  
throwout values in its first column...

maybe this might help:
in the end all matrices should have the same number of lines.



thx in advance, i´ll keep on trying ;)



[[alternative HTML version deleted]]



--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] count sequence of integers [Broadcast]

2007-02-15 Thread Wiener, Matthew
The function rle will give you what you are looking for.

Hope this helps,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Martin Becker
Sent: Thursday, February 15, 2007 5:52 AM
To: Samuel Kemp
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] count sequence of integers [Broadcast]

Samuel Kemp wrote:
 Hi,

 I would like to be able to count a sequence of numbers. For example,
given a
 vector of the following integers

 (1,1,1,2,2,2,2,3,3,3,3,3,3,1,1,1,1, 3,3)

 the function would return

 (3, 4, 6, 4,2)

 Does anyone have any cool ideas to solve this?

   
Maybe not the most efficient way, but

   count - function (x) diff(c(0,which(diff(x)!=0),length(x)))

should work (for integer sequences!):

   x-c(1,1,1,2,2,2,2,3,3,3,3,3,3,1,1,1,1,3,3)
   count(x)
[1] 3 4 6 4 2

Regards,

  Martin

 Any help appreciated.

 Regards,

 Sam.

   [[alternative HTML version deleted]]

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


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




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] legend in lattice densityplot [Broadcast]

2007-02-14 Thread Wiener, Matthew
From the documentation for xyplot (referred to from densityplot):

The position of the key can be controlled in either of two possible
ways. If a component called space is present, the key is positioned
outside the plot region, in one of the four sides, determined by the
value of space, which can be one of top, bottom, left and right.


Hope this helps,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Albert Vilella
Sent: Wednesday, February 14, 2007 8:46 AM
To: R-help@stat.math.ethz.ch
Subject: Re: [R] legend in lattice densityplot [Broadcast]

How can I place the legend to the left or right of the densityplot? By
default, it goes at the top, and as it is a rather long list, the
density plot only uses half the space of the whole graphic...

On 11/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Me too on Windows XP.

 Its probably just a bug or unimplemented feature in the SVG driver.
 Write to the maintainer of that package

 For a workaround generate fig output and then convert it to svg using
whatever
 fig editor or converter you have.

 (On my windows system I use the free fig2dev converter although it
inserted
 a DOCTYPE statement into the generated SVG file that IE7 did not
recognize
 but once I manually deleted that it displayed ok in IE7.)

 # after producing file01.fig run
 #   fig2dev -L svg file01.fig file01.svg
 # or use some other fig to svg converter or editor
 xfig(file = /file01.fig, onefile = TRUE)
 library(lattice)
 set.seed(1)
 DF - data.frame(x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)),
f = sample(c(A,B,C,D,E),300,replace=TRUE))
 densityplot(~ x, DF, groups = f, auto.key = TRUE, plot.points = FALSE,
  par.settings = list(superpose.line = list(col = c(1,1,2,2), lty =
1:2,
  lwd = c(1,1,1,1,2
 dev.off()


 On 11/30/06, Albert Vilella [EMAIL PROTECTED] wrote:
  Should it be a problem to print this dashed line plots as svgs?
 
  library(RSvgDevice)
  devSVG(file = /home/avilella/file01.svg,
width = 20, height = 16, bg = white, fg = black,
onefile=TRUE,
xmlHeader=TRUE)
  densityplot(...)
  dev.off()
 
  I am getting all the lines as continuous, not dashed...
 
  On 11/30/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
   Yes  by using the lty suboption of superpose.line.
   Here is a modification of the prior example to illustrate:
   We also use lwd as well in this example.
  
   set.seed(1)
   DF - data.frame(x =
c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6)),
  f = sample(c(A,B,C,D,E),300,replace=TRUE))
   library(lattice)
   densityplot(~ x, DF, groups = f, auto.key = TRUE, plot.points =
FALSE,
par.settings = list(superpose.line = list(col = c(1,1,2,2), lty =
1:2,
lwd = c(1,1,1,1,2
  
  
   On 11/30/06, Albert Vilella [EMAIL PROTECTED] wrote:
Can I combine colors and line types? For example, would it be
possible
to have 5 colors per 2 types of lines (continuous and dashed)?
   
On 11/29/06, Chuck Cleland [EMAIL PROTECTED] wrote:
 Albert Vilella wrote:
  Are this legend colors correlated to the plot?

   They are if you rely on the colors in

 trellis.par.get(superpose.line)$col

   If you want different colors you might use trellis.par.set()
to
 temporarily change the colors:

 x - c(rnorm(100,-2,1),rnorm(100,0,1),rnorm(100,2,1))
 f - rep(c(A,B,C), each=100)
 df - data.frame(x,f)
 library(lattice)

 oldpar - trellis.par.get(superpose.line)$col

 trellis.par.set(superpose.line = list(col = heat.colors(3)))

 densityplot(~ x, groups = f, data = df,
  plot.points=FALSE,
  auto.key=TRUE)

 trellis.par.set(superpose.line = list(col = oldpar))

   If you don't require points or lines in the key, you also
could do
 something like this:

 densityplot(~ x, groups = f, data = df,
  plot.points=FALSE,
  key = simpleKey(levels(df$f),
  lines=FALSE,
  points=FALSE,
  col=heat.colors(3)),
  col=heat.colors(3))

   To use your own colors without changing the trellis settings
and to
 get lines or points in the key, you probably need at least to
use key =
 simpleKey() rather than the auto.key argument, and you may
need to look
 into draw.key().  Other people on the list might know simpler
approaches
 for using your own colors in this situation.

  If I do a:
 
  densityplot(~x, groups=f, plot.points=FALSE,
  auto.key=TRUE,col=heat.colors(5))
 
  I get different colors in the legend than the plot...
 
 
  On 11/29/06, Chuck Cleland [EMAIL PROTECTED] wrote:
  Albert Vilella wrote:
   Hi,
  
   I have a densityplot like this:
  
   x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6))
 

Re: [R] matlab style plotting in R [Broadcast]

2007-02-13 Thread Wiener, Matthew
In traditional R graphics, you can take a look at matplot.
You might also want to look at the lattice package.

Hope this helps,

Matt Wiener
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Maria
Vatapitakapha
Sent: Tuesday, February 13, 2007 12:20 PM
To: r-help@stat.math.ethz.ch
Subject: [R] matlab style plotting in R [Broadcast]

Hello

I was wondering how I can achieve matlab style plotting in R,
in the sense that matlab allows you to plot multiple sets of variables
within the same
x-y axes. plot in R does not seem to cater for this. I tried 'overplot'
from
the gplots package but this assumes different y axes for the variables.

any suggestions would be very appreciated

Maria

[[alternative HTML version deleted]]

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




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] R [Broadcast]

2007-02-08 Thread Wiener, Matthew
Hi.  The package you are looking for is not a standard package (that is,
one that gets installed automatically with R).

There is documentation available, though.  From cran
(http://cran.r-project.org), go to manuals, look at R Installation and
Administration, particularly Section 6, which talks about installing
packages.

Briefly:
Install.packages(KernGPLM) might work (in unix or windows).  And on
Windows, you can also download a zip file from cran and use Install
package from local zip file in the menu.

Hope this helps.

Regards,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of magda haggag
Sent: Thursday, February 08, 2007 2:55 PM
To: r-help@stat.math.ethz.ch
Subject: [R] R [Broadcast]

Dear Professor,
   
  I am preparing for a Ph.D in semiparametric regression at Cairo
university in Egypt. Referring to R package KernGPLM, I obtained R
version 2.4.1 but I did not find package KernGPLM. Please, help me how
can I obtain this package. Thanks in advance. 
   
   
  Name: Magda Haggag
  E-mail:  [EMAIL PROTECTED]
  Address: 27, Notrdam Desion st., Gleem, Alexandria, Egypt.

 
-
8:00? 8:25? 8:40?  Find a flick in no time

[[alternative HTML version deleted]]

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




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] help on determining operating system [Broadcast]

2006-12-12 Thread Wiener, Matthew
You can indeed compile and run R directly through the unix layer in Mac
OS (or at least you could about 2 years ago, which was the last time I
tried).

Regards,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Doran, Harold
Sent: Tuesday, December 12, 2006 2:47 PM
To: Kenneth Benoit; LU YING
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] help on determining operating system [Broadcast]

BTW, Mac OS sits on the Darwin unix system. So, you have all the
benefits of Mac and can access unix via the terminal (Steve Jobs is
brilliant). Things like emacs are waiting for you to use on the Mac. I
haven't explored whether one can install R on the Mac and use it via the
unix interface (or whether there is any reason to do so).

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Kenneth Benoit
 Sent: Tuesday, December 12, 2006 2:39 PM
 To: LU YING
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] help on determining operating system
 
 Hi - I don't want to ignite any holy wars, but for 10 years 
 until last year I used Linux, I occasionally use a Windows 
 machine at home, and last year switched to Mac OS.  Of all 
 the GUIs for R out there, the mac is the best by far IMHO.  
 And R on my macbook is faster than on a pentium 4 3.2GHz 
 running either linux or win xp.
 
 Ken
 
 LU YING wrote:
  Dear list,
  
  I am an R user and I also write my own package in 
 R(sometime i need to 
  write  in C), and right now i am thinking about buying a new 
  workstation--and i am trying to decide if i should get 
  a mac with OS X or a linux machine (for example Dell).
  
  I have experience using R on linux (but i have been just a 
 user and never 
  been a admin) but i am hesitating of managing a linux 
 system on my own 
  (btw I would like to have my new workstation to be used as 
 a server), so 
  right now I am leaning toward of buying a Mac Pro. But from 
 the website, 
  it sounds like R doesnt work quite well with Mac operating system 
  yet...so I was wondering if anybody here have any experiences of 
  using/developing R package on a Mac machine? Is it smooth enough?
  
  (oh by the way, i am not a Mac user yet, Windows has been 
 the primary 
  operating system that i used, but after hearing many good things 
  of OS X, I am really interested in switching over.)
  
  any suggestions are appreciated!
  
  Ying
  
  
  Ying Lu
  Assistant Professor
  Dept. Sociology
  U-Colorado at Boulder
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
 
 
 -- 
 Kenneth Benoit
 Associate Professor of Political Science
 Department of Political Science, Trinity College
 Dublin 2, Ireland
 http://benoit.tcd.ie
 Tel: 353-1-608-2491
 Fax: 353-1-677-0546
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] Accessing R from Java [Broadcast]

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

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

 

Hello All,

 

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

Here are my computer specifications :

1.   Windows XP

2.   Java 1.4.0

3.   R 2.2.1

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

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

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

 

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

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

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

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

 

Is there anyway I can call R inside Java code ?

Please help me. Thank you

 

Best regards,

 

Fuad

 


[[alternative HTML version deleted]]

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




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] postcript file / xyplot function [Broadcast]

2006-10-03 Thread Wiener, Matthew
This is FAQ 7.22.  Lattice functions produce graphic objects, which are not
displayed by default. If you print your graph, you should be fine.  Also,
take a look at the documentation for panel.xyplot.  Using type = c(p, r)
should make things simpler.
Regards,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Tuesday, October 03, 2006 8:00 AM
To: R-help@stat.math.ethz.ch
Subject: [R] postcript file / xyplot function [Broadcast]

Hi,

I  would like save a curve in a postscript file.

It when I use a common plot function (plot)

postscript(file=file.eps)
plot(x,y)
dev.off()

It's not working with the  xyplot function (lattice package).

postscript(file=Z,height=8,width=8,horizontal=FALSE)
xyplot(data[,3]~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)
COEFF-coef(lm(log(y)~x))
panel.curve(exp(COEFF[1]+COEFF[2]*x))
dev.off()

Do anyone know how to use the postscript function with a xyplot function ?

Thanks by advance 

Jessica Gervais

[[alternative HTML version deleted]]

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



--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] java R interface [Broadcast]

2006-08-31 Thread Wiener, Matthew
We have successfully used Rserve:  http://stats.math.uni-augsburg.de/Rserve/

Hope this helps,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lu Yuefeng
Sent: Thursday, August 31, 2006 1:24 PM
To: r-help@stat.math.ethz.ch
Subject: [R] java R interface [Broadcast]

Hello all,

I am wondering if you have experience or information about calling R
routines within JAVA? Is it feasible and how to pass the data/results? TXIA!

Yuefeng

[[alternative HTML version deleted]]

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



--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] Plot y ~ x under condition of variable a and b [Broadcast ]

2006-08-25 Thread Wiener, Matthew
It's the |source in your formula that tells lattice to separate them.

If you drop that, you'll get all points without S and P distinguished at
all.  If you add a groups argument, you should get them presented with
different colors/symbols/etc. depending on your trellis settings (warning:
untested code):

par.plot(lnvol~lnden, groups = source,data=dat,sub=as.factor(plotid),col=T)

Hope this helps,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jennystadt
Sent: Friday, August 25, 2006 11:28 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Plot y ~ x under condition of variable a and b [Broadcast]



Hi All,

I want to plot y~ x under the condition of variable a and b. Followed is the
dataset:

 plotid lndenlnvol source
369  9037.0 10.419002 -4.101039226  S
370  9037.0  9.840548 -2.432385723  S
371  9037.0  8.973351 -1.374842169  S
372  9037.0  8.242756 -0.813800113  S
373  9037.0  8.006368 -0.366743413  S
374  9037.0  7.396335 -0.041375532  S
375  9037.0  6.194405  0.744573249  S
376  9038.0 10.417209 -2.938129138  S
377  9038.0  9.709296 -1.906228589  S
378  9038.0  8.581107 -1.187441385  S
379  9038.0  7.539027 -0.748873856  S
380  9038.0  6.866933 -0.228547521  S
381  9038.0  6.672033  0.222818889  S
382  9038.0  6.380123  0.863026089  S
11003.1  7.281089  5.563470357  P
21003.1  7.165854  5.587837467  P
31003.1  7.126938  5.604757978  P
41003.1  6.833951  5.709078555  P
560 3.1  6.634462  5.678818058  P
610 3.2  7.052830  5.534234273  P
710 3.2  6.905777  5.559511276  P
810 3.2  6.885776  5.590614404  P
910 3.2  6.685106  5.716040812  P
10103.2  6.495349  5.631784504  P
11103.3  6.697376  5.414815010  P
12103.3  6.553336  5.441823472  P
13103.3  6.581116  5.455788329  P
14103.3  6.279641  5.543868038  P
15103.3  6.119298  5.528003301  P
16103.4  7.035589  5.783924732  P
17103.4  6.875624  5.798852319  P
18103.4  6.812445  5.807787244  P

I used  par.plot(lnvol~lnden|source,data=dat,sub=as.factor(plotid),col=T);
It gave good plots, but it put the different data sources to separated
graphs, i.e. S and P. What I want is to plot them on the same graph. If
anyone has the experience in doing plotting like this, please kindly give me
some hints. Thanks!

Jen.

[[alternative HTML version deleted]]

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



--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] using split.screen? [Broadcast]

2006-07-18 Thread Wiener, Matthew
This means that the margins for 10 screens would take up more room than you
have - essentially the plot area is being squeezed to nothing.  You can try
reducing your margins using par.

Also, it looks like you're trying to split into 20 screens there.

Hope this helps,

Matt 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bill Shipley
Sent: Tuesday, July 18, 2006 10:02 AM
To: R help list
Subject: [R] using split.screen? [Broadcast]

Hello.  I am having trouble understanding the use of split.screen.  I want
to divide the device surface first into 4 equal screens:
split.screen(figs=c(2,2))
 
This works.
 
I next want to subdivide each of these 4 screens into 10 subscreens.  I do,
for the first of these 4 screens:
 
screen(1,new=T)
and then: split.screen(figs=c(10,2))
 
My understanding is that this should split screen 1 (i.e. top right) into 10
screens within its area.  However, this does not work and I get the
following error message: Error in plot.new() : figure margins too large

Does anyone know what I am doing wrong? 
 

Bill Shipley

 

 

[[alternative HTML version deleted]]

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

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


Re: [R] Handshake exception in Rserve [Broadcast]

2006-07-17 Thread Wiener, Matthew
We had something similar, and as far as I recall the problem turned out to
be that we had not set the config file to allow remote connections.

This would probably be better put on the Rosuda mailing list:
http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel

Hope this helps,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jaydeep chovatia
Sent: Monday, July 17, 2006 12:52 AM
To: r-help@stat.math.ethz.ch
Cc: [EMAIL PROTECTED]
Subject: [R] Handshake exception in Rserve [Broadcast]

Hello,

 

We are facing some problem while calling a Rserve API from our Java client.
The details are as below:

 

1) We have installed Rserve on linux machine Nagarajan(Port: 6311) and
related modules.

 

2) We have started the Rserve in daemon mode perfectly by executing the
comman  R CMD Rserve on the linux machine.

 

But when the Java client executes the statement: Rconnection c = new
Rconnection (Nagrajan, 6311), we are getting an exception: handshake
exception:  expected  32 bytes received -1 byte.

 

It would be really great if you could help us out to resolve the issue or
provide a probable root cause of the problem.

 

Thank you,

Jaydeep

 


DISCLAIMER\ ==\ This e-mail may contain privileged a...{{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] superimposing histograms con't [Broadcast]

2006-06-28 Thread Wiener, Matthew
I wrote some code to do this.  It only works with 2 groups (that's all I
needed), but could probably be generalized.  It got my graph made, and I
haven't needed a graph like this one again, so I never went back to really
clean it up.

It works by first plotting both sets of rectangles, then going back over the
ones that had the first bar totally covered by the second.

Hope this helps,

Matt Wiener


f.back.front.hist -
function(breaks, x1, x2, col1 = gray50, col2 = white,
   lwd = diff(range(mids))/20,
   xlab = , ylab = ,
   leg.text = NULL, ...){
if(length(x1) != length(x2))
  stop(x1 and x2 must have same length)
if(length(x1) != length(breaks) - 1)
  stop(length of breaks must be 1 more than length of x1 and x2)
plot.lim - c(0, max(c(x1, x2)))
mids - 0.5 * (breaks[-1] + breaks[-length(breaks)])
plot(mids, pmax(x1, x2), col = par()$bg, lwd = lwd,
 ylim = plot.lim, xlab = xlab, ylab = ylab,
 cex.axis = 1.5, font.axis = 2, cex.lab = 1.5, font.lab = 2, ...)
rect(breaks[-length(breaks)], 0, breaks[-1], x1, col = col1)
rect(breaks[-length(breaks)], 0, breaks[-1], x2, col = col2)
ind - x1  x2
rect(breaks[-length(breaks)][ind], 0,
 breaks[-1][ind], x1[ind] ,col = col1)
if(!is.null(leg.text))
  legend(mids[1], plot.lim[2], leg.text,
 fill = c(col1, col2), cex = 1.5)

  } 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Miller
Sent: Wednesday, June 28, 2006 4:21 PM
To: 'Bill Shipley'; 'R help list'
Subject: Re: [R] superimposing histograms con't [Broadcast]

I was just thinking about this last night.

I would like to do the same but WITH overlapping.

For example, I graph 2 sets of count data. Say the bars for the 1`s
overlap...I would like to show that with a different shading for the group
that has the higher frequency. For example, it could be black up to a
frequency of 5 followed by diagonal-dashes from 5-7 representing the higher
frequency of a second group.

Thank you,
Jeff Miller



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bill Shipley
Sent: Wednesday, June 28, 2006 3:54 PM
To: R help list
Subject: [R] superimposing histograms con't

Earlier, I posted the following question:
I want to superimpose histograms from three populations onto the same graph,
changing the shading of the bars for each population. After  consulting the
help files and the archives I cannot find out how to do  this (seemly)
simple graph. To be clear, I want
- a single x axis (from -3 to 18)
 - three groups of bars forming the histograms of each population (they
will not overlap much, but this is a detail)
- the bars from each histogram having different shadings or other  visually
distinguishing features.
 
Gabor Grothendieck [EMAIL PROTECTED] pointed to some code to to this
but I have found another way that works even easier.
 
hist(x[sel1],xlim=c(a,b),ylim=c(A,B))  - this plots the histogram for the
first group (indexed by sel1) but with an x axis and a y axis that spans the
entire range.
 
par(new=T)  - to keep on the same graph
 
hist(x[sel2],main=Null,xlab=NULL,ylab=NULL,axes=F) -superimposes the second
histogram
 
par(new=T)  - to keep on the same graph
 
hist(x[sel3],main=Null,xlab=NULL,ylab=NULL,axes=F) -superimposes the third
histogram
 
 

Bill Shipley

North American Editor, Annals of Botany

Editor, Population and Community Biology series, Springer Publishing

Dipartement de biologie, Universiti de Sherbrooke,

Sherbrooke (Quibec) J1K 2R1 CANADA

[EMAIL PROTECTED]

http://callisto.si.usherb.ca:8080/bshipley/

 

 

[[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] strange matrix behaviour: is there a matrix with one row?

2006-04-07 Thread Wiener, Matthew
Use drop = FALSE in your subscripting calls.  That will retain matrixness.

For example:
y - matrix(1:8, ncol = 2)
is.matrix(y[-c(1,2,3),,drop = FALSE]

More info is on the help page for [.  You can type:  ?[ to get it from
the command line.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, April 07, 2006 9:16 AM
To: Gabor Grothendieck
Cc: Brian Quinif; r-help@stat.math.ethz.ch; [EMAIL PROTECTED]
Subject: [R] strange matrix behaviour: is there a matrix with one row?

Consider this:

 y - matrix(1:8, ncol=2)
 is.matrix(y[-c(1,2),])
[1] TRUE
 is.matrix(y[-c(1,2,3),])
[1] FALSE
 is.matrix(y[-c(1,2,3,4),])
[1] TRUE

It seems like an inconsistent behaviour:
- with 2 or more rows we have a matrix
- with 1 row we do not have a matrix and
- with 0 rows we have a matrix again

I just stumbled on this behaviour, because I had a problem
with my program in which I have assumed that matrix with
some rows removed is still a matrix, which seems to be mostly
true, but it is not true if only one row is left.

Comments? Suggestions?
How to work around this problem - without to many if statements?

Best regards,
Ryszard

__
R-help@stat.math.ethz.ch 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] how to change the trellis graph background color

2006-03-31 Thread Wiener, Matthew
Take a look at trellis.par.set().

For example, trellis.par.set(theme = col.whitebg()) changes things to look
more or less like the default from the standard R graphics functions.  But
you can change one option at a time too.

Hope this helps,

Matt Wiener 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lisa Wang
Sent: Friday, March 31, 2006 4:23 PM
To: R-Help
Subject: [R] how to change the trellis graph background color

Hello there,

Please shed some light on how to change the background color of trellis
graphic background. 


Thanks a lot

lisa Wang
Toronto, Ca

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

__
R-help@stat.math.ethz.ch 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] Impaired boxplot functionality - mean instead of median

2005-12-01 Thread Wiener, Matthew
interaction(A, B) will create a single factor made up of the combinations of
the two factors A and B.  Perhaps that would let you use plotmeans.

Hope this helps,

Matt Wiener


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Evgeniy Kachalin
Sent: Thursday, December 01, 2005 3:37 PM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] Impaired boxplot functionality - mean instead of median


Marc Schwartz (via MN) пишет:
Marc Schwartz (via MN) пишет:

So plotmeans is incapable of: boxplot(numerical~fact1+fact2). Is there 
any way further?
 
 
 I think that somehow we are talking past each other here.
 
 plotmeans() does what it is designed to do, which is to simplify the
 process of plotting group-wise point estimates and user defined error
 bars/intervals around the point estimates.
 
 In your case, these intervals would be standard deviations around each
 of the group means as you have indicated.
 
 Review the examples in ?plotmeans.
 
 As Martin and others have pointed out, you need to remove boxplots from
 the equation here, as they were not designed to plot means and standard
 deviations.
 

Again, what I'm talking about: plotmeans is incapable of analyzing the
formula. For example, I have two factors: A - a, b, c, and B - d, e, f.

If i plot: boxplot(num~A+B) what do I get? Eight boxes: ad, ae, af, ba,
be, bf, cd, ce, cf. If I plot: plotmeans(num~A+B) - what do I get?
Nothing. Because plotmeans cannot combine two factors in various
combination. Is there a simple way to do it?

Anyway... That's wrong way, all what is neccessary is to have a boxplot
with mean istead of median. Is there simple way to do it?

Statistical software like Statistica 7.0 offers any possible combination
of what Boxplot could mean. Is it possible to have only one
modification to R's boxplot?

Thank you for kind answers.
Also please tell me, where should I send replies: to conference adress
or to those who answer me directly.

-- 
Evgeniy

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

2005-11-16 Thread Wiener, Matthew
You can also look at xyplot in the lattice package.  You will have to set up
your data slightly differently than for the standard graphics package, but
it may well be worth learning to do so.  The lattice package has enormous
flexibility for combining multiple sets of data in one panel or plotting
them in separate panels.

Hope this helps,

Matt

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vivien W. Chen
Sent: Wednesday, November 16, 2005 8:49 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Combine related plots


Dear R users,

If I have to combine plots which have the same independent and dependent
variables in one graph. Which command should I use? Any example? Can I use
panel?

Your help will be deeply appreciated. Thanks!

-Vivien Chen-

[[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] Scale of plots

2005-11-07 Thread Wiener, Matthew
See xlim and ylim in the documentation on the plot command.
Hope this helps,

Matt Wiener
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Miller
Sent: Monday, November 07, 2005 10:12 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Scale of plots


I would like to know how I can change the axis to run from 0 to 50 say, 
instead of the 0 to 200 it gives me.

Many thanks
Mark Miller

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

2005-09-28 Thread Wiener, Matthew
It's randomForest.

Searching (simple text find) on the packages web page of CRAN using either
random or forest would find you this.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Louis Ferre
Sent: Tuesday, September 27, 2005 8:45 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Random Forest with R


Hi,
what is the name of the package that provides Random Forest with R.
Sincerely
Louis Ferré
http://www.univ-tlse2.fr/grimm/smash/ferre/index.html
Equipe GRIMM-2254
Département de Math-Info
5 allées Antonio Machado
31058 Toulouse Cedex
Tel: 0561504608
   0561503982

[[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] R , Java DCOM

2005-09-21 Thread Wiener, Matthew
This is not  a direct answer to your question.  But Rserve
(http://stats.math.uni-augsburg.de/Rserve/) provides another possible
approach.  We've had good success with it.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rajarshi Guha
Sent: Wednesday, September 21, 2005 10:00 AM
To: R
Subject: [R] R , Java  DCOM


Hi,
 I am working on a Java project that will run primarily on Windows. As
part of the project I would like to use the R engine.

However, from what I have seen on this list  the SJava list, installing
SJava on Windows can be troublesome.

As a result I was wondering if anybody had used DCOM to access R from a
Java program on Windows (if it is all possible).

Any pointers to documents and/or examples would be appreciated.

Thanks,

---
Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
---
Gravity brings me down.

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

2005-09-14 Thread Wiener, Matthew
Depending on the size of your objects, you may be able to just keep them in
a list, especially as you say you will need them in the same order later.

If because of memory constraints or for some other reason you really need to
have a separate file for each round, you can generate object and file names
using paste, assign the object to the name with assign, and save the file:

(warning:  untested code)
for(i in 1:n){
obj.name - paste(base.obj.name, i, sep = .)
file.name - paste(obj.name, rda, sep = .)  # or whatever other
file name you want
this.obj - my.fn.that.creates.object(my.arguments)
assign(obj.name, this.obj)
save(list = obj.name, file = file.name)
}

When retrieving the files, you can use a similar loop, but instead of using
assign, you can use get to retrieve the value and assign it to another
variable.  Or, in interactive use, you know the name so you can refer to the
variable.

Hope this helps,

Matt


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Shahrokh Keiwani
Sent: Wednesday, September 14, 2005 9:43 AM
To: r-help@stat.math.ethz.ch
Subject: [R] *** saving files ***


   Hi,

   

   I need help  :o(

   

   I want that my function saves result files in a for()-loop while it runs
   automatically.

   

   the filenames must be saved like:

   

   file_1  - for 1. result

   file_2  - for 2. result

   file_3  - for 3. result

   

   and

   .

   .

   .  

   

   file_n - for n. result

   

   the file names are the same identified by _1, _2 , _3, ... , _n

   

   these files will loaded by a second function later in the same sequence
   (_1 to _n). 

   

   how can I do that ...

   

   



   

   

[[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] adding text to the corner of a lattice plot

2005-09-09 Thread Wiener, Matthew
I think this message from the help archives might address your question
(found using the query lattice mtext on R site search:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/51605.html.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of RINNER Heinrich
Sent: Friday, September 09, 2005 4:16 AM
To: r-help@stat.math.ethz.ch
Subject: [R] adding text to the corner of a lattice plot


Dear R community,

I am using R 2.1.1 on Windows XP, package lattice Version 0.12-5, and
want to add text (sort of a dat-stamp actually) to the lower left corner
of a lattice plot, prefarably _after_ the plot has been created.

Here is a simple example what I do in base graphics:

# base graphics:
 plot(rnorm(100), rnorm(100))
 mtext(as.character(Sys.Date()), side = 1,line = -2, outer = T, adj =
0, font = 1, cex = 0.7)

How can I get the same using lattice?
# lattice:
 require(lattice)
 xyplot(rnorm(100) ~ rnorm(100))
 ???

__
R-help@stat.math.ethz.ch 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] label *on the side* in conditional lattice plots?

2005-08-31 Thread Wiener, Matthew
I think you might be able to use the horizontal argument to lattice to
rotate all your plots and squish them in the other dimension.  (Though I
don't know whether you consider that a good outcome ...)

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Maciej Kalisiak
Sent: Wednesday, August 31, 2005 4:21 PM
To: r-help@stat.math.ethz.ch
Subject: [R] label *on the side* in conditional lattice plots?


I'm doing bwplot(x ~ y | z, ...) with lattice, but would like the
z-labels to appear to the *side* of each bwplot, rather than on top...
is this possible?  The main reason is that my bwplots are horizontal,
and as such can be nicely squished in the vertical axis (big
space-saver when including in papers), but  the labels get in the
way, look too large in comparison, while I have all this empty space
to the side of the plots which is being wasted instead...

-- 
Maciej Kalisiak
[EMAIL PROTECTED]
http://www.dgp.toronto.edu/~mac

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

2005-07-21 Thread Wiener, Matthew
You can use the breaks argument in image to do this.  (You don't specify a
function you're using, but other heatmap functions probably have a similar
parameter.)  Look across all your data, figure out the ranges you want to
have different colors, and specify the appropriate break points in each call
to image.  Then you're using the same color set in each one.  You run the
risk, of course, that some of your images will have a very narrow color
range, which might obscure interesting features.  But nothing stops you from
making more than one plot.

Hope this helps.

Regards,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jacob Michaelson
Sent: Thursday, July 21, 2005 9:26 AM
To: r-help@stat.math.ethz.ch
Subject: [R] heatmap color distribution


Hi all,

I've got a set of gene expression data, and I'm plotting several  
heatmaps for subsets of the whole set.  I'd like the heatmaps to have  
the same color distribution, so that comparisons may be made  
(roughly) across heatmaps; this would require that the color  
distribution and distance functions be based on the entire dataset,  
rather than on individual subsets.  Does anyone know how to do this?

Thanks in advance,

Jake

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

2005-07-21 Thread Wiener, Matthew
Breaks affects the binning into colors.  Try this.  Assume that temp is one
of your data sets.  It's values are restricted to 0.25 - 0.75, and we'll
assume that the full data set goes from 0 to 1.

 temp - matrix(runif(60, 0.25, 0.75), nc = 6)
 breaks - seq(from = 0, to = 1, length = 11)
 image(temp2, col = heat.colors(10)) # full range of
color
 image(temp2, col = heat.colors(10), breaks = breaks)# muted colors

The second image is told about all the colors, and about the full range of
data through breaks, and only uses the colors in the middle.

Is that what you mean?

HTH, 

Matt

-Original Message-
From: Jake Michaelson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 21, 2005 10:45 AM
To: Wiener, Matthew
Cc: R-help@stat.math.ethz.ch
Subject: Re: [R] heatmap color distribution


Thanks for the reply.  As I understand it, breaks only controls the  
binning.  The problem I'm having is that each subset heatmap has  
slightly different min and max log2 intensities.  I'd like the colors  
to be based on the overall (complete set) max and min, not the subsets'  
max and min -- I could be wrong, but I don't think breaks will help  
me there.  And you're right - this might obscure some of the  
trends/features, but we'll also plot the default heatmaps.

Also (I should have specified) I'm using heatmap.2.

Thanks,

Jake

On Jul 21, 2005, at 8:09 AM, Wiener, Matthew wrote:

 You can use the breaks argument in image to do this.  (You don't  
 specify a
 function you're using, but other heatmap functions probably have a  
 similar
 parameter.)  Look across all your data, figure out the ranges you want  
 to
 have different colors, and specify the appropriate break points in  
 each call
 to image.  Then you're using the same color set in each one.  You run  
 the
 risk, of course, that some of your images will have a very narrow color
 range, which might obscure interesting features.  But nothing stops  
 you from
 making more than one plot.

 Hope this helps.

 Regards,

 Matt Wiener

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Jacob Michaelson
 Sent: Thursday, July 21, 2005 9:26 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] heatmap color distribution


 Hi all,

 I've got a set of gene expression data, and I'm plotting several
 heatmaps for subsets of the whole set.  I'd like the heatmaps to have
 the same color distribution, so that comparisons may be made
 (roughly) across heatmaps; this would require that the color
 distribution and distance functions be based on the entire dataset,
 rather than on individual subsets.  Does anyone know how to do this?

 Thanks in advance,

 Jake

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





 --- 
 ---
 Notice:  This e-mail message, together with any attachment...{{dropped}}

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


Re: [R] unable to call R t-test from Java

2005-07-20 Thread Wiener, Matthew
This does not address the question of how to do this the way you're trying
to do it, using Omegahat.  But I've had good results using Simon Urbanek's
program Rserve:  http://stats.math.uni-augsburg.de/Rserve/

Hope this helps,

Matthew Wiener
Applied Computer Science  Mathematics
Merck Research Laboratories
Rahway, NJ 07065
732-594-5303 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of O'Brien, Laura
Sent: Wednesday, July 20, 2005 10:42 AM
To: r-help@stat.math.ethz.ch
Subject: [R] unable to call R t-test from Java


Hello,

My colleague and I would like to write Java code that invokes R to do a
simple TTest.  I've included my sample java code below.  I tried various
alternatives and am unable to pass a vector to the TTest method.  In my
investigation, I tried to call other R methods that take vectors and also
ran into various degrees of failure.   Any insight you can provide or other
Web references you can point me to would be appreciated.

Thank you,
Laura O'Brien
Application Architect



---  code   --


package org.omegahat.R.Java.Examples;

import org.omegahat.R.Java.ROmegahatInterpreter;
import org.omegahat.R.Java.REvaluator;


public class JavaRCall2
{

/**
 * want to see if I can eval a t.test command like what I would run in
the
 * R command line
 */

static public void runTTestByEval_cores(REvaluator e,
ROmegahatInterpreter interp)
{
/* produces a core */
System.err.println(eval a t.test);
Object value = e.eval(t.test (c(1,2,3), c(4,5,6)));
if (value != null)
interp.show(value);
}


/**
 * want to see if I can eval anything that takes a vector, e.g. mean, 
 * like what I would run in the R command line
 */

static public void runMeanByEval_works(REvaluator e,
ROmegahatInterpreter interp)
{
System.err.println(\r\n  evaluation string mean command);
Object value = e.eval(mean(c(1,2,3)));
if(value != null) 
{
interp.show(value ); 
System.err.println(\r\n);
}
}

/**
 *  if I pass mean a org.omegahat.Environment.DataStructures.numeric what do
I get?  NaN
 */
 
static public void runMeanByNumericList_nan(REvaluator e,
ROmegahatInterpreter interp)
{
 Object[] funArgs = new Object[1];
 // given argument is not numeric or logical
 
 org.omegahat.Environment.DataStructures.numeric rList1 = new
org.omegahat.Environment.DataStructures.numeric(3);   

 double[] dList = new double[3];
 dList[0] = (double) 1.1;
 dList[1] = (double) 2.2; 
 dList[2] = (double) 3.3;
 rList1.setData(dList, true);
 System.err.println(rList1.toString());

 funArgs[0] = rList1 ;
 
 System.err.println(\r\n Calling mean and passing an omegahat
vector);


 Object value =  e.call(mean, funArgs); 
 if(value != null) 
 {
 interp.show(value ); 
 System.err.println(\r\n);
 }

}

/**
 * let's run some tests on the vector passed in and see what R thinks
I'm handing it
 * 
 * it returns 
 * isnumeric: false
 * mode:  list
 * length:2
 */

public static void runTestsOnOmegahatNumeric(REvaluator e,
ROmegahatInterpreter interp)
{
Object[] funArgs = new Object[1];
// given argument is not numeric or logical
 
org.omegahat.Environment.DataStructures.numeric rList1 = new
org.omegahat.Environment.DataStructures.numeric(3);   

double[] dList = new double[3];
dList[0] = (double) 1.1;
dList[1] = (double) 2.2; 
dList[2] = (double) 3.3;
rList1.setData(dList, true);
System.err.println(rList1.toString());

funArgs[0] = rList1 ;
 
System.err.println(\r\n Calling isnumeric and passing an omegahat
vector);
   
Object value =  e.call(is.numeric, funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println(\r\n);
}

// mode is list

System.err.println(\r\n Calling mode and passing an omegahat
vector);
   
value =  e.call(mode, funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println(\r\n);
}

System.err.println(\r\n Calling length and passing an omegahat
vector);
System.err.println(\r\n);
System.err.println(INTERESTING:  thinks the length is 2!);

   
value =  e.call(length, funArgs); 
if(value != null) 
{
interp.show(value ); 
System.err.println(\r\n);
}

}

/**
 * run the mean on a java array.  Does it also return NAN?  
 * It returns a different value than the mean -- 2.1... instead of
2.2
 */

 

Re: [R] Another simple q - removing negative values

2005-07-15 Thread Wiener, Matthew
To leave x with only the non-negative elements, you can use x[x = 0].  Also
see the function subset.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Hopkins
Sent: Friday, July 15, 2005 8:00 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Another simple q - removing negative values



Sorry folks but again I have failed in my understanding of how to do a very
simple thing.  I've read the various texts and searched the help archives
but no positive result so far.

I want to remove all the rows in a data frame where one of the variables has
negative values.  In approx Stata pseudocode:

   drop _all, if( x  0 )

Please either point me to relevant sections of the docs or supply me with
solution - I'm sure it's very simple.

Michael

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

2005-06-20 Thread Wiener, Matthew
Federico -

match will give you the (first) index of each element of its first
argument in its second argument.  So  match(vector.1, vector.2)  tells you
where each element of vector.1 appears in vector.2.  So if you use table
on that vector, you'll see how many times each element of vector.2 appears. 

Something like:

first.occur - match(vector.1, vector.2)
table(factor(vector.2[first.occur], levels = sort(unique(vector.2)))

(changing it into a factor means you won't lose values of vector.2 that
never appear in vector.1.)

An example:

 vec1 - sample(1:10, 500, replace = TRUE)
 table(vec1)
vec1
 1  2  3  4  5  6  7  8  9 10 
61 37 43 47 49 59 51 48 53 52 
 vec2 - 0:11
 vec3 - match(vec1, vec2)
 table(factor(vec2[vec3], levels = sort(unique(vec2
 0  1  2  3  4  5  6  7  8  9 10 11 
 0 61 37 43 47 49 59 51 48 53 52  0 
 

This also works if one of the members of vec1 is not in vec2 -- that member
simply gets ignored. (As you can see if add, say, a 20 at the end of
vec1.)

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Federico Calboli
Sent: Monday, June 20, 2005 4:16 PM
To: r-help
Subject: [R] vectorisation suggestion


Hi All,

I am counting the number of occurrences of the terms listed in one  
vector in another vector.

My code runs:

for( i in 1:length(vector3)){
   vector3[i]  = sum(1*is.element(vector2,  vector1[i]))
}

where

vector1 = vector containing the terms whose occurrences I want to count
vector2 = made up of a number of repetitions of all the elements of  
vector1
vector3 = a vector of NAs that is meant to get the result of the  
counting

My problem is that vector1 is about 6 terms, and vector2 is  
62... can anyone suggest a faster code than the one I wrote?

Cheers,

Federico Calboli


--
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

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

__
R-help@stat.math.ethz.ch 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] a more elegant approach to getting the majority level

2005-05-26 Thread Wiener, Matthew
The which.max solution is fine as long as the maximum is always unique.
Otherwise, which.max will give you the first maximum.

So using the x == max(x)  version will have an advantage if there can be
ties.

Regards,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Uwe Ligges
Sent: Thursday, May 26, 2005 10:57 AM
To: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] a more elegant approach to getting the majority level


Rajarshi Guha wrote:

 Hi, I have a factor and I would like to find the most frequent level.
 
 I think my current approach is a bit long winded and I was wondering if
 there was a more elegant way to do it:
 
 x - factor(sample(1:0, 5,replace=TRUE))
 
 levels(x)[ which( as.logical((table(x) == max(table(x == TRUE ) ]

(== TRUE) can ALWAYS be omitted, see also:
  library(fortunes)
  fortune(TRUE)

x == max(x) should be replaced by which.max(x)

as.logical() is superfluous


Hence we get:
   names(which.max(table(x)))

Uwe Ligges



 (The length of x will always be an odd number, so I wont get a tie in
 max())
 
 Thanks,
 
 ---
 Rajarshi Guha [EMAIL PROTECTED] http://jijo.cjb.net
 GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
 ---
 Alcohol, an alternative to your self
 - 'Alcohol' by the Bare Naked Ladies
 
 __
 R-help@stat.math.ethz.ch 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] Plot range resizing when adding additiona lines

2005-05-24 Thread Wiener, Matthew
In traditional, or base graphics, see matplot, which does exactly what
you describe.

  You can also look at lattice graphics, which will give you flexibility to
plot in a single panel or multiple panels.

Hope this helps,
Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Hikel, Jerry
Sent: Tuesday, May 24, 2005 4:41 PM
To: R-help@stat.math.ethz.ch
Subject: [R] Plot range resizing when adding additiona lines


Hi -- I have searched the documentation and archives on graphing
capabilities in R for the past couple of hours, but I haven't been able
to find anything directly related to my problem.

I want to create a plot with several lines displayed on it. I want each
line to be displayed in a different color, so it seems the only way to
do this is to create a plot and then use the lines() function. However,
once i create the original plot, when I add new lines to the plot, the
axes range stays the same, and the new lines often extend beyond the
range of the original axes, cutting off the data of the added lines.

Is there any way to force the plot to resize it's axes range when new
lines are added, or is there some other optional way of implementing
this? Thanks.


DISCLAIMER: This e-mail message and any attachments are inte...{{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] R annoyances

2005-05-19 Thread Wiener, Matthew
(a) If what you're trying to do is just apply exp, or any other element-wise
function, you can just say exp(mtx).  You avoid both apply and the
transpose, and save time in the bargain.  If your actual function really
does depend on multiple elements, it may be a little more complicated.  You
could conceivably write a myapply function to do the apply followed by the
transpose, but then of course you still need to keep track of which way
you're going.

(b) You want to look into the drop = FALSE option:
Sub.mtx - mtx[,1,drop = FALSE]

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chalasani, Prasad
Sent: Thursday, May 19, 2005 10:37 AM
To: r-help@stat.math.ethz.ch
Subject: [R] R annoyances


Dear R Folks,
I'm a big fan of R, but there are a couple of things
that repeatedly annoy me, and I wondered if anyone
has neat ways to deal with them.

(a) When using apply row-wise to a matrix, it returns
the results column-wise, and to preserve the original
orientation, I've to do a transpose. E.g. I've to keep
doing a transpose, which I consider to be quite annoying.

transformed.mtx - t(apply( mtx, 1, exp))

(b) When extracting 2 or more columns of a matrix, 
R returns the result as a matrix, BUT when extracting
just one column, it returns a vector/array, rather than
a matrix, so I've to keep doing as.matrix, which is annoying.

sub.mtx - as.matrix(mtx[,1])

Of course I could write a suitable function
cols - function(mtx,range) as.matrix(mtx[, range])
but then I lose the syntactic sugar of being able to say [,1].

__
R-help@stat.math.ethz.ch 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] apply vs sapply vs loop - lm() call appl(y)ied on array

2005-04-21 Thread Wiener, Matthew
Christoph --

There was just a thread on this earlier this week.  You can search in the
archives for the title:   refitting lm() with same x, different y.

(Actually, it doesn't turn up in the R site search yet, at least for me.
But if you just go to the archive of recent messages, available through
CRAN, you can search on refitting and find it.  The original post was from
William Valdar, on April 19.)

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christoph Lehmann
Sent: Thursday, April 21, 2005 9:24 AM
To: R-help@stat.math.ethz.ch
Subject: [R] apply vs sapply vs loop - lm() call appl(y)ied on array


Dear useRs

(Code of the now mentioned small example is below)

I have 7 * 8 * 9 = 504 series of data (each length 5). For each of 
theses series I want to compute a lm(), where the designmatrx X is the 
same for all these computations.

The 504 series are in an array of dimension d.dim - c(5, 7, 8, 9)
means, the first dimension holds the data-series.

The lm computation needs performance optimization, since in fact the 
dimensions are much larger. I compared the following approaches:

using a for-loop. using apply, and using sapply. All of these require 
roughly the same time of computation. I was astonished since I expected 
at least sapply to outperfomr the for-loop.

Do you have me another solution, which is faster? many thanks

here is the code
## --
t.length - 5
d.dim - c(t.length,7,8,9) # dimesions: time, x, y, z
Y - array( rep(1:t.length, prod(d.dim)) + rnorm(prod(d.dim), 0, 0.1), 
d.dim)
X - c(1,3,2,4,5)

##  performance tests
## using for loop
date()
z - rep(0, prod(d.dim[2:4]))
l - 0
for (i in 1:dim(Y)[4])
  for (j in 1:dim(Y)[3])
   for (k in 1:dim(Y)[2]) {
 l - l + 1
 z[l] - unlist(summary(lm(Y[,k, j, i] ~ X)))$r.squared
   }
date()

## using apply
date()
z - apply(Y, 2:4, function(x) unlist(summary(lm(x ~ X)))$r.squared)
date()

## using sapply
date()
fac - rep(1:prod(d.dim[2:4]), rep(t.length, prod(d.dim[2:4])))
z - sapply(split(as.vector(Y), fac), FUN = function(x) 
unlist(summary(lm(x ~ X)))$r.squared)
dim(z) - d.dim[2:4]
date()

## --

-- 
Christoph LehmannPhone:  ++41 31 930 93 83
Department of Psychiatric NeurophysiologyMobile: ++41 76 570 28 00
University Hospital of Clinical Psychiatry   Fax:++41 31 930 99 61
Waldau[EMAIL PROTECTED]
CH-3000 Bern 60 http://www.puk.unibe.ch/cl/pn_ni_cv_cl_04.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] Question for layout function

2005-04-21 Thread Wiener, Matthew
Shawn --

You can do this by re-using numbers in the layout matrix.  The examples in
the help for layout have several examples of this.

For this particular example, I think that layout(cbind(c(1,1), c(2,3)))
would probably do it (untested).

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Shawn Lee
Sent: Thursday, April 21, 2005 9:23 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Question for layout function


Dear people,

Is there a way to generate three graphs having 2x2 layout, but left half
is merged ?
Like below.

 -
|||
|||
|||
|||
 -

Two times of layout function with par(new=FALSE) do not accept it.


Shawn Lee


-- 
The information contained in this communication and any atta...{{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] Keeping factors with zero occurrences in table output

2005-04-20 Thread Wiener, Matthew
Ravi --

If you use table on a factor, you'll get 0's if appropriate:

 table(sample(1:5, 10, replace = TRUE))  #no 2's, by chance

1 3 4 5 
3 1 2 4 

 table(sample(1:5, 20, replace = TRUE))  # no 6's here, so 6 doesn't show
up

1 2 3 4 5 
3 5 2 5 5 

## now make it a factor, and you get 0 3's and 0 6's 
 table(factor(sample(1:5, 20, replace = TRUE), levels = 1:6))

 1  2  3  4  5  6 
 5  4  0  1 10  0 

## just happened to get no 3's in previous sample; it doesn't happen every
time:
 table(factor(sample(1:5, 20, replace = TRUE), levels = 1:6))

1 2 3 4 5 6 
7 3 3 5 2 0 


You can probably create the factor you want with interaction on
participants and ranks.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ravi Varadhan
Sent: Wednesday, April 20, 2005 11:38 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Keeping factors with zero occurrences in table output


Dear R group,

 

I have a data frame which contains data on preferences on 7 items (ranks 1
through 7) listed by each participant.  I would like to tabulate this in a
7x7 table where the rows would be the items and the columns would be the
number of times that item received a particular rank.  

 

I tried doing this by creating a matrix by rbinding each vector obtained
using table on each item.  This, however, does not work because there are
some items which didn't receive some of the ranks, so table does not list
that item.  Is there a way to force it to list the item and give a 0 to
it? Or, is there a simpler way to solve this problem?

 

Thanks for any help,

Ravi.

 

--

Ravi Varadhan, Ph.D.

Assistant Professor,  The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email:   mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]

--

 


[[alternative HTML version deleted]]

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

__
R-help@stat.math.ethz.ch 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] Storing vectors as vectors and iterating through them

2005-04-18 Thread Wiener, Matthew
Ken -- try using lists:

 vec.list - list(1:5, 2:4, 3:8)
 vec.list - c(vec.list, list(7:9))
 vec.list
[[1]]
[1] 1 2 3 4 5

[[2]]
[1] 2 3 4

[[3]]
[1] 3 4 5 6 7 8

[[4]]
[1] 7 8 9

Then you can use lapply or sapply, or just a for loop, to iterate over
the list, applying your function to each element.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ken Termiso
Sent: Monday, April 18, 2005 1:09 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Storing vectors as vectors and iterating through them


Hi all,

I have a bunch of int vectors. Each vector holds a bunch of ints that 
correspond to row numbers of an existing matrix. I use the int vectors to 
pull out rows of data from a matrix, i.e.

data - my_matrix[int_vector,]

I would like to store these int vectors in some sort of data structure that 
will preserve them as-is and allow iteration. I guess what I'm looking for 
would be something analogous to the java Vector class, as in this java-like 
pseudocode :

Vector V = new Vector;
V.add(a,b,c) // where a,b,c are lists

for(int i = 0; iV.size; i++)
{
List L = (List)Vector.get(i);
plot(L);
}

The point is to iterate through the data structure containing the int 
vectors, and, for each int vector, do some clustering and plotting, but what

I cannot find is a data structure in R that would support this.. trying 
c(a,b,c) does not preserve each int vector, but instead merges all the ints 
into one vector. I need to keep them separate (so I can create a separate 
plot for each vector).

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] ks.test for conditional distribution Y|x

2005-04-07 Thread Wiener, Matthew
Couldn't you do this by subtracting 0.5 + x from your y values and checking
for normality with mean 0 and sd = 1 (using ks.test or another test of
normality).

If you fail, you'll have to do additional work to find out whether pairs
with some particular x value (or range of x values) is causing the problem,
but I think this fits the question as stated.

Of course, if you have discrete x values, and enough data at each one, you
could just run the check for each x.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vicky Landsman
Sent: Thursday, April 07, 2005 3:16 PM
To: R-help list
Subject: [R] ks.test for conditional distribution Y|x


Dear experts, 
Is it possible to use ks.test function to check the goodness of fit of the
conditional distribution Y|X=x? 
For example, I would like to check that my data (Y,X) come from
Norm(0.5+x,1) using KS. 
Thank you in advance, 
Victoria Landsman. 
[[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] R FAQ 2.8

2005-04-01 Thread Wiener, Matthew
I have used the R statistical computing environment.

No-one has ever asked me to change it, but maybe someone else has something
better.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robin Hankin
Sent: Friday, April 01, 2005 8:30 AM
To: R-help@stat.math.ethz.ch
Subject: [R] R FAQ 2.8


Hi

[thanks to everyone for advice on Recall() and sapply()]

The R FAQ section 2.8 discusses how to cite R in publications, but does 
not (AFAICS) tell
me how to describe R in a sentence.

To wit, in my latest paper (destined for Rnews)  one sentence reads:

The R programming language (3) has been applied . . .

where reference (3) is R Core 2004.

Now, the referee has pointed out that the expression R computer 
language is not
to be encouraged, as R is an implementation of the S language.

How would the List rephrase my sentence above?



  I also use the phrase R code, which the referee flags for rewording 
(on similar
grounds to the above).

Any suggestions for this?




--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

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

2005-03-08 Thread Wiener, Matthew
I have had my best luck by re-parametrizing so that I no longer needed
restrictions.  For example, if parameters must be positive, then I optimize
over parameters in log space, taking the exponential within my function.
This requires small changes to the function I'm optimizing (and the
gradient, if supplied), but, for me at least, has worked better than trying
to enforce box constraints as in L-BFGS-B.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sébastien Ballesteros
Sent: Tuesday, March 08, 2005 8:24 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Non-linear minimization


hello, I have got some trouble with R functions nlm(),
nls() or optim() : I would like to fit 3 parameters
which must stay in a precise interval. For exemple
with nlm() :

fn-function(p) sum((dN-estdata(p[1],p[2],p[3]))^2)
out-nlm(fn, p=c(4, 17, 5),
hessian=TRUE,print.level=2)

with estdata() a function which returns value to fit
with dN (observed data vactor)

My problem is that only optim() allows me to set
parameters interval with L-BFGS-B method but this
one doesn't work in my case.

I have heard about nls2 package (www.inra.fr/bia) but
it doesn't work on Windows.

Do you know any solutions

Thank's a lot for reading my post

Best regards

Sebastien
INA P-G ecology dpt

__
R-help@stat.math.ethz.ch 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] Creating a correlation Matrix

2005-02-07 Thread Wiener, Matthew
From the help for cor (from the stats package):

If x and y are matrices then the covariances (or correlations) between the
columns of x and the columns of y are computed.

So if you make a matrix with each column corresponding to one of your
variables, you can get what you're after.

For future reference, help.search(correlation) turns up the proper page as
the first suggestion.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jessica Higgs
Sent: Monday, February 07, 2005 10:58 AM
To: R-help@stat.math.ethz.ch
Subject: [R] Creating a correlation Matrix


Hi all:

I have a question on how to go about creating a correlation matrix.  I have 
a huge amount of data21 variables for 3471 times. I want to see how 
each of the variables correlate to each other.  Any help would be 
appreciated, including which package and which functions I should use to do 
this.

Thanks,
Jessica Higgs

Masters Student
Department of Meteorology
Penn State 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-help@stat.math.ethz.ch 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] Creating a correlation Matrix

2005-02-07 Thread Wiener, Matthew
It looks like you have missing observations.  With the use argument, you
can specify complete observations or pairwise-complete observations.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jessica Higgs
Sent: Monday, February 07, 2005 12:54 PM
To: Spencer Graves; R-help@stat.math.ethz.ch
Subject: Re: [R] Creating a correlation Matrix


I've tried using cor() by the following sequence:

C - cor(x, y = NULL, use = all.obs, method = c(pearson))

where x is my matrix of 21 columns and 3471 rows.

and I get this error:

Error in cor(x, y = NULL, use = all.obs, method = c(pearson)) :
 missing observations in cov/cor

any suggestions?

At 08:32 AM 2/7/2005 -0800, Spencer Graves wrote:
  Have you considered cor?  The command 'help.search(correlation)' 
 suggests among other functions var(stats), the documentation for which 
 also includes cor.
  If this is not adequate, PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html .  It may help you get more 
 useful replies in the future.  spencer graves

Jessica Higgs wrote:

Hi all:

I have a question on how to go about creating a correlation matrix.  I 
have a huge amount of data21 variables for 3471 times. I want to see 
how each of the variables correlate to each other.  Any help would be 
appreciated, including which package and which functions I should use to 
do this.

Thanks,
Jessica Higgs

Masters Student
Department of Meteorology
Penn State 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-help@stat.math.ethz.ch 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] two issues (black and white trellis graphics)

2005-02-03 Thread Wiener, Matthew
On the first issue, there's a recent post you can find in the archives.
It's from Deepayan Sarkar on January 2 this year.  It would probably pop up
on a search for black white lattice or something similar.

The key part of his answer:

I'd do something like this as part of the initialization:

...
library(lattice)
ltheme - canonical.theme(color = FALSE) ## in-built BW theme
ltheme$strip.background$col - transparent ## change strip bg
lattice.options(default.theme = ltheme)  ## set as default

Hope this helps,

Matt Wiener


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dean Sonneborn
Sent: Thursday, February 03, 2005 2:53 PM
To: R-help@stat.math.ethz.ch
Subject: [R] two issues


I'm working on a graphic but have run into a road block about two 
issues.  I don't have a color printer so I want to produce the graphic in 
black and white. I'm currently using this 
statement  trellis.device(bg=white)  but the body of the graphic contains 
color. What is the code to create the whole thing in black and white. The 
other issue might be a bit more tricky. I'm using this statement: 
auto.key=TRUE  and in the body of the graphic I'm getting two different 
symbols and on the screen I see two symbols in the key but when I print it 
the key only contains one symbol for both!

here's the whole R code statement:
dotplot(chemical~adjlogmle| convert*tdnew, data=allrisk , group=rodentx, 
main=Interspecies Conversion, pch=1:2, auto.key=TRUE, scales = 
list(tick.number=10), fontfamily = HersheySans)

Thanks,

Dean Sonneborn M.S.
Public Health Sciences *
University of California, Davis
916 734-6656

* formerly Epidemiology  Preventive Medicine

[[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] how to use do.call(rbind, get(list(mlist)))

2005-01-21 Thread Wiener, Matthew
Roger --

First, if you have the data frames in a list already, you can just use
those; no need to bother with the names.  If the data frames are all
separate, but you have the names, you can first create a list of the data
frames themselves:

do.call(rbind, lapply(mlist, get))  # assumes they're in the workspace

An example:
 temp1 - matrix(runif(10), 5, 2)
 temp2 - matrix(-runif(10), 5, 2)   (for easy identifiability)
 temp3 - do.call(rbind, lapply(c(temp1, temp2), get))
 temp3 - do.call(rbind, list(temp1, temp2)) (same as above)

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of roger bos
Sent: Friday, January 21, 2005 12:07 PM
To: r-help@stat.math.ethz.ch
Subject: [R] how to use do.call(rbind, get(list(mlist)))


I have around 200 data frames I want to rbind in a vectorized way. 
The object names are:

m302
m303
...
m500

So I tried:

mlist - paste(m,302:500,sep=)
dat - do.call(rbind, get(list(mlist)))

and I get Error in get(x, envir, mode, inherits) : invalid first argument

I know rbind is valid because 

dat - rbind(m302, m303, m304, m305)

works, I am just too lazy to type it out to m500.

I also tried it without the get() portion, but then dat ends up being
a column with just the names of the objects, not the objects
themselves.

Thanks in advance for showing me the errors in my attempts.

Roger

__
R-help@stat.math.ethz.ch 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] Calculating a table of symbol frequencies

2005-01-06 Thread Wiener, Matthew
Kurt -- 

If you create a vector  of alignment positions, you should be able to do 

alignment.pos - rep(1:236, each = 72)
table(data.frame(as.vector(align1), alignment.pos))

You may want to coerce align1 to a factor with appropriate levels, in case
you are missing some amino acids.  Otherwise there's an automatic coercion,
I believe, and you will use only the levels actually present in your data.

Here's an example using the first 10 letters of the alphabet instead of the
amino acid set:

 align1 - matrix(sample(LETTERS[1:10], 200, replace = TRUE), nr = 5, nc =
40) 
 alignment.pos - rep(1:40, each = 5)
 table(data.frame(as.vector(align1), alignment.pos))

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Wollenberg, Kurt R
Sent: Thursday, January 06, 2005 11:36 AM
To: 'r-help@stat.math.ethz.ch'
Subject: [R] Calculating a table of symbol frequencies


Hello all:

I have a protein sequence alignment in a data frame (align1, 72 x 236),
where each row is a protein and each column a site in the alignment. AA is
vector of amino acid symbols plus - (gap). I can calculate amino acid
frequencies at each site by:

align1.F - matrix(0,nrow=22,ncol=236,dimnames=list(AA,seq(1:236)))
for(i in 1:236)
 align1.F[names(summary(align1[[i]])),i] -
(summary(align1[[i]])/length(align1[[i]]))

Is there a more efficient (i.e., without a loop) way to do this? Is there
some way to use table or ftable to create an 22 x 236 table of amino acid
frequencies from align1 and AA in one fell swoop?

Thanks,
Kurt Wollenberg, PhD
Tufts Center for Vision Research 
New England Medical Center
750 Washington St, Box 450 
Boston, MA, USA
[EMAIL PROTECTED] 
617-636-8945 (Fax)
617-636-9028 (Lab)

The most exciting phrase to hear in science, the one that heralds new
discoveries, is not Eureka! (I found it!) but  That's funny ... 
--Isaac Asimov


** 
Confidentiality Notice\ **\  The inf...{{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] Replacing all NA values in a matrix

2005-01-05 Thread Wiener, Matthew
Michael --

is.na works on the full matrix.  The commands below construct a matrix,
insert some NA's, and then convert them all to 0. 

 temp1 - matrix(runif(25), 5, 5)
 temp1[temp1  0.1] - NA
 temp1[is.na(temp1)] - 0

Hope this helps.

Regards,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of michael watson
(IAH-C)
Sent: Wednesday, January 05, 2005 9:26 AM
To: R-help@stat.math.ethz.ch
Subject: [R] Replacing all NA values in a matrix


OK, dumb question, and it is probably in the docs somewhere, but after
12 months working with R and quite a while looking at the docs, I still
don't know (or have forgotten) how to replace all NA values in a matrix
at once with some other value.  I can do it column by column using
is.na(), but I can't figure out how to do it for the whole matrix.  My
apologies, I am ashamed ;-)

Michael Watson
Head of Informatics
Institute for Animal Health,
Compton Laboratory,
Compton,
Newbury,
Berkshire RG20 7NN
UK

Phone : +44 (0)1635 578411 ext. 2535
Mobile: +44 (0)7990 827831
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

__
R-help@stat.math.ethz.ch 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] Massive clustering job?

2004-12-15 Thread Wiener, Matthew
It sounds like clara in package cluster might help.

Regards,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dan Bolser
Sent: Wednesday, December 15, 2004 6:37 AM
To: R mailing list
Subject: [R] Massive clustering job?



Hi, 

I have ~40,000 rows in a database, each of which contains an id column and
20 additional columns of count data.

I want to cluster the rows based on these count vectors.

Their are ~1.6 billion possible 'distances' between pairs of vectors
(cells in my distance matrix), so I need to do something smart.

Can R somehow handle this?

My first thought was to index the database with something that makes
nearest neighbour lookup more efficient, and then use single linkage
clustering. Is this kind of index implemented in R (by default when using
single linkage)?

Also 'grouping' identical vectors is very easy. I tried making groups more
fuzzy by using a hashing function over the count vectors, but my hash was
too crude. Any way to do fuzzy grouping in R which scales well?

For example, removing identical vectors gives me ~30,000 rows (and ~900
million pairs of distances). As an example of how fast I can group, the
above query took 0.13 seconds in mysql (using an index over every element
in the vector). However, if I tried to calculate a distance between every
pair of non identical vectors (lets say I can calculate ~1000 eutlidian
distances per second) it would take me ~10 days just to calculate the
distance matrix.

Sorry for all the information. Any suggestions on how to cluster such a
huge dataset (using R) would be appreciated.

Cheers,
Dan.

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

__
[EMAIL PROTECTED] 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] Logical and

2004-11-11 Thread Wiener, Matthew
Alexander --

a[!(a %in% b)] should do the trick.

setdiff could also probably be used.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alexander Sokol
Sent: Thursday, November 11, 2004 8:34 AM
To: [EMAIL PROTECTED]
Subject: [R] Logical and


Hello,

I have the following very simple problem:

Say I have two vectors,

a-c(1,7,4,5,9,11)
b-c(7,4,9)

I would like to create a vector containing the elements in a which are not
in 
b.

Obviously, this is possible by writing

a[a!=b[1]  a!=b[2]  a!=b[3]]

But I would like a solution which is applicable to the situation where the 
number of elements in b is unknown.

I have looked in the R manuals, the FAQ and the mailing lists, but have been

unable to find a solution.

Thank you for your replies,
 Alexander

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

__
[EMAIL PROTECTED] 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] Quick data-manipulation question

2004-10-28 Thread Wiener, Matthew
Sean --

You want do.call(rbind, your.list.of.data.frames).  do.call is helpful in
a lot of situations when you want to construct a list of arguments and then
apply a function.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sean Davis
Sent: Thursday, October 28, 2004 9:30 AM
To: r-help
Subject: [R] Quick data-manipulation question


I have a list of data frames and I want to concatenate them into a 
single data frame, basically appending all of the data frames to each 
other (they are all the same shape, in terms of columns).  I'm looking 
for a nice way to do that.  I can of course just consecutively rbind 
them to a master dataframe, but I have 22,000 such data frames, each 
with a few hundred rows, so this process takes a good while.  Should be 
simple, I imagine

Here is a toy data structure.
j - list()
for (i in letters[1:26]) {j[[i]] - 
data.frame(rep(i,25),matrix(rnorm(250),nrow=25))}

Thanks.

Sean

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

__
[EMAIL PROTECTED] 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] graph question

2004-10-12 Thread Wiener, Matthew
Dean --

I believe just setting log = y in your plot command should do this.

For example:

 plot(runif(100, 1, 100), runif(100, 1, 100), log = xy)
gives me tick marks at 2, 5, 10, 20, 50, and 100.  (YMMV because of the
random numbers.)

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dean Sonneborn
Sent: Tuesday, October 12, 2004 2:02 PM
To: [EMAIL PROTECTED]
Subject: [R] graph question


I would like to produce a graph which plots a log scale variable on the 
y-axis but have the tick marks on the y-axis  be the non log transformed 
values that are round like .5, 1, 2, 3, 4 etc. Has anyone done something 
like this in the past? How did you implement it in the code?

Thanks,
Dean

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

__
[EMAIL PROTECTED] 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-(wiki)-pedia?

2004-10-07 Thread Wiener, Matthew
When you think there should be new links, or can offer an example you think
would be clearer, it might be worth submitting a documentation modification
proposal (through the bug tracking link on the R home page, for example).
That would improve the basic documentation, which is what most people will
see first.

Regards,
Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dan Bolser
Sent: Thursday, October 07, 2004 1:30 PM
To: Gabor Grothendieck
Cc: [EMAIL PROTECTED]
Subject: Re: [R] R-(wiki)-pedia?


On Wed, 6 Oct 2004, Gabor Grothendieck wrote:

Dan Bolser dmb at mrc-dunn.cam.ac.uk writes:

: 
: Is there an R wiki?
: 
: Looking at the huge amount of traffic on this list, I think wiki could be
: an exelet outlet for all the constructive enthusiasm here.
: 
: I don't think it would be too hard to port the existing R documentation
: (the stuff you get with the ?) onto a wiki system, then users could add
: their own examples and comments. 
: 
: Having distinct web page style organization would be easier to navigate
: than the mailing list archives. I like the online version of the R-docs,
: but I miss 'user comments' and I miss being able to fix trivial things.
: 
: The user contributed links could supply the best statistical online
: resources to supplement the R-documentation, with links to the relevant
: FAQ's and Tutorials supplementing the whole thing.
: 
: Now I have said it this sounds too good to not exist already... Anyone
: dumped the R-documentation onto a wiki system?
: 
: Given the capability of R to be integrated into web pages, this could be
: really really great. 
: 
: Cheers,
: Dan.

There is one at

http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?RwikiHome

Unfortunately, no one seems to use it.

I just added some pages... I think it would be great if people could get
motivated to contribute to something like this. Its one of those cases of
just getting the ball rolling...

Do you think you can dump the existing R-docs into this wiki as a
framework to get things going?

So often I read the docks and think, now if only this linked here, and if
only this example were more clear etc...

After I solve my problem I want to fix the docs. Wiki would let me do
that. 

How about you host a 'best diff in 30 days' competition each month, and
winning contributors could be announced on the list?

Can we integrate R-embedded web pages into the wiki?




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


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

__
[EMAIL PROTECTED] 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] a little question about R

2004-09-07 Thread Wiener, Matthew
letters[1;4]
LETTERS[1:4] for capitals.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, September 07, 2004 8:42 PM
To: [EMAIL PROTECTED]
Subject: [R] a little question about R


Hello,sir: Here's a little question about R which needs your help.Thanks in
advance. 
If I wanna make a sequence just like a,b,c,d (In other words,a vector
consists of 4 characters :a,b,c,d ).How can I do it in a shortcut manner?
Yes,I can do it as following: c(a,b,c,d) and the result is:[1] a
b c d.
But I remember there's a shortcut manner to do the same thing,something like

c(a:d).But the system said:Error in a:d : NA/NaN argument So I
wonder the correct method to do it(I remember the expression is very similar
with
c(a:d)). Thanks from the bottom of my heart. My best regards!

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

__
[EMAIL PROTECTED] 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] for (i in ...) { df[[i]]- .....}

2004-08-27 Thread Wiener, Matthew
Take a look at do.call.  

In your case, 'do.call(cbind, cc)' should work.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Luis Rideau Cruz
Sent: Friday, August 27, 2004 9:12 AM
To: [EMAIL PROTECTED]
Subject: [R] for (i in ...) { df[[i]]- .}


R-help,

In the following loop :

for(i in 1:8)
{
cc[[i]]-tapply(test[,i+6],list(puntar=test$puntar),sum)/tapply(test[,5],lis
t(puntar=test$puntar),sum)

cbind.data.frame(cc[[1]],cc[[2]],cc[[3]],cc[[4]],
cc[[5]],c[[6]],cc[[7]],cc[[8]])

}

Is there anyway I can 'cbind.data.frame' the objects cc[[ i ]] without
actually writing every single element??
In this case there are 8 but what if it is a large number??


Thank you

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

__
[EMAIL PROTECTED] 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] Welch-JM-Test or Brown-Forsythe-Test in R?

2004-06-21 Thread Wiener, Matthew
Does oneway.test do what you want?

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sven Hartenstein
Sent: Monday, June 21, 2004 3:23 PM
To: [EMAIL PROTECTED]
Subject: [R] Welch-JM-Test or Brown-Forsythe-Test in R?


Hi, 

I want to test mean differences of  2 groups with heterogenous
variances and wonder whether Welch-JM-Test and/or Brown-Forsythe-Test
are available in R. (These two are the ones I found in the literature
and SPSS provides, I'm open for alternatives.)

Any help apreciated!


Sven

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

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


RE: [R] Sloppy argument checking for named arguments

2004-06-02 Thread Wiener, Matthew
Christian --

This is not a bug, but a feature, and the dot is not the issue here.  R uses
partial argument matching on function arguments.  

  So:

 f - function(foobar = 0){print(foobar)}
 f
function(foobar = 0){print(foobar)}

 f(fo=1)
[1] 1
 f(foo=1)
[1] 1
 f(foob=1)
[1] 1
 f(fooba=1)
[1] 1
 f(foon=1)
Error in f(foon = 1) : unused argument(s) (foon ...)

 f(foobar2=1)
Error in f(foobar2 = 1) : unused argument(s) (foobar2 ...)

This is mentioned in Venables  Ripley, MASS 4th edition on p. 55. I can't
find it right now in the Introduction to R that is linked to on the main
html help index page.   However, it is discussed in the R Language
Definition you can get to from the same page.

It seems like there must be an easier path to the information that I haven't
thought of.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, June 03, 2004 12:20 AM
To: [EMAIL PROTECTED]
Subject: [R] Sloppy argument checking for named arguments



Dear R Gurus,

i recently noticed that R does sloppy argument checking for named
arguments, if the argument contains a dot.
Example:

  f - function(foo.bar=0) { print(foo.bar) }
  f(foo=1)
[1] 1

I guess, this should be considered as a bug.
Anyway, the consequence is that bugs caused by typing errors
of this kind may are *very* hard to discover in complex progams.

Christian

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

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


RE: [R] type checking --- just a thought

2004-05-14 Thread Wiener, Matthew
Ivo --

The stopifnot statement can be used to do this sort of check.  For
example, if you need to check that one of your arguments is a vector with
length = N, you can add

stopifnot(is.vector(myarg))
stopifnot(length(myarg) = N)

To the beginning of your function.  This will throw an error if one of the
conditions is not met.  The rest of your conditions can be checked
similarly.

Hope this helps,

Matt Wiener



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of ivo welch
Sent: Friday, May 14, 2004 10:23 AM
To: [EMAIL PROTECTED]
Subject: [R] type checking --- just a thought



hi:  would it be useful to build into R an optional mechanism that 
typechecks arguments?  for example,

sum.across - function (  inpmatrix : matrixtype( dim[1]1, dim[2]3 
) ) : vector { }
   # this would define a sum.across function that can take matrices 
or data sets, but not vectors,
   # and which indicates that it will return a vector.

xsum - sum.across( 1:10 );  # error

repeat - function( series : vector( dim0 ),  times : scalar( 
value0 ) ) : vector;

similarly, a common input error condition may be calling a function with 
a NULL vector, or with a vector with fewer than N observations.  many 
statistical functions have such hard-wired limits.  I know that if 
statements can do this, but this might make for a nice standardized 
language feature.  on the other hand, the effort and complexity may not 
be worth the extra functionality.

and one beg to the language maintainers for something that I hope is simple:

in R 1.8.2, please add to the source function information where 
(file:linenumber) dies or ends.

regards,

/ivo

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

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


[R] FW: Aligning different trellis plots

2004-04-20 Thread Wiener, Matthew
All --

I am trying to combine trellis plots and having a couple of small problems.

I'm trying to combine two trellis plots that display data of different
kinds.  Each has a single row of plots, and I'd like to display them over
one another.  So I use 

print(plot1, split = c(1,1,2,1), more = TRUE)
print(plot2, split = c(1,2,1,2))

I end up with two minor issues.  First, I'd like to have the top of the
bottom plot touch the bottom of the top plot, so it all looks like one plot
(I'd turn off the strip in the bottom one).  I've turned off the x labels
and bottom axes for the top plot, but there still ends up being some space
between them.  The effect I'm looking for is like setting various components
of mar to 0 in base graphics, but I can't figure out how to do it.

The second issue has to do with axes.  My two plots have the same number of
panels across, and I would like them to line up vertically.  However, my
y-axis labels, on the left of each plot, are slightly different size, and
this means that the panels are of slightly different sizes in the two plots.

Here's a toy example that shows my two problems.

df.1 - data.frame(x = rep(1:10, 5),
   y = runif(50, 0, 10),
   group = rep(1:5, each = 10))
df.2 - data.frame(x = rep(1:10, 5),
   y = runif(50, -1, 1),
   group = rep(1:5, each = 10))
plot.1 - xyplot(y ~ x | group, data = df.1,
 scales = list(x = list(alternating = 0),
   y = list(alternating= 1)),
 xlab = ,  ## same results with
xlab = NULL
 layout = c(5,1,1))
plot.2 - xyplot(y ~ x | group, data = df.2,
 scales = list(alternating = 1),
 layout = c(5,1,1))

print(plot.1, split = c(1,1,1,2), more = TRUE)
print(plot.2, split = c(1,2,1,2))

I realize that it could be the xlab =  that is giving me trouble -- it may
still be reserving space.  But xlab = NULL does the same thing, and I
haven't been able to find anything else to try.

One moderately ugly way to solve the problem is to use position instead of
split in the print statement for the trellis plots, and use overlapping
ranges to force the bottom of the top plot to line up with the top of the
bottom plot.  But it would be nice to have something a little more
automatic.

Or is there some better way to do this altogether -- perhaps that would
force a single plot to contain two kinds of panels?  That seems to really go
against the principle of lattice graphics, though.

Thanks for any help.

Regards,

Matt Wiener


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


RE: [R] Readbin and file position

2004-02-13 Thread Wiener, Matthew
The seek command will allow you to skip to a particular byte position in
the file.  You can define the position you want relative to your current
position, or to the start of the file.

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan Greenberg
Sent: Thursday, February 12, 2004 9:51 PM
To: R-help
Subject: [R] Readbin and file position


I have a binary file which is an image with multiple bands, arranged in BSQ
format such that R, B and G are all N x M sized matrices (corresponding to
Red, Blue and Green colors respectively).  The BSQ file arranges the data as
[R, B, G], so to access the B matrix, I have to read forward N x M + 1
number of samples.  Is there a fast way to define a variable as the B matrix
exclusively (e.g. Can I use readbin to fast forward N x M + 1 samples to
the beginning of the B matrix, and then read/define the B matrix
exclusively, or do I have to read the entire file into memory, then subset
out the B matrix?)

Thanks!

--j

-- 
Jonathan Greenberg
Graduate Group in Ecology, U.C. Davis
http://www.cstars.ucdavis.edu/~jongreen
http://www.cstars.ucdavis.edu
AIM: jgrn307 or jgrn3007
MSN: [EMAIL PROTECTED] or [EMAIL PROTECTED]

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



--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


RE: [R] Error in randomForest.default(m, y, ...) : negative lengt h vectors are not allowed

2003-12-03 Thread Wiener, Matthew
Christian -- 

You don't provide enough information (like a call) to answer this.  I
suspect, though, that you may be subsetting in a way that passes
randomForest no data.

I'm not aware offhand of an easy way to get this error from randomForest.  I
tried creating some data superficially similar to yours to see whether
something would break if there were only a single value in the variable to
be explained, but everything worked fine (though it does give a reasonable
warning).

 test.dat - data.frame(a = rep(0, 1000), b = runif(1000), c = sample(0:1,
1000, replace = TRUE, p = c(.8, .2))
 t8 - randomForest(a ~ b + c, data = test.dat)
Warning message: 
The response has five or fewer unique values.  Are you sure you want to do
regression? in: randomForest.default(m, y, ...) 
 test.dat[sample(1:1000, 100),a] - runif(100, 1, 200)
 t8 - randomForest(a ~ b + c, data = test.dat)

Some other generated data might come up with the error, but I'd bet on the
subsetting problem.

Hope this helps,  -Matt

Matthew Wiener
RY84-202
Applied Computer Science  Mathematics Dept.
Merck Research Labs
126 E. Lincoln Ave.
Rahway, NJ 07065
732-594-5303 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christian Schulz
Sent: Wednesday, December 03, 2003 9:42 AM
To: [EMAIL PROTECTED]
Subject: [R] Error in randomForest.default(m, y, ...) : negative length
vectors are not allowed


Hi,

what i'm doing wrong?
I'm using a data.frame with ~ 90.000 instances
and 7 attributes, 5 are binary recoded 
1 independend variable are a real one 
and the target is a real one,too.

The distributions are not very skewed in the dummy variables
,but in the real variables are ~ 60.000 
zero values instances, but zero means
no money is payed and is a important value!

Many thanks for help  suggestions,
regards,christian

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] add a point to regression line and cook's distance

2003-12-03 Thread Wiener, Matthew
If you know that the line should pass through (0,0), would it make sense to
do a regression without an intercept?  You can do that by putting -1 in
the formula, like:  lm(y ~ x - 1).

Hope this helps,

Matt

Matthew Wiener
RY84-202
Applied Computer Science  Mathematics Dept.
Merck Research Labs
126 E. Lincoln Ave.
Rahway, NJ 07065
732-594-5303 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Spencer Graves
Sent: Wednesday, December 03, 2003 5:51 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [R] add a point to regression line and cook's distance


  What is the context?  What do the outliers represent?  If you 
think carefully about the context, you may find the answer. 

  hope this helps.  spencer graves
p.s.  I know statisticians who worked for HP before the split and who 
still work for either HP or Agilent, I'm not certain which.  If you want 
to contact me off-line, I can give you a couple of names if that might 
help. 

[EMAIL PROTECTED] wrote:

Hi, 

This is more a statistics question rather than R question. But I thought
people on this list may have some pointers.

MY question is like the following:
I would like to have a robust regression line. The data I have are mostly
clustered around a small range. So
the regression line tend to be influenced strongly by outlier points (with
large cook's distance). From the application
's background, I know that the line should pass (0,0), which is far away
from the data cloud. I would like to add this
point to have a more robust line. The question is: does it make sense to do
this? what are the negative impacts if any?

thanks,
jonathan

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
  


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Questions on Random Forest

2003-11-25 Thread Wiener, Matthew
It looks like image_and_label has only 2 columns, so when you take
img_and_label[,2] you have a vector left.  Even if that weren't the case,
you're going to need to pass in both the gray scale points and labels,
presumably in a data frame.  You've created a character matrix below, so
you're just passing in a character vector of labels.

You'll probably want something like 
rf - randomForest(label~image,data=image_and_label,importance=TRUE,
proximity=TRUE),

assuming that image_and_label is a data frame with elements image and label.


For the second question, see the documentation for the predict method for
random forests; for the third, the answer is yes, random forests can be used
with multiple variables.

There is an introduction to the random forests package in volume 2, issue 3
of the R newsletter (available in the documentation section of cran).

Hope this helps,

Matt Wiener

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Fucang Jia
Sent: Monday, November 24, 2003 10:31 AM
To: [EMAIL PROTECTED]
Subject: [R] Questions on Random Forest


Hi, everyone,

I am a newbie on R. Now I want to do image pixel classification by random 
forest. But I has not a clear understanding on random forest. Here is some 
question:

As for an image, for example its size is 512x512 and has only one variable 
-- gray level. The histogram of the image looks like mixture Gaussian Model,

say Gauss distribution (u1,sigma1), (u2,sigma2),(u3,sigma3). And a image 
classified by K-means or EM algorithm, so the class label image is also 
512x512 and has 0, 1, 2 value.

I read the binary image data as follows:

datafile - file(bone.img,rb)
img - readBin(datafile,size=2,what=integer,n=512*512,signed=FALSE)
img - as.matrix(img)
close(datafile)

labelfile - file(label.img,rb)
label - readBin(labelfile,size=2,what=integer,n=512*512,signed=FALSE)
label - as.matrix(label)
close(labelfile)

img_and_label - c(img,label)  // binds the image data and class label
img_and_label - as.matrix(img_and_label)
img_and_label - array(img_and_label, dim=c(262144,2))


Random Forest need a class label like Species in the  iris. I do not know 
how
to set a class label like Species to the img.  So I run the command as 
follows:

set.seed(166)
rf - randomForest(img_and_label[,2],data=image_and_label,importance=TRUE,
proximity=TRUE)

which outputs:

Error in if (n == 0) stop(data (x) has 0 rows) :
argument is of length zero

Could anyone tell what is wrong and how can do the RF?

Secondly, if there is an new image , say img3 (dimension is 512x512,too), 
how can I
use the former result to classifify the new image?

Thirdly, whether or not random forest be used well if there is only one 
variable, say pixel
gray level, or three variables, such as red, green, blue color component to 
an true color
image?

Thank you very much!

Best,

Fucang


Fucang Jia, Ph.D student
Institute of Computing Technology, Chinese Academy of Sciences
Post.Box 2704
Beijing, 100080
P.R.China
E-mail:[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] 64-bit R on AIX?

2003-10-14 Thread Wiener, Matthew
R-helpers --

Has anyone gotten R to compile as a 64-bit application on AIX 5L (or any
other version)?

(I don't have the details of the errors here, as I'm not the person actually
doing the compiling.  I might be able to get them if someone wants to see
them in particular.)

Thanks for any help.

Matthew Wiener
RY84-202
Applied Computer Science  Mathematics Dept.
Merck Research Labs
126 E. Lincoln Ave.
Rahway, NJ 07065
732-594-5303

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] newby problem - concatenate lists

2003-09-19 Thread Wiener, Matthew
c(x,y) will do it.
Hope this helps -Matt

-Original Message-
From: Axel Benz [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 19, 2003 8:57 AM
To: [EMAIL PROTECTED]
Subject: [R] newby problem - concatenate lists


Hi,
a very basic question:
What ist the easiest way in R to concatenate two lists of vectors?
E.g, I have
x-list(c(1,2))
y-list(c(3,4))
and I want to receive
list(c(1,2),c(3,4))

thank you!

Axel

Fraunhofer Institut fuer
Arbeitswirtschaft und Organisation (IAO)
Dipl. Inf. Axel Benz
Nobelstr. 12
D-70569 Stuttgart
Germany
Tel. +49(0)7119702289
Fax. +49(0)7119702192
mail: mailto:[EMAIL PROTECTED]
www: http://www.vis.iao.fhg.de



[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Getting 2 kinds of quotes inside a pasted string

2003-09-11 Thread Wiener, Matthew
Hi, all.

I would like to use pipe to run a file through an awk program before
scanning (to reduce the amount of data I'll be taking in).  I would like to
construct the awk program in R, and also to be able to set the awk variable
FS, to accommodate different field separators in different files.

My problem is that I keep getting the quotes escaped in the string that
comes out, and that sets the field separator to something different.

What I'd like to end up with is something like: 
awk 'BEGIN{FS=;}'  
If I can get this, I can put the rest of the awk program together.  What I
actually keep getting is 
awk 'BEGIN{FS=\;\}'.  
That is, the quote characters are escaped.

I can print this with quote = FALSE, and get the string I'm looking for.
But when I paste that into the larger awk program, the quotes are
nonetheless escaped (presumably because the print, quote = FALSE affects
only display and not the internal structure).

I've also tried sprintf, but run into the same problem.  I'd very much
appreciate it if someone could show me how to create the string I'm looking
for, or tell me a better way to go about filtering the file in the first
place.  I'd prefer not to scan in everything and do the subsetting in R; the
files I'm using are very large, and the whole point is not to have to load
the whole file into memory.

Thanks very much,

Matthew Wiener
RY84-202
Applied Computer Science  Mathematics Dept.
Merck Research Labs
126 E. Lincoln Ave.
Rahway, NJ 07065
732-594-5303 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Variance Computing- - HELP!!!!!!!!!!!!!!!!!!

2003-08-19 Thread Wiener, Matthew
Hi.

There is no reason the variance of a normal should decrease as you take
larger samples.  Indeed, in your call itself, you say that you want a sample
from a normal with a standard deviation of 3, and so a variance of 9.  As
expected, both of your estimates of variance are close to 9.

What should decrease is the variance of the estimate of the mean, which is
the variance of the sample divided by the number of elements in your sample.
That will indeed decrease as n increases.
 
Also, a couple of R programming points raised by your example:

You can populate your entire matrix of random numbers with a single call,
with good time savings.  (That probably doesn't matter much in this toy
example, but might if you do larger simulations for some problem.)
For example:  matrix(rnorm(10, 0, 3), nr = 100, nc = 1000) gets you your
matrix small.

Similarly, your loop over the rows for taking variance can be replaced by 
yy - apply(small, 1, var)
Which may not be faster, but is certainly easier to read.  And of course
you'd want to replace the call to var with a function that calculates
standard error.

Hope this helps,

Matt Wiener


-Original Message-
From: Padmanabhan, Sudharsha [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 19, 2003 1:43 PM
To: [EMAIL PROTECTED]
Subject: [R] Variance Computing- - HELP!!



Hello,

I am running a few simulations for clinical trial anlysis. I want some help 
regarding the following.

We know trhat as the sample size increases, the variance should decrease,
but 
I am getting some unexpected results. SO I ran a code (shown below) to check

the validity of this.

large-array(1,c(1000,1000))
small-array(1,c(100,1000))
for(i in 1:1000){large[i,]-rnorm(1000,0,3)}
for(i in 1:1000){small[i,]-rnorm(100,0,3)}}
yy-array(1,100)
for(i in 1:100){yy[i]-var(small[i,])}
y1y-array(1,1000)
for(i in 1:1000){y1y[i]-var(large[i,])}
mean(yy);mean(y1y);
[1] 8.944
[1] 9.098


This shows that on an average,for 1000 such samples of 1000 Normal numbers, 
the variance is higher than that of a 100 samples of 1000 random numbers.

Why is this so?


Can someone please help me out

Thanks.

Regards

~S.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

--
Notice:  This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (Whitehouse Station, New Jersey, USA), and/or
its affiliates (which may be known outside the United States as Merck Frosst,
Merck Sharp  Dohme or MSD) that may be confidential, proprietary copyrighted
and/or legally privileged, and is intended solely for the use of the
individual or entity named on this message.  If you are not the intended
recipient, and have received this message in error, please immediately return
this by e-mail and then delete it.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] exporting help

2003-07-08 Thread Wiener, Matthew
Perhaps you should read one of the introductory manuals in the Contributed
Documentation section of cran.us.r-project.org.  This will introduce many
of the basic commands, and save you time and frustration.

You will probably end up wanting to use either read.table or scan to get
your data into R.

Hope this helps,

Matt Wiener

-Original Message-
From: Ashley Minor [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 08, 2003 4:17 PM
To: [EMAIL PROTECTED]
Subject: [R] exporting help


i need step by step directions on how to export a text file into the r
file

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

--
Notice: This e-mail message, together with any attachments, ...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] cumulative frequency distribution plot

2003-06-24 Thread Wiener, Matthew
You can also take a look at ecdf in the stepfun package.

Hope this helps,
Matt

-Original Message-
From: Spencer Graves [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 24, 2003 2:39 PM
To: Tommy E. Cathey
Cc: [EMAIL PROTECTED]
Subject: Re: [R] cumulative frequency distribution plot


  It depends on what you mean by that.  Consider the following:

  x - rnorm(100)
  plot(x, pnorm(x))

  This plot is a cdf of pseudo-normal data.

  I've seen many people make these things, and I've never understoon

what they see in these plots that they can't see better in a normal 
probability plot:

  qqnorm(x, datax=T)

  What can you see in the first type plot that is not so easily seen
in 
the second?

Spencer Graves

Tommy E. Cathey wrote:
 Does R do cumulative frequency distribution plots?
 
 --
 Tommy E. Cathey, Senior Scientific Application Consultant
 High Performance Computing  Scientific Visualization
 SAIC, Supporting the EPA
 Research Triangle Park, NC
 919-541-1500 EMail: [EMAIL PROTECTED]
 My e-mail does not reflect the opinion of SAIC or the EPA.
 
 Federal Contact - John B. Smith
 919-541-1087- [EMAIL PROTECTED]
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

--
Notice: This e-mail message, together with any attachments, cont... {{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Combining the components of a character vector

2003-04-04 Thread Wiener, Matthew
The collapse argument does what you want:

x - c(Bob, loves, Sally)
paste(c, collapse =  )

Hope this helps,

Matt Wiener

-Original Message-
From: John Miyamoto [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 02, 2003 6:54 PM
To: R discussion group
Subject: [R] Combining the components of a character vector


Dear Help,
   Suppose I have a character vector.

x - c(Bob, loves, Sally)

I want to combine it into a single string:  Bob loves Sally .
paste(x) yields:
paste(x)
[1] Bob   loves Sally

The following function combines the character vector into a string in the
way that I want, but it seems somewhat inelegant.

paste.vector - function(x, ...) {
output - NULL
for (i in 1:length(x)) output - paste(output, x[i], ...)
output  } #end of function definition

paste.vector(x)
[1]  Bob loves Sally

Is there a more natural (no loop) way to do this in R?

John Miyamoto


John Miyamoto, Dept. of Psychology, Box 351525
University of Washington, Seattle, WA 98195-1525
Phone 206-543-0805, Fax 206-685-3157, Email [EMAIL PROTECTED]
Homepage http://faculty.washington.edu/jmiyamot/


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] cdf function: inverse to quantile?

2003-04-04 Thread Wiener, Matthew
Take a look at ecdf in package stepfun.

-Original Message-
From: DED (David George Edwards) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 03, 2003 6:20 AM
To: '[EMAIL PROTECTED]'
Subject: [R] cdf function: inverse to quantile?


Is there a function in R for calculating empirical cumulative distribution
functions, i.e. the inverse of the quantile function? Perhaps in some
library? I'd hate to have to re-invent the wheel.


David Edwards, Biostatistics, 
Novo Nordisk A/S, Bagsværd, Denmark.
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
Tlf: +45 44 42 62 35. Fax: +45 44 42 14 80


[[alternate HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] a statistic question about chisq.test()

2003-03-26 Thread Wiener, Matthew
One other option.

I usually find that when I do the chisq.test with exact p-value calculation,
I find the p-values are nearly identical to the results when I use the
approximation and get the warnings (I'm usually dealing with just a few bins
with less than 5, and many bins with more than 5).

So frequently, when I'm using chisq.test in a program, and expect to do it
many times, I'll sometimes eliminate the warnings this way:

old.warn - options()$warn
options(warn = -1)
 do the chisq.test here 
options(warn = old.warn)

This will suppress the warning messages.  

Hope this helps.

Matt Wiener

-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 26, 2003 4:24 PM
To: aprilsun
Cc: [EMAIL PROTECTED]
Subject: Re: [R] a statistic question about chisq.test()


aprilsun wrote:
 
 Hi,
 In the chisq.test(), if the expected frequency for some categories is 5,
there will be a warning message which says
 Warning message:
 Chi-squared approximation may be incorrect in: chisq.test(x, p = probs)

It's a warning message, not an error. It point's you to the problem that
a number  5 is not large, whereas in theory large numbers are
assumed when running this test.

 
 I am wondering whether there are some methods to get rid of this
mistake... Seems the ?chisq.test() doesn't provide more
 options to solve this problem. Or, the only choice is to preprocess the
data to avoid this situation?

It depends on the problem. Fisher's exact test (or it's extended
version) might be an alternative, see ?fisher.test and an appropriate
statistics textbook.

Uwe Ligges


 Thanks a lot!
 
 aprilsun

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] manipulating ... inside a function

2003-03-21 Thread Wiener, Matthew
As Brian Ripley pointed out in a recent post, you can just give g() its own
... argument.

Regards, 

Matt Wiener

-Original Message-
From: Liaw, Andy [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 21, 2003 3:37 PM
To: '[EMAIL PROTECTED]'
Subject: [R] manipulating ... inside a function


Dear R-help,

Can some one tell me how to do the following (if it's possible)?

Suppose I have a function like this:

f - function(x, y, ...) {
## some code
g(x, y, ...)
   ## some more code
}

The problem is that g() may not understand everything that comes through in
  Is there a way to delete some component of ... and then pass it to
g()?

Here's the description of the real problem:  f() is a panel.something
function, and g() is a model fitting function.  Lattice passes
panel.number as part of ... to f(), and g() complains about unused
argument panel.number.

I'd be very grateful for any help!

Cheers,
Andy



--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


--
Notice: This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (Whitehouse Station, New Jersey, USA) that
may be confidential, proprietary copyrighted and/or legally privileged, and
is intended solely for the use of the individual or entity named on this
message.  If you are not the intended recipient, and have received this
message in error, please immediately return this by e-mail and then delete
it.


==


--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] r-help using random generating

2003-03-19 Thread Wiener, Matthew
You can save some time by generating all your samples at one time:

t1 - matrix(rnorm(5 * n, 100, 10), nc = n)
apply(t1, 2, mean)
(Or use colVars and colMeans to save even more time)

Hope this helps,

Matt Wiener

-Original Message-
From: Cheryl H. [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 18, 2003 11:26 PM
To: [EMAIL PROTECTED]
Subject: [R] r-help using random generating


To whom it may concern:
Given that my sample size is n, my mean is 100, and my sd is 10, I need to 
use a random number generator (which I believe is the function 
rnorm(5,100,10)), but I need to repeat it a large number of times, and then 
plot the sampling distributions of the sample means, sd's, and variances of 
those generated sets. I'm having a real hard time trying to figure out how 
to do this easily. Please help if possible! Thanks,
Cheryl

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] multidimensional function fitting

2003-02-27 Thread Wiener, Matthew
Take a look at package mgcv.  Hope this helps.  --Matt

-Original Message-
From: RenE J.V. Bertin [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 27, 2003 1:39 PM
To: [EMAIL PROTECTED]
Subject: [R] multidimensional function fitting


Hello,

I have been looking around for how to perform a multidimensional, arbitrary
function fit (in any case non-linear; more below), but haven't found
anything yet on how to accomplish this. I found some references to the
funfits package (that apparently is now called fields), but as far as I have
understood it, it does not do what I need.

Basically, I have a set of data that describe some measured, dependent
variable as a function of a number of controlled variables, in casu
z=f(x,y). What I need is to obtain some f that reliably describes my data on
the range of controlled variables. (This is for inverse-filtering in a
visual stimulus programme, so I don't really care about the form of f as
long as it is reasonably simple to implement -- i.e. a spline surface would
not be ideal in the context ;^). )

Clearly, something like

fit-lm(z~x+y+x*y+x*x+y*y, data)

does not give the result I want.

Is there a package somewhere that allows to do this sort of operation? Like
a multidimensional version of polyreg()?

Thanks in advance,
RenE Bertin

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

--

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] help on cut?

2003-01-29 Thread Wiener, Matthew
cut returns a factor.  Try something like 

t1 - cut(data.vector, breaks = my.breaks, labels = my.label)
as.numeric(as.character(t1))

This is an issue that comes up frequently with factor.  Take a look at the
help page for factor for some warnings.

Hope this helps,

Matt Wiener

-Original Message-
From: Nina Wawro [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003 11:39 AM
To: R-help
Subject: [R] help on cut?


Dear R-users,

I'm trying to recode a variable.
After using
cut(data.vector,breaks=my.breaks,labels=my.label)
I need the data.vector to have the same values as the labels.


To make it clear:
x-runif(10)
y-cut(x,breaks=c(0,0.3,0.7,0.9,1),labels=c(3,6,7,9))
as.numeric(y) returns something like a vector 1 3 3 2 2 1 4 2 3 4 .
I need something like 3 7 7 6 6 3 7 9 6 7 9 for further use.

I might be using the wrong function but a loop seems to be inefficient as I
need to do it about 60 times with varying length of labels
Is there a quick solution?
Thanks for any help in advance!

Nina Wawro

R.1.6.0 on Windows2000

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


--

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help