Re: [R] String in data frame

2005-04-16 Thread Prof Brian Ripley
Please read `An Introduction to R': R does not have `strings' or `namelists' whereas it does have `lists' but d$num is not one. To communicate, you need a common language with your readers. You are not speaking R, and your `examples' are not R output. I suspect d$num is a numeric vector and

Re: [R] example on front page doesn't work in R 2.0.1

2005-04-16 Thread Uwe Ligges
Hubert Feyrer wrote: On Fri, 15 Apr 2005, Sundar Dorai-Raj wrote: You snipped too much: ... This is where it says ade4, etc. is not found. If you would like to install these packages, it's rather easy: install.packages(c(ade4, RColorBrewer, pixmap)) Ah, thanks! i'll try to see how I can add the

RE: [R] Pearson corelation and p-value for matrix

2005-04-16 Thread John Fox
Dear Andy, That's clearly much better -- and illustrates an effective strategy for vectorizing (or matricizing) a computation. I think I'll add this to my list of programming examples. It might be a little dangerous to pass ... through to cor(), since someone could specify type=spearman, for

Re: [R] Getting subsets of a data frame

2005-04-16 Thread Fernando Saldanha
Thanks, it's interesting reading. I also noticed that sw[, 1, drop = TRUE] is a vector (coerces to the lowest dimension) but sw[1, , drop = TRUE] is a one-row data frame (does not convert it into a list or vector) FS On 4/16/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: You should look

RE: [R] Pearson corelation and p-value for matrix

2005-04-16 Thread John Fox
Dear Mark, -Original Message- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Friday, April 15, 2005 9:41 PM To: John Fox Cc: 'R-Help'; 'Dren Scott' Subject: RE: [R] Pearson corelation and p-value for matrix John, Interesting test. Thanks for pointing that out. You are

Re: [R] function corresponding to map of perl

2005-04-16 Thread Fernando Saldanha
I defined map as follows: map - function(x, y, fun) { mymat - matrix( c(x,y), c(length(x), 2) ) tmat - t(mymat) oldmat - tmat result - apply(tmat, 2, function(x) {fun(x[1], x[2])}) } It seems to work (see below). Of course you can turn it into a one-liner.

RE: [R] Getting subsets of a data frame

2005-04-16 Thread Liaw, Andy
Because a data frame can hold different data types (even matrices) in different variables, one row of it can not be converted to a vector in general (where all elements need to be of the same type). Andy From: Fernando Saldanha Thanks, it's interesting reading. I also noticed that

RE: [R] Pearson corelation and p-value for matrix

2005-04-16 Thread Liaw, Andy
From: John Fox Dear Andy, That's clearly much better -- and illustrates an effective strategy for vectorizing (or matricizing) a computation. I think I'll add this to my list of programming examples. It might be a little dangerous to pass ... through to cor(), since someone could

Re: [R] How to get predictions, plots, etc. from lmer{lme4}

2005-04-16 Thread Douglas Bates
Michael Kubovy wrote: Kindly send a cc to me when replying to the list. I'm having trouble using lmer beyond a first step. My data: some(exp1B) sub ba amplitude a b c d 2 1 1.00 1.5 65 63 4 8 414 1.15 0.0 92 41 3 4 434 1.15 3.0 88 48 2 2 63

[R] Almost seasonal decomposition

2005-04-16 Thread Dieter Menne
Dear ts-friends, I have an almost seasonal signal. It's human respiration pressure, where the respiration signal is regular but non-sinusoidal, with a slightly drifting period. Overlaid on the signal are non-periodic twitches (think weak hickups) with amplitudes 2-5 times higher than the

Re: [R] can test the if relationship is significant in cancor?

2005-04-16 Thread Kjetil Brinchmann Halvorsen
ronggui wrote: i have try hard to find the answer by google,but i can not find any solution. so i wan to ask: 1,can we test the if canonical relationship is significant after using cancor? One reference is T. W. Anderson: An Introduction to Multivariate Statistical Analysis, second edition,

Re: [R] Define local function

2005-04-16 Thread Duncan Murdoch
Peter Dalgaard wrote: Ales Ziberna [EMAIL PROTECTED] writes: I am also very interested how this could be done, possibly in such a way that this would be incorporated in the function itself and there wouldn't be a need to write environment(f) - NULL before calling a function, as is proposed in the

Re: [R] How to get predictions, plots, etc. from lmer{lme4}

2005-04-16 Thread Michael Kubovy
Any comments on the following strategy: (1) Take the log-odds of the frequencies of b and a (adding 1/6, as Tukey recommended) and run lme. (2) If the estimates from lme are in line with the estimates I got from lmer, then use the results from lme. On Apr 16, 2005, at 9:16 AM, Douglas Bates

[R] [R-pkgs] g.data version 1.6, upgrade in response to changes in R-2.1.0

2005-04-16 Thread Brahm, David
Version 1.6 of the g.data package is available on CRAN. The g.data package is used to create and maintain delayed-data packages (DDP's). Data stored in a DDP are available on demand, but do not take up memory until requested. You attach a DDP with g.data.attach(), then read from it and assign to

[R] [R-pkgs] bayesm: a package for Bayesian infererence for Marketing/Micro-Econometrics

2005-04-16 Thread Peter E. Rossi
We are pleased to announce the release of version 0.0 of bayesm on CRAN. bayesm covers many important models used in marketing and micro-econometrics applications. The package includes: Bayes Regression (univariate or multivariate dep var) Multinomial Logit Multinomial and Multivariate Probit

RE: [R] function corresponding to map of perl

2005-04-16 Thread Liaw, Andy
From: Fernando Saldanha I defined map as follows: map - function(x, y, fun) { mymat - matrix( c(x,y), c(length(x), 2) ) tmat - t(mymat) oldmat - tmat result - apply(tmat, 2, function(x) {fun(x[1], x[2])}) } It seems to work (see below). Of course you can turn

[R] HOWTO compare univariate binomial glm lrm models which are not nested

2005-04-16 Thread Jan Verbesselt
Thanks a lot for the input! I forgot to add family=binomial, for a binomial glm. Now the AIC's are positive! I was planning to use AIC (from the binomial glm) and c-index (lrm) to compare and rank different uni-variate (one continue explanatory variable) logistic models to evaluate the

[R] Re: HOWTO compare univariate binomial glm lrm models which are not nested

2005-04-16 Thread Prof Brian Ripley
Compare them by `goodness for purpose': you have not told us the purpose. Please do read some of the extensive literature on model comparison. On Sat, 16 Apr 2005, Jan Verbesselt wrote: Thanks a lot for the input! I forgot to add family=binomial, for a binomial glm. Now the AIC's are positive! I

RE: [R] Getting subsets of a data frame

2005-04-16 Thread Prof Brian Ripley
Perhaps Fernando will also note that is documented in ?[.data.frame, a slightly more appropriate reference than Bill's. It would be a good idea to read a good account of R's indexing: Bill Venables and I know of a couple you will find in the R FAQ. On Sat, 16 Apr 2005, Liaw, Andy wrote: Because

[R] [R-pkgs] Version 1.0-0 of the Rcmdr package

2005-04-16 Thread John Fox
Dear list members, I've just uploaded version 1.0-0 of the Rcmdr package to CRAN. For people who haven't seen the package before, the R Commander provides a basic-statistics graphical user interface to R, based on the tcltk package. The new version incorporates a number of improvements to the R

RE: [R] Getting subsets of a data frame

2005-04-16 Thread Prof Brian Ripley
On Sat, 16 Apr 2005, Prof Brian Ripley wrote: Perhaps Fernando will also note that is documented in ?[.data.frame, a slightly more appropriate reference than Bill's. It would be a good idea to read a good account of R's indexing: Bill Venables and I know of a couple you will find in the R FAQ.

[R] Re: Inverse of the Laplace Transform/Gaver Stehfest algorithm

2005-04-16 Thread Tolga Uzuner
Tolga Uzuner wrote: Hi there, Is there an implementation of the Gaveh Stehfest algorithm in R somewhere ? Or some other inversion ? Thanks, Tolga Well, at least here is Zakian's algorithm, for anyone who needs it: Zakian-function(Fs,t){ # Fs is the function to be inverted and evaluated at t a

[R] Re: Inverse of the Laplace Transform/Gaver Stehfest algorithm

2005-04-16 Thread Tolga Uzuner
Tolga Uzuner wrote: Tolga Uzuner wrote: Hi there, Is there an implementation of the Gaveh Stehfest algorithm in R somewhere ? Or some other inversion ? Thanks, Tolga Well, at least here is Zakian's algorithm, for anyone who needs it: Zakian-function(Fs,t){ # Fs is the function to be inverted and

[R] Element-wise multiplication

2005-04-16 Thread GiusVa
Dear members, The code I am writing heavily use element-wise multiplication of matrix and vectors, e.g. X, is nxm matrix e, is nx1 matrix Doing Z=X*e[,], I obtain a nxm matrix, Z, where each column of X is multiplied (element-wise) by e. Is this the best way to achieve the result I want? By

Re: [R] Element-wise multiplication

2005-04-16 Thread Gabor Grothendieck
On 4/16/05, GiusVa [EMAIL PROTECTED] wrote: Dear members, The code I am writing heavily use element-wise multiplication of matrix and vectors, e.g. X, is nxm matrix e, is nx1 matrix Doing Z=X*e[,], I obtain a nxm matrix, Z, where each column of X is multiplied (element-wise) by e. Is

Re: [R] Getting subsets of a data frame

2005-04-16 Thread Fernando Saldanha
I am reading as fast as I can! Just started with R five days ago. I found the following in the documentation: Although the default for 'drop' is 'TRUE', the default behaviour when only one _row_ is left is equivalent to specifying 'drop = FALSE'. To drop from a data frame to a list, 'drop =

[R] help on extract variance components from the fitted model by lm

2005-04-16 Thread wenqing li
Hey, all: Do we have a convenient command(s) to extract the variance components from a fitted model by lm (actually it's a nexted model)? e.g.: using the following codes we could get MSA,MSB(A) and MSE. How to get the variance component estimates by command in R rather than calculations by hand?

Re: [R] Ack! Odd correlation matrix problem

2005-04-16 Thread Chris Bergstresser
Spencer Graves wrote: Does the following answer the question: cor(B, use=complete.obs) ** snip ** cor(B, use=pairwise.complete.obs) Yep. That's exactly the issue. I had thought the reference to casewise deletion in the help for complete.obs was referring solely to the two variables

Re: [R] help on extract variance components from the fitted model by lm

2005-04-16 Thread Marc Schwartz
On Sun, 2005-04-17 at 02:38 +0800, wenqing li wrote: Hey, all: Do we have a convenient command(s) to extract the variance components from a fitted model by lm (actually it's a nexted model)? e.g.: using the following codes we could get MSA,MSB(A) and MSE. How to get the variance component

Re: [R] Ack! Odd correlation matrix problem

2005-04-16 Thread Chris Bergstresser
Spencer Graves wrote: Does the following answer the question: cor(B, use=complete.obs) ** snip ** cor(B, use=pairwise.complete.obs) Yep. That's exactly the issue. I had thought the reference to casewise deletion in the help for complete.obs was referring solely to the two variables

RE: [R] Generating a binomial random variable correlated with a

2005-04-16 Thread Ashraf Chaudhary
Ted: Thank you for your help. All I want is a binomial random variable that is correlated with a normal random variable with specified correlation. By linear I mean the ordinary Pearson correlation. I tried the following two methods, in each case the resulting correlation is substantially less

Re: [R] How to create a vector with one, two, three, ...?

2005-04-16 Thread Frank Duan
Sorry, I didn't get the question clear. What I meant is to create a character vector with length 200: one, two, three, ..., two hundred On 4/15/05, Federico Calboli [EMAIL PROTECTED] wrote: On Fri, 2005-04-15 at 14:30 -0400, Frank Duan wrote: Hi R people, I met a naive prolem. Could anyone

Re: [R] How to create a vector with one, two, three, ...?

2005-04-16 Thread Marc Schwartz
I may be wrong, but I am unaware of anyone that has created a number to text function in R. If you search Google: http://www.google.com/search?q=numbers+into+words There are various program examples, from VB to JavaScript to PHP, etc. It shouldn't be too hard to convert one of them to R. Most

[R] Unlogical phenomenon caused by locator

2005-04-16 Thread Sebastien Durand
I was wondering if someone could help me! Here is what I don't understand! Why the text in the function isn't showing up before the locator action? ### plot(1:10) toto-function(){ cat(Why this text isn't showing up before the point selection ) point-locator(2) return(point) }

[R] nls segmented model with unknown joint points

2005-04-16 Thread andy
Hello, I am interested in fitting a segmented model with unknown joint points in nls and perhaps eventually in nlme. I can fit this model in sas (see below, joint points to be estimated are a41 and a41), but am unsure how to specify this in the nlm function. I would really appreciate any

RE: [R] How to create a vector with one, two, three, ...?

2005-04-16 Thread John Fox
Dear Frank, This was an interesting exercise. Here's a solution: numbers2words - function(x){ helper - function(x){ digits - rev(strsplit(as.character(x), )[[1]]) nDigits - length(digits) if (nDigits == 1) as.vector(ones[digits]) else if (nDigits == 2)

RE: [R] nls segmented model with unknown joint points

2005-04-16 Thread Bill.Venables
This is how I'd write the formula for use with nls/nlme: y ~ b41*(x - 1) + b42*(x^2 - 1) + ifelse((a41 - x) = 0, b43*(a41 - x)^2, 0) + ifelse((a42 - x) = 0, b44*(a42 - x)^2, 0) This is a direct translation from your funny foreign-looking code below that probably makes it clear what's going

RE: [R] nls segmented model with unknown joint points

2005-04-16 Thread andy
Thank you very much Dr. Venables, I'll give this a try. Regards- andy On Sun, 2005-04-17 at 13:36 +1000, [EMAIL PROTECTED] wrote: This is how I'd write the formula for use with nls/nlme: y ~ b41*(x - 1) + b42*(x^2 - 1) + ifelse((a41 - x) = 0, b43*(a41 - x)^2, 0) + ifelse((a42 - x) = 0,