Re: [R] Saving/exporting graphs

2004-05-25 Thread Jason Turner
> HI:
>
> I have tried to find a way in which to export/save graphs via the command
> line. I know i can right click on it and save it as wmf etc.
> But I was wandering if there is a function such as Splus'
> export.graph

?win.metafile

as in

win.metafile("c:/foo.wmf")
plot(blah,blah,blah)
dev.off()

Cheers

Jason

__
[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] SCO & R

2004-05-27 Thread Jason Turner
On Thu, May 27, 2004 at 12:53:46PM -0700, Greg Tarpinian wrote:
...
> recently
> I read an article in Forbes which discussed how SCO
> was going after companies that have been using Linux.

It couldn't have been that recent; SCO dropped the most Linux-
relevant portions of its lawsuit back in January.

http://www.groklaw.net/article.php?story=20040206175445975

Further, SCO is under investigation for racketeering in 
Australia.  The "pay us money, because we own Unix" letters 
may be a form of illegal shakedown in Oz.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[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


Re: [R] problems with quantreg installation

2004-05-30 Thread Jason Turner
> make: g77: Command not found
> make: *** [akj.o] Error 127


You need a fortran compiler.  Search the RPM lists for g77 (or just
"fortran").

Cheers

Jason

__
[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] ffnet problem

2004-05-31 Thread Jason Turner
> Anyway, what steps should I take now?

"should" isn't quite what I'm telling you; just free advice.  :)

I use nnet from the nnet package (VR bundle), and find it very good.  And
it doesn't require any additional libraries.  If you've got a binary
installation, you've probably got it already...

library(nnet)
?nnet

I found nnet isn't as "quick and dirty" out of the box as ffnet, but gives
you much more control over the fit and diagnostics (less "black-box"-ish).

Cheers

Jason

__
[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] zipping a new package

2004-06-02 Thread Jason Turner
On Sun, May 30, 2004 at 03:19:24PM -0500, Laura Holt wrote:
> Dear R People:
> 
> I have finally created a little R package.
> 
> Do I need to do anything special to create a zip file for that package, or 
> just use Winzip, please?
> 
> thanks so much
> 
> R Windows Version 1.9.0
> 

Re-read "Writing R Extensions" for a full description, particularly
"Checking and building packages".  In your case, from the directory 
just above the top-level directory of your package.

Rcmd BUILD --binary yourpackagename

This takes care of a lot of things related to the build; zipping is
only part of it.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[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


Re: [R] Little question

2004-06-08 Thread Jason Turner
On Tue, 2004-06-08 at 21:44, zze-PELAY Nicolas FTRD/DMR/BEL wrote:
> Here I got a function :
> 
> f<-function(x){
> res<-list()
> res$bool=(x>=0)
> res$tot=x
> return(res)
> }
> 
> I want that a=res$bool and b=res$tot
> I know that a possible solution is :
> 
Like

foo <- function(x,...){
list(a=(x>=0),b=x)
}

Cheers

Jason

__
[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] off topic publication question

2004-06-08 Thread Jason Turner
On Wed, 2004-06-09 at 05:11, Erin Hodgess wrote:
> If a single author is writing a journal article,
> should she use "We performed a test"
> or "I performed a test",
> please?


Does the particular journal specify a style manual or style sheet?  The
Chicago Manual of Style \cite{Chicago2003}, p160, says "'We' is
sometimes used by an individual who is speaking for a group... called
the editorial 'we'.  Some writers also use 'we' to make their prose
appear less personal and to draw in the reader or listener."

Although journals may vary in their requirements, you are presumably
speaking for a group (the University of Houston Downtown), and "we" is
probably safer than "I".  Probably.

It's important to note that the Chicago Manual does *not* claim to be
authoritative, merely helpful.
 
Cheers

Jason

@Book{Chicago2003,
  editor =   {University of Chicago Press Staff},
  title ={The Chicago Manual of Style},
  publisher ={University of Chicago Press},
  year = 2003,
  address =  {Chicago},
  edition =  {Fifteenth}
}

__
[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] more obvious contribution mechanism?

2004-06-08 Thread Jason Turner
On Wed, 2004-06-09 at 13:22, ivo welch wrote:
> can we put a "how to donate money to R" on the R webpage?  perhaps with 
> a paypal button?
> 

Does the R Foundation link meet this need?

http://www.r-project.org/foundation/main.html

Cheers

Jason

__
[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] moving data and output?

2004-06-09 Thread Jason Turner
> Hello,
>
> I have a few questions now:

Yes.  Since the mail is archived to help other people, in future please
send a small mail for each question, with a descriptive subject line for
each.  This makes it easier for everyone.

> 1.  How can I move data the following way:
>
> I have 2 variables:
>
> one   two
> 1 5  ^
> 3 4  |
> 1 3  |
> 4 4  |
>
> Now I want to move the two one arround (sorry I don't know how to say
> that in english).  That means:  I want to move the first item at the
> end of my column and move the second at the first place, the third at
> the second, and so on.  You can see it at the arrow next to the 'two'
> column.  The colum named 'one' should be as it is.

By using indexing.  If this is a matrix called mymatrix:

mymatrix[,2] <- mymatrix[c(4,1:3),2]

If it's a data frame called mydf:

mydf$two <- mydf$two[c(4,1:3)]



> 2. How can I make outputs of the grafics (plot, hist, ...) into a file?

See the help pages and examples...

?postscript
?Devices
?pdf

> 3. Can I make latex output of the grafics (any tool, like texdraw or
> pictex ...)?

I use either eps or pdf for inclusion into LaTeX.  You also have the fig
file format, so you can use xfig to edit before inclusion.

> 4. I know about sink().  But can I format the output for LaTeX, like a
> \begin{tabular} ... \end{tabular} for a dist() matrix or similar?

Two ways:
1) Install the Hmisc package, and see ?latex
2) Install the xtable package, and see ?xtable.

> 5. Acording to the other questions, where can I find answers for this
> questions, if I'm not the first one who is asking?

1) help.search("some keyword")
2) go to http://cran.r-project.org, and follow the "Search" link to search
the mail archives.

Cheers

Jason

__
[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] rownames of single row matrices

2004-06-11 Thread Jason Turner
On Fri, 2004-06-11 at 20:09, Robin Hankin wrote:
> Hi
> 
> I want to extract rows of a matrix, and preserve rownames even if only
> one row is selected.  

The infamous drop=TRUE default.  help("[") goes into this.

Your toy example, two ways:

> a <- matrix(1:9,3,3)
> rownames(a) <- letters[1:3]
> colnames(a) <- letters[1:3]
> a[1,,drop=FALSE]
  a b c
a 1 4 7
> a[1,,drop=TRUE]
a b c 
1 4 7 

Does that help?

Cheers

Jason

__
[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] R can't find some functions in assist package

2004-06-30 Thread Jason Turner
> Oh yes. The "load package" under the "packages menu" in the Windows
> version
> does that. To check I typed "library(assist)" after starting R. Same
> behavior, ssr is found, but others like predict.ssr, and plot.ssr, give a
> "not found" message.

Short answer:  Try using "predict" instead of "predict.ssr".  I think
you're meant to quietly use the predict and plot methods provided, and not
mention their inner names.

Long answer:
Namespaces.  This means that a method for an object isn't visible to R as
a whole.  This avoids conflics should another package pick the same names.

Does this work?

getAnywhere(predict.ssr)

Cheers

Jason

__
[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] recommended citation

2004-07-04 Thread Jason Turner
> Dear Sirs,
>
> I used the nlme package for the statistical analysis of my data for
> prepared MS. Please, can you write me what is your recommended form of
> citation of this program?
> Thanks in advance for your reply.
>

I "cheat" and cite the book that supports it:

@Book{Pinheiro:2000:MMS,
  author =   "Jose C. Pinheiro and Douglas M. Bates",
  title ="Mixed-effects models in {S} and {S-PLUS}",
  publisher =Springer Verlag,
  address =  New York,
  year = "2000",
}

__
[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] System memory

2004-07-05 Thread Jason Turner
> Dear All,
>
> I have been experiencing the following problem when I use a lot of system
> memory when using R heavily.
...
What version of R, Xemacs, ESS, and Debian?  What are the "crash" symptoms
(error message?).  Have you tried upgrading everything you can (ESS has
recently released a new stable (5.2.x) version).

As a possible item to check, run

ps ajx | grep R

from a terminal after you exit R from within ESS.  On my Win XP box, I've
found that R sometimes fails to exit cleanly after a q("no"), and remains
running after ESS has tried to disengage.  The ESS "*R*" buffer remains
hung, and Rterm's user CPU usage goes to about 98%.  Killing R from the
task manager stopped this.  The same might (might!) be an issue under
Debian, and killing it from the command line might help.

Cheers

Jason

__
[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] Slight problem in sort

2003-08-14 Thread Jason Turner
Frank E Harrell Jr wrote:
sort(c(3,1,NA))
[1] 1 3

Shouldn't NAs be retained by default?
help(sort)

sort(c(3,1,NA),na.last=TRUE)

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Question about 'NA'

2003-08-14 Thread Jason Turner
Christian Mora wrote:
Hi all,

Ive got a database with 10 columns (different
variables) for 100 subjects, each column with
different # of NA's. I'd like to know if it is
possible to use a function to exclude the NA's using
only a specific column, lets say:
Data2 <- omit.exclude(Data1$column1) ??, then
Data3 <- omit.exclude(Data1$column2) and so on 

I use indexing for that.

Data2 <- Data1[!is.na(Data1$column1),]

nb - don't use this:

# WRONG WRONG WRONG!
Data2 <- Data1[! (Data1$column1 == NA),]
NA means you don't know.  Therefore, it doesn't equal anything, 
including NA.  For example, I don't know your birthday, and I don't know 
Napoleon's birthday.  That doesn't mean you two have the same birthday, 
even though they'd both be represented as NA.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] evaluating and walking in names

2003-08-14 Thread Jason Turner
Cezar Augusto de Freitas Anselmo wrote:
Hi, all.
Suppose I have an object with names (like a data.frame) and I want to walk
in a loop with your names. How can I do this? The idea is like this:
my.data<-data.frame(matrix(runif(6),ncol=2))
names(my.data)
[1] "X1" "X2"
for(i in names(my.data)){
my.variable <- cat(paste("my.data$", i, "\n", sep=""))
print(mean(my.variable))
}
#it doesn't work.

Thnaks for all,
C.

Cezar Freitas (ICQ 109128967)
IMECC - UNICAMP
Campinas, SP - Brasil
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

You want assign().

df <- data.frame(matrix(runif(20),ncol=2))

# using ii instead of i makes searches *much* easier with
# a text editor.
for(ii in names(df)) {
  assign(ii,df[[ii]])
}
ls()
[1] "X1" "X2" "df" "ii"
# might not be exactly the same on your machine due
# to floating point rounding.
all.equal(X1,df$X1)
[1] TRUE
all.equal(X2,df$X2)
[1] TRUE
Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Books for R

2003-08-18 Thread Jason Turner
[EMAIL PROTECTED] wrote:
Then the best book is Venables & Ripley (2002) for R.
A.S.
Agreed.  V&R (2002) also cites Bates & Pinheiro's "Mixed Effects Models 
 in S and S-PLUS" (2000) is particularly good for linear and non-linear 
mixed-effects models.  Highly recommended.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] "subscript out of range" message

2003-08-21 Thread Jason Turner
[EMAIL PROTECTED] wrote:
Hi All:
I was recently working with a dataset on arsenic poisoning. Among the 
variables in the dataset, I used the following three variables to 
produce crosstabulations (variable names: FOLSTAT, GENDER, ASBIN; all 
three were categorical variables, FOLSTAT denoted follow up status for 
the subjects and had seven levels, GENDER denoted sex (two levels: 
male,female), and ASBIN denoted binarized arsenic concentrations (two 
levels: "<0.05", ">0.05" denoting less than 0.05 mg/L and more than 0.05 
mg/L respectively).
To illustrate, I used the following code for crosstabulation:
x <- table(FOLSTAT,GENDER,ASBIN)
# from the results, I then wanted to subset a table for the ASBIN
value ">0.05"
I used the following code to subset the table:
y <- x[,,ASBIN=">0.05"]
Two errors.

1) Your logical index won't work.  For the second level of ASBIN, use 
x[,,2].  Since the third dimension of the table x has only 2 elements 
(one for each level of ASBIN), sending it a logical vector that is as 
long as your number of subjects (N) is only going to confuse it.  It's 
going to run out of levels of table.  And it did - "subscript out of ..."

1) Is this a cut-and-paste error?
> y <- x[,,ASBIN=">0.05"]
It won't work anyway, but for future reference, logical "equals" is ==, 
not =.  In other words, "==" is a question, "=" is an assignment.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] problem compiling R in suse8.2

2003-08-22 Thread Jason Turner
Ernesto Jardim wrote:
Hi

I'm trying to compile R in SuSE 8.2 (updated with the gcc 3.3.1) but I'm
getting the following error:
Works fine on my SuSE 8.2 box.

[EMAIL PROTECTED]:~/> gcc -vgcc -v
...
gcc version 3.3 20030226 (prerelease) (SuSE Linux)
[EMAIL PROTECTED]:~> uname -a
Linux kryten 2.4.20-4GB-athlon #1 Fri Jul 11 20:16:51 UTC 2003 i686 
unknown unknown GNU/Linux


/usr/X11R6/include/X11/keysymdef.h:1181:2: invalid preprocessing
directive #d
make[4]: *** [dataentry.lo] Error 1
make[4]: Leaving directory
`/usr/local/src/compile/R-1.7.1/src/modules/X11'
make[3]: *** [R] Error 2
make[3]: Leaving directory
`/usr/local/src/compile/R-1.7.1/src/modules/X11'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/usr/local/src/compile/R-1.7.1/src/modules'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/usr/local/src/compile/R-1.7.1/src'
make: *** [R] Error 1

Maybe an XFree86-devel library?

[EMAIL PROTECTED]:~> rpm -q -a | grep X
XFree86-fonts-75dpi-4.3.0-15
XFree86-fonts-scalable-4.3.0-15
XFree86-man-4.3.0-15
XFree86-server-4.3.0-15
XFree86-devel-4.3.0-15
XFree86-GLX-4.3.0-15
XFree86-4.3.0-15
XFree86-libs-4.3.0-42
...
Hope it helps

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] advise for modeling a linear mixed model

2003-08-23 Thread Jason Turner
Frank Mattes wrote:
Dear R help-list reader,

I'm trying to investigate my data with linear mixed model and are 
seeking advise how to write the model in R. I was trying to get hold of 
the recommended book from Bates et al, but neither the major bookshop 
nor our university library had the book.
...

Is gated a continuous variable?  You could compare it as...

(gated as fixed effect)

lme(freq ~ day*group + gated, random = ~day | ID data=frame,
  method = "ML")
vs

(gated as random effect)

lme(freq ~ day*group, random = ~day + gated | ID data=frame,
  method = "ML")
and use anova() to compare.  Note that you'll need the "ML" as opposed 
to REML to compare using anova.

Or have I missed something?

check out ?corClasses, too, to help with correlated error terms.

As for the book, Bates & Pinheiro, I'm working my way slowly through it, 
and it's well worth it.  Well written, and very informative.  The 
"slowly" working through it is because my spare time is very short these 
days.  I strongly urge you to purchase it from your favorite on-line 
book retailer (or pop by Foyles to grab one - just a couple blocks up 
from Charring Cross station, if memory serves).

In the mean time, if you can't immediately grab a copy, go over here:

http://www.insightful.com/support/documentation.asp?DID=3

and select "S-PLUS 6 Guide to Statistics (Part I)", and read the chapter 
on Linear and Non-Linear Mixed-effects models (Chapter 14 in my copy). 
I've got this, and a copy of Bates & Pinheiro.  The free guide isn't 
bad, B&P is excellent.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] package xtable

2003-09-02 Thread Jason Turner
Ernesto Jardim wrote:
Hi,

How can I avoid xtable of printing rownumbers when exporting a
data.frame ?
Are there more packages that deal with LaTeX besides xtable and Sweave ?
Check out Frank Harrell Jr's "Hmisc" and "Design" packages (on CRAN). 
He also published a great booklet, available at the URL below, that 
includes the full LaTeX/S code used to produce it.  Nice.

http://hesweb1.med.virginia.edu/biostat/s/doc/summary.pdf

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Calling functions of R from Perl?

2003-09-03 Thread Jason Turner
Bernhard Bals wrote:
Hi,

I've already asked this question, but unfortunately I've combined it 
with another question. So it was ignored in almost all cases. Thanks to 
those who have already given some hints.

Here again:

I don't want to use R interactively (issue commands after the prompt > 
..), but use some functionality of R from inside a Perl script.

Can I use methods of R from a Perl script: Is there an interface from
Perl (or at least from C/C++) to R (f.e. invoke R functions from Perl,
C, C++ or some other language)?
If so, can you please point me to the documentation on the Web or in
literature where this is decribed?
Do you have some trivial demo Perl script (or C/C++ program) that uses 
this technique, f.e. calls an R method like "mean" or "standard deviation"?

Haven't used it myself, so I don't know how well it works, but this one 
might do what you want...

http://www.omegahat.org/RSPerl/index.html

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] help.start( )

2003-09-03 Thread Jason Turner
Ming wrote:
Dear R experts,

I installed R-1.7.1 on Linux (Red Hat 9.0) starting from R-1.7.1.tgz without a problem.  Then I fired up R and tried things and found that help.start( ) does not work.  I downloaded Sun Java j2re1.4.2, installed that and re-installed R-1.7.1 from scratch.  I tried help.start( ) again and the browser (Mozilla 1.2.1) crashed.

I read about copying libjavaplugin_oji.so into mozilla/plugins and installed R-1.7.1 (again from scratch).  Mozilla still crashed.  Can you tell me how to make help.start( ) work in R-1.7.1?

It doesn't help much, but it works fine on my SuSE 8.2 box, using 
R-1.7.1 (patched) and Mozlla 1.2.1.  I've also used Konqueror (the KDE 
browser/file manager) using help.start(browser="konqueror").  Have you 
tried that (or Galleon, or Opera, or ...)?

Cheers

Jason
--
Indigo Industrial Controls Ltd.
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Newbie question about plotting density objects

2003-09-09 Thread Jason Turner
cmprobst wrote:
Dear List,

I have an array of 6400 x 56 elements. I want to calculate the density function for each column and plot all 56 density functions in one plot.

I have tried several procedures, but they all failed.

What can I do?
56 lines could even confuse a spider, so you might want to re-think your 
plotting approach.  However

## untested code!
## get a density object for each column.
den.list <- apply(zz,2,density)
## set up your plot window
all.x <- sapply(den.list,function(d,...) {d$x})
all.y <- sapply(den.list,function(d,...) {d$y})
plot(all.x,all.y,type="n")
## now plot each one on that graph
## this will make each line the same colour; for
## different line types or colours, you'll probably
## have to use a for() loop.
lapply(den.list,function(d,...) {lines(d$x,d$y)})

There's probably a much, much cleaner way to do that, though.  I think 
the sm library has the sm.density function that takes an "add" argument 
to its plots...  too busy to check that out on this box, however.

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R book

2003-09-11 Thread Jason Turner
On Fri, 2003-09-12 at 03:09, [EMAIL PROTECTED] wrote:
> Hi All,
> 
> I'd be interested in your opinions of the book
> 
> "Introductory Statistics with R" by Peter Dalgaard 
> 
> Does it well describe the R object concept, the language itself and
> statistical aspects (I am not a statistician)?


The title of the book is accurate.  It's concerned mostly with
introducing statistics gently, and is very kind to non-statisticians. 
It teaches enough R to perform the statistics it teaches (table of
contents should be available online from your favorite online
bookstore), but doesn't get deeply into the language itself.  

I find it a good book for a gentle introduction; once you're past the
stage of needing it, it's a good "loaner" to coleagues who don't yet use
R.  "Here, borrow this for a week, and if you find it helps, buy a
copy". 

After graduating from this book, the next sensible purchase is "Modern
Applied Statistics with S" (Venables and Ripley).

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] how to print a plot

2003-09-15 Thread Jason Turner
On Tue, 2003-09-16 at 08:56, Weiming Zhang wrote:
> Hi,
> 
> I am using R-1.7.1 on Linux. I integrated XEMACS with R. Could anybody
> tell me how to print a plot? I used plot function to make some graphs
> and then I wanted to print them or to save them to files. But I could
> not find out how to do it.

Have you tried:
help(Devices) 
help(pdf)

What I do:

pdf(file="myplots.pdf")
plot(...)
dev.off()

Use Acrobat or gv to view the pdf files.  Postscript is also good, but
not as universally understood; I have many coleagues who work in very
standard Windows environments, where ghostscript is unknown.  PDF is a
very sensible choice for e-mailing graphs.


-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Quit asking me if I want to save the workspace!

2003-09-16 Thread Jason Turner
On Wed, 2003-09-17 at 14:26, Murray Jorgensen wrote:
> Rafael A. Irizarry wrote:
> > you can type this:
> > 
> > q("no")
> > 
> > see the help file for q
> 
> Still more work than two mouse clicks.

Two clicks!  How awful!   ;)

Actually, it bugs me too, so my desktop shortcut (under Win XP) has this
for "Target".
###
"C:\Program Files\R\rw1071\bin\Rgui.exe" --no-save
###
 
(my mail client might've line-wrapped that by the time you see it. 
Everything between the ### marks is one line.  *Include* the quotes. 
There is a space between Rgui.exe" and --no-save)

See Appendix B of "An Introduction to R" if you need more info.

Hope that helps.

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Date on x-axis of xyplot

2003-09-16 Thread Jason Turner
On Wed, 2003-09-17 at 16:31, Deepayan Sarkar wrote:
...
> Is the date class standard enough to warrant including a check for it in 
> lattice ?
> 

I've never used it myself, but the lack of POSIXct support in the
lattice graphics axes has often caused me to think up new ways around
the plot.  Unless I'm missing an obvious way to apply that...

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Date on x-axis of xyplot

2003-09-16 Thread Jason Turner
On Wed, 2003-09-17 at 17:29, Deepayan Sarkar wrote:
> On Tuesday 16 September 2003 23:51, Jason Turner wrote:
> > ... the lack of POSIXct support in the
> > lattice graphics axes has often caused me to think up new ways around
> > the plot.  Unless I'm missing an obvious way to apply that...
> 
> Actually, lattice does support POSIXct for some time now, 

My bad.  Will check this further.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] using matrix data for function

2003-09-17 Thread Jason Turner
On Thu, 2003-09-18 at 06:02, Bing Zhang wrote:
> Hi All,
> 
> I have a function, f(x,y)
> I have a matrix of data, m,  with the 1st column is x and the 2nd column is y
> What's the best way to get f(x,y) for each row of the matrix?
> I tried 
> result<-f(m[,1],m[,2]) but it doesn't work.

That is the best way, provided your function handles vectors nicely. 
Apparently, yours doesn't.

Next best is something like apply(m,2,f)

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


RE: [R] using matrix data for function

2003-09-17 Thread Jason Turner
On Thu, 2003-09-18 at 06:41, Bing Zhang wrote:
> Thanks. How about I have a third parameter for the function, which is a fixed 
> object? i.e. the function is f(o,x,y)

1) My earlier reply had a typo. Should've been apply(m,1,f).

2) Luckily, the answer to this question, and any more you're likely to
have about apply(), are documented quite nicly.  help(apply) 

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Using POSIX?t rather than "chron" or "date"

2003-09-17 Thread Jason Turner
On Wed, 2003-09-17 at 19:03, Gabor Grothendieck wrote:
> The problem with POSIXt is that you must consider timezones 
> and daylight vs.  standard time issues even if you don't want 
> to.  
...
> I had previously suggested that we either put chron into the base 
> or create a new timezone-less version of POSIXt to complement what 
> is already in the base.  See:

When I don't want to be bothered with time zones, DST, etc, I set all
time zones to UTC.  Works fine for me.  I'd love to say I thought of it
myself, but it's an old trick frequently used in industrial real-time
control systems that have daylight savings features when they're not
welcome.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] aov and data behind plots

2003-09-21 Thread Jason Turner
On Mon, 2003-09-22 at 00:57, Monica Palaseanu-Lovejoy wrote:

> Now i have a question relating "aov". When i use aov i end up with 
> 4 plots. How do i "see" the data behind those plots? I know about 
> summary - but this gives me only some statistical info. 

There's more than one (very different) answer to that question; it
depends what you mean by "the data behind those points".

The functions fitted(), resid(), cooks.distance(), and qqnorm() are all
handy functions, used by those plots.  coef() is also quite useful, as
is dummy.coef().

Failing that, have you tried str(your.aov.object)?  This gives a
detailed summary of each object element.  str(summary(your.aov.object))
might also be helpful.  Be careful about picking out object components
directly, however; if a nice, pre-packaged generic function exists to do
the job you want, it's much better to use that, rather than depend on
the internal object structure never changing.

> Also, if i 
> want to identify which of my set of values gives a certain segment 
> of the plot - how do i identify these values? 

See the help pages for locator() and identify().  The tricky bit for you
is making the four plots appear separately.  plot.lm() is the function
that makes those four plots; pick through it to find what you want.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Updating a linear model

2003-09-22 Thread Jason Turner
On Tue, 2003-09-23 at 07:02, Paul Meagher wrote:
> My google search for Plackett's Algorithm didn't return too much except that
> Plackett's algorithm appears to be useful in Control Theory - it is
> elaborated as "Plackett's algorithm for on-line recursive least squares
> estimation".  Sounds something like what I want.

Recursive least squares is touched upon in Ogata, pp 861-863.

@Book{Ogata1987,
  author =   {Katsuhiko Ogata},
  title ={Discrete-Time Control Systems},
  publisher ={Prentice-Hall},
  year = 1987,
  address =  {Englewood Cliffs, New Jersey}
}

These algorithms are built for speed, not robustness.  They are written
for online real-time systems that might have to solve many of these
identification problems in under a second.  As such, you won't get the
nice features of things like a trimmed least squares (though weighting
is covered in Ogata).

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] loops in Sweave

2003-09-23 Thread Jason Turner
On Wed, 2003-09-24 at 03:06, Millo Giovanni wrote:
> Dear all,
> 
> I was wondering whether there is a way to make loops in Sweave, i.e. for example to:
> 1) calculate a parameter, say, a=length(b)
> 2) according to that, add #a# chapters to the document, each including some 
> repetitive analysis, each time done on a particular subset of the data indexed by 
> the elements of 1:a.
> This would be of great help for repeating exploratory data analyses on, say, 
> questionaries when the number of questions changes without having to change the 
> Sweave .snw file.

Two possible ways, off the top of my head:

1) Within LaTeX, use \Sexpr{a} to get the length, then loop within
LaTeX.  I believe Lamport includes an example of looping within LaTeX,
but I haven't got the book handy.

2) Within the R chunk, generate the table using xtable() (package
"xtable") or Latex (package "Hmisc") and print directly within R.  I
haven't tried it, but something like
<>=
## build your table in R
tt <- xtable(foo)
print(tt)

@

might do the trick.  I'd been meaning to look at this anyway; you
question prompted me ;)

Check the Sweave manual at Herr Dr Leisch's site.
http://www.ci.tuwein.ac.at/~leisch/Sweave
This has the R chunk options required to produce the above, if my
untested example is not correct.

Cheers

Jason

-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] least squares regression line

2003-09-23 Thread Jason Turner
On Wed, 2003-09-24 at 11:04, Carmen Fridell wrote:
> I can't seem to find the command to find the least squares regression line 
> for my bivariate data set. Can you please help? ~Carmen

Any time you're lost in R, you can type "help.start()".  This will start
a web browser, which loads the starting help page.  Click on "Keyword
Search".  Once the new page loads, type in some of the words you're
looking for.  "regression" is a good place to start.  That will lead to
a list of potential matches by subject.  Hint - you're looking for a
function to estimate a *linear* model.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] storing objects (lm results) in an array

2003-09-24 Thread Jason Turner
On Thu, 2003-09-25 at 05:34, Christoph Lehmann wrote:
> Hi
> 
> I have calculated lots (>1000) of linear models and would like to store
> each single result as an element of a 3D matrix or a similar storage:
> something like
> 
> glm[i][j][k] = lm(...)
> 
> Since I read that results are lists: Is it possible to define a matrix
> of type list? 
> 
> Or what do you recommend?

1) glm is already a function name in R.  I'd suggest a different name.

2) I don't recommend a matrix.  Matricies require contiguous memory
chunks - it's possible to not have a long enough "block" of memory
available, even when the total free memory is sufficient, when storing
large matricies.

What's wrong with nested lists?  Something like my.lms[[i]][[j]][[k]] <-
lm(...)

This can "scatter" its storage across discontinuous chunks of memory.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] models with I(1) errors

2003-09-24 Thread Jason Turner
On Wed, 2003-09-24 at 19:31, Vito Muggeo wrote:
> Dear all,
> I'm interested in fitting time-series linear models with I(1) errors. Namely
> given
> y_t=a+b*t+u_t
> the random term u_t are such that
> u_t-u_{t-1}=e_t~iid N(0,\sigma)
> 

library(nlme)
help(lme)  #note the optional correlation argument
help(corClasses)

You can specify AR(1) (among other) correlation structures in the error
term with lme().

The cannonical reference for the nlme library is

@Book{
  PinheiroBates2000,
  author =   {Jos\'e C. Pinheiro and Douglas M. Bates},
  title ={Mixed-Effects Models in S and S-PLUS},
  publisher ={Springer-Verlag},
  year = {2000},
  address =  {New York}
}

Cheers

Jason


-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Sweave \Sexpr() issue

2003-09-24 Thread Jason Turner
On Thu, 2003-09-25 at 11:20, Fernando Henrique Ferraz wrote:
>Hi, I'm having a little issue with \Sexpr{bla} relating to the number of digits 
> it is using to print its output.

Try \Sexpr{format(bla,digits=3)}

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] geodata conversion

2003-09-28 Thread Jason Turner
On Sun, 2003-09-28 at 13:10, Yaqing Gu wrote:
> Hey,
> I have a data set of 1.20MB. I used read.table( ) to read in the data and then 
> tried to convert it to geodata type. But it failed and I got 
> "Error in vector("double", length) : cannot allocate vector of length 1351974000" 
> message.
> All the commands I used were:
> 
> rawdata<-read.table(file=" ")
>datag<-as.geodata(rawdata)
> 
> BTW, what is the biggest origin data size as.geodata( ) can convert? 

Depends how much memory R can give it.

Check

help(Memory)

and read the FAQs.  You'll find them under "Miscelaneous Items", in the
browser, after you use the command "help.start()"

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545

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


Re: [R] Help needed: plotting with no device

2003-09-29 Thread Jason Turner
Ross Boylan wrote:

On Mon, Sep 29, 2003 at 05:09:49PM -0400, Ben Bolker wrote:

 Can you use save.image() to rescue your results?
 I would try save.image(file="salvage.RData") and see if the file 
appears.  Otherwise I would say you're probably out of luck.

The problem is I can't get back to the command prompt, so I can't do
save.image() or anything else.
It may be possible to reconstruct the state from a core dump.  I say 
"may" with not much confidence it'll be worth the effort, but it might 
be possible.

Only problem is, there's no way I know under Linux to dump core and 
continue; you only get one shot at it.

man 7 signal on my SuSE box gives a list of which signals cause a 
process to dump core.  After that, you'll have to find a Local Guru to 
pick it apart - and R's memory structures aren't trivial.

It might be easier to start again.

Hope it helps

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] subsetting a matrix

2003-09-30 Thread Jason Turner
(Ted Harding) wrote:

On 30-Sep-03 Rajarshi Guha wrote:

Hi,
 I'm trying to take a set of rows and columns out of a matrix. I hve
been using the index aray approach. My overll matrix is X and is 179 x
65. I want to take out 4 columns and 161 rows.
...
This is documented in "An Introduction to R", under the section "Arrays 
and Matricies".  There's lots of good stuff in there.  From R:

help.start()

And click on "An Introduction to R".

The short answer to this particular question:
a) negative indicies remove rows or columns.  Since you only want to 
remove 4 columns, I'd use that.
b) Since you only want to keep 18 rows, I'd use the numbers of the rows 
you want to keep.

As a toy example, say you wanted to remove columns 51 to 54, and keep 
the last 18 rows:

newX <- X[162:179,-(51:54)]

There's even more handy stuff in the document mentioned above.

cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] variables

2003-09-30 Thread Jason Turner
forkusam wrote:
Hi,
can someone please help me.
I will give a simple example of my problem. 
p <- function()
{
 i <- 1
 sr <- function(){
 i<-i+3
 i<- sqrt(i)
}
cat(i) 
}
 This is just an example. My main problem is defining
i like a global variable which I can use in the sub-
and main functions without any complicated switches. 
Thanks in advance.
cilver
Within the function p(), it should "just work".  Try this slight 
variation of your example:

p <- function()
{
  i <- 1
  sr <- function(){
i<-i+3
i<- sqrt(i)
i #explicitly return the newly calculated value
  }
  cat("sr() returned ",sr(),"\n")
  #now check if i was actually modified outside sr()
  cat("i = ",i,"\n")
}

When I load this into R...

> p()
sr() returned  2
i =  1
note that i is not visible outside the function p().  It disappears when 
p() exits.

> i
Error: Object "i" not found
The internal function variables being available to sub-fuctions is an 
example of "lexical scoping", and it's one of the things that makes R so 
nice to work with.  Try demo(scoping) for a very interesting use of 
lexical scoping.

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] truncating axis

2003-10-01 Thread Jason Turner
Diego Riano wrote:

Hello

Does anyone know how to truncate and axis in R?

Not sure what you mean, but do to plot arguments xlim and ylim do what 
you want?  See help(par) for these and other plot controls.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Text cutoff in legends

2003-10-01 Thread Jason Turner
Marcel Sutter wrote:

Dear r-help

If I display plots on the X11 device, the legends looks fine. But if 
make an EPS, the longer entry in the legend is cutoff (and also in the 
.pdf I do from the .eps)

Can you give me a hint and tell me what I do wrong, please ?
Probably nothing.  The X11 and postscript devices have different 
boundaries.  The plot is made to fit them, and the legend added to that. 
  I don't usually use dev.copy(); I just repeat the plot commands after 
the postscript() device is opened.  Try that; if that doesn't work, 
adjust your legend placement.

postscript("plot.eps",paper="special",horizontal=F,onefile=F,width=8.0,height=7.0) 

dev.set (2)
dev.copy (which=3)
dev.off (3)
R Version 1.6.1  (2002-11-01) on SuSE Linux 8.0
Might as well upgrade R while you're at it.  1.8 will be out Real Soon Now.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: Mandelbrot set and C code

2003-10-01 Thread Jason Turner
[EMAIL PROTECTED] wrote:

  I decided to take on the 'proper' solution to calculate the
Mandelbrot set in R, i.e. to do the raw calculations in C and then link
that code with R. 
This is very cool.  I did a slight tweak to your mandelbrot.R code, so 
that x can be a list with components x and y.  This allows you to keep 
zooming in using your mouse to click on the plot (one of the incredibly 
nifty features of such sets).

Using the "tweaked" version below, call the function as you suggested:

image(mandelbrot(), col = c(heat.colors(49), "black"))

Then use locator(2) to define your next view:

image(mandelbrot(locator(2)), col = c(heat.colors(49), "black"))

Click the mouse in the corners of the zoom window, and away you go. 
Lather. Rinse. Repeat.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] lda source code

2003-10-01 Thread Jason Turner
Wei Geng wrote:

I am new to R. Trying to find out how lda() {in MASS R1.8.0 Windows} was
implemented in R. Does anyone know where to find out lda source code ?
Thanks.
Here:

http://cran.r-project.org

Hint: MASS is a *package*.  You want to view its *source*.

Same with most other R packages.  Or just about anything else you want 
to know about R.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] lda source code

2003-10-01 Thread Jason Turner
Wei Geng wrote:
Hi Jason, Spencer,

Thanks for the prompt response. The strange thing about MASS is that it's
not in "Package Sources" as most of other R packages are. It seems to come
with the binary R installation. I checked out the Rxx/library/MASS on my
laptop, there are source code (script) for Venables & Ripley's book but no
source code for lda().
Ah.  On CRAN, the MASS library is part of a bundle called VR.  Download 
the source for that.

There are a few bundles on the CRAN source pages - if you encounter this 
problem again, just follow the Package Sources link, and search the page 
for "MASS" (or whatever the package name is).  Use "Edit->Find", or 
Ctrl-F, or whatever.  In the case of MASS, you find this one:

VR:

Functions and datasets to support Venables and Ripley, `Modern 
Applied Statistics with S' (4th edition).
Bundle of:	MASS class nnet spatial

It's the "Bundle of" part you're looking for.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: Mandelbrot set and C code

2003-10-01 Thread Jason Turner
Jason Turner wrote:

...I did a slight tweak to your mandelbrot.R code, so
that x can be a list with components x and y.  This allows you to keep 
zooming in using your mouse to click on the plot (one of the incredibly 
nifty features of such sets).

Using the "tweaked" version below, call the function as you suggested:

image(mandelbrot(), col = c(heat.colors(49), "black"))

Then use locator(2) to define your next view:

image(mandelbrot(locator(2)), col = c(heat.colors(49), "black"))

Of course, I would've been nice if I'd included the tweaked version.  D'ho!

###
# Function to calculate the Mandelbrot set. This function calls a #
# C routine in order to perform the calculations faster.  #
# #
# Written by Mario dos Reis. September 2003   #
# Modified: added if(is.list(x)){...} at start to check if co-ords#
#       are from locator() or similar - jason turner oct 2 2003   #
###
mandelbrot <- function(x = c(-3, 1),# x limits
   y = c(-1.8, 1.8),# y limits
   nx = 600,# x resolution
   ny = 600,# y resolution
   iter = 20)   # maximun number of iterations
{
  if(is.list(x)) {
y <- range(x$y)
x <- range(x$x)
  }
  xcoo <- seq(x[1], x[2], len = nx) # x coordinates
  ycoo <- seq(y[1], y[2], len = ny) # y coordinates
  set = numeric(nx*ny)  # this will store the output of
# the C routine
  # This is the call to the C function itself
  the.set = .C("mandelbrot",
xcoo = as.double(xcoo),
ycoo = as.double(ycoo),
nx = as.integer(nx),
ny = as.integer(ny),
set = as.integer(set),
iter = as.integer(iter))$set
  # Create a list with elements x, y and z,
  # suitable for image(), persp(), etc. and return it.
  return(list(x = xcoo, y = ycoo, z = matrix(the.set, ncol = ny, byrow 
= T)));
}

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] indexing a vector

2003-10-02 Thread Jason Turner
morozov wrote:

Dear All:
I'd like to know how to sort and then index a vector of floats by several 
levels in R.
For example



x<-rnorm(100)
MyLevels<-quantile(x,probs=c(0,.5,1))
MyLevels
 0% 50%100% 
-2.11978442 -0.03770613  2.00186397

next i want to replace each x[i] in x by 1,2,3 or 4 depending on which 
quantile that x[i] falls. How do I do that in a "vector" fashion?
I think rank() is the function you're looking for.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] foo.RData or foo.r?

2003-10-03 Thread Jason Turner
Federico Calboli wrote:
On Fri, 2003-10-03 at 13:16, Adaikalavan RAMASAMY wrote:

*.R is for the script file and is ASCII type.
*.Rdata (or sometimes *.rda) is the usual extension for R data and
contains binary information.
If you try to cat a *.Rdata file, you will end up with gibberish as it
is binary.
Try opening *.Rdata with emacs if you can. Emacs will recognise it as a
fundamental type and not as an ESS type. There might be ways to
associate Rdata files with ESS. But other people might not consider
reading your "*.Rdata" files.
I dunno about this, but if I open R under emacs first and then I load my
foo.RData, it loads fine.
By "fine", you mean it looks like normal R code?

On Un*x systems(including Linux), the extension is a matter of 
convenience, not necessity.  It's possible to save your R code, 
transcripts, etc with any extension you want (.R, .S, or even silly 
things, like .exe if you want).  And Emacs will still cheerfully read 
them just fine.

However, just because you *can*, doesn't mean you *should* ;)

There is a *convention* in R that workspace images or saved objects 
(using save.image() or save() ) should have filenames that end in .RData 
.  R code should have filenames that end in .R .  This isn't necessary, 
but it helps keep things tidy and easy to organise.  ESS also has some 
built-ins to recognise .R as R code, so it can do nice things like 
highlight syntax, indent well, and send code to an R session to be 
evaluated.

Short answer:  anything that's R code *should* be named with .R at the 
end.  Anthing R created after you told it save() or save.image() or 
answered "y" to the "Save workspace image" question *should* have a name 
ending with .RData .  None of this is strictly necessary, but there are 
a bunch of nice things that happen if you do.

Clear as mud?  ;)

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: R: [R] r editors

2003-10-03 Thread Jason Turner
Nick Drew wrote:

On a similar note, what are some alternative data editors that one might use
instead of the default R data editor? I'm not interested in Excel but
something that's freeware, easy to install and use. Any recommendations?
If you don't like Excel for financial or license reasons, Open office 
works quite well these days (www.openoffice.org).

If you don't like Excel because you find spreadsheets clunky, the next 
step for me perl or some such thing.

Something in between?  I'm all ears.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Placing legends

2003-10-04 Thread Jason Turner
Doug Bourne wrote:

I'm trying to automate making a bunch of figures and I need a way to 
automate legend position.  As I understand it the legend is placed based 
on coordinates.  I don't know before hand what the coordinates are going 
to be.  On one graph my y axis might go from -50 to -10.  On another it 
might go from 0 to 180.

Easiest way is to:
1) make your plot.
2) change to co-ordinate system.
3) add the legend.
plot(...some stuff...)
par(usr=c(0,1,0,1))
# say you want you legend at 60% across, 80% up.
legend(x=0.6,y=0.8,...legend stuff...)
?par has this.  Check out "usr"

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Point and click

2003-10-04 Thread Jason Turner
Cliff Lunneborg wrote:

The following query raises the question: What is it that students learn
from point and click dialogs?"
[long boring ramble - I'm sure you know how to find the delete key when 
it gets tedious ;) ]

I think it's fair to say that they don't learn the software, or its 
internal structures/methods/etc at all (Mac users have always told me 
that this is the point; I'm not getting into that holy war).

I will state one thing - the point and click interface *can* teach about 
the underlying software mechanisms, but it has to be a well thought-out 
interface.

Example - I never used a computer that had a heirarchical filesystem 
until I went to university.  I then had to learn two:  IBM PC clones 
were used to teach us AutoCAD (ever seen AutoCAD run on an 8086 with 
640K of RAM?  It's not pretty ;).  I also worked on the student 
newspaper, which was a Mac-only shop.  The Macs came later; I was 
working in layout initially, back when layout really involved printouts, 
big cardboard sheets, and wax to stick the articles to the cardboard.

I did not understand directory structure on the PCs at all.  It never 
clicked.  I simply "parroted" the commands I was taught to use, and 
managed to stay out of trouble.  "Polly wanna .dwg file."  Then I worked 
on the Macs.  The display of folders made it clear to me, in about five 
seconds.  I realised right away what I'd been missing, and flew back 
into the PC world with a bit more insight.

As a result, I know that nice point-and-drool GUIs can educate about the 
underlying design and approach, but the design really must be considered 
very carefully.  It's also important to take away the "crutch" from time 
to time, too (going back to PCs, in the above example).

I've yet to see a GUI for a statistical software system that meets this 
criteria, and I can't imagine what one would look like (I'm an engineer, 
not a designer ;).  I don't even know if it can be done. I'm sure 
anybody who understood heirarchical filesystems prior to GUIs would've 
thought similar things - that if one can't understand something so 
basic, there's really no simplifying or alternate explanation that'll 
work.  Had that thinking prevailed, I might've been another engineer who 
doesn't know a thing about how computers actually work (there's no 
shortage, believe me).

Just my $0.05 NZ (exchange rates, and all)

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] please help me on this problem

2003-10-05 Thread Jason Turner
Yong Wang wrote:

Dear all:
I am totally new to R, actually, statistics software.I get two very
simple, even stupid question:
1) where I should put the data file in order to use it , I tried to build
a
work dir in library( package:base) and save the text file (data) there,
I'm not sure where such a work directory might be, but it sounds like 
you need to show a TA what you did.

It sounds like you need to carefully read the FAQ.

help.start()

the follow the "Frequently Asked Questions" link, and (if you're using R 
on windows) the "FAQ for Windows Port"

then, I use read.table(filename), not work; I tried the full path, still
not work. I must have done something wrong.
Quite likely.  But without more details, there's no way to say more. 
There isn't only one way to make a mistake, so there isn't one answer to 
"it didn't work".

Read the FAQ.  It really does help.  Read it carefully, and not in a 
frame of mind where you're saying to yourself "I'll never understand 
this, this can't possibly help."  You will, it can.

2) is it possible to create a data file in R instead of put data in a txt
file and then save the file under R?
Yes, after you've got a grip on the above.  *After* the above is clear, 
read the help pages for "save" and "load".

Read the FAQ.

I tried to find answer from the introduction, failed.
But not the FAQ, presumably.

I really appreciate your help, thank you very much.
No problem.  By the way, read the FAQ.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Generating automatic plots

2003-10-08 Thread Jason Turner
Xavier Fernández i Marín wrote:
...
varlist <- c("var1", "var2", "var3", "var4", ...)
Instead of a character vector with the names, it'd make life easier if 
you had a list of the vectors...

# make sure you use the naming - makes life easier later.
mylist <- list(var1=var1, var2=var2, var3=var3, var4=var4)
Then...

for(i in seq(along=mylist)) {  # seq(along=...) is safest.
  jpeg(names(mylist)[i], width=...)
  boxplot(mylist[[i]] ~ missing, xlab=...)
  dev.off() # you didn't have this.  it's required.
}
# but I don't see how "missing" gets correctly passed in your example,
# so I'm not sure what it's supposed to do.
I suppose that is because I forget something related to the extraction of 
values in vectors, but I can't find it on the R manual neither in other books 
about R that I have checked.
Nope.  It's about passing a strings of text to plot, instead of actual 
data.  You'd have to actually parse the string to produce the value. 
And that's getting tricky (at least, it's tricky to my brain).  The 
above is pretty simple by comparison.

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] using split.screen() in Sweave

2003-10-08 Thread Jason Turner
Christoph Lehmann wrote:

Dear R and sweave users

A further problem, which I couldn't resolve, using the manual: In R I
use the split.screen command to put e.g. two timecourses one above the
other into one plot:
split.screen(c(2,1))
screen(1)
plot(stick,type='h', col="red",lwd=2)
screen(2)
plot(deconvolution.amplitude,type='h',col="blue",lwd=2)
Is there a similar way, doing this in Sweave?
I've never used split.screen.  Check out ?par, and read the entries for 
mfcol and mfrow.  Also check out ?layout.

HTH

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Jason Turner
Achim Zeileis wrote:

On Wednesday 08 October 2003 11:27, Thomas Bock wrote:
...
I can not understand why the expression in

the subject does not work correct:
> dcrn[which(fn == inve[2])]
numeric(0)

> inve[2]

[1] 406.7

...
  1.) `==' comparisons have a certain tolerance
  2.) the print output is not necessarily "precisely" your number
Instead of using `==' you should use a comparison with a certain 
tolerance you can specify...
I usually specify...

tol <- sqrt(.Machine$double.eps)
dcrn[(fn - inve[2]) < tol]
See ?.Machine for details.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Jason Turner
Whoops.  Hit "send" too quickly.

Jason Turner wrote:
tol <- sqrt(.Machine$double.eps)
dcrn[(fn - inve[2]) < tol]
that should be
dcrn[abs(fn - inve[2]) < tol]
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] run R under unix

2003-10-08 Thread Jason Turner
Zhen Pang wrote:
...
I now want to run the code under unix. However, I do not know how to run 
this code in txt file under unix. I just log in to the unix and enter 
the R, what should I do next?

One more question is: if I log off my computer when R is running under 
unix (i.e., disconnect my computer from server), will I get the result 
when I log in my computer next time?
...

You'll lose it if you run R in the normal, interactive way.  Running it 
in the background will allow you to log out and still have it running, but!

1) If you're not the only person using this machine, you learn the 
command "nice" before you begin.
2) I'm not certain you'll be able to produce jpeg or png graphics when 
backgrounded; your backgrounded task needs access to the windowing 
system for graphics rendering, and local security policy might prohibit 
this.
3) Save early, save often.  You probably already know that, but it bears 
repeating.

Here are some suggested steps to run your simulation in background mode. 
 Unfortunately, the exact commands will depend on which version of Unix 
you're using, and what command shells are available.  Consult your local 
expert.

1) transfer the text file of commands to the unix machine.  FTP, using 
ASCII mode is safest.
2) log onto the Unix machine.
3) run sh, ksh, or bash.  (the syntax for what follows is different for 
the C shell, and I don't know it).
4) using a stripped-down version of your script which will complete in a 
short time (say, a minute or two), just to check that things work, type

nohup nice 15 R < my.small.script >my.output 2>&1 &

(again, learn what "nice" means before you use it.  This may not be 
suitable, and it's impossible for me to tell from here if it is).

I know that's not the full answer, but only someone who knows the local 
setup can give you that answer.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Previous Commands

2003-10-09 Thread Jason Turner
Rau, Roland wrote:

Dear All,

yesterday I took the R-1.8.0-source file and compiled it on my own. As I am
using Linux just for a couple of weeks, it was my first compiling session
with ./configure, make, 
Everything went fine, except for one thing: if I want to look at the
commands history by using the cursor keys, it does not work. Instead of
displaying the previous commands, it returns something like "[[A".
Is this a common problem?
Does anyone have a solution?
I had R-1.7.1 installed previously via an RPM-package for my Mandrake 9.1
distribution and everything went fine.
You need the readline-devel libraries installed.  Depending on what 
Linux distro you're currently on (still Mandrake?), they may be 
available as an RPM or Debian package.  Install them, then if you still 
have the source directory, do a "make distclean ; configure ; make", 
then make install and try again.  If you've deleted the source 
directory, just untar the source and rebuild.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Fitting AR(p) models

2003-10-09 Thread Jason Turner
Laura Quinn wrote:
I am wanting to fit AR(p) models to column data for a series of matrices
I have. Rather than trying to compute the AR models "per column" I was
hoping to be able to do this per matrix (i.e. one AR model for each column
in said matrix). However, when i attempt this, if there is just one "NA"
value in any of the columns, the program refuses to compute AR models for
any of the columns.(I am using na.action=na.omit)
Is there a way I can force the calculation to provide AR models for
complete columns, or alternatively, a better way to deal with NA's to
provide an AR model, (eg via interpolation?) despite some missing values?
Interpolation might not make sense for your data.  Can't tell from here. 
 Certainly it's quick, but it can also be pretty dirty - it 
over-weights those data regions.  You can get around this by 
interpolating, then selecting a lower resolution (window with a larger 
deltat), and build your model from that.

If the NAs are few and far between, some additional code to pick where 
the NAs are in each column, and build AR models from the longest 
continuous segment might be preferable.

Apart from that, there's not much else I can add.  Other takers?

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] command line limit under unix?

2003-10-09 Thread Jason Turner
Zhen Pang wrote:
I have made my testing program to run successfully under unix in the 
background. However, my simulation work does not work. I read the 
foo.results file, I found it only have part of my code and not any 
output I want. Is there any line limit? My code is nearly 400 line. I 
can cut some of them, but I want to know whether there is any limit or 
exactly the number of limit is. Thanks.
400 lines of input isn't large.   Were there any error messages?

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] don't display rulers in image() command and script file input

2003-10-17 Thread Jason Turner
Ernie Adorio wrote:

Dear R experts,

1. How can I turn off the display of rulers in image() command?
Are rulers the same as axes?  If so, try
image(...,axes = FALSE)
See example(image) for detials.

2. Rather than typing my commands at the command line, how can I  input a file 
contents aside from doing a copy and paste operation?
?source

Also, see the FAQ, 7.18.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Matrix of Index Variables

2003-10-20 Thread Jason Turner
[EMAIL PROTECTED] wrote:

What is a good way to create a matrix of index variables based on all 
possible combinations of a list of factors in a data-frame, say list(age, sex)? "age" 
and "sex" are numeric and factor variables in a dataframe, with 99 and 2 
values, respectively.
I would like to use these for subsetting the data-frame, apply functions to 
subset and collecting the results.

Rather than creating a new index, I think you want the function "by()". 
 Something like

foo <- by(mydata,list(age=mydata$age, sex=mydata$sex), 
your.summary.function)

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] selecting subsets of data from matrix

2003-10-20 Thread Jason Turner
Laura Quinn wrote:

Thanks for your help everyone,

My data is a matrix. However if i use the command:

x[(x[,20] > 315 | x[,20] < 45), ]

and then request a summary, I get a warning message saying that a large
number of the row names have been duplicated - I don't understand this?
If x is the original matrix, and subx is the subseted matrix
(x[(x[,20] > 315 | x[,20] < 45), ])  ...
Do you get this warning message when you type summary(x)?

If you're not explicitly using the rownames for anything other than 
labeling, it can be safely ignored.  Duplicate rownames are a bit 
strange to R, but they're not illegal in matricies.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] run R under linux

2003-10-21 Thread Jason Turner
Zhen Pang wrote:
I want to do 200 simulations. I found during the fisrt 128 simulations, 
some parameters may be NAs, since I use if (abs(aold-anew)<1e-5) {print 
(anew)  break} to break the one estimation. 
...
 > I want to know how to resume my program with the seeds saved, and do
like continueing the 130th one without break. If possible, the results 
of the first 128 simulations can be saved and combine with the remaining 
simulation.
help(try)

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] BEGINNER: please help me to write my VERY simple function

2003-10-21 Thread Jason Turner
Michele Grassi wrote:

Hi.
1)I have two variables: call a<-c(e.g.0,3,6,7...)
   b<-c(e.g.6,8,3,4...)
I want to create a third vector z wich contain the 
pairs values z<-c(0,6,3,8,6,3,7,4and so on for each 
pairs (a,b)).
There is a specific function?
How can i write my own function?

For that, you don't need to.

help(expand.grid)


2)When i try to write a function and then i save it 
like "function.R" file, i try to retrieve it with 
source comand. As result i obtain an error 
message "error in parse: sintax error on line...". I 
apply deparse() and i see an incorrect parsing: how 
avoid unwanted parsing?
I'm really not sure what you're trying to do with deparse here, but I 
don't think it's supposed to do what you meant.  The error message is 
what should be attended to - fix that with your favorite text editor.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] run R under linux

2003-10-21 Thread Jason Turner
Zhen Pang wrote:

We are not allowed to submit job directly, so I never type R to use R, 
just make a batch. How can I use try() to correct my codes? In the 
interactive mode, I know how to continue, but now I never enter the R 
window, where to find my results and save seed to continue?

Like you'd program any exception handling.  A toy example to get you 
started might look like this:

(somewhere inside your script file)
...
results <- vector(length=200,mode="numeric") #or whatever you use
set.seed(123)
...
errors <- list()
for(ii in 1:200) {
  foo <- try(some.simulation.thingy(your.params))
  if(inherits(foo,"try-error")) { #something bombed
results[ii] <- NA
errors[[as.character(ii)]] <- foo
  } else { #it worked
results[ii] <- foo
  }
}
...
save(results,errors,file="results+errors.RData")
...
The end.
Play with that, and see if you get some useful ideas.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] select text using only the keyboard

2003-10-22 Thread Jason Turner
Simon Fear wrote:
I have a different wish: I want to be able to mouseclick in
the middle of a line to get the cursor there (as in SPlus).
While I appreciate that to get my wish I should just write
a little patch, I estimate it would take me about 2 years 
to reach the point where I was capable of it, assuming I 
did nothing else, and I would certainly have to understand 
Windows, which in previous brushes I have found to be 
very bad for the brain.
Or you could get a copy of (X)Emacs, and use ESS.  Total install and 
learning warm-up time should be in the order of a week at most.  It does 
all these nice things, and much more.  In my short experience with it, 
XEmacs plays nicer with ESS under Windows than GNU Emacs - YMMV.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] multivariate ARMA analysis with R

2003-10-23 Thread Jason Turner
Vincent Spiesser wrote:

Hi,
I try to make a multivariate ARMA analysis.
Function arima (from ts packages only accept univariate argument.
Does an R function exist for multivariate analysis ?

Thanks
Vincent Spiesser
The dse bundle on CRAN has functions for VARX multivariate time series 
models.

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Searching a Table

2003-10-23 Thread Jason Turner
Nicole Baggette wrote:

Is there any way to search a column of a table?

 

I read in a table and I want to create a subset based on the criteria that a
certain column (filled with words) has a word which starts with a certain
letter. The only method I have seen that searches this way is apropos(), but
that doesn't seem to search the location I want. If anyone can make a
recommendation I would appreciate it.
help(grep)

To search for words that start with "W" or "w" (minus the quotes) in a 
data frame called "mydata", column 3,

grep("\\bw", mydata[,3], ignore.case=TRUE, perl=TRUE)

Which means - "\\b" - word boundary.
The "w" and ignore.case should be self-explanatory.
perl - use perl style regular expressions.
example:

foo <- c("now is The Time","for all good llamas","to come to the party")
foo
#find lines that contain words starting with "t" or "T"

grep("\\bt",foo,ignore.case=TRUE,perl=TRUE)

foo[grep("\\bt",foo,ignore.case=TRUE,perl=TRUE)]

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Scan() question

2003-10-23 Thread Jason Turner
Janice Warner wrote:

I am just beginning to use R 1.7.1 on Windows XP and can not do a simple 
> scan of a .txt file with integer data separated by tabs.


First I figured out that I need to open a connection to the file 
>(which isn't mentioned in scan()).

It isn't mentioned because it isn't needed.

I'd try

read.csv(filename,sep="\t") # for tab-separated files

> But now when I scan,  I get "Read 0 items".  What can I do?

Shouldn't happen quite like that.

I have a file on my XP box, in my "My Documents" folder, called 
"foo.txt".  It's a two-column text file, tab-separated.  First column is 
 the numbers 1 to 12.  Second column is some random numbers.

> scan("c:/documents and settings/jason turner/my documents/foo.csv")
Read 24 items
 [1]  1.  0.05905332  2.  0.21829890  3. 
0.07104709
 [7]  4.  0.67140721  5.  0.44471572  6. 
0.75093844
[13]  7.  0.40647603  8.  0.85937071  9.  0.31583605
[19] 10.  0.77993103 11.  0.55067598 12.  0.25861385

Notice the "/" rather than the "\" as the directory delimiter.

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] how to remove NaN columns ?

2003-10-24 Thread Jason Turner
[EMAIL PROTECTED] wrote:
How can I remove columns with NaN entries ?

Here is my simple example:


data <- read.csv("test.csv")
xdata <- data[3:length(data)]
xs <- lapply(xdata, function(x){(x - mean(x))/sqrt(var(x))})
x <- data.frame(xs)
x
   C D   EF
1 -0.7071068 NaN -0.7071068 -0.7071068
2  0.7071068 NaN  0.7071068  0.7071068
I am sure it is possible to remove column D (with NaN's) in some simple 
fashion, using is.nan function
without explicitly looping through, and I am sure I was able to do it in 
the past, but I cannot recall how.

In addition to Andy's helpful suggestion, if your data is a matrix 
rather than a data.frame, you can use which() with arr.ind=TRUE.  For 
this example, Andy's suggestion is cleaner, however.

> foo <- as.matrix(foo)
> foo
   C   D  E  F
1 -0.7071068 NaN -0.7071068 -0.7071068
2  0.7071068 NaN  0.7071068  0.7071068
> which(is.nan(foo))
[1] 3 4
> which(is.nan(foo),arr.ind=TRUE)
  row col
1   1   2
2   2   2
> unique(which(is.nan(foo),arr.ind=TRUE)[,2])
[1] 2
>
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] questions please

2003-10-24 Thread Jason Turner
Simone Panigada wrote:
...
*  I am running a glm to model animal abundance relating it to research 
effort and other variables. I have 10 years of data and I am treating year 
as a factor, R is comparing each year with the first year my data sheet, 
while I would like to compare each year with each other. Is there any 
function in R to do this?
...

Short answer:

If your model was glm(critters ~ year, ...), change this to

your.model <- glm(critters ~ year - 1,...)

In other words, drop the intercept if you don't want to compare to a 
particular year.  A model that defines coefficients for each year *and* 
an overall intercept is over-defined; there's no additional information 
given by the extra term.

You might also benefit from the package multcomp (which requires 
mvtnorm) which has the function simint().

Long answer:

Get your hands on a copy of "Modern Applied Statistics with S" by 
Venables and Ripley, and read chapters 6 and 7 rather thoroughly.  This 
goes into the reasons behind the choice of comparing one year to others.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Scan() question

2003-10-24 Thread Jason Turner
Oops.  The file name is obviously "foo.csv", not "foo.txt".  Sorry if 
that caused confusion.

Jason Turner wrote:
I have a file on my XP box, in my "My Documents" folder, called 
"foo.txt".  It's a two-column text file, tab-separated.  First column is 
 the numbers 1 to 12.  Second column is some random numbers.

 > scan("c:/documents and settings/jason turner/my documents/foo.csv")
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R performance on Unix

2003-10-28 Thread Jason Turner
morozov wrote:

Hi
I'm observing a huge difference in the performance speed of R on Windows and 
Unix, even though I know that my Unix machine is much more powerful than my 
Win machine. 
In particular, any character processing task is very time consuming on Unix.

strptime(x,"%H:%M:%S") is about 10 times slower on Unix for vector x of the 
length of ~ 500. read.table() also is very slow. is there any way to speed up 
these ?

As was pointed out, the strptime issue sounds like a C-library problem 
on your machine.  The text processing might be the same.  Is this a 
development version of a Un*x OS?  What's the output of uname -a?  Is it 
a source or binary build of R?  If binary, try building and installing 
from source (provided you've got the disk space, you can do this, even 
if you're not root).  Is the problem apparent on other boxen with 
similar OSs (ie is it hardware)?

If you absolutely must continue to use that box and OS and R build, 
read.table() can be sped up using the colClasses argument (R doesn't 
have to guess what class each column should be), but it sounds like a 
problematic installation.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] ts vs. POSIX

2003-10-28 Thread Jason Turner
Erin Hodgess wrote:
What if I have a time series which is collected every Monday, please?

What is the proper way to use the start option within the ts command
in order to indicate that this is Monday data, please?
ts objects don't directly support dates.  There is some provision for 
monthly data, but this isn't the same as uniform, across-the-board date 
support.  What they do have is a start time, a deltat, and frequency 
(observations per period).  The main reason to use ts objects *isn't* 
the date/time handling, but for the nice functions (acf, spectrum, etc) 
you can use for regularly spaces time samples.

For weekly data, I'd use one of the following approaches (assuming the 
series starts in the first Monday of 2003):

1)
# dates in a year,week format
> foo <- ts(1:100,start=c(2003,1),frequency=52)
or

2)
# dates as numeric representation of POSIXct objects
foo <- ts(1:100,start=as.numeric(as.POSIXct("2003-1-6")),deltat=60*60*24*7)
> start(foo)
[1] 1041764400
> end(foo)
[1] 1101639600
> last <- end(foo)
> class(last) <- "POSIXct"
> last
[1] "2004-11-29 New Zealand Daylight Time"
(2) depends on as.numeric(POSIXct.object) giving a sensible, 
single-digit answer.  This is not guaranteed.  It works today, but 
nobody promised this approach would work tomorrow.

Hope that helps.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Question about the high dimensional density estimation

2003-11-01 Thread Jason Turner
[EMAIL PROTECTED] wrote:
> Hi,
> I found that the R package "KernSmooth" can deal with 
> only 1D and 2D data. But now I have a collection of
> 4-dimensional data (x1,x2,x3,x4) and would like to estimate
> the "mode" of the underlying density. What can I do
> about it ?

The gss package might do what you want here.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]

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


Re: [R]A matrix is full rank is equal to having independent columns?

2003-11-03 Thread Jason Turner
Feng Zhang wrote:
Dear R listers,

Just a simple question.
If we say an nxm matrix (n>m) is full rank of m,
does this mean that this matrix has linearly independent columns?
Yes.  Now be careful how you define rank.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R for various ports of linux

2003-11-05 Thread Jason Turner
Nathan Leon Pace, MD, MStat wrote:

To all:

I currently download the R binaries for Redhat 7.x Linux.

There is considerable turmoil in the vendors of Linux. Redhat apparently 
is changing it's business model to paid versions.

This might motivate my department to use a different vendor of Linux.

Is there anything predictable about which vendors/versions of Linux will 
have R binaries in the future?
Short answer: build from source.  You won't regret it.

Long answer:
The "build from source" approach is remarkably painless under any Linux 
distribution I've tried (RH, SuSE, Slackware, et. al.).  It's also 
painless under Solaris.

The days of having to be a programmer to build R from source have been 
over for years.  If you're computer literate enough to use R, you're 
probably over-qualified to build from sources.

Kudos to R-core for their attention to detail in making what's 
complicated "under the hood" quite simple for the end user.

Alternate answer:
If you absolutely must have binaries, there will be binaries as long as 
there are users of your OS with time they wish to commit to building 
them.  This may be where your sysadmin steps in :)

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] building r-patch

2003-11-05 Thread Jason Turner
Vadim Ogranovich wrote:
...
I am building r-patch from the sources (rsync-ed today).
 
make check produced the following message:
 
running tests of Internet and socket functions
  expect some differences
...  assorted error messages, then ...
 OK

 
 
I noticed that I had to expect some differences so my question is how to
tell whether it's harmless or not?
The "OK".  If made exited without an error, the regression tests were 
passed.  In this case, the differences between the maintainers' results 
and yours were due to local login and network setup differences.

Hope that helps

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R input file scanning

2003-11-06 Thread Jason Turner
Mathieu Drapeau wrote:

Hi,
I would like to know how can I solve my problem...
I want to load some data (surrounded by a tag) that are stored in a file 
that contains also some scrap (header and descriptions) that I want to 
skip. How can I do that?

By writing some code to use readLines() or scan().  I'll be more 
specific if you will.  :)

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] precision in operations

2003-11-07 Thread Jason Turner
javier garcia - CEBAS wrote:

Hi all;
could you remind me what is the function to change the precision of the 
operations done in R? I can't remember nor find it.

There isn't one.  R does all its calculations with system defined 
double-precision or integers (on most platforms where R is used, these 
are both 32 bits).  See help(is.single)

Are you thinking of format(...,digits=n) ?  This only affects display 
(i.e. printing).

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] precision in operations

2003-11-07 Thread Jason Turner
Douglas Bates wrote:

Jason Turner <[EMAIL PROTECTED]> writes:
...
There isn't one.  R does all its calculations with system defined
double-precision or integers (on most platforms where R is used, these
are both 32 bits).  See help(is.single)


Usually the double-precision representation is 64 bits in memory and,
for the IA-32 processors (Intel and AMD x86 family), 80 bits in the
floating point registers.
Blush.  Of course.

I hate it when I hit "send" without checking if I was thinking when I wrote.

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] kmeans error (bug?)

2003-11-10 Thread Jason Turner
Murad Nayal wrote:
I am running kmeans in a loop for a range of possible cluster numbers.
The error terminates the loop. is there a mechanism by which I can
'trap' the error so that I can rerun kmeans with another set of initial
centers and hence allow the loop to run to completion. something like
try {} catch() mechanism of C++ for example.
For R version < 1.8.0, ?try
For R version >= 1.8.0, see also ?tryCatch
Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] (no subject)

2003-11-12 Thread Jason Turner
Stefan Wagner wrote:

Hi all,

I am looking for a clever way to create the following graph using R:

I got information on the shares of some subgroups over time (summing 
> up to 1 in each year). The graph I want to create should display the
> evelopment of the individual shares over time by shading rectangulars
> for each share in a different color.

?polygon

to start. Also have a look at the code for barplot.

But given that about eight percent of adult males are colour-blind to 
some degree, be careful how you pick your colours, or you'll just 
confuse some of your audience.

http://www.visibone.com/colorblind/ shows how "web-safe" colours look to 
people with colour deficient vision.  Don't bet on everyone who has 
these issues knowing they have it; I know people who discovered they 
were partially colour blind when they were in their fourties.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Running R-program as queue jobs

2003-11-13 Thread Jason Turner
Philipp Pagel wrote:
	Hi!

On Thu, Nov 13, 2003 at 09:59:48AM +, Arne Gjuvsland wrote:

I have a problem with running my R programs as queue jobs. When I try
to submit a batch file to the queue with qsub I get the following error
message:

/home/gjuvslan/kluster/R-1.7.1/bin/R.bin: error while loading shared
libraries: 
libpcre.so.0: cannot load shared object file: No such file or directory


When executed from the command prompt the batch file does its job.


Did you run the script on the same machine in both cases? I got burnt a
couple of times with different machines running different versions of
the OS, non-identical versions of shared libraries etc...
In addition to Philipp's good sugestion, I've been burnt on the same 
machine, but with the batch job running as a different user.  When 
environment variables are needed, or private libraries need to be 
loaded, things go bad very quickly.

Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] ISOdate() and strptime()

2003-11-14 Thread Jason Turner
Thomas Lumley wrote:

On Fri, 14 Nov 2003, Simon Fear wrote:

Is the behaviour of ISOtime() and strptime() determined by ISO
or POSIX standard? Seems not to fit R's "no nannying" policy
at all. 



It's determined by your operating system, so you're complaining to the
wrong people.
And since R is written to be portable across multiple OSs, you might get 
an idea how tricky this becomes.  Hence the "iron fist" approach to date 
handling.  Believe me, I've programmed date handling - it's always a 
terrible, nasty, messy business when international locales and different 
operating systems clash.  I'm stunned it's as good as it is, subtle 
traps and all.

Cheers

Jason

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


Re: [R] remove 0 rows from a data frame

2003-11-23 Thread Jason Turner
Tord Snall wrote:

Dear all,

As part of a larger function, I am randomly removing rows from a data
frame. The number of removed rows is determmined by a Poisson distribution
with a low mean. Sometimes, the random number is 0, and that's when the
problem starts:
...
However, sometimes rpois(1, 2) lead to nft=0, and in that case I do not want 


temp2<- temp[-sample(nrow(temp), 0), ]
temp2
[1] occ x   y   dbh age
<0 rows> (or 0-length row.names)
This is a language feature, not a bug.  The easiest way around it is to 
catch the case where it's an issue.  Something like

if(nft==0) {
rows <- 1:nrow(temp)
} else {
rows <- -1 * sample(1:nrow(temp),nft)
}
temp2 <- temp[rows,]
Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Stangle - dropping re-used code chunks

2003-11-23 Thread Jason Turner
My question is:  is there a way for Rtangle() to *not* print re-used 
code chunks?  It'd be easy enough to brew up a perl script to do just 
this, but if methods exist already, I'd rather use them.  My reading of 
the help pages and FAQs has missed something, if it's there.

Background:
I have course notes on R, written using Sweave.  I want to provide the R 
code separately so the course attendees don't have to re-type everthing 
in the manual.

In this manual, I typically show a command, then re-use the chunk to 
produce a plot.  Something like this:

%% first, show how the plot is done...
<>=
par(mfrow=c(2,2))
mottle.acf <- acf(mottle.t[,1], lag.max=45)
mottle.pacf <- pacf(mottle.t[,1], lag.max=45)
mottle.acf <- acf(mottle.t[,1], lag.max=45, ci.type="ma")
mottle.pacf <- pacf(mottle.t[,1], lag.max=45, ci.type="ma")
@

%% then plot it.

\begin{figure}[tbh]
  \centering
<>=
<>
@
  \caption{Autocorrelation plot of the \Data{mottle} dataset.}
  \label{fig:ex.ts.acf.mottle}
\end{figure}
%% example ends
Stangle will (correctly) print the <> chunk twice, 
since it is called twice; once to create it, and once to re-use it.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Time series indexing/subsetting

2003-11-24 Thread Jason Turner
[EMAIL PROTECTED] wrote:

R-listers:

I may be asking too much from R, but is there a way to use time indexing 
on a time series object.  For instance:


tsobject <- ts(1:12, start =1999, freq = 4)
tsobject
 Qtr1 Qtr2 Qtr3 Qtr4
19991234
20005678
20019   10   11   12
tsobject[1999,Qtr4]

Qtr4 isn't a part of the tsobject.  It's produced by the print method 
for ts objects in general.

I believe you want "window"  Something like...

> window(tsobject, start=c(1999,4), deltat =1)
Time Series:
Start = 1999.8
End = 2001.8
Frequency = 1
[1]  4  8 12
Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] hist plot and custom "band" width

2003-11-25 Thread Jason Turner
Mathieu Drapeau wrote:

Hi,
I have some difficulties to figure how to set a range to my histogram 
bands.
I have values that are [0,50] and they appear once in my list. How 
can I do a histogram that include all the values between a range of 
1 together? [0,1],[10001,2],[21,3], ...
?hist
see the "breaks" argument.
Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] weighted mean

2003-11-25 Thread Jason Turner
[EMAIL PROTECTED] wrote:

How do I go about generating a WEIGHTED mean (and standard error) of a
variable (e.g., expenditures) for each level of a categorical variable
(e.g., geographic region)?  I'm looking for something comparable to PROC
MEANS in SAS with both a class and weight statement.
That's two questions.
1) to apply a weighted mean to a vector, see ?weighted.mean
2) to apply a function to data grouped by categorical variable, you 
probably need "by" or "tapply".  See the help pages and examples for both.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] strptime Usage

2003-11-25 Thread Jason Turner
Ko-Kang Kevin Wang wrote:

Hi,

I have a column in a dataframe in the form of:

as.vector(SLDATX[1:20])
 [1] "1/6/1986"  "1/17/1986" "2/2/1986"  "2/4/1986"  "2/4/1986"
 [6] "2/21/1986" "3/6/1986"  "3/25/1986" "4/6/1986"  "4/10/1986"
[11] "4/23/1986" "4/30/1986" "5/8/1986"  "5/29/1986" "6/15/1986"
[16] "6/18/1986" "6/23/1986" "6/29/1986" "7/16/1986" "7/25/1986"
...

First, you have to make this character vector into a time object.
You want something like:
times <- strptime(as.vector(SLDATX[1:20]),"%d/%m/%Y")

so R knows what format you're using for dates.

From there, format(times,"%Y/%m") will work.

Subtle trap - strptime produces a list of 9 vectors; "times" will always 
have length 9.  If you want to include this into a data frame, you'll 
need to convert to a  POSIX time type:

as.POSIXct(times)

to get the right length.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] creating graphs in BATCH mode

2003-11-26 Thread Jason Turner
Reinhard Sy wrote:

Hi 
 a short question is there a way to generate jpeg's etc. in BATCH mode ? The 
following example does not work in BATCH:
...
Error in jpeg("/tmp/my.jpg") : R_X11 module cannot be loaded
In addition: Warning message: 
X11 module is not available under this GUI 
Execution halted
[EMAIL PROTECTED]:09][~][57]>
Under Unix and Unix-like systems, R needs a running X server to produce 
JPEGs.  You needn't start the X-server; check out XVFB - X Virtual Frame 
Buffer - which sets up a virtual X server, but with no display.  You may 
already have this installed:  "man Xvfb" will tell you.

http://www.visualmining.com/support/server/XvfbonUnix.html

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] check WARNING...

2003-12-01 Thread Jason Turner
Jeff D. Hamann wrote:

I've been developing a package and have been getting the following warning
when running the check command:
* checking S3 generic/method consistency ... WARNING
plot:
  function(x, ...)
plot.summaries:
  function(trees, sp)
I'm unclear; is "summaries" a class?  If not, try naming the function 
plotSummaries, or some such thing (no dot ".")

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Two questions about the creating new package

2003-12-02 Thread Jason Turner
Song Baiyi wrote:

Hello everyone,

I am just trying to colloct all my function into a new packages. I met 
two questions which hurt me so much:

1. when I use the "prompt" to help to write Rd file for a variable x 
which is character vector, say x <- c("a","b"), it always give the error 
informaion:
Error in get(x, envir, mode, inherits) : variable "a" was not found.
Obvious it regards the "a" as the variable name instead of the item of a 
vector. So how can I put a character vector into the pacakge, or it must 
be a data.frame to put into a package?
Use the "name" argument to prompt.

prompt(name="x")

should work.

2. Also about the constant character vector. I have a constant vector 
which record the column names. I hope when the package is loaded, this 
vector will be loaded without explict writing "data(***)". Therefore the 
users and other functions can use it. How can I do it? A more generate 
question is where should I put those R codes which will be excuted after 
the package is loaded?
See help(.First.lib) .  In this case, you'd want something like

.First.lib <- function(lib,pkg){
  data(foo)
}
When writing a package, these functions are traditionally (but not 
manditorily) stored in a file called zzz.R .

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[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 Jason Turner
[EMAIL PROTECTED] wrote:

Hi, 

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?

Have you tried a more robust fit (ltsreg() in the package lqs springs to 
mind)?  Using this, without forcing the intercept to zero, might give 
you some idea if your idea makes sense.  Venables and Ripley (Modern 
Applied Statistics with S, Springer-Verlag, 2002) give a good 
introduction to robust linear models, and how to estimate their error 
distribution.  Julian Faraway also gives an overview of the same, in his 
"Practical Regression and ANOVA using R".
http://cran.r-project.org/doc/contrib/Faraway-PRA.pdf

Hope that helps

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] bug in as.POSIXct ?

2003-12-04 Thread Jason Turner
[EMAIL PROTECTED] wrote:

I think that there is a bug in the as.POSIXct function on Windows.

 Here is what I get on Win2000, Pentium III machine in R 1.8.1.


dd1 <- ISOdatetime(2003, 10, 26, 0, 59, 59)
dd2 <- ISOdatetime(2003, 10, 26, 1, 0, 0)
dd2 - dd1
Time difference of 1.000278 hours

Now, the 26th of October was the day that change to the standard time
occurred, so I suspect that this has something to do with that.  In fact

dd1
[1] "2003-10-26 00:59:59 Central Daylight Time"

dd2
[1] "2003-10-26 01:00:00 Central Standard Time"

so it looks like the switch from CDT to CST happens at 1:00 (instead of
2:00 ?).
Or, it did happen at 2:00 CDT, when the time fell back one hour to 1:00 
CST.  1:00 am occured twice on that day, once as CDT and once as CST.  R 
picked the last one.  A bit pathological at first glance, but 
date-handling often is.

As for the dd2 - dd1 value, the "correct" value depends which 1:00 am 
was chosen.  On Windows, this should be 1 hour, 1 second, no?  I'm 
thinking 1:00 am CST == 2:00 am CDT, so in CDT entirely, your expression 
is basicly 02:00:00 CDT - 00:59:59 CDT.

This makes me suspect that Linux picked the former 1:00 am, from your 
report.  Since R gets its date intricacies from the OS, there really 
isn't much that can be done about this, until someone builds a full 
POSIX time implementation that takes all the world's locales and time 
zones into account, and welds it into R.  Volunteers?

It's things like this that make me convert everything to UCT (GMT, or 
Zulu, if you prefer).  Not R's fault; stupid calendar tricks are to 
blame here.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


  1   2   3   >