Re: [R] predict.lm(...,type="terms") question

2012-09-01 Thread peter dalgaard
On Sep 2, 2012, at 03:38 , David Winsemius wrote: > > Why should predict not complain when it is offered a newdata argument that > does no contain a vector of values for "x"? The whole point of the terms > method of prediction is to offer estimates for specific values of items on > the RHS of

Re: [R] predict.lm(...,type="terms") question

2012-09-01 Thread David Winsemius
On Sep 1, 2012, at 4:33 AM, Rui Barradas wrote: Hello, John is right, there seems to be an error in predict.lm. It can be made to work but if the model is fitted with lm(...,data) then it messes things up. Apparently predict.lm disregards the data argument and uses whatever it finds in t

Re: [R] Computing 'exp(1e3)*0' correctly....

2012-09-01 Thread Rolf Turner
On 02/09/12 10:52, CHEL HEE LEE wrote: I have some trouble to deal the value of 'NaN'. For example, exp(1e3) [1] Inf exp(1e3)*0 [1] NaN The correct answer should be 0 rather than NaN. I will very appreciate if anyone can share some technique to get a correct answer. There is no techniqu

Re: [R] R_closest date

2012-09-01 Thread arun
Hi, Try this: dat1 <- read.table(text="   PT_ID    IDX_DT  OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY 13  4549 2002-08-21 2002-08-20    -1  183    2 14  4549 2002-08-21 2002-11-14    85    91    1 15  4549 2002-08-21 2003-02-18  181    89    1 16  4549 2002-08-21 2003

[R] (Newbie) help cannot find chrome

2012-09-01 Thread Carilda Thomas
Following the beginning tutorial, I typed help.start() and was given a choice of browsers. I picked chrome but got back that chrome is not found. I cannot seem to change or get rid of it now. I looked at /etc/R/Renviron but don't see anywhere to set browser (R_BROWSER = ${R_BROWSER ...etc) - nothin

Re: [R] Computing 'exp(1e3)*0' correctly....

2012-09-01 Thread Rui Barradas
Em 02-09-2012 00:10, Jeff Newmiller escreveu: I disagree that this answer is "wrong". If you want a mathematically correct answer you are going to have to obtain it by applying intelligence to the algorithm in which this calculation occurred. Logarithms are the product of intelligence. And t

Re: [R] Computing 'exp(1e3)*0' correctly....

2012-09-01 Thread Jeff Newmiller
I disagree that this answer is "wrong". If you want a mathematically correct answer you are going to have to obtain it by applying intelligence to the algorithm in which this calculation occurred. This is not a mailing list about numerical methods in general, so it probably isn't appropriate to

[R] Computing 'exp(1e3)*0' correctly....

2012-09-01 Thread CHEL HEE LEE
I have some trouble to deal the value of 'NaN'. For example, > exp(1e3) [1] Inf > exp(1e3)*0 [1] NaN The correct answer should be 0 rather than NaN. I will very appreciate if anyone can share some technique to get a correct answer. __ R-help@r-proje

Re: [R] R_closest date

2012-09-01 Thread Rui Barradas
Hello, Try the following. dat <- read.table(text=" PT_ID IDX_DT OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY 13 4549 2002-08-21 2002-08-20-1 1832 14 4549 2002-08-21 2002-11-1485911 15 4549 2002-08-21 2003-02-18 181891 16

Re: [R] Help on numerical object and ifelse function

2012-09-01 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of arun > Sent: Friday, August 31, 2012 8:47 AM > To: Andras Farkas > Cc: R help > Subject: Re: [R] Help on numerical object and ifelse function > > Hi, > Try this: > z1<-c(z,z,z,z,z

Re: [R] help on setting boundaries for generating random numbers

2012-09-01 Thread peter dalgaard
On Sep 1, 2012, at 19:20 , Petr Savicky wrote: > On Sat, Sep 01, 2012 at 02:29:40AM -0700, Andras Farkas wrote: >> Dear All, >> ? >> is there a way to set low and high limits to a simulation with rlnorm()? >> ? >> as an example: >> ?a <-rlnorm(500,0.7,1) >> ? >> ? >> I get the summary of >> ? >>

Re: [R] help on setting boundaries for generating random numbers

2012-09-01 Thread Petr Savicky
On Sat, Sep 01, 2012 at 02:29:40AM -0700, Andras Farkas wrote: > Dear All, > ? > is there a way to set low and high limits to a simulation with rlnorm()? > ? > as an example: > ?a <-rlnorm(500,0.7,1) > ? > ? > I get the summary of > ? > Min. 1st Qu. MedianMean 3rd Qu.Max. 0.1175 1.0590

Re: [R] Vectorial analogue of all.equal()?

2012-09-01 Thread Bert Gunter
Hi Rui: Good points. However, as my offering is, I think, little more than a disguised loop -- as compared to yours' and Ted's truly vectorized solutions --I think it is far too inefficient to useful. I offered it merely for its "aesthetic" interest, which is what you noted in your comments below.

Re: [R] Vectorial analogue of all.equal()?

2012-09-01 Thread Bert Gunter
Yes, Rui's suggestion is what I would do, too. However, for fun, here is a different, way less efficient, but perhaps instructive (or amusing?) alternative using Vectorize() and all.equal() directly: > foo <- function(target,current,...)isTRUE(all.equal(target,current,...)) > equals <- Vectorize(

Re: [R] help on setting boundaries for generating random numbers

2012-09-01 Thread arun
Hi, May be this might help you. set.seed(1)  a <-rlnorm(500,0.7,1)  a1<-a[a>30|a<0.5] set.seed(2) a2 <-rlnorm(500,0.7,1) a3<-a2[a2>30|a2<0.5] a4<-a2[!a2%in%a3] summary(a4) #   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. # 0.5105  1.2500  2.2990  3.6850  4.7140 25.3600 a[a%in%a1]<-sample(a4,leng

[R] R_closest date

2012-09-01 Thread WANG WEIJIA
Hi, I have encountered an issue about finding a date closest to another date So this is how the data frame looks like: PT_ID IDX_DT OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY 13 4549 2002-08-21 2002-08-20-1 1832 14 4549 2002-08-21 2002-11-148591

Re: [R] Vectorial analogue of all.equal()?

2012-09-01 Thread Rui Barradas
Hello, The two approaches are conceptually different. With yours we get equality given a certain number of (significant) digits, which might be what you are looking for if the measurements are known to be made with those digits, a frequent case. And there's also Bert's Vectorize way, with th

Re: [R] Vectorial analogue of all.equal()?

2012-09-01 Thread Ted Harding
Thanks, Rui, but that was not my (apparently implicit) question. Apologies if my wording gave the wrong impression. I was really asking if such a function was already available somewhere in R. Yes, your definition of equals() is one possibility; or, with the work-round I was using, equals <- fu

Re: [R] Vectorial analogue of all.equal()?

2012-09-01 Thread Rui Barradas
Hello, Like this? equals <- function(x, y, tol = .Machine$double.eps^0.5) abs(x - y) < tol x <- rnorm(5) y <- x[2] equals(x, y) [1] FALSE TRUE FALSE FALSE FALSE y <- rnorm(3) y[2] <- x[2] equals(x, y) [1] FALSE TRUE FALSE FALSE FALSE Warning message: In x - y : longer object length is not a

[R] Vectorial analogue of all.equal()?

2012-09-01 Thread Ted Harding
Greetings All. Once again, I am probably missing something fairly accessible, but since I can't find it I'd welcome advice! I have a dataframe derived from a text file of data in tabular format. For one of the variables, say X, I want to select the subsets which in which X equals a particular val

Re: [R] Query in Taylor Diagram

2012-09-01 Thread Jim Lemon
On 09/01/2012 08:16 PM, Roopashree Shrivastava wrote: Dear all, I am coming across a funny problem in taylor diagram. When I plot the diagram for given values of a variable some points are going outside the diagram. i have never seen such a diagram and hence cannot understand the reason for it.

[R] help on setting boundaries for generating random numbers

2012-09-01 Thread Andras Farkas
Dear All,   is there a way to set low and high limits to a simulation with rlnorm()?   as an example:  a <-rlnorm(500,0.7,1)     I get the summary of   Min. 1st Qu. MedianMean 3rd Qu.Max. 0.1175 1.0590 2.1270 3.4870 4.0260 45.3800 I would like to set limits so that the simulated

Re: [R] predict.lm(...,type="terms") question

2012-09-01 Thread Rui Barradas
Hello, John is right, there seems to be an error in predict.lm. It can be made to work but if the model is fitted with lm(...,data) then it messes things up. Apparently predict.lm disregards the data argument and uses whatever it finds in the global environment. In the examples below, after r