[R] Invalid device number in savePlot

2005-07-05 Thread OlsenN
Hi, I recently encountered an error using the command "savePlot" when trying to save the third of 3 open graph windows. After successfully saving and closing the first two windows I receive an "Invalid device number in savePlot" error. The following is copied and pasted from an example session to

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

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

RE: [R] Missing Data Line Type?

2005-05-24 Thread OlsenN
The dashed line can be added to the plot with a call to "lines" after removing the NAs from your x/y vectors (I'm assuming 'missing' means NA). > plot(x,y,type='l') > lines(x[!is.na(y)],y[!is.na(y)],lty=2) Vertical lines can be accomplished with "segments". norm -Original Message- From:

RE: [R] How to convert array to c()

2005-05-18 Thread OlsenN
Look at ?assign, one possible answer is shown in the examples. Modified for your example: for (i in 1:nrow(a)) { nam <- paste("r",i, sep=".") assign(nam, a[i,]) } would give you four separate objects r.1 to r.4 containing the 4 vectors. Not sure if that's exactly what you wanted

RE: [R] How to convert color to black & white

2005-05-13 Thread OlsenN
Muhammad, Here's one option: barplot(1:5,col=gray(seq(0,1,length=5))) Norm Olsen Fisheries and Oceans Canada -Original Message- From: [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Sent: 5/13/2005 11:40 AM Subject: [R] How to convert color to black & white Dear all, Could someone please

[R] Clear RGUI console under WinXP

2005-05-11 Thread OlsenN
Hi, The recent thread on how to send mail from R got me thinking about a solution to clearing the rgui console under WinXP (something I've often wanted to do and I've seen others ask about). If you create a small vb script, say called "RClear.vbs": Dim wsh Set wsh = CreateObject("WScript.Shell")

RE: [R] converting an ASCII file to a matrix

2005-05-10 Thread OlsenN
This seems to work but it's a bit ugly with the loop (I'm sure you could replace the loop with "apply"). asc2mat <- function(fname) { x <- sapply(scan(fname, "character", sep="\n"), strsplit, "") rlen <- sapply(x, length) res <- matrix(nrow=length(bar), ncol=max(rlen)) for (i in 1:nrow(

RE: [R] Does R have a command for sending emails?

2005-05-10 Thread OlsenN
At the risk of beating this to death ... if you use Outlook mail on Windows, you can create a simple 'sendmail' vbscript: ' start === Dim pOutlook, pMail, fso, f Set pOutlook = CreateObject("Outlook.Application") Set pMail = pOutlook.CreateItem(olMailItem) Set fso = CreateObject("Scripting.F

RE: [R] making a log file with error messages?

2005-05-02 Thread OlsenN
One way is to define your own function to use as the "error" option value. E.g. my.error.fun <- function() { cat(geterrmessage(), file="rerr.txt", append=T) } then, options("error"=my.error.fun) Norm -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of C

RE: [R] environment variables

2005-04-28 Thread OlsenN
use quiet=T help("scan") norm -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hua Li Sent: Thursday, April 28, 2005 12:32 PM To: r-help@stat.math.ethz.ch Subject: [R] environment variables In R, is there any way that I can let R not printing out the "