Re: [R] search path question

2007-05-29 Thread David Forrest
On Tue, 29 May 2007, Zhiliang Ma wrote:

> Hi R users,
>
> Is there a simple function that can add a folder into current R search path?

This works for adding libraries to your search path, but I don't think it 
would work for finding data files outside of your getwd() quite as you'd 
like:

.libPaths(c("/home/foo/R/library",.libPaths()))

> For example, suppose my current work directory is "D:\work", but my input
> files are stored in folder "C:\inFiles\",  I know I can change work
> directory or add "C:\inFiles\" before files name when I scan them, but I
> don't want to do that. I want to find a function that can simply add
> "C:\inFiles\" into R's search path, so that we I scan a file R will go to
> all the search paths to find it. In matlab, path(path,"C:\inFiles") will do
> this job, I'm just wondering if there is a similar function in R can do this
> job.
>
> Thanks,
> zhiliang
>
>   [[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.
>

-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Partitioning a kde2d into equal probability areas

2007-05-04 Thread David Forrest
Hi,

I'd like to partition a 2d probability density function into regions of 
equal probability.  It is straightforward in the 1d case, like 
qnorm(seq(0,1,length=5)) but for 2d I'd need more constraints.

Any suggestions for how to approach this?  Is seems like a spatial 
sampling problem but I'm not sure where to look.

Thanks for your time,

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Random Number Generator of Park and Miller

2007-04-25 Thread David Forrest
On Tue, 24 Apr 2007, gracezhang wrote:

>
> Hi,
>
> I failed to search for R package providing random number generator of "Park
> and Miller".
> Anyone know any R package supporting this kind of function?

rng.lcg<-function(x,p1=16807,p2=0,N=2147483647){(x*p1+p2)%%N}

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] graphs superimposed on pictures?

2007-04-11 Thread David Forrest
On Wed, 11 Apr 2007, Robert Biddle wrote:

> Hi:
>
> I am doing some work that involves plotting points of interest
> superimposed on photographs and maps. I can produce the plots fine in R, but 
> so far
> I have had to do the superimposition externally, which makes it tedious to do 
> exploratory work.
> I have looked to see if there is some capability to put a background picture 
> on a plot window,
> but I have not found anything.
> Advice, anyone?

The cover from Paul Murrell's book "R Graphics" does just that.
http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html for 
examples.

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 nnet

2007-03-27 Thread David Forrest
On Tue, 27 Mar 2007, Nguyen Thanh Khiem wrote:

> I have a problem when using nnet to predict the negative values. For example
> :
>
> X = matrix(c(1,1,0,0,1,0,1,0),4,2)
> X
> Y = matrix(c(0,1,1,0)) - 0.5 # XOR - 0.5
> Y
> nn = nnet(X,Y,size=3)
> val = predict(nn,X)
> val # this is expected to be close to Y, but it's not !
>
> The 'val' is always positive. I tried to change the options, but the result
> isn't much better.

nn = nnet(X,Y,size=3,linout=TRUE)
> val = predict(nn,X)
> val # this is expected to be close to Y, but it's not !
[,1]
[1,] -0.4994022
[2,]  0.4996643
[3,]  0.4994101
[4,] -0.4996929

>
> Could someone give me an advice ? I searched everywhere I can but nothing
> found.

?nnet

especially:

   linout: switch for linear output units. Default logistic output
   units.

>
> Thanks a lot.
>
>

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] reading BMP into R

2007-03-12 Thread David Forrest
On Mon, 12 Mar 2007, Milton Cezar Ribeiro wrote:

> Hi R-gurus
>
> How can I read my "bmp" files into R?

RSiteSearch('bmp')
system('convert my.bmp my.pnm')
library(pixmap)
?read.pnm

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] color quantization / binning a variable into levels

2007-02-21 Thread David Forrest
My apologies for the tremendously tardy reply, but I ran into a 
similar problem and discovered findInterval and colorRampPallet 
as an alternative and though it might be worthy of a RSiteSearch() result 
for someone.

?findInterval
?colorRampPalette

jet.colors <-
colorRampPalette(c("#7F", "blue", "#007FFF", "cyan",
   "#7FFF7F", "yellow", "#FF7F00", "red", 
"#7F"))

c.min<-range(volcano)[1]
c.max<-range(volcano)[2]
c.n<-200
c.brks<-seq(c.min,c.max,length=c.n)
c.ramp<-jet.colors(c.n)
c.ramp[findInterval(c.min,c.brks)]<-NA  #  make the first one transparent

# hack levelplot() or image()
plot(expand.grid(1:87,1:61),
   col=c.ramp[findInterval(volcano,c.brks,all.inside=TRUE)],
   pch='.',cex=10)

Dave

On Wed, 22 Feb 2006, Adelchi Azzalini wrote:

> On Tue, 21 Feb 2006 11:08:38 -0600 (CST), David Forrest wrote:
>
> perhaps "binning" of package "sm" is what you want
>
> best wishes,
> Adelchi Azzalini
>
> DF> Hi all,
> DF>
> DF> I'd like to quantize a variable to map it into a limited set of
> DF> integers for use with a colormap.  "image" and filled.contour"  do
> DF> this mapping inside somewhere, but I'd like to choose the colors
> DF> for plotting a set of polygons.  Is there a pre-existing function
> DF> that does something like this well?  i.e., is capable of using
> DF> 'breaks'?
> DF>
> DF> quantize<-function(x,n=10, breaks=NULL){
> DF> # bin the variable x into n levels
> DF>   xmin<-min(x)
> DF>   xmax<-max(x)
> DF>   1+floor(n*(x-xmin)/(xmax-xmin)*.999)
> DF> }
> DF>
> DF> x<- -10:10
> DF> cbind(x,quantize(x,2),quantize(x),quantize(x,21))
> DF>
> DF> quantize(x,breaks=c(5,7))   #
> DF>
> DF> Thanks for your time,
> DF>
> DF> Dave
>
>

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Start and Restart R over SSH

2007-02-19 Thread David Forrest
On Mon, 19 Feb 2007, Benilton Carvalho wrote:

> Hi Nils,
>
> if the server you're using is *NIX, this is what you can do:
>
>  example
> ssh [EMAIL PROTECTED]
> screen
> R
>
> << do what you need in R>>
> << close the terminal without quitting R >>
>
> ssh [EMAIL PROTECTED]
> screen -r
> << continue working in R >>
> %% end example
>
> the "problem" is if you need X... it works until you quit the
> terminal, but "screen -r" doesn't reconnect the X11.

I find vnc sometimes helps with keeping a X active for an R session.

Also, if you take care to close your x11 devices, and if when you re-ssh 
you happen to get the same forwarded X DISPLAY=localhost:11.0 or whatever, 
the R session in screen will use the new forwarded connection.

It also seems like using Sys.putenv(DISPLAY='localhost:11.0')  overrides 
the DISPLAY that screen's child R session inherits from the initial 
invocation of screen.

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] feedback on "writing r extensions"

2007-01-16 Thread David Forrest
On Tue, 16 Jan 2007, Gabor Grothendieck wrote:

> It would also be nice if there were links in the .Rd files back
> to the source of the commands, not just the source of the
> documentation.   That would facilitate
> and encourage readers to paruse the source to clarify
> the meaning of the help files.

Perhaps it would be feasible to make an RSourceSearch() function (like 
RSiteSearch()) that could recognize things like documentation, functions, 
and internals and direct users to the source code.

Dave

> On 1/16/07, David Forrest <[EMAIL PROTECTED]> wrote:
>> On Tue, 16 Jan 2007, Martin Maechler wrote:
>>
>>>>>>>> "Scott" == Scott Harrison <[EMAIL PROTECTED]>
>>>>>>>> on Mon, 15 Jan 2007 13:15:09 -0500 writes:
>> ...
>>> For "edits", we'd mostly like to receive feedback on the
>>> *source* of the above automatically produced document
>>> (which is also the source of the PDF version, same URL as above,
>>> just replace ".html" by ".pdf")
>>>
>>> The development source is always available at
>>>  https://svn.r-project.org/R/trunk/doc/manual/R-exts.texi
>>
>> Would it be horrid to include the reference to the sources in the derived
>> documents?  It might help with self-documenting the process and help
>> demonstrate the benefits of R's open source philosophy.
>>
>>> Thanking you for offering feedback,
>>
>> Thank you.
>>
>> Dave
>> --
>>  Dr. David Forrest
>>  [EMAIL PROTECTED](804)684-7900w
>>  [EMAIL PROTECTED] (804)642-0662h
>>http://maplepark.com/~drf5n/
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.
>

-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] feedback on "writing r extensions"

2007-01-16 Thread David Forrest
On Tue, 16 Jan 2007, Martin Maechler wrote:

>>>>>> "Scott" == Scott Harrison <[EMAIL PROTECTED]>
>>>>>> on Mon, 15 Jan 2007 13:15:09 -0500 writes:
...
> For "edits", we'd mostly like to receive feedback on the
> *source* of the above automatically produced document
> (which is also the source of the PDF version, same URL as above,
> just replace ".html" by ".pdf")
>
> The development source is always available at
>  https://svn.r-project.org/R/trunk/doc/manual/R-exts.texi

Would it be horrid to include the reference to the sources in the derived 
documents?  It might help with self-documenting the process and help 
demonstrate the benefits of R's open source philosophy.

> Thanking you for offering feedback,

Thank you.

Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] zero margin / marginless plots (in lattice?)

2007-01-12 Thread David Forrest
On Thu, 11 Jan 2007, David Forrest wrote:

> Thanks.  The xaxs|yaxs='i' works well for the base graphics.  Is there an
> additional parameter in play for lattice graphics?  The closest I could
> gotten is the below which still leaves a bit of a margin:
>
> xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
> xyplot(y~x,xy,scales=list(axs='i',draw=FALSE),type='l',xlab=NULL,ylab=NULL)


>From an old email of Depayan's I see these margins in lattice are are due 
to 'padding' and this lattice theme seems to eliminate them:

theme.novpadding <-
   list(layout.heights =
list(top.padding = 0,
main.key.padding = 0,
key.axis.padding = 0,
axis.xlab.padding = 0,
xlab.key.padding = 0,
key.sub.padding = 0,
bottom.padding = 0),
layout.widths =
list(left.padding = 0,
key.ylab.padding = 0,
ylab.axis.padding = 0,
axis.key.padding = 0,
right.padding = 0))


Then, using the quakes data example from ?xyplot :

library(stats)
xyplot(lat~long,quakes,
   scales=list(axs='i',draw=FALSE),
   ,xlab=NULL,ylab=NULL,par.settings = theme.novpadding)


...Then this graphic should drop nicely into GoogleEarth with a 
boundingbox matching the data:

range(quakes$lat);range(quakes$long)
[1] -38.59 -10.72
[1] 165.67 188.13

dev.copy(png,width=400,height=400,file='quakes.png')

and post it to the web and KMZ file as at:

http://www.maplepark.com/drf5n/extras/R_xyplot_googleEarth.kmz

Thanks.

>
> Dave
>
> On Wed, 10 Jan 2007, Marc Schwartz wrote:
>
>> On Wed, 2007-01-10 at 21:18 -0600, David Forrest wrote:
>>> Hi,
>>>
>>> I'd like to produce a marginless or zero margin plot so that the pixel
>>> coordinates represent the mathematics.
>>>
>>> xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
>>> png('junk.png',width=300,height=300)
>>> par(mar=c(0,0,0,0))
>>> plot(xy$x,xy$y,xlim=c(0,1),ylim=c(,1))
>>> dev.off()
>>>
>>> The resultant file has about a 10 pixel margin around these lines, and I'm
>>> not sure what parameter or function is controlling this offset.  Any
>>> hints?
>>>
>>> Thanks for your time,
>>> Dave
>>
>> By default, the axis ranges are extended by +/- 4%.  You can change this
>> by using:
>>
>>  plot(xy$x, xy$y, xlim = c(0, 1), ylim = c(0, 1),
>>   xaxs = "i", yaxs = "i")
>>
>> where 'xaxs' and 'yaxs' set the axis ranges to the actual data ranges.
>>
>> See ?par for more information.
>>
>> HTH,
>>
>> Marc Schwartz
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] zero margin / marginless plots (in lattice?)

2007-01-12 Thread David Forrest
On Thu, 11 Jan 2007, David Forrest wrote:

> Thanks.  The xaxs|yaxs='i' works well for the base graphics.  Is there an
> additional parameter in play for lattice graphics?  The closest I could
> gotten is the below which still leaves a bit of a margin:
>
> xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
> xyplot(y~x,xy,scales=list(axs='i',draw=FALSE),type='l',xlab=NULL,ylab=NULL)

Hi again,

If there isn't a way to completely eliminate the margins in lattice/grid 
plots, is there a way to find the graphic device extents as measured in 
data coordinates?

Dave


>
> Dave
>
> On Wed, 10 Jan 2007, Marc Schwartz wrote:
>
>> On Wed, 2007-01-10 at 21:18 -0600, David Forrest wrote:
>>> Hi,
>>>
>>> I'd like to produce a marginless or zero margin plot so that the pixel
>>> coordinates represent the mathematics.
>>>
>>> xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
>>> png('junk.png',width=300,height=300)
>>> par(mar=c(0,0,0,0))
>>> plot(xy$x,xy$y,xlim=c(0,1),ylim=c(,1))
>>> dev.off()
>>>
>>> The resultant file has about a 10 pixel margin around these lines, and I'm
>>> not sure what parameter or function is controlling this offset.  Any
>>> hints?
>>>
>>> Thanks for your time,
>>> Dave
>>
>> By default, the axis ranges are extended by +/- 4%.  You can change this
>> by using:
>>
>>  plot(xy$x, xy$y, xlim = c(0, 1), ylim = c(0, 1),
>>   xaxs = "i", yaxs = "i")
>>
>> where 'xaxs' and 'yaxs' set the axis ranges to the actual data ranges.
>>
>> See ?par for more information.
>>
>> HTH,
>>
>> Marc Schwartz
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] zero margin / marginless plots (in lattice?)

2007-01-11 Thread David Forrest
Thanks.  The xaxs|yaxs='i' works well for the base graphics.  Is there an 
additional parameter in play for lattice graphics?  The closest I could 
gotten is the below which still leaves a bit of a margin:

xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
xyplot(y~x,xy,scales=list(axs='i',draw=FALSE),type='l',xlab=NULL,ylab=NULL)

Dave

On Wed, 10 Jan 2007, Marc Schwartz wrote:

> On Wed, 2007-01-10 at 21:18 -0600, David Forrest wrote:
>> Hi,
>>
>> I'd like to produce a marginless or zero margin plot so that the pixel
>> coordinates represent the mathematics.
>>
>> xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
>> png('junk.png',width=300,height=300)
>> par(mar=c(0,0,0,0))
>> plot(xy$x,xy$y,xlim=c(0,1),ylim=c(,1))
>> dev.off()
>>
>> The resultant file has about a 10 pixel margin around these lines, and I'm
>> not sure what parameter or function is controlling this offset.  Any
>> hints?
>>
>> Thanks for your time,
>> Dave
>
> By default, the axis ranges are extended by +/- 4%.  You can change this
> by using:
>
>  plot(xy$x, xy$y, xlim = c(0, 1), ylim = c(0, 1),
>   xaxs = "i", yaxs = "i")
>
> where 'xaxs' and 'yaxs' set the axis ranges to the actual data ranges.
>
> See ?par for more information.
>
> HTH,
>
> Marc Schwartz
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] zero margin / marginless plots

2007-01-10 Thread David Forrest
Hi,

I'd like to produce a marginless or zero margin plot so that the pixel 
coordinates represent the mathematics.

xy<-data.frame(x=c(0,1,1,0,0),y=c(0,1,0,0,1))
png('junk.png',width=300,height=300)
par(mar=c(0,0,0,0))
plot(xy$x,xy$y,xlim=c(0,1),ylim=c(,1))
dev.off()

The resultant file has about a 10 pixel margin around these lines, and I'm 
not sure what parameter or function is controlling this offset.  Any 
hints?

Thanks for your time,
Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Does strptime(...,tz="GMT") do anything?

2007-01-08 Thread David Forrest
Hi All

In trying to correlate some tide gauge data I need to deal with varying 
timezones.  From the documentation on strptime, it seemed that the tz 
variable might have some effect on the conversion, but I'm not seeing an 
effect.

> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="PST")+0
[1] "2006-12-01 01:02:00 EST"
> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="")+0
[1] "2006-12-01 01:02:00 EST"
> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="GMT")+0
[1] "2006-12-01 01:02:00 EST"
> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="UTC")+0
[1] "2006-12-01 01:02:00 EST"
> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="EST")+0
[1] "2006-12-01 01:02:00 EST"

What is the recommended way of handling this?  Computing and adding 
offsets manually?

> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="UTC")+3600*3
[1] "2006-12-01 04:02:00 EST"

Or am I doing something wrong with the strptime(..., tz="EST") function?

Thanks for your time,
Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] acos(0.5) == pi/3 FALSE

2006-09-18 Thread David Forrest
On Mon, 18 Sep 2006, [iso-8859-1] I?aki Murillo Arcos wrote:

> Hello,
>
>   I don't know if the result of
>
>   acos(0.5) == pi/3
>
> is a bug or not. It looks strange to me.

Real numbers are strange.  Would the result of:

acos(0.5) - pi/3

close enough to zero for you?  Try help('Comparison') ,  ?'==' for an
explanation, or 'abs(acos(0.5) - pi/3) < 1e-9' for a solution.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] color quantization / binning a variable into levels

2006-02-21 Thread David Forrest
Hi all,

I'd like to quantize a variable to map it into a limited set of integers
for use with a colormap.  "image" and filled.contour"  do this mapping
inside somewhere, but I'd like to choose the colors for plotting a set of
polygons.  Is there a pre-existing function that does something like this
well?  i.e., is capable of using 'breaks'?

quantize<-function(x,n=10, breaks=NULL){
# bin the variable x into n levels
  xmin<-min(x)
  xmax<-max(x)
  1+floor(n*(x-xmin)/(xmax-xmin)*.999)
}

x<- -10:10
cbind(x,quantize(x,2),quantize(x),quantize(x,21))

quantize(x,breaks=c(5,7))   #

Thanks for your time,

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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

2006-01-09 Thread David Forrest
On Mon, 9 Jan 2006, Gabor Grothendieck wrote:

> On 1/9/06, Thomas Lumley <[EMAIL PROTECTED]> wrote:
> > On Mon, 9 Jan 2006, Michael Dewey wrote:
> > >
> > > Further to that I feel that (perhaps because they do not like to blow 
> > > their
> > > own trumpet too much) the authors of books on R do not stress how much 
> > > most
> > > questioners could gain by buying and reading at least one of the many 
> > > books
> > > on R. When I started I found the free documents useful but I made most
> > > progress when I bought MASS. I do realise that liking books is a bit last
> > > millennium.
> > >
> >
> > Very late last millenium, though.
> > "When I were young[er] we didn't have all these fancy yellow books."
> >
> > More seriously, yes, reading books about R and S is very effective and is
> > how most of the R experts learned.  In my case it was the Blue Book, the
> > White Book, and the Ripley/Venables/Smith notes on S-plus (which have
> > evolved to the Introduction to R).
>
> In addition to books, the various manuals, contributed documents and
> mailing list archives, all of which one should review,
> the key thing to do if you want to really learn R is to read source code
> and lots of it.  I think there is no other way.  Furthermore, the fact that
> you can do this is really a key advantage of open source.

There has to be some reason to dig into the source code.  Just starting at
line 1 and reading until you are enlightened would be frustrating,
repetetive, and nearly pointless.  The great benefits of the R books is
that they have interesting results (a fancy graph, analysis, or report)
that you can trace back to the constituent parts and (with open source
code) learn everything you want to and be confident that the rest is there
if you need it.  Books using R do an excellent job of showing what is
possible and, through recursive study of the open source code, how to do
it.  Books connect high-level tasks to low-level functions.

R has plenty of documentation, but if the measure of excellence is simply
number of pages or weight, SAS's documentation might still win even if we
include the pages of R source code.  Both packages have lots of detailed
documentation, where if you understood everything that was written, you'd
know how to do what you want.  The authors of neither R nor SAS have
failed to document their functions.

Where I think the R (and SAS) documentation is lacking is in the
connections between the documentation elements.  RTFM isn't helpful if you
can't find TFM.  For instance, there is more than one way to make a graph,
(see http://addictedtor.free.fr/graphiques/thumbs.php?sort=package for 135
of them) how does a novice know which function to use?  How do you find
out the alternate ways to do things?  The hateful MS Excel solves this by
registering the alternate graphic capabilities under a hierarchical GUI
menu.  We solve it with an email list and several fuzzy searches.

Since R has such an extensive set of extensions, maybe we need a section
in the R-intro documentation near
http://cran.r-project.org/doc/manuals/R-intro.html#Writing-your-own-functions
titled "Finding existing functions".  It could explain the difference
between base and recommended, installed, CRAN, and how someone can find
and use things in these areas using help(), '?', help.search(),
help.start(), RSiteSearch(), and the mailing lists.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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

2006-01-08 Thread David Forrest
On Fri, 6 Jan 2006, Detlef Steuer wrote:
...
> Back to operating wikis:The wiki spamming is a serious problem,
> especially because I HATE to login to read or edit anything. So the
> choice is: take the wiki as seriously as work and have a look every
> other day to remove the spam (or better: form a group of volunteers).
> That hurts or at least is no fun. Or put restrictions on it. That hurts
> even more. Perhaps I do not understand Philippe`s "loggable". What does
> a logfile with IPs help? The spammers are strangers selling viagra; I
> don`t want to find them :-)

Sometimes you can mark the spammer's IP's as spammers and then ban editing
by them.  For my own UseMod wiki, I avoid spam by rejecting edits that
change more than 3 URLS.  But this is getting off of the R help topic.

> To sum it up:There is a very simple way to proceed:Philippe uses his
> Docuwiki install as official, _general_ Rwiki and I close down mine. The
> beginners will find their niche in there, if there is a real demand. I
> wouldn´t mind to give up "my" wiki, because I have to admit it failed
> to achieve what I would have liked.

I like wikis too, and contributed a few pages to your wiki.  The low
use-rate and high wiki spamming content makes it not a place I frequent.

> So, Philippe, if you like, you can take over. I would replace my wiki
> with a notice where to find yours and the community gets a second chance
> :-)

http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl does have some
useful content.  Maybe it would be good to wade through it and figure out
how to patch the standard R documentation to include those contributions.

An advantage of a wiki is the low barrier to adding correctable
documentation.  The email list also provides low-barrier-to-entry
documentation, and its success demonstrates the clear need for additional
documentation.

Considering that, maybe there would be a benefit in rolling references to
good email threads into the documentation in some sort of an automatic
method.  Perhaps if an email question leads to a clarification or good
example of a feature, someone could post a message to the thread that
tags it for inclusion by reference to relevant documentation in the next
release cycle.

If this wishful thinking would come to pass, then the standard
documentation could point people towards using the mail archive in a more
directly useful manner, and we'd retain the peer-reviewed answer quality
of the email list.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 comment about R:

2006-01-04 Thread David Forrest
On Tue, 3 Jan 2006, Gabor Grothendieck wrote:
...
> In fact there are some things that are very easy
> to do in Stata and can be done in R but only with more difficulty.
> For example, consider this introductory session in Stata:
>
> http://www.stata.com/capabilities/session.html
>
> Looking at the first few queries,
> see how easy it is to take the top few in Stata whereas in R one would
> have a complex use of order.  Its not hard in R to write a function
> that would make it just as easy but its not available off the top
> of one's head though RSiteSearch("sort.data.frame") will find one
> if one knew what to search for.

This sort of thing points to an opportunity for documentation.  Building a
tutorial session in R on how one would do a similar analysis would provide
another method of learning R.  "An Introduction to R" is a good bottom-up
introduction, which if you work through it does teach you how to do
several things.  Adapting other tutorials or extended problems, like the
Stata session, to R would give additional entry points.  A few end-to-end
tutorials on some interesting analyses would be helpful.

Any volunteers?

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] Element-by-element multiplication operator?

2005-11-09 Thread David Forrest
On Wed, 9 Nov 2005, Gates, Michael BGI SF wrote:

> Is there an element-by-element multiplication in R, like the .* operator in 
> Matlab?
>
> eg: A (2x3)
>  B (2x3)
> C=A.*B
> C (2x3)
> C = [[a11*b11  a12*b12  a13*b13]; [a21*b21  a22*b22  a23*b23]]
>
> I can't find one...

It is the default:

matrix(1:6,nrow=2) * cbind(1:2,1:2,1:2)
 [,1] [,2] [,3]
[1,]135
[2,]48   12

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

-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 1 month to a date

2005-10-12 Thread David Forrest
On Wed, 12 Oct 2005, Jim Porzak wrote:

>  OTOH,
>
>  > seq(as.Date("2004-01-31"), by = "month", length = 14)
>   [1] "2004-01-31" "2004-03-02" "2004-03-31" "2004-05-01" "2004-05-31"
>   [6] "2004-07-01" "2004-07-31" "2004-08-31" "2004-10-01" "2004-10-31"
>  [11] "2004-12-01" "2004-12-31" "2005-01-31" "2005-03-03"
>
>  I would prefer to see dates forced to be within each month, not
>  "leaking" into next month.
>
>  IOW:
>   [1] "2004-01-31" "2004-02-29" "2004-03-31" "2004-04-30" "2004-05-31", etc

It depends how you intend "1 month after 2004-01-31".  Is the the same
number of days before the beginning of the next month or after the end of
the stated month?

   seq(as.Date("2004-02-01"), by = "month", length = 14)-1

   [1] "2004-01-31" "2004-02-29" "2004-03-31" "2004-04-30" "2004-05-31"

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] 3d points for objects

2005-09-16 Thread David Forrest
On Fri, 16 Sep 2005, Robin Hankin wrote:

> Hi
>
> I am putting together some manpages for my octonion package,
> which is nearing completion.
>
> Does anyone have a dataset consisting of 3D coordinates of
> points that collectively form a shape reminiscent of a
> simple, friendly, recognizable object?  A few dozen points would
> be about the right size.
>
> Something like a teapot or a rabbit (or even the R logo!)
> would be good.
>

Try the teapot in netcdf:
http://www.maplepark.com/~drf5n/cgi-bin/wiki.cgi?RMeshVisualization
http://www.maplepark.com/~drf5n/extras/teapot.nc

>
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> 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
>

-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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

2005-08-24 Thread David Forrest
On Wed, 24 Aug 2005, Shin, David wrote:
...
> > system("c:\\program files\\sas institute\\v8\\sas.exe test")
> Warning message:
> c:\program not found

Escape the spaces too.  It is trying to run the program c:\program or
c:\progra~1\sas

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] Drawing information-rich, Tufte style scatterplots and axes

2005-06-16 Thread David Forrest
On Thu, 16 Jun 2005, Steven J. Murdoch wrote:

> I have been working on using R to draw information-rich graphs based
> on suggestions from "The Visual Display of Quantitative Information"
> by Edward Tufte.  Thanks to the members of the list who have helped me
> with this.
>
> I have now produced the first version of this code, which I used to
> generate graphs for a paper I recently co-authored. There are
> descriptions of the new functions, examples of their use and links for
> downloading the source here:
>
>  http://www.cl.cam.ac.uk/users/sjm217/projects/graphics/fancyaxis.html

Pretty.  Thanks.

>
> If anyone has any comments or suggestions I would be very interested.

I posted a link to it on the GraphGallery page of the R Wiki:
http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?GraphGallery

Why not make it a package?

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] Plotting quiver vector tensor arrows 2d field data

2005-06-14 Thread David Forrest
Hi All,

I'd like to plot something like
http://www.nawcwpns.navy.mil/~weather/mugu/mesodata/analysis.html

Looking through the galleries at
 http://addictedtor.free.fr/graphiques/allgraph.php
 http://r-spatial.sourceforge.net/gallery/
 http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?GraphGallery

 demo(graphics)

I did not find a function to plot a 2d field on a matrix.  I did find
mention of a quiver function in the archives.  Is this the best solution
or are there other tools I missed?

quiver<- function(u,v,scale=1,length=0.05)
# first stab at matlab's quiver in R
# from http://tolstoy.newcastle.edu.au/R/help/01c/2711.html
# Robin Hankin Tue 20 Nov 2001 - 13:10:28 EST
  {
xpos <- col(u)
ypos <- max(row(u))-row(u)

speed <- sqrt(u*u+v*v)
maxspeed <- max(speed)

u <- u*scale/maxspeed
v <- v*scale/maxspeed

matplot(xpos,ypos,type="p",cex=0)
arrows(xpos,ypos,xpos+u,ypos+v,length=length*min(par.uin()))
  }

par.uin <- function()
  # determine scale of inches/userunits in x and y
  # from http://tolstoy.newcastle.edu.au/R/help/01c/2714.html
  # Brian Ripley Tue 20 Nov 2001 - 20:13:52 EST
{
u <- par("usr")
p <- par("pin")
c(p[1]/(u[2] - u[1]), p[2]/(u[4] - u[3]))
}

u <- matrix(rnorm(100),nrow=10)
v <- matrix(rnorm(100),nrow=10)
quiver(u,v)

I added these functions as an example to the Wiki:
http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?GraphGallery
http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?QuiverPlot

Thanks for your time,
Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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/manage spatial boundary data

2005-06-10 Thread David Forrest
On Fri, 10 Jun 2005, Roger Bivand wrote:

> On Thu, 9 Jun 2005, David Forrest wrote:
>
> > I have some disconnected boundary data from a finite element ocean model
> > and I'd like to make a plot.
> >
> > Maptools looks promising, but since my data is not in a shapefile or a
> > map, I'm unclear on what the best way to approach the problem.
>
> If the line segments are unconnected, you will first need to establish
> (short) lists saying which segments (in which order and direction) bound
> each polygon to be filled with colour when plotting. A package you can
> consider for "rolling your own" spatial rings is sp, which is on CRAN.

The segments are largely connected -- my domain is bounded by a list of
open boundary segments, land boundary segments, and several islands.
library(sp) looks like the proper tool.

> Once you have the list describing segment membership, order and direction
> for each ring, building a SpatialRings object is not difficult. The hard
> bit is going from spaghetti line segments to the list imposing order.
>
> Alternatively, the PBSmapping package may have suitable functions for
> coersing polySet objects into rings. If your coordinates were in the
> Pacific, I'd say PBSmapping might already have what you need, but your
> example coordinates are Atlantic.
>
> (Could I suggest moving this discussion to R-sig-geo, referenced in the
> "Spatial" Task View on CRAN (top left corner in navigation bar)?

Sure.  I just subscribed.

How do you find the Task Views?  I found the mailing list off of
http://www.r-project.org/ -- Mailing Lists and the CRAN link brings up
mirrors.

Doh! I just answered my own question; these are different:

   http://www.r-project.org/
   http://cran.r-project.org/

I thought they were simple mirrors of the homepage for downloading, but
the menus are different.

The page at http://cran.r-project.org/ Task Views / Spatial
http://cran.r-project.org/src/contrib/Views/Spatial.html looks like just
what I need.  Thanks again.

> >
> > >geom[1:10,]
> >  lon  lat  depth
> > 1  -75.42481 35.58192 16.172
> > 2  -75.40726 35.58567 18.045
> > 3  -75.41351 35.60312 17.333
> > 4  -75.3 35.58959 20.787
> > 5  -75.39495 35.60706 19.834
> > 6  -75.36964 35.59370 20.950
> > 7  -75.37556 35.61159 20.941
> > 8  -75.35530 35.61660 23.107
> > 9  -75.34950 35.59800 22.960
> > 10 -75.33418 35.62194 23.934
> >
> > >island1<-c(2,3,4,2)
> > >water<-c(1,3,5,7,8,10)
> > > land<-c(1,2,4,6,9,10)
> > > plot(geom$lon[land],geom$lat[land],pch='.',t='l')
> >  lines(geom$lon[water],geom$lat[water],pch='.',t='l',col="blue")
> >  lines(geom$lon[island1],geom$lat[island1],pch='.',t='l',col="green")
> >
> > The above is toy-sized: dim(geom) is on the order of 12,3 and there
> > are about 30 different islands.  Maptools seems devoted to shapefiles,
> > and it is unclear how to create 'polylists'.
> >
> > Is there a good way to manage and graph data defined on irregular grids?
> >
> > Dave

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 plot more than 3 sets in Venn Diagrams?

2005-06-10 Thread David Forrest
On Fri, 10 Jun 2005, Jim Lemon wrote:

> Tan Hui Hui Jenny wrote:
> > I'm trying to plot Venn diagrams with more than 3 sets (5 actually) in 
> > order to describe graphically the genetic variation between populations.
> >
> > I tried the limma library but realised it can only plot 3 sets.
> >
> > Is there any solution? Of course I could plot the chart manually but it'll 
> > take too long (have other datasets). One of my dataset is given below.
> >
> Hi Jenny,
>
> Best I could do is four sets. The code is a bit rough but consistent
> with the vennDiagram function in the limma package.
>
> Jim
>

There's a pretty 5-set radially symmetric Venn diagram on
http://www.combinatorics.org/Surveys/ds5/VennSymmEJC.html

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 Graph Gallery : categorization of the graphs

2005-06-09 Thread David Forrest
On Tue, 7 Jun 2005, David Forrest wrote:
...
>http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?UsePictures
>
> This page demonstrates the use of pictures and the use of a public image
> server for hosting graphics files.

Also, there's a page:
  http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?GraphGallery
which points to a few graphics galleries (R and not-R) around the web.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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


[R] Plot/manage spatial boundary data

2005-06-09 Thread David Forrest
I have some disconnected boundary data from a finite element ocean model
and I'd like to make a plot.

Maptools looks promising, but since my data is not in a shapefile or a
map, I'm unclear on what the best way to approach the problem.

>geom[1:10,]
 lon  lat  depth
1  -75.42481 35.58192 16.172
2  -75.40726 35.58567 18.045
3  -75.41351 35.60312 17.333
4  -75.3 35.58959 20.787
5  -75.39495 35.60706 19.834
6  -75.36964 35.59370 20.950
7  -75.37556 35.61159 20.941
8  -75.35530 35.61660 23.107
9  -75.34950 35.59800 22.960
10 -75.33418 35.62194 23.934

>island1<-c(2,3,4,2)
>water<-c(1,3,5,7,8,10)
> land<-c(1,2,4,6,9,10)
> plot(geom$lon[land],geom$lat[land],pch='.',t='l')
 lines(geom$lon[water],geom$lat[water],pch='.',t='l',col="blue")
 lines(geom$lon[island1],geom$lat[island1],pch='.',t='l',col="green")

The above is toy-sized: dim(geom) is on the order of 12,3 and there
are about 30 different islands.  Maptools seems devoted to shapefiles,
and it is unclear how to create 'polylists'.

Is there a good way to manage and graph data defined on irregular grids?

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 Graph Gallery : categorization of the graphs

2005-06-07 Thread David Forrest
On Tue, 7 Jun 2005, Dan Bolser wrote:
...
> >http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?Tips_And_Examples
>
> Great!
>
> We would need an image bin to support this though (for the average user).

Hi Dan & all

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

This page demonstrates the use of pictures and the use of a public image
server for hosting graphics files.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 Graph Gallery : categorization of the graphs

2005-06-07 Thread David Forrest
On Tue, 7 Jun 2005, Dan Bolser wrote:

> On Tue, 7 Jun 2005, David Forrest wrote:
>
> >On Tue, 7 Jun 2005, Dan Bolser wrote:
> >...
> >> I agree, but its hard to get people contributing without something
> >> centralized (some central autohrity). The problem with the existing wiki
> >>
> >> http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?RwikiHome
> >>
> >> Is that it currenlty does not support images (afaik).
> >
> >Counterexample:
> >
> >http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?Tips_And_Examples
>
> Great!
>
> We would need an image bin to support this though (for the average user).

Something like http://www.imageshack.us/  perhaps?

http://img97.echo.cx/img97/4207/teapot24fl.png or
http://img97.echo.cx/my.php?image=teapot24fl.png

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 Graph Gallery : categorization of the graphs

2005-06-07 Thread David Forrest
On Tue, 7 Jun 2005, Dan Bolser wrote:
...
> I agree, but its hard to get people contributing without something
> centralized (some central autohrity). The problem with the existing wiki
>
> http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?RwikiHome
>
> Is that it currenlty does not support images (afaik).

Counterexample:

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


Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 Graph Gallery : categorization of the graphs

2005-06-06 Thread David Forrest
On Mon, 6 Jun 2005, Dan Bolser wrote:

> On Mon, 6 Jun 2005, Romain Francois wrote:
...
> >It seems that the next improvement to the R Graph Gallery is
> >categorization of the graphics, that way each graph will be easier to
> >find. That step should be done *carefully* if we want to avoid the
> >opposite side-effect : graph not reachable through the categories.
...
>
> I would humbly suggest that the underlying data (graphs/categories/etc) be
> organized in such a way as to allow multiple categorizations. That way
> there could be any number of different categorizations applied to the same
> graphs, as one overall categorization may reflect only one particular
> viewpoint.

Heartily seconded!

> This way the chosen categories (however you decide to choose) would not be
> set in stone, but would be intimatly flexible.
>
> Also a single graph should be allowed to occur under multiple categories
> of a particular categorization.
...

An example of non-hierarchical categorization is the
keyword-categorization method used by Wikis.  See
http://www.usemod.com/cgi-bin/mb.pl?CategoryCategory for an example.

If a graph could be in multiple categories (3d, social science, color,
publication ready/published) it could be identified with multiple keywords
and dynamically listed in each of the sub-galleries.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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 Graph Gallery : categorization of the graphs

2005-06-06 Thread David Forrest
On Mon, 6 Jun 2005, Romain Francois wrote:

> Le 06.06.2005 17:21, Peter Dalgaard a écrit :
...
> >BTW, shouldn't there a way there from http://addictedtor.free.fr ? I
> >seem to get stuck on the home page with nothing to click (except "R"
> >and the labels on the left).
> >
> >
> >
> Hello Peter,
>
> My english fails me at understanding your question. I don't get stuck
> anywhere.
>
> Romain

Perhaps the javascript menu on the left does not function on some
browsers.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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

2005-04-07 Thread David Forrest
On Thu, 7 Apr 2005, Earl F. Glynn wrote:

...
> picture, don't you "see" numbers?
>
> Maybe you don't see a number here, but I do. #ff0080 is interpreted in some
> (non-R) contexts as a single number.  In many contexts, including HTML,


> colors are represented as three bytes in hex with this notation and the "#"
> means "hexadecimal".  The RGB color componets can be discerned quite easily:
> hex FF is decimal 255 (red), hex 00 is decimal 0 (green), hex 80 is decimal
> 128 (blue).  Some programs, e.g., Dreamweaver, allow specification of colors
> in this hex 3-byte form directly.  The "16 million" colors you seen on a
> "true color" display are from the 256*256*256 (or in hex FF*FF*FF) possible
> RGB triples.
>
> > For example, R already provides both hsv() and rgb() to create colours
> > from vectors of three numbers, but the correspondence is different in each
> > case.
>
> Sorry if some consider this off topic:
> HSV as a color space is really only liked by computer scientists.  Image
> processing and color engineers rarely if ever use HSV.
>
> There are MANY other color spaces and computations possible (see "color
> spaces" or "color conversions" or other color topics on  this page
> http://www.efg2.com/Lab/Library/Color/Science.htm).  Most of these color
> manipulations in R are not easy because the very first step, converting
> colors, I mean numbers , like #ff0080 to the red, green components is
> hindered because one must reinvent the wheel of hex-to-decimal conversion.

I think R has the hex to decimal OK, but might be lacking in the decimal
to hex case

zz<-function(x){
x<-as.numeric(sub("#",'0x',x));
c(x%/%256^2,
  x%/%256%%256,
  x%%256) }

> zz('#0f0e0d')
[1] 15 14 13
> zz('#ff0080')
[1] 255   0 128

If you already have the 3 byte triplet in read in as a binary, the same
integer arithmetic does the extraction.

> Perhaps R will someday introduce a "pixel" type that would encapsulate the
> three color components (for color images at least).  A matrix of pixels
> could easily be made into an image.  Some color computations such a Maxwell
> Triangle, or a CIE Chromaticity Chart (sorry the links are currently broken,
> but the image can be seen on this Chinese translation page)
> http://bluemoon.myrice.com/efg/color/chromaticity.htm in R is more difficult
> than it should be because of how R is designed now.  Many image processing
> statistical problems could be tackled directly in R if there were an easier
> way to manipulate pixels and images.
>
> But the hex manipulations I'm advocating could be used for variety of other
> purposes.  E.g, I must periodically deal with a binary data stream of flow
> cytometery data -- part ASCII, part binary.  Reading this stream directly
> from R would be nice and is almost doable.  Working with raw data and
> understanding  exactly what you've got would be facilitated by better
> conversion capabilities within R.

I'm still not sure what you mean by hex manipulations.

R has string manipulations, hex-to-number manipulations,
binary-file-to-number manipulations, mixed file to number manipulations,
and number to number manipulations.

What I think you are asking for is /displaying/ numbers.

Since R's sprintf() doesn't support the %x, (or %o, or %u) formats, I'm
not sure how to use R to translate the number 257 into #000101

zzinv<-function(x){}
# such that:

> zzinv(257) #or zzinv(c(0,1,1))
"#000101"

Is zzinv() the operation you need?

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] (no answer)

2005-04-01 Thread David Forrest
On Fri, 1 Apr 2005, Frank E Harrell Jr wrote:

> I wish to perform brain surgery this afternoon at 4pm and don't know
> where to start.  My background is the history of great statistician
> sports legends but I am willing to learn.  I know there are courses and
> numerous books on brain surgery but I don't have the time for those.
> Please direct me to the appropriate HowTos, and be on standby for
> solving any problem I may encounter while in the operating room.  Some
> of you might ask for specifics of the case, but that would require my
> following the posting guide and spending even more time than I am
> already taking to write this note.

Try:

help.search.google<-function (string){
RURL = "http://www.google.com/search";
RSearchURL = paste(RURL, "?sitesearch=r-project.org&q=",
string, sep = "")
browseURL(RSearchURL)
return(invisible(0))
}

help.search.archive<-function (string){
RURL = "http://www.google.com/u/newcastlemaths";
RSearchURL = paste(RURL, "?q=", string, sep = "")
browseURL(RSearchURL)
return(invisible(0))
}

help.start()
help.search.google("brain+surgery")
help.search.archive("brain+surgery")

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] sub('^','var',1:3) produces unexpected results

2005-03-22 Thread David Forrest
Hi,

According to help(sub), the ^ should match the zero-length string at the
beginning of a string:

sub('^','var',1:3) # "1" "2" "3"
sub('$','var',1:3) # "1var" "2var" "3var"

# This generates what I expected from the first case:
sub('^.','var',11:13)  # "var1" "var2" "var3"

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
R-help@stat.math.ethz.ch 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] US 2004 Elections map

2004-12-09 Thread David Forrest
On Thu, 9 Dec 2004, Hedderik van Rijn wrote:

>
> even for people who didn't like the outcome of the US elections this
> year, it must have been a joy to see all the nice (and not so nice)
> graphs that were shown. As an exercise, I recreated the map shown on
> the NY-Times website [
> http://www.nytimes.com/packages/khtml/2004/11/03/politics/
> 20041103_px_ELECT_GRAPHIC.html ]
>
> If you're interested,
>
>http://www.ai.rug.nl/~hedderik/R/US2004
>
> contains the created maps, the data and the code. Note that there are
> some differences in the R map and the NYT map (most notably with
> respect to some missing data in some New England states, some
> mismatches in county names, and the representation of NYC), but I was
> quite satisfied with the map as it stands now.
>
>- Hedderik.

Hi Hedderik,

I really like that -- Is there a place where R collects a portfolio of
graphics and the code to build them?  I think these sorts of things could
help demonstrate and disseminate the graphics abilities of R.

Dave
-- 
 Dr. David Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] what about a mascot ?

2004-12-08 Thread David Forrest
On Wed, 8 Dec 2004, internautem wrote:

> My friend Veslot proposed me the Raven !
> http://www.teteamodeler.com/allopass/images/corbeau.jpg
>
> As a matter of fact the intelligence of this bird is
> comparable to one of a monkey, although its brain is close to
> a reptile brain. R is quite the same : small, compact, but so
> clever.

I like it.  It makes me think of Poe's "The Raven":

http://www.heise.de/ix/raven/Literature/Lore/TheRaven.html

Although the poem is a bit dark, I like the shared features of R and the
Raven: terse, (keyboard-) tapping, answering questions, and making
predictions.

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] The hidden costs of GPL software?

2004-11-23 Thread David Forrest
On Tue, 23 Nov 2004, Philippe Grosjean wrote:

> Patrick Burns wrote:
> > []
> > No, I'm not volunteering to build the system.
>
> Too bad! ;-)
>
> Indeed, the idea to index tens of thousands of functions could not be
> appealing to many of us! Why not to consider to test such ideas at the
> package level? I mean, building a system that points out the packages of
> interest (those in CRAN, of course), given a search phrase would be a more
> resonable work. Then, looking at online help of that particular package
> would be the small additional effort required by the user. The problem here
> is with heterogeneous packages (the misc, and the like)...

This mail archive works well if the questions are well posed and answered:

help.search.archive<-function(string){
   RURL="http://www.google.com/u/newcastlemaths";
   RSearchURL=paste(RURL,"?q=",string,sep='')
   browseURL(RSearchURL)
   return(invisible(0))
 }
help.search.google<-function(string){
   RURL="http://www.google.com/search";
   RSearchURL=paste(RURL,"?sitesearch=r-project.org&q=",string,sep='')
   browseURL(RSearchURL)
   return(invisible(0))
 }

help.search.archive('volatility') # may soon show Dr. Harrell's example
help.search.google('volatility') # may show enough

Is there package data that is not searchable through the google search?

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] help! a urgent question

2004-11-19 Thread David Forrest
On Fri, 19 Nov 2004, an ying wrote:

> Dear Sir/Madam,
>
> I am doing a project related to R.
> However, it is always difficult find some R functions.
> The R user guide seems not complete.
> Is there any free document about all R functions ?
> Who knows ? please help me.
> My email is [EMAIL PROTECTED]

There has been much discussion on this topic on this mailing list
recently, and an important result is that there is no complete user guide.
Like any computer language, R is extensible, and there is no complete
listing.  If you know what you are looking for, for example 'urgent
question', try this in R:

 help.search.archive<-function(string){
   RURL="http://www.google.com/u/newcastlemaths";
   RSearchURL=paste(RURL,"?q=",string,sep='')
   browseURL(RSearchURL)
   return(invisible(0))
 }
 # and

help.search.archive("urgent question") # to find urgent questions

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] The hidden costs of GPL software?

2004-11-18 Thread David Forrest
On Thu, 18 Nov 2004, Frank E Harrell Jr wrote:
...
> ...
> I second all of that.  What you are describing Mike could be done with
> a community-maintained wiki, with easy to add hyperlinks to other sites.

There is a wiki at http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl but it
doesn't seem to get much use.

Last time I was hunting for help on R, I made the page
http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?SearchFunctions
 and in particular:

help.search.archive<-function(string){
   RURL="http://www.google.com/u/newcastlemaths";
   RSearchURL=paste(RURL,"?q=",string,sep='')
   browseURL(RSearchURL)
   return(invisible(0))
 }

help.search.archive('wiki') # example

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] The hidden costs of GPL software?

2004-11-18 Thread David Forrest
On Wed, 17 Nov 2004, Mike Prager wrote:

...
> Using CLI software, an infrequent user has trouble remembering the known
> functions needed and trouble finding new ones (especially as that user gets
> older).  What might help is an added help facility more oriented towards
> tasks, rather than structured around functions or packages.
...

Another good (non-GUI) tool for the CLI is keyword completion.  R in ESS
does this, giving you lists of possible functions, variables and objects,
or feedback if there isn't any.  R's CLI completes, but only with
filenames in the current directory.

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] Random number

2004-10-27 Thread David Forrest
On Wed, 27 Oct 2004, Kunal Shetty wrote:

> thank you Sundar,Andy, Partha for your prompt reply.
>
>   as for the "%*%" is matrix multiplication problem sunder here is a sample of 
> what i want...
>
> x <- rnorm(100,17,24) # X values
> y <- rnorm(100,7,11)  # Y values
>
> # since X and Y values are independent to get their
> # covariance need to multiply each of them with a Matrix say A
>
> A <- matrix(c(10,25,8,40),nrow=2,ncol=2)

If x and y are independent, then their covariance should be
zero, or at least symmetric.

Are you looking for z as a bivariate normal with covariance matrix A and
means (17,7)?

 randMV<-function(n=NA,vMean=NA,mSig=NA){
 # create n observations of multivariate normal data with a
 # mean of vMean and covariance mSig
 #
  p<-length(vMean)
  VD<-eigen(mSig)
  mSigH<-VD$vectors%*%diag(sqrt(VD$values))%*%solve(VD$vectors)

  ret<-matrix(rnorm(n=p*n),ncol=p)%*%mSigH +rep(vMean,each=n)
  ret
 }

z<-randMV(100,c(17,7),A)

colMeans(z)
cov(z)

>
>  further  i would like to assign both x and y vectors to one variale
>
>  say z <- c(x,y)
>
>   but if i do this  my matrix multiplication fail
>
> i.e  w <- A%*%z
>  Error in A %*% z : non-conformable arguments ??
>
>
> so it tired multiply the  X and Y vector individually
>
>  x<- (A%*%x)
>  y<- (A%*%y)
>
>
>  Error in A %*% z : non-conformable arguments ??
>
>
>   the error persist...sunder...
>
>   or anybody who could direct me..?
>
> regards
> Kunal
>
>
>
>
>
> Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote:
> >
> >
> > Kunal Shetty wrote:
> >
> > > Dear R- User
> > >
> > > I created  two random number sets using rnorm function and calcuted their 
> > > respective means. However now I would like to randomly
> > > replace some values with NA. Thus create my own test data.
> > >   Any help or suggestions on this ?
> > >
> > >
> >
> > Use ?sample:
> > n <- 100
> > x <- rnorm(n)
> > x[sample(n, 4)] <- NA
> > sum(is.na(x))
> > # [1] 4
> >
> > >  Also wanted to confirm when multiplying two random number vectors x am y by 
> > > matrix..is this how i do it.
> > > A is the matrix
> > >
> > >z <- c(x,y)# x and y the two set of vectors
> > >
> > >w <- A%*%Z   # each element in each vector multipled by the matrix .
> > >
> >
> > (Be careful: R is case sensitive (z != Z).)
> >
> > I'm not really clear what you want here. "%*%" is matrix multiplication
> > and "*" is elementwise multiplication. Also using "c" makes a vector or
> > length "n = length(x) + length(y)". This implies that "A" above "p x n"
> > (i.e. p rows, n columns) and the result "w" would be "p x 1". Please
> > provide an example of what you expect to see by the multiplication.
> >
> > --sundar
> >
> > >
> > > regards
> > > Kunal
> > >
> > > __
> > > [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
>

-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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-08 Thread David Forrest
On Fri, 8 Oct 2004, Barry Rowlingson wrote:

> Here's a function for searching the Rwiki from R:
>
> rwiki.search <- function(string){
>
>RwikiURL="http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl";
>RwikiSearchURL=paste(RwikiURL(),"?search=",string,sep='')
>browseURL(RwikiSearchURL)
>
>return(invisible(0))
> }
>

Hmm, that's nice.

>
> Then you can do rwiki.search("gabor") and the results pop up in your
> browser.
>
> Perhaps we need some more documentation-getting functions in R, such as
> this, something to search the mailing list archives, and maybe a
> readPostingGuide() function...
>
> Or is this spoonfeeding too much, and people should be able to go to a
> web page and stick something in the search box?

Some people need spoonfeeding, and sometimes its nice to be able to do
things more than one way.


rwiki.search('SearchFunctions')

help.search.archive<-function(string){
   RURL="http://www.google.com/u/newcastlemaths";
   RSearchURL=paste(RURL,"?q=",string,sep='')
   browseURL(RSearchURL)
   return(invisible(0))
 }

help.search.archive('wiki')

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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


[R] Removing constants from a data frame

2004-09-17 Thread David Forrest

Suppose I have

x<-data.frame(v1=1:4, v2=c(2,4,NA,7), v3=rep(1,4),
 v4=LETTERS[1:4],v5=rep('Z',4))

or a much larger frame, and I wish to test for and remove the constant
numeric columns.

I made:

   is.constant<-function(x){identical(min(x),max(x))}

and
   apply(x,2,is.constant) # Works for numerics
   x[,-which(apply(x,2,is.constant))]

I'd really like to be able to delete the constant columns without losing
my non-numerics.  Ignoring the character columns would be OK.

Any suggestions?

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] Plotting irregular grid as image or persp

2004-09-10 Thread David Forrest
Thanks Deepanyan,


On Sat, 28 Aug 2004, Deepayan Sarkar wrote:
...
> Yes, I think rgl would be the right tool for this. Even apart from the 3d
> acceleration issues, one of the problems with getting this in R would be that R
> doesn't do raster graphics, and I don't think hidden surface algorithms are
> very easy to implement in the R model.
...
> >
> >   library(ncdf)
> > #  library(rgl)
> >   teapot<-open.ncdf("teapot.nc")
> ># wget http://www.maplepark.com/~drf5n/extras/teapot.nc
> >   edges<-get.var.ncdf(teapot,"tris")
> >   vertices<-get.var.ncdf(teapot,"locations")
> >
> >   xy<-vertices[c(1,2),] # this would be cooler with ?persp's trans3d
> >
> >   plot(1:2,xlim=range(unlist(xy[1,])), ylim=range(xy[2,]),type='n')
> >   apply(edges,2,function(x){polygon(t(xy[,x]))})
>
> I was playing around with this yesterday and got something similar (but more
> general). I didn't send it to you because I wasn't sure if that's what you
> wanted. Of course, I'm more familiar with the lattice version of trans3d, so it
> uses that. There are 2 versions, one using grid, one with base graphics.
>
> As I said, there are glitches due to faulty drawing order of the triangles.
> Shading is also possible (as implemented in wireframe), but those calculations
> are done in C code, so it would take a bit longer to carry over.
>
>
> library(grid)
> library(lattice)
>
>
> plotMesh.grid <-
> function(l, z, rot.mat, dist = 0.1)
> ## rot.mat: 4x4 transformation matrix
> ## dist: controls perspective, 0 = none
> {
> x <- ltransform3dto3d(l[,z], rot.mat, dist = dist)
> id <- seq(length = ncol(x) / 3)
> ord <- order(x[3, id * 3] + x[3, id * 3 - 1] +
>  x[3, id * 3 - 2])
> grid.newpage()
> xscale <- range(x[1,])
> yscale <- range(x[2,])
> md <- max(diff(xscale), diff(yscale))
> pushViewport(viewport(w = 0.9 * diff(xscale) / md,
>   h = 0.9 * diff(yscale) / md,
>   xscale = xscale,
>   yscale = yscale))
> id <-
> as.vector(outer(1:3, (id[ord]-1) * 3, "+"))
> grid.polygon(x = x[1,id],
>  y = x[2,id],
>  default.units = "native",
>  gp = gpar(fill = "gray"),
>  id = rep(id[ord], each = 3))
> }
>
>
>
> plotMesh.base <-
> function(l, z, rot.mat, dist = 0.1, subset = TRUE)
> ## rot.mat: 4x4 transformation matrix
> ## dist: controls perspective, 0 = none
> {
> x <- ltransform3dto3d(l[,z], rot.mat, dist = dist)
> id <- seq(length = ncol(x) / 3)
> ord <- order(x[3, id * 3] + x[3, id * 3 - 1] +
>  x[3, id * 3 - 2])
> xscale <- range(x[1,])
> yscale <- range(x[2,])
> plot(xscale, yscale, type = "n")
> x <- cbind(x, NA)
> id <-
> as.vector(rbind(outer(1:3, (id[ord]-1) * 3, "+"),
> ncol(x)))
> polygon(x = x[1,id],
> y = x[2,id],
> col = "gray")
> }
>
>
> rot.mat <- ltransform3dMatrix(list(y = -30, x = 40))
> plotMesh.grid(l, z, rot.mat, dist = 0)
> plotMesh.base(l, z, rot.mat, dist = 0)

Those are nice -- I did want a varying color however, and needed to
separate the calls to polygon:

 plotMesh.base<-function(vertices,edges,col,rot.mat=diag(4),dist=0.1,...){
  ## rot.mat a 4x4 homogeneous transformation matrix
  ## dist: controls perpective per lattice::ltransform3dto3d

  # rotate
  vertices<-ltransform3dto3d(vertices,rot.mat,dist)
xscale <- range(vertices[1,])
yscale <- range(vertices[2,])
plot(xscale, yscale, type = "n")

  # find rough plot order

  ord<-order(apply(edges,2,function(x){sum(vertices[3,x])}))

  if (length(col) == 1){
sapply(ord,function(x){
  polygon(vertices[1,edges[,x]],vertices[2,edges[,x]],col=col,...)})
  } else {
sapply(ord,function(x){
  polygon(vertices[1,edges[,x]],vertices[2,edges[,x]],col=col[x],...)})
  }
  invisible(ord)
 }

rot.mat <- ltransform3dMatrix(list(z=45,y=30)) #;rot.mat

plotMesh.base(l,z,rot.mat=rot.mat,col=rainbow(dim(z)[2]),lty=0)


and the resultant image is:

   http://www.maplepark.com/~drf5n/images/teapot2.png


I posted some really rough notes at
http://www.maplepark.com/~drf5n/cgi-bin/wiki.cgi?RMeshVisualization

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] How to draw an observation uniformly from a given dataset?

2004-09-08 Thread David Forrest
On Wed, 8 Sep 2004 [EMAIL PROTECTED] wrote:

> Hi all,
>
> I have two questions stated below:
>
> 1. How to draw an observation uniformly from a given data?
>
> For example, I have a dataset (or dataframe) with 10 observations (with a
> set of variables) and I want to "uniformly" select an observation from this
> given dataset, that is, the probability of selecting each observation is
> 1/10.

sample(1:10,3,replace=TRUE)

>
> 2. How to do this "combinations"?
>
> source vector = (1,2)
> the length of the target vector = 3
>
> My expected outputs should be:
> 111, 112, 121, 122, 211, 212, 221, 222.

sample(c(1,2),3,replace=TRUE)

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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


[R] Plotting irregular grid as image or persp

2004-08-27 Thread David Forrest
Hi,
   I have an array of 2d node locations and an array triangles, and would
like to plot something like a image or persp.


An example of doing it with rgl is:

  library(ncdf)
  library(rgl)
  # wget http://www.maplepark.com/~drf5n/extras/teapot.nc
  teapot<-open.ncdf("teapot.nc")
  z<-get.var.ncdf(teapot,"tris")
  l<-get.var.ncdf(teapot,"locations")
  z<-as.vector(z)

 demo.teapot<-function(x=1){
  rgl.triangles(l[1,z],l[2,z],l[3,z])
  x<-readline("Hit any key to continue")
  rgl.pop()}

 demo.teapot() # produces a 3d rgl plot of the teapot

I wrote some rgl.* helper functions (
http://www.maplepark.com/~drf5n/cgi-bin/wiki.cgi?ElcircVisualization )
to drive rgl.points(), rgl.lines(), rgl.triangles(), rgl.quads() such that
I can call :

rgl.drf5n.polys(verts=l,conns=z) # plot points, wireframe, triangles,
# quads, depending on shape of conns)

but I'd really like to be able to plot an irregular grid with the
known triangles as specified colors, and I'm not sure
what would be the best package.

library(fields) extrapolates the image beyond the data
library(tripack) refits and plots its own data

What should I use? Suggestions?

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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] Reading SAS data into R

2004-08-27 Thread David Forrest
On Fri, 27 Aug 2004, Sundar Dorai-Raj wrote:

>
> Søren Højsgaard wrote:
>
> > Dear all,
> > One of my students (whom I am trying to convince to use R) wants to get a fairly 
> > large SAS dataset into R (about 150mB). An obvious and simple thing she tried was 
> > to write the dataset as a .csv-file and then read that into R, but that takes 
> > forever (or something close to that..). The dataset is so large, that exporting it 
> > as an Excel file from SAS is not feasible (more than 65000 lines). I am reluctant 
> > to ask her to go through all the data base steps (then she'll just stick to 
> > SAS...). Can anyone help me out on that one?
> > Thanks in advance
> > Søren Højsgaard
> >
> >
>
> See ?read.ssd in package:foreign or ?sas.get in package:Hmisc. Both
> require you have SAS installed and in your PATH.

Those routines use the SAS XPORT procedure, which is a good
semi-non-proprietary way to save your data anyway.  I just fought with
this a long while and found that XPORT needs to write short variable
names, but cannot accept the longer table names.  The short stub of SAS I
needed was:


Given a sas file '/junk/data.sas7bdat' files, the short stub of SAS code should
extract the data to '/junk/rd.xport' (The paths here may be all messed
up, but maybe the options below will save you the hours I lost.)


 libname src2rd '/junk/data'
 libname rd xport '/junk/rd'
 proc copy in=src2rd out=rd;
 select data;

However it may fail if there are long variable names.  The SAS below works
around that:

 options VALIDVARNAME=V7; /* enable longnames of {V6|V7|UPCASE|ANY} */
 data shrtnm;
set verylonggtablename;
 run;

 However, when longnames are enabled, the XPORT procedure fails on long
variable names, so the option must be set to truncate the long variable
names into shortnames:


 options VALIDVARNAME=V6; /* enable xport varname truncation */
 proc copy in=work out=rd1 memtype=data;
select shrtnm ;
 run;

Once this is done, the data may be imported into R using read.xport
Library(foreign) :

 x<-read.xport("/junk/x.xport")


R is sooo much better than SAS.

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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


[R] Q: how to submit documentation patches?

2004-08-25 Thread David Forrest
I don't want to gripe here, but I would like to know the best method for
submitting suggestions and patches to the documentation.

It looks like for many help items, we need to track from the html file
which help.search("*")/help("*") presents, back to the authoritiative
documentation file from which they are generated.  It seems the
installation process discards much of the .../{package}/man/*.Rd files, so
to build patches to the original documentation requires a download and
extraction from the source.

Is there a way to retain the authoritiative files, patch them, re-install
the patched documentation, and perhaps produce a useable patch for the
package maintainers?

Something like
  R CMD INSTALL --docs-only pixmap_mine_0.4-1.tar.gz
  # to rebuild the documentation
or
  R CMD INSTALL --keep-docs --library=/usr/lib/R/library \
   utils.xx.yy.tar.gz  # to keep the authoritative documentation


with a:

 diff -ru pixmap/man pixmap_mine/man >pixmap_doc.patch

 ... as a convenient way to deliver the document criticism, correction, or
elaboration to the package maintainers.

As it is, one has to either download, patch and reinstall the packages, or
edit the .../help/, .../html/, derived files directly to make minor
improvements in the documentation.

I apologise for the complaining, but I did spend too much time today
rediscovering that 'pixmap' is a package for computing images, (I was
off-line, and knew there was something in R that read, plotted, or wrote
graphics files) and a small change like the patch to utils/help/methods
attached would also have saved me some time.  R does many things, but the
documentation is hard to patch and improve.

And back to my subject:
  Is producing patches against the authoritative documentation the
recommended way to improve the documentation?

Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/diff -ur R-1.9.1-dist/src/library/utils/man/methods.Rd 
R-1.9.1/src/library/utils/man/methods.Rd
--- R-1.9.1-dist/src/library/utils/man/methods.Rd   2003-12-09 02:24:25.0 
-0500
+++ R-1.9.1/src/library/utils/man/methods.Rd2004-08-24 23:33:44.0 -0400
@@ -47,7 +47,8 @@
   The original \code{methods} function was written by Martin Maechler.
 }
 \seealso{
-  \code{\link{S3Methods}}, \code{\link[base]{class}}, \code{\link{getS3method}}
+  \code{\link{S3Methods}}, \code{\link[base]{class}}, \code{\link{getS3method}},
+  \code{\link[methods]{showMethods}}
 }
 \references{
   Chambers, J. M. (1992)
__
[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] Bug in colnames of data.frames?

2004-08-17 Thread David Forrest
On Tue, 17 Aug 2004, Arne Henningsen wrote:

> Thank you for all your answers!
>
> I agree with you that it is not a bug. My mistake was that I thought that a
> data frame is similar to a matrix, but as ?data.frame says they "... share
> many of the properties of matrices and of lists".
...
>
> I think the current presentation
> > myData
>   var1 var2 var3 xyzzy
> 1156 5
> 2268 4
> 337   10 3
> 448   12 2
>
> is confusing because it is not directly (without another command like str())
> apparent why myData[[ "var1" ]] works fine while myData[[ "xyzzy" ]] does
> not.

In some ways it is a bug -- in the documentation, print.data.frame, or
format.data.frame

Consider assigning a wider dataframe to var4:

myData<-data.frame(matrix(1:12,4),var4=I(data.frame(xyzzy=5:2,plugh=1:4)))
myData  # error
class(myData[["var4"]])<-"data.frame"
myData  # gives indications of sub-variables by var.xyzzy, var.plugh
myData[["var4.plugh"]]  # NULL
myData[["var4"]][["plugh"]]

str(myData)

By the way, is there a way of making such an assignment in one step
without the I() class() hack?

dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

__
[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: AW: [R] built-in Sweave-like documentation in R-2.x

2004-08-10 Thread David Forrest
On Tue, 10 Aug 2004, A.J. Rossini wrote:

> "Khamenia, Valery" <[EMAIL PROTECTED]> writes:
>
> >
> > I think just smarter C-c C-r would be kind of trade-off here.
> >
> > hm, maybe there are some other voices here similar to mine?
> > It would be easier to discuss the subj.
>
> Within ESS, you've got the ess-thread-eval (similar to
> ess-chunk-eval), so the guts for cross-chunk evals are there, so the
> next part would be as you say, making C-c C-r SWeave-aware.
>
> An simpler alternative to code would be to allow one to
> eval-chunk-and-step, stepping through chunks, similar to C-c C-n for
> stepping through lines.  Would this solve the basic problem?  3 x (2
> or 3 keystrokes) for 3 chunks.

I'd really like something like that -- I'll often be using repeated C-c
C-n and accidently hit one on the end of the chunk and end up in
TeX-normal mode due to AUCTeX, requiring a save and revert.
Functionality like (M-n c M-x ess-eval-chunk) bound to a key would be
great.  But with my elisp skills, I can't quite make this work:

(defun ess-eval-chunk-and-step (vis)
  "Tangle the current chunk, send to the ESS process, and move on
to the next chunk.

Arg has same meaning as for `ess-eval-region'."
  (interactive "P")
  (ess-eval-chunk vis)
  (noweb-next-code-chunk)
)


Dave
-- 
 Dave Forrest
 [EMAIL PROTECTED](804)684-7900w
 [EMAIL PROTECTED] (804)642-0662h
   http://maplepark.com/~drf5n/

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


[R] push/pop on a stack

2003-02-25 Thread David Forrest
Is there a package for stacks with pushing and popping?

I'd really like to do something like

push(par(no.readonly=TRUE))

 some stuff

par(pop())

It seems like it wouldn't be difficult, and that someone may have already
implemented a set of stack functions, and I wouldn't like to duplicate it.

Thanks for your time,
Dave
-- 
 Dave Forrest(434)924-3954w(111B) (804)642-0662h (804)695-2026p
 [EMAIL PROTECTED] http://mug.sys.virginia.edu/~drf5n/

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


Re: [R] postgres

2003-02-11 Thread David Forrest
On 11 Feb 2003, Joshua Gramlich wrote:

> Is anyone using R with postgres?  I'd like to do so, but cannot seem to
> find any reasonable explanation of how to do so.
>
>
> Joshua Gramlich
> Chicago, IL

library(RPgSQL)  # It isn't in an obvious place:
 # http://lib.stat.cmu.edu/R/CRAN/src/contrib/Devel
db.connect()
db.ls()

Dave,
-- 
 Dave Forrest(434)924-3954w(111B) (804)642-0662h (804)695-2026p
 [EMAIL PROTECTED] http://mug.sys.virginia.edu/~drf5n/

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



[R] Command line completion?

2003-02-06 Thread David Forrest

Using R 1.6.0 on a redhat linux system, if I start typing at the prompt,
and hit , it seems to do a completion based on the filenames in the
current directory, but upon hitting return after picking one of these
completions, it returns an 'Error: Object "xxx.yyy" not found'.

It /is/ helpful in completing a filename inside a function, (it even
supplies the closing '"'), but that doesn't seem especially useful.  It
seems that it would be nice for it to either attempt to source in the
object not found if it is a file name, or for the readline completion to
work on the list of objects and functions instead of the filenames.  As it
is, it seems to assume the right thing to do is something that it cannot.

Is there some bit of the documentation that explains the readline /
completion functions?

Thanks for your time,
Dave,
-- 
 Dave Forrest(434)924-3954w(111B) (804)642-0662h (804)695-2026p
 [EMAIL PROTECTED] http://mug.sys.virginia.edu/~drf5n/

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