[R] new version of randomForest

2002-12-17 Thread Liaw, Andy
A new version of the randomForest package is now available on CRAN. The DESCRIPTION is: Package: randomForest Title: Breiman's random forest for classification and regression Version: 3.4-1 Depends: R (>= 1.5.0) Author: Fortran original by Leo Breiman and Adele Cutler, R port by Andy Liaw and Mat

RE: [R] Can I build an array of regrssion model?

2002-12-18 Thread Liaw, Andy
And if you *really* want piecewise linear function (and most likely you want the pieces to be continuous, no?), there are better ways than yours. For "manual" fitting, use something like: library(splines) lm(y ~ bs(x, knots=..., deg=1)) For more automatic fitting, I believe bruto() or even m

RE: [R] Memory Leak in R v1.6.1

2002-12-19 Thread Liaw, Andy
For the benefit of those who might have similar problem... -Original Message- From: Annette Molinaro [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 18, 2002 11:51 PM To: Liaw, Andy Subject: Re: [R] Memory Leak in R v1.6.1 Thanks Andy! It worked! - Original Message - From

RE: [R] Can I build an array of regrssion model?

2002-12-19 Thread Liaw, Andy
Try lines(predict(mod), col="red"). (This is assuming your original x data are sorted.) abline(mod) draws a single straight line, using intercept and slope from a simple linear regression model ('mod'). If mod has more than one slope (as is the case with bs()), it won't make sense. Andy >

RE: [R] Printing correlation matrices (lm/glm)

2002-12-19 Thread Liaw, Andy
Try print(summary(lm2, corr=TRUE), symbolic.corr=FALSE). It *is* in the help page. HTH, Andy > From: [EMAIL PROTECTED] > Subject: [R] Printing correlation matrices (lm/glm) > > Hi Folks, > > I'm analysing some data which, in its simplest aspect, > has 3 factors A, B, C each at 2 levels. > >

[R] new optimized BLAS

2002-12-20 Thread Liaw, Andy
Dear R-help, Here's a posting to the most recent NA-digest: From: Robert van de Geijn <[EMAIL PROTECTED]> Date: Fri, 13 Dec 2002 11:15:23 -0600 Subject: Fast BLAS Libraries for Current Architectures Recent research by Kazushige Goto, Visiting Scientist at UT-Austin, has resulted in high-performa

RE: [R] Bug in boxplot(..., add=TRUE) ?

2003-01-14 Thread Liaw, Andy
It may not be a bug, but I wonder if it's an "unintended feature"... As Rich said, it seems unintuitive to have a plot function called with add=TRUE add axes to existing plot. This is not documented in either help pages for boxplot and bxp. Andy > -Original Message- > From: Roger Peng [

RE: [R] Is R really an open source S+ ?

2003-01-14 Thread Liaw, Andy
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > This is not a criticism. I'm just curious. Is there an > effort to keep R > comparable to S+? > Or are the two languages diverging? I am doing what probably > legions have > done before me, > and legions will after me...using R on exam

RE: [R] contour plot

2003-01-17 Thread Liaw, Andy
When you have numerical "x" variables, rather than factors, you can make sensible contour plot. Short of that, nothing in this world will give you "beautiful curves". Andy > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 17, 2003 1:45 PM

RE: [R] random number generator?

2003-01-28 Thread Liaw, Andy
Might I suggest taking a poll (even though unscientific) of how many people will be affected by a change in default RNG? My totally arbitrary guess is very few, if any. If I'm not mistaken, Python had only recently changed the default RNG to Mersenne-Twister. If Python can do it, I should think

RE: [R] Curve Fitting Question - Newbie

2003-01-28 Thread Liaw, Andy
If you don't need the parameters in the curve, it seems like library(modreg) lines(supsmu(1:1000, foo.dat), lwd=3) gives a very reasonable result. HTH, Andy > -Original Message- > From: C Grant [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, January 28, 2003 6:39 PM > To: [EMAIL PROTECTED]

RE: [R] random number generator?

2003-01-29 Thread Liaw, Andy
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > > "AL" == Andy Liaw writes: > > AL> Might I suggest taking a poll (even though > unscientific) of how many people > AL> will be affected by a change in default RNG? My > totally arbitrary guess is > AL> very few, if any.

RE: [R] Any interest in commercial add-on libraries based onCyte l's StatXact/LogXact?

2003-08-18 Thread Liaw, Andy
Another example: Jerry Friedman's MART is available in R from Salford for the same price as the stand-alone TreeNet, even though they don't advertise it on their web site. Andy > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Sunday, August 17, 2003 9:50

RE: [R] type I and type III sums of squares

2003-08-18 Thread Liaw, Andy
Not knowing any more details about your experiment and data, we can only speculate. If the reason (or part of the reason) that you need to run ANOVA 3 million times is that you have that many responses collected from the same experiment (or several experiments, but not 3 million different experime

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

2003-08-19 Thread Liaw, Andy
First of all, your subscripting is wrong. The first index is for row, and the second for column. Thus large[i,] refers to the i-th row of large, rather than the i-th column. Also, the code as you provided contain syntax error. Try: set.seed(311) ## Always a good idea to set seed for simulatio

RE: [R] RandomForest

2003-08-20 Thread Liaw, Andy
Please tell us the version of the package, the version of R, and the platform you're working in. Sounds like you should upgrade to a newer version of the randomForest package. In Breiman's original code, he is counting the number of misclassified cases and dividing that by the total number of cas

RE: [R] RandomForest

2003-08-20 Thread Liaw, Andy
simplify the splitting. You might find the heuristics in the CART book, but I'm not sure. HTH, Andy > -Original Message- > From: Vladimir N. Kutinsky [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 20, 2003 10:26 AM > To: Liaw, Andy; [EMAIL PROTECTED] > Subject: R

RE: [R] anova(lme object)

2003-08-21 Thread Liaw, Andy
Yes. One way is to use anova(res1, type="marginal"). Read the help page and the book (or any decent linear models book). Andy > -Original Message- > From: Mahbub Latif [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 21, 2003 12:51 PM > To: [EMAIL PROTECTED] > Subject: [R] anova(lme

RE: [R] R tools for large files

2003-08-26 Thread Liaw, Andy
> From: Richard A. O'Keefe [mailto:[EMAIL PROTECTED] > > Murray Jorgensen <[EMAIL PROTECTED]> wrote: > "Large" for my purposes means "more than I really want to read > into memory" which in turn means "takes more than 30s". I'm at > home now and the file isn't so I'm not sure i

RE: [R] Simple simulation in R

2003-08-26 Thread Liaw, Andy
I believe simple math stat calculations should be sufficient for this. For simplicity, assume X1 through X4 are iid with mean m and variance v. Note that var1 = (3*var2 + x4) / 4 so cov(var1, var2) = cov(var2, (3*var2 + x4)/4) and since var2 and x4 are independent, this covariance can be

RE: [R] Mann-Whitney U Table

2003-08-26 Thread Liaw, Andy
See ?qwilcox. Andy > -Original Message- > From: Mark Lamias [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 26, 2003 2:56 PM > To: '[EMAIL PROTECTED]' > Cc: Mark Lamias > Subject: [R] Mann-Whitney U Table > > > Does anyone have a piece of code or know how I can use R to > generate a

[R] R on Linux/Opteron?

2003-08-26 Thread Liaw, Andy
Dear R-help: Has anyone tried using R on the the AMD Opteron in either 64- or 32-bit mode? If so, any good/bad experiences, comments, etc? We are considering getting this hardware, and would like to know if R can run smoothly on such a beast. Any comment much appreciated. Best, Andy Andy Liaw

RE: [R] rfImpute (for randomForest) crashed

2003-08-26 Thread Liaw, Andy
Dave, If possbile, please send me (privately) the data that caused the crash and I'll have a look. Andy > -Original Message- > From: David Parkhurst [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 26, 2003 3:37 PM > To: [EMAIL PROTECTED] > Subject: [R] rfImpute (for randomForest) cr

RE: [R] R on Linux/Opteron?

2003-08-27 Thread Liaw, Andy
read that Itanium is slower than P4 for number crunching...) Best, Andy > From: Luke Tierney [mailto:[EMAIL PROTECTED] > > On 26 Aug 2003, Peter Dalgaard BSA wrote: > > > Dirk Eddelbuettel <[EMAIL PROTECTED]> writes: > > > > > On Tue, Aug 26, 2003 at 03:

RE: [R] Using files as connections

2003-08-28 Thread Liaw, Andy
You are using the connection the wrong way. You need to do something like: fcon <- file("c:/data/perry/data.csv", open="r") for (iline in 1:slines) { isel <- isel + 1 cline <- readLines(fcon, n=1) ... } close(fcon) BTW, here's how I'd do it (not tested!): strvec <- rep("",slines) se

RE: [R] is zscore() deprecated or Windows only?

2003-08-30 Thread Liaw, Andy
help.search("zscore") on my installation (R 1.7.1 on WinXP) didn't find any zscore function anywhere, let alone base. I suspect you are looking for scale()... Andy > -Original Message- > From: John Christie [mailto:[EMAIL PROTECTED] > Sent: Friday, August 29, 2003 8:34 PM > To: [EMAIL

RE: [R] Histogram question

2003-09-02 Thread Liaw, Andy
You can do it "by hand"; e.g., x <- rnorm(50) x.hist <- hist(x, prob=TRUE, plot=FALSE) x.prob <- x.hist$count / length(x) ## Alternatively: x.prob <- diff(x.hist$breaks) * x.hist$density You can then use barplot or whatever you like to plot x.prob. HTH, Andy > -Original Message- > From:

RE: [R] PLS LDA

2003-09-10 Thread Liaw, Andy
Do you mean the pls.pcr package by Prof. Wehrens? This is what I do: o Code the two groups as 0s and 1s (numeric, not factor). o Run PLS as usual. Cases with predicted values > 0.5 get classified as 1s, otherwise as 0s. o Note that you need to modify the code inside the mvr() functi

RE: [R] coef names in lm

2003-09-10 Thread Liaw, Andy
If you coerce "design" into a data frame and then do lm.1 <- lm(response ~ . - 1, data=design, ...) that should work. Andy > -Original Message- > From: Jean Eid [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 10, 2003 4:28 PM > To: [EMAIL PROTECTED] > Subject: [R] coef names in

RE: [R] Flipping a heatmap

2003-09-11 Thread Liaw, Andy
My feeling is that heatmap is not the right thing to use on a correlation matrix. The heatmap function expects a data matrix, and does a two-way clustering of cases and variables. It tries to rearrange the rows and columns so that similar colors are closer together. This obviously will not work

RE: [R] S+DOX eqivalent in R?

2003-09-15 Thread Liaw, Andy
Lenth's PSE is "quick and easy". Why not just roll your own? Andy > -Original Message- > From: Nitin Jain [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 11, 2003 4:22 PM > To: [EMAIL PROTECTED] > Subject: [R] S+DOX eqivalent in R? > > > Dear List, > > I am looking for a functi

RE: [R] simplifying randomForest(s)

2003-09-16 Thread Liaw, Andy
Ramon, > From: Ramon Diaz-Uriarte [mailto:[EMAIL PROTECTED] > > Dear All, > > I have been using the randomForest package for a couple of difficult > prediction problems (which also share p >> n). The > performance is good, but > since all the variables in the data set are used, > interpreta

RE: [R] Interfacing C++ , MysQL and R

2003-09-16 Thread Liaw, Andy
> From: Anne Piotet [mailto:[EMAIL PROTECTED] > > Hello! > > After a presentation of some statistical analysis of > process datas, (where the few R possibilities I was able to > show made quite a big impression), I was asked if it was > possible to program a statistical application whic

RE: [R] Retrieve ... argument values

2003-09-16 Thread Liaw, Andy
Try: myfunc <- function(x, ...) { if (hasArg(ylim)) a <- ...$ylim plot(x, ...) } HTH, Andy > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 16, 2003 10:14 AM > To: [EMAIL PROTECTED] > Subject: [R] Retrieve ... argument

RE: [R] plotting in the same figure

2003-09-17 Thread Liaw, Andy
Look at the argument "new" under ?par. Probably better way is to use the following sequence: plot(...) # whatever your first plot is. lines(...) # add line to the existing plot. points(...) # add points to the existing plot. There are many other functions that add to the existing plot. HTH,

RE: [R] Transpose Data Frame Question

2003-09-17 Thread Liaw, Andy
Isn't this what you want? > x <- data.frame(id=rep(1:2, each=2), test = rep(c("test1","test2"), 2), + score = c(120, 34, 132, 28)) > x id test score 1 1 test1 120 2 1 test234 3 2 test1 132 4 2 test228 > reshape(x, timevar="test", direction="wide") id score.tes

RE: [R] using matrix data for function

2003-09-17 Thread Liaw, Andy
Don't think this is "best", but here's one way: > mat <- matrix(1:12, 6) > mat [,1] [,2] [1,]17 [2,]28 [3,]39 [4,]4 10 [5,]5 11 [6,]6 12 > f <- function(x, y) x + y > apply(mat, 1, function(x) do.call("f", as.list(x))) [1] 8 10 12 14 16 18 Note that

RE: [R] predict for mlm does not work properly

2003-09-19 Thread Liaw, Andy
> From: ZABALZA-MEZGHANI Isabelle > > Hello, > > I've just fitted a model with multi-responses, and I get an > object of class "lm" "mlm". My problem is that as soon as I > invoke the predict method for a dataframe "newdata", the > methods runs and give me back prediction at the fitting > po

RE: [R] newby problem - concatenate lists

2003-09-19 Thread Liaw, Andy
Lists are just like vectors: > x<-list(c(1,2)) > y<-list(c(3,4)) > c(x,y) [[1]] [1] 1 2 [[2]] [1] 3 4 HTH, Andy > -Original Message- > From: Axel Benz [mailto:[EMAIL PROTECTED] > Sent: Friday, September 19, 2003 8:57 AM > To: [EMAIL PROTECTED] > Subject: [R] newby problem - concatenate

RE: [R] Data frame from list of lists

2003-09-22 Thread Liaw, Andy
Don't know if this will be any faster, and it doesn't give you a data frame, but the final conversion to data frame is probably fairly easy: > xx <- do.call("rbind", lapply(ListOfLists, function(x) do.call("cbind", x))) > xx A L T [1,] "1" "a" "1064233098" [2,] "2" "b" "1064233

RE: [R] R-project [.com?] [.net?]

2003-09-23 Thread Liaw, Andy
> From: Murray Jorgensen [mailto:[EMAIL PROTECTED] > > I got a shock a few days ago when I accidentally visited > www.r-project.com . I thought that the r-project site had been hacked This one seems to be about some sort of city revival projects in Japan. (The introduction starts with "Recycle

RE: [R] Rank and extract data from a series

2003-09-23 Thread Liaw, Andy
Here's one way. Suppose your "time series" is in a vector called "x". top10 <- sort(x, decreasing=TRUE)[1:10] mean.index <- mean(which(x %in% top10)) HTH, Andy > -Original Message- > From: James Brown [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 23, 2003 7:51 AM > To: [EMAIL PR

RE: [R] weird behaviour when calling c++

2003-09-24 Thread Liaw, Andy
This is sort of like calling up an auto mechanic and ask "My car just won't start. Can you fix it?" The answer is almost surely "yes", but not without looking at the car (or at least get answers on quite a few questions)! Showing us the code would be a start. Since you can use gdb to debug the c

RE: [R] density() integrates to 1?

2003-09-24 Thread Liaw, Andy
There was a related thread on R-help, probably last year. The question was getting density() to numerically integrate to 1. The answer is, "yes". If you do fine enough partitions, you will see that it integrates to one. And yes, a kernel density estimate is theoretically a true density (assumin

RE: [R] coloring dendrgram in heatmap?

2003-09-29 Thread Liaw, Andy
> From: Xiao-Jun Ma [mailto:[EMAIL PROTECTED] > > No, I meant coloring the edges of the dendrogram on the left > or top of the image plot. I'm not sure if this can be done with the current plot.dendrogram() (which heatmap() calls to draw the trees). You may want to experiment with the edgePa

[R] can I have a matrix of factors, please?

2003-09-29 Thread Liaw, Andy
Dear R-help, Is it a violation of the S language to have a matrix of factors? What I would like to have is just a factor object that has dim attribute, and can be printed (and subsetted) like a matrix; i.e., all columns/rows have the identical levels. However, I can't get it to work: > x <- fac

RE: [R] can I have a matrix of factors, please?

2003-09-29 Thread Liaw, Andy
> From: Liaw, Andy [mailto:[EMAIL PROTECTED] > > Dear R-help, > > Is it a violation of the S language to have a matrix of > factors? What I would like to have is just a factor object > that has dim attribute, and can be printed (and subsetted) > like a matrix; i.e

RE: [R] Generation of labels for 2 factors

2003-09-30 Thread Liaw, Andy
Not sure exactly what you want, but try: countrySector <- factor(paste(df$country, df$sector, sep=":")) where df is the data frame. This creates a factor for the combination. If you want numeric code, just coerce with as.numeric(). HTH, Andy > -Original Message- > From: Xavier Ferná

RE: [R] R-1.7.1 for Redhat 9

2003-10-01 Thread Liaw, Andy
Tell us the output of something like tail -20 /volume1/scratch/jallemee/R-1.7.1/tests/Examples/base-Ex.Rout so we know where it bombed (and may be how it bombed). Andy > -Original Message- > From: Joke Allemeersch [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 01, 2003 6:02 AM

RE: [R] Solving a tridiagonal system

2003-10-01 Thread Liaw, Andy
I see that the LAPACK routine DGTSV is in the R source, and defined in R_ext/lapack.h, but I don't know how to get to it from R. Andy > -Original Message- > From: Roger Koenker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 01, 2003 10:33 AM > To: Thomas W Blackwell > Cc: [EMAIL P

RE: [R] using a string as the formula in rlm

2003-10-02 Thread Liaw, Andy
It may help you to read Bill Venables' column in R News http://cran.r-project.org/doc/Rnews/Rnews_2002-2.pdf, pages 24-26. Andy > -Original Message- > From: Rajarshi Guha [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 02, 2003 11:25 AM > To: [EMAIL PROTECTED] > Subject: [R] using a

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

2003-10-02 Thread Liaw, Andy
You need to install the tools needed to build packages from source. You can read about it in Q3.1 of R for Windows FAQ. Andy > -Original Message- > From: Rex Bryan Dell1700 [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 02, 2003 12:15 PM > To: [EMAIL PROTECTED] > Subject: [R] R] Re

RE: [R] polynomial fit

2003-10-06 Thread Liaw, Andy
Or even mars() in the mda package... Andy > From: Thomas W Blackwell [mailto:[EMAIL PROTECTED] > > Karim - > > try function gam() in package mgcv. > > library("mgcv") > help("gam") > > - tom blackwell - u michigan medical school - ann arbor - > > On Mon, 6 Oct 2003, Karim Elsawy w

RE: [R] Problem getting an ifelse statment to work

2003-10-06 Thread Liaw, Andy
This is a "long" way; i.e., not necessarily efficient: > qs2 [1] 2 1 1 4 4 4 1 1 1 4 2 4 3 1 4 3 3 2 4 3 > qs9 [1] 4 4 1 3 4 3 1 3 1 4 1 2 3 3 4 4 1 4 2 3 > decision <- function(a, b) { + if (a == 1 || b == 1) return(1) + if (a == 2 || b == 2) return(2) + if (a == 3 || b == 3) return

RE: [R] .First.lib doesn't appear to be running after calling lib rary()

2003-10-07 Thread Liaw, Andy
>From the R-exts manual: The R subdirectory contains R code files. The code files to be installed must start with a (lower or upper case) letter and have one of the extensions .R, .S, .q, .r, or .s. We recommend using .R, as this extension seems to be not used by any other software. It should

RE: [R] 2 questions regarding base-n and identifing digits

2003-10-08 Thread Liaw, Andy
> From: Andrej Kveder [mailto:[EMAIL PROTECTED] > > Dear listers, > > I have two questions: > (1) > Is there a way in R to change the base-n of the calculations. > I wnat to run some calculations either in binary (base-2) or > base-4. Is there a way to specify that in R - to chnage from > the

RE: [R] startup file and lambda

2003-10-09 Thread Liaw, Andy
See ?Startup. Andy > -Original Message- > From: christoff pale [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 09, 2003 10:40 AM > To: [EMAIL PROTECTED] > Subject: [R] startup file and lambda > > > Hi,s there a .Rrc file? so that when R starts up > it automatically loads this file?

RE: [R] colnames from submatrix?

2003-10-13 Thread Liaw, Andy
If the columns you want to exclude can only contain all 0s (and not some other values such as 1s), you can do something like: mat[, colSums(mat != 0) > 0] to extract the non-zero columns of the matrix. "mat != 0" gives you a matrix of TRUEs and FALSEs, and colSums() of this matrix tells you how

RE: [R] different results depending of variable position.

2003-10-14 Thread Liaw, Andy
> From: Ronaldo Reis Jr. [mailto:[EMAIL PROTECTED] > > Hi, > > I make an analysis and depending of the order of the variables, the > significance change, look. [output of glm fits omitted] > Why this? Because, as the output says: > Terms added sequentially (first to last) When the predic

RE: Fw: [R] SIMCA algorithm implementation

2003-10-15 Thread Liaw, Andy
SIMCA, I believe, is Svante Wold's invention, and extensively used in the chemometrics area (analysis of data from analytic chemistry). My vague impression of what it does is PCA in the individual classes. I have not been able to locate a detail description of the algorithm. (I'd appreciate it v

RE: [R] SOM library for R

2003-10-15 Thread Liaw, Andy
Doing help.search("SOM") in R gives batchSOM(class) Self-Organizing Maps: Batch Algorithm SOM(class) Self-Organizing Maps: Online Algorithm somgrid(class) Plot SOM Fits so you ought to have it in your (recent enough) version of R. The "class" package is part of t

RE: [R] aov and non-categorical variables

2003-10-15 Thread Liaw, Andy
> From: Alexander Sirotkin [at Yahoo] [mailto:[EMAIL PROTECTED] > > Thanks. One more question, if you don't mind. > > If instead of aov(), I call lm() directly it fits a > linear regression model and if it encounters > categorical variable it does what needs to be done in > this case - defines

RE: [R] princomp with more coloumns than rows: why not?

2003-10-16 Thread Liaw, Andy
In the `Detail' section of ?princomp: princomp only handles so-called Q-mode PCA, that is feature extraction of variables. If a data matrix is supplied (possibly via a formula) it is required that there are at least as many units as variables. For R-mode PCA use prcomp. Andy > -Original Me

RE: [R] R memory and CPU requirements

2003-10-17 Thread Liaw, Andy
A couple of comments: o Methods such as decision trees do not need to expand factors into columns of 1df contrasts, so the memory requirement is vastly different. The models produced is also very, very different. o Why would you want "all possible interactions" of 10 variables, 6 of which are

[R] RE: [S] Dynamic Memory Allocation in R

2003-10-17 Thread Liaw, Andy
> From: Gamal Abdel-Azim [mailto:[EMAIL PROTECTED] > > While trying to expand the memory/object size in R, I noticed > that R might be using > only heap memory. Is this true? Are all objects in R created > in the heap not > allocated? It's not logical that this is the case!! Otherwise > the

RE: [R] heatmap function

2003-10-17 Thread Liaw, Andy
One of the good thing about R (and S in general, I guess) is that if a function does mostly what you want, except for some small things, you can just make another copy of it, change the name, and make the desired changes to the new function (provided the changes you need to make isn't in the compil

RE: [R] Problems with crossprod

2003-10-17 Thread Liaw, Andy
Somehow R creates `a' as a matrix with 0 rows and 5 columns. I don't know how crossprod() or other linear algebra functions deals with such a degenerate matrix. I'd suggest R Core to add checks for strictly positive dimensions in such functions. (Also, I find it strange that A[1,] is a vector, b

RE: [R] Processing logic for Huge Data set

2003-10-20 Thread Liaw, Andy
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Loops are time consuming in R. Try one of the apply functions > for vectorized > calculations, like "apply", "lapply","sapply" or "tapply". > Also see help for > "split". Have you actually compared for loop with apply, in terms of timin

RE: [R] How to upgrade R

2003-10-20 Thread Liaw, Andy
What I do is to separate packages that shipped with R separate from other contributed packages from CRAN, so that when I upgrade, I can wipe clean the old R and re-install while keeping all other packages in place. What's not clear to me is a good way of keeping two versions of R simultaneously (f

RE: [R] nnet behaving oddly

2003-10-21 Thread Liaw, Andy
> From: Rajarshi Guha [mailto:[EMAIL PROTECTED] > > Hi, > I was trying to use the nnet library and am not sure of > whats going on. I am calling the nnet function as: > > n <- nnet(x,y,size=3,subset=sets[[1]], maxit=200) Please give us output of something like: str(x) summary(y) Also, I b

RE: [R] Lines between coordinates

2003-10-21 Thread Liaw, Andy
I suspect you are looking for segments(). Andy > From: GWIGGNER Claus-Peter (EXT) > > Hello, > > Given x1, ..., xn and y1, ..., yn I'd like to draw n lines > between xi,yi. The xi, yi shoulfd be 2-D coordinates. > > What is an elegant solution? > Thanks. > > > > This message and any

RE: [R] How to upgrade R

2003-10-21 Thread Liaw, Andy
It's actually easier than I thought (and perhaps than you described). What Prof. Ripley suggested, combined with the options to the configure script, should make this fairly straight-forward, even with "make install". Cheers, Andy > From: David Brahm [mailto:[EMAIL PROTECTED] > > Andy Liaw <[E

RE: [R] run R under linux

2003-10-21 Thread Liaw, Andy
> From: Jason Turner [mailto:[EMAIL PROTECTED] > > 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

RE: [R] generic algorithm

2003-10-23 Thread Liaw, Andy
Could it be that you meant genetic (rather than "generic") algorithm? If so, from the package descriptions, the "gafit" and "seao" packages on CRAN might be relevant. HTH, Andy > -Original Message- > From: zhu wang [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 23, 2003 10:51 AM >

RE: [R] how to remove NaN columns ?

2003-10-24 Thread Liaw, Andy
As an example: > dat <- data.frame(x=1:5, y=NaN, z=5:1) > dat x y z 1 1 NaN 5 2 2 NaN 4 3 3 NaN 3 4 4 NaN 2 5 5 NaN 1 > bad <- sapply(dat, function(x) all(is.nan(x))) > dat[,!bad] x z 1 1 5 2 2 4 3 3 3 4 4 2 5 5 1 HTH, Andy > -Original Message- > From: [EMAIL PROTECTED] > [mailto:

RE: [R] how to select random rows ?

2003-10-27 Thread Liaw, Andy
Like this: a.subset <- a[sample(nrow(a), how.many.I.want), ] HTH, Andy > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Sent: Monday, October 27, 2003 10:26 AM > To: [EMAIL PROTECTED] > Subject: [R] how to select random rows ? > > > How can I select random

RE: [R] expanding factor with NA

2003-10-27 Thread Liaw, Andy
Strangely (to me), just passing na.action=na.pass to model.matrix doesn't work: > f <- factor(rep(letters[1:3], 5)) > is.na(f[sample(15, 3)]) <- TRUE > model.matrix(~f, data=model.frame(~f, na.action=na.pass)) (Intercept) fb fc 11 0 0 21 1 0 31 0 1 4

RE: [R] stacking histograms

2003-10-27 Thread Liaw, Andy
The hist() function expects to be given data, not the counts in the bins. It sounded like you are giving hist() the counts. One thing you may try is by constructing an object of class "histogram" by hand (see the "Value" section of ?hist), and just plot() it. However, beware that by default hist(

[R] problem with the installed R script

2003-10-28 Thread Liaw, Andy
Dear R-help, I had a problem running a Perl script on AIX inside pipe() or system(). The Perl script was not finding some modules when run from within R. The sysadmin tracked it down to a problem with R_LD_LIBRARY_PATH in the installed /usr/local/bin/R script: original: : ${R_LD_LIBRARY_PATH=${

RE: [R] ifelse with a factor variable

2003-10-28 Thread Liaw, Andy
Does the following help you? > x <- factor(c("A", "B", NA)) > levels(x) <- c(levels(x), "unknown") # add an "unknown" level > x[is.na(x)] <- "unknown" # change NAs to "unknown" > x [1] A B unknown Levels: A B unknown Andy > -Original Message- > From: Goran Brostrom [mailto:

RE: [R] automate save.image

2003-10-29 Thread Liaw, Andy
You can use the callback manager that Duncan Temple Lang implemented in R. Search the R-help archive for "auto-save". Andy > From: Remigijus Lapinskas [mailto:[EMAIL PROTECTED] > > Dear all, > > Sometimes, during an R session, my computer hangs and I > loose all the objects created during this

RE: [R] Re: packaging a package addon

2003-10-31 Thread Liaw, Andy
> From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] > > On Thu, 30 Oct 2003, Ross Boylan wrote: [...] > > Finally, a comment on R CMD check: perhaps it could produce > some more > > of the output when things fail? I found that to diagnose > the loading > > problems as I developed this, I had

RE: [R] Partial least squares.

2003-10-31 Thread Liaw, Andy
The package `pls.pcr' has NIPALS and SIMPLS. There's also gpls in BioConductor 1.3. Andy > -Original Message- > From: Carlos J. Gil Bellosta > [mailto:[EMAIL PROTECTED] > Sent: Friday, October 31, 2003 8:02 PM > To: [EMAIL PROTECTED] > Subject: [R] Partial least squares. > > > Dear R

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

2003-11-03 Thread Liaw, Andy
> From: Jason Turner [mailto:[EMAIL PROTECTED] > > [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 de

RE: [R] hclust doesn't return merge details

2003-11-03 Thread Liaw, Andy
> From: Arne Neumann [mailto:[EMAIL PROTECTED] > > Dear R-users, > > I tried to receive the merge details of a clustering by using > the summary function of hclust. For illustration I use the > Longley data as done by Prof Ripley (Wed 11 Apr 2001) d <- > dist(longley.y) > d <- d/max(d) > h

[R] RE: [Rd] fast nearest-neighbor in R?

2003-11-05 Thread Liaw, Andy
Please send such queries to R-help. See if knn() in the "class" package (part of the VR bundle that is shipped with R) does what you want. Andy > -Original Message- > From: Mirka Zednikova [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 05, 2003 11:58 AM > To: [EMAIL PROTECTED] >

RE: [R] Mean Significance

2003-11-05 Thread Liaw, Andy
As Prof. Ripley said, the test on contrast is valid only if you selected the contrast before seeing the data. Using the same data for both hypothesis generation and hypothesis confirmation is extremely hazardous! Andy > From: Igor Roytberg [mailto:[EMAIL PROTECTED] > > Hello, > > If you deter

RE: [R] R input file scanning

2003-11-06 Thread Liaw, Andy
If the portion of the file that you want to read is "rectangular" (same number of fields in all lines and same type of data in each column), you can use either read.table() or scan() and supply the skip= argument to skip over the headers you don't want to read in. HTH, Andy > From: Mathieu Drapea

RE: [R] Plotting Andrew's curves?

2003-11-06 Thread Liaw, Andy
Is that the technique for visualizing multivariate data by plotting linear combinations of sine and cosine curves using the data values as coefficients? Seems to be fairly easy to cook up with a few lines of R code... Andy > From: Eryk Wolski [mailto:[EMAIL PROTECTED] > > Hi! > Is there a func

RE: [R] xyplot

2003-11-07 Thread Liaw, Andy
Need to wrap the xyplot() in print(), as in print(xyplot(...)) Andy > From: Dr. Peter Schlattmann > > Dear all, > > I am trying to use xyplot inside a function > > plotme<-function(dataframe) > { > xyplot(x~y|z,data=dataframe) > } > > x,y,z are members of the data frame. > > When calling

RE: [R] Annoteting graphs using text

2003-11-07 Thread Liaw, Andy
You want to use paste() inside text(), not cat(). Andy > From: Craig H. Ziegler [mailto:[EMAIL PROTECTED] > > Dear All, > > I am new to R and am trying to learn how to create functions > using R. Below is code which calculates Lin's Concordance > Coefficient. After I calculate the coefficie

RE: [R] average of y at each level of x?

2003-11-07 Thread Liaw, Andy
Try (untested): p1 <- tapply(y, x, function(z) mean(z == 0)) HTH, Andy > From: Bill Simpson [mailto:[EMAIL PROTECTED] > > I have x,y data and would like to compute the average of y at > each level > of x. > > > x > [1] 0.006110 0.007027 0.007027 0.007027 0.008081 0.008081 > 0.008081 0.008

RE: [R] stack overflow and predict()

2003-11-07 Thread Liaw, Andy
Try something like this (suppose x is the matrix of predictors in the training set, and xtest is the same for the test set): my.rp <- rpart(y ~ x, ...) test.pred <- predict(my.rp, newdata=data.frame(x=I(xtest))) Make sure the name of the variable in the data frame given to newdata matches the nam

RE: [R] A co-occurrence matrix

2003-11-11 Thread Liaw, Andy
Does the following help? > group <- c(1, 2, 1, 1, 3) > outer(group, group, "==") [,1] [,2] [,3] [,4] [,5] [1,] TRUE FALSE TRUE TRUE FALSE [2,] FALSE TRUE FALSE FALSE FALSE [3,] TRUE FALSE TRUE TRUE FALSE [4,] TRUE FALSE TRUE TRUE FALSE [5,] FALSE FALSE FALSE FALSE TRUE > outer

RE: [R] installing an add-on package

2003-11-11 Thread Liaw, Andy
You should be reading the R for Windows FAQ (rw-FAQ), which is under the "Help" menu on Rgui. Big hint: Look under the "Packages" menu in Rgui. Andy > From: Christian Gold [mailto:[EMAIL PROTECTED] > > Dear all, > > my apologies if I am posting a silly question - but I > couldn't find any h

RE: [R] repeat until function

2003-11-12 Thread Liaw, Andy
As others already pointed out, the fast way is to use sample(). What I'd like to add is the following, which I learned from peeking at the C code underneath sample(): To draw n samples without replacement from 1:N (N>=n), you only need a loop from 1 to n that used up n random numbers. The algori

RE: [R] repeat until function

2003-11-12 Thread Liaw, Andy
> From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] > > Ripley (1987) Stochastic Simulation, pp.80-1 for one. I am > pretty sure it is Knuth's book, although I don't have that to > hand. I attribute it to > Moses & Oakford (1963). Thanks to Brian, Peter and Duncan for the info. And I have

RE: [R] R CMD check problems

2003-11-14 Thread Liaw, Andy
In the directory where you ran the check, you should have a subdirectory like pkg.Rcheck (substitute "pkg" with the name of your package). That's where the package got installed for the purpose of the check. You could try to source() the files there and see if you can find the problem. HTH, Andy

RE: [R] Expressions and Functions

2003-11-14 Thread Liaw, Andy
You should be able to use deriv(..., func=TRUE) to get a function returned, instead of an expression. If you need to use D, here's a rather clumsy way that seems to work: > dx2x <- D(expression(x^2), name="x"); dx2x 2 * x > eval(parse(text=paste("f <- function(x){", paste(

RE: [R] Vector indices and minus sign

2003-11-14 Thread Liaw, Andy
> From: Thomas Lumley [mailto:[EMAIL PROTECTED] > > On Fri, 14 Nov 2003, David Orme wrote: > > > Hi, > > > > I got caught out by this behaviour in 1.8.0 and I wondered why this > > happens: > > > > Some anomaly of this sort is unavoidable because R allows > positive or negative numeric indices

  1   2   3   4   5   6   7   8   9   10   >