Re: [R] NAs are removed

2022-01-14 Thread Avi Gross via R-help
I do not know what your major problem/issue is but the code you shared seems to be looking for a character value of '2' in what looks like a numeric vector containing the number 2. -Original Message- From: Neha gupta To: Ebert,Timothy Aaron Cc: r-help mailing list Sent: Fri, Jan 14,

Re: [R] [External] NAs are removed

2022-01-14 Thread Richard M. Heiberger
this is a related issue. For this example, the ifelse statement is 10 times slower than a much simpler != comparison. > tmp <- sample(1:2, 40, TRUE) > tmp [1] 2 2 2 2 1 2 1 2 1 1 1 1 1 2 1 2 2 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 1 1 2 1 2 1 2 2 > ifelse(tmp==2, 0, 1) [1] 0 0 0 0 1 0 1 0 1 1 1 1 1

Re: [R] NAs are removed

2022-01-14 Thread Ebert,Timothy Aaron
I don’t see any. To support this claim I tried it (but no dataframe): CA = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,

Re: [R] Method Guidance

2022-01-14 Thread Leonard Mada via R-help
Dear Jeff, I am sending an updated version of the code. The initial version assumed that the time points correspond to an integer sequence. The code would fail for arbitrary times. The new code is robust. I still assume that the data is in column-format and that you want the time to the

Re: [R] NAs are removed

2022-01-14 Thread Neha gupta
I have a variable in dataset "CA", which has the following values: [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [40] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 then I used this statement prot <- ifelse(ts$CA == '2', 0, 1)

Re: [R] NAs are removed

2022-01-14 Thread Ebert,Timothy Aaron
Hi Neha, You used a variable named "fraction" so we took a guess. However, as another pointed out 1/0 does not give NA in R. number/0 returns Inf except 0/0 which returns NaN. So 1/0 <= 1 returns FALSE and 0/0 <= 1 returns NA. A great deal of the behavior of your program hinges on what

Re: [R] NAs are removed

2022-01-14 Thread Neha gupta
I have a variable CA which has a value of 1 or 2, and I am using this code in if statement prot <- ifelse(ts$CA == '2', 0, 1) On Fri, Jan 14, 2022 at 10:04 PM Bill Dunlap wrote: > > fraction <- 0/0 > > if (fraction < .5) TRUE else FALSE > Error in if (fraction < 0.5) TRUE else FALSE : >

Re: [R] NAs are removed

2022-01-14 Thread Neha gupta
Hi Jim and Ebert How I am using divide by zero, I did not understand? I am using caret and AUC metric. If I do, what is the solution? On Fri, Jan 14, 2022 at 9:41 PM Jim Lemon wrote: > Hi Neha, > You're using the argument "na.omit" in what function? My blind guess > is that there's a divide

Re: [R] NAs are removed

2022-01-14 Thread Bill Dunlap
> fraction <- 0/0 > if (fraction < .5) TRUE else FALSE Error in if (fraction < 0.5) TRUE else FALSE : missing value where TRUE/FALSE needed -Bill On Fri, Jan 14, 2022 at 12:55 PM Bert Gunter wrote: > Unlikely. > > > 1/0 > [1] Inf ## not NA > > Bert > > On Fri, Jan 14, 2022 at 12:41 PM Jim

Re: [R] NAs are removed

2022-01-14 Thread Duncan Murdoch
On 14/01/2022 3:54 p.m., Bert Gunter wrote: Unlikely. 1/0 [1] Inf ## not NA However: > if (0/0 <= 1) print("something") Error in if (0/0 <= 1) print("something") : missing value where TRUE/FALSE needed Duncan Murdoch Bert On Fri, Jan 14, 2022 at 12:41 PM Jim Lemon wrote: Hi

Re: [R] NAs are removed

2022-01-14 Thread Bert Gunter
Unlikely. > 1/0 [1] Inf ## not NA Bert On Fri, Jan 14, 2022 at 12:41 PM Jim Lemon wrote: > Hi Neha, > You're using the argument "na.omit" in what function? My blind guess > is that there's a divide by zero shooting you from behind. > > Jim > > On Sat, Jan 15, 2022 at 6:32 AM Neha gupta >

Re: [R] NAs are removed

2022-01-14 Thread Jim Lemon
Hi Neha, You're using the argument "na.omit" in what function? My blind guess is that there's a divide by zero shooting you from behind. Jim On Sat, Jan 15, 2022 at 6:32 AM Neha gupta wrote: > > Hi everyone > > I use na.omit to remove NAs but still it gives me error > > Error in if (fraction <=

[R] NAs are removed

2022-01-14 Thread Neha gupta
Hi everyone I use na.omit to remove NAs but still it gives me error Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed My data is: data.frame': 340 obs. of 15 variables: $ DepthTree: num 1 1 1 1 1 1 1 1 1 1 ... $ NumSubclass : num 0 0 0 0 0 0 0 0 0 0 ... $ McCabe

Re: [R] How to create density ellipses with R

2022-01-14 Thread John Fox
Dear Paul, On 2022-01-14 1:17 p.m., Paul Bernal wrote: Dear John and R community friends, To be a little bit more specific, what I need to accomplish is the creation of a confidence interval ellipse over a scatterplot at different percentiles. The confidence interval ellipses should be drawn

Re: [R] How to create density ellipses with R

2022-01-14 Thread Duncan Murdoch
On 14/01/2022 1:17 p.m., Paul Bernal wrote: Dear John and R community friends, To be a little bit more specific, what I need to accomplish is the creation of a confidence interval ellipse over a scatterplot at different percentiles. The confidence interval ellipses should be drawn over the

Re: [R] How to create density ellipses with R

2022-01-14 Thread Paul Bernal
Dear John and R community friends, To be a little bit more specific, what I need to accomplish is the creation of a confidence interval ellipse over a scatterplot at different percentiles. The confidence interval ellipses should be drawn over the scatterplot. Any other guidance will be greatly

Re: [R] How to create density ellipses with R

2022-01-14 Thread Martin Maechler
> Gerrit Eichner > on Fri, 14 Jan 2022 16:42:28 +0100 writes: > Hi Paul, take a look at base R's function contour (and the > Examples section of its help page), and follow maybe the > hints under "See also". > Hth -- Gerrit Also, with Recommended packages

Re: [R] How to create density ellipses with R

2022-01-14 Thread John Fox
Dear Paul, As I understand it, the ellipse package is meant for drawing confidence ellipses, not density (i.e., data) ellipses. You should be able to use ellipse::ellipse() to draw a bivariate-normal density ellipse (assuming that's what you want), but you'll have to do some computation

Re: [R] How to create density ellipses with R

2022-01-14 Thread Gerrit Eichner
Hi Paul, take a look at base R's function contour (and the Examples section of its help page), and follow maybe the hints under "See also". Hth -- Gerrit - Dr. Gerrit Eichner Mathematical Institute, Room

[R] How to create density ellipses with R

2022-01-14 Thread Paul Bernal
Dear R friends, Happy new year to you all. Not quite sure if this is the proper place to ask about this, so I apologize if it is not, and if it isn´t, maybe you can point me to the right place. I would like to know if there is any R package that allows me to produce density ellipses. Searching