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, 2022 5:11 pm
Subject: Re: [R] NAs are removed

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)

Is the problem exist here?


On Fri, Jan 14, 2022 at 11:02 PM Ebert,Timothy Aaron  wrote:

> 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 "fraction" is in
> your program.
>
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Neha gupta
> Sent: Friday, January 14, 2022 4:50 PM
> To: Jim Lemon 
> Cc: r-help mailing list 
> Subject: Re: [R] NAs are removed
>
> [External Email]
>
> 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 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 <= 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      : num  1 1 1 1 1 1 3 3 3 3 ...
> > >  $ LOC          : num  3 4 3 3 4 4 10 10 10 10 ...
> > >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> > >  $ CA          : num  1 1 1 1 1 1 1 1 1 1 ...
> > >  $ CE          : num  2 2 2 2 2 2 2 2 2 2 ...
> > >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667
> > > 0.667
> > > 0.667 0.667 ...
> > >  $ numCovered  : num  0 0 0 0 0 0 0 0 0 0 ...
> > >  $ operator    : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> > 1 3
> > > 4 7 ...
> > >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2
> > > 2 2
> > 2
> > > 2 2 2 2 ...
> > >
> > >        [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_ma
> > > ilman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2k
> > > VeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06S
> > > kfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
> > > PLEASE do read the posting guide
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> > g_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeA
> > sRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKt
> > GPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
> > > and provide commented, minimal, self-contained, reproducible code.
> >
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
> and provide commented, minimal, self-contained, reproducible code.
>

    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide 

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 0 1 0 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 1 1 1 0 1 0 
1 0 0
> as.numeric(tmp != 2)
 [1] 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 0 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0 1 1 1 0 1 0 
1 0 0
>??micro
> microbenchmark::microbenchmark(ifelse=ifelse(tmp==2, 0, 1), 
> notequal=as.numeric(tmp !=2))
Unit: nanoseconds
 expr  min   lqmean median   uq   max neval cld
   ifelse 2952 3239 3542.81 3382.5 3567 12464   100   b
 notequal  205  287  348.09  328.0  369  1599   100  a 


> 
> From: Neha gupta 
> Sent: Friday, January 14, 2022 5:11 PM
> To: Ebert,Timothy Aaron 
> Cc: Jim Lemon ; r-help mailing list 
> 
> Subject: Re: [R] NAs are removed
> 
> [External Email]
> 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)
> 
> Is the problem exist here?
> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, 2, 2, 2, 2, 2)
prot <- ifelse(CA == '2', 0, 1)
print(prot)

R responds:
[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
[37] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[73] 0 0 0 0 0 0

You can check other statements in the same way. That said, in a huge dataset 
you might want to ask if the data provided match what you are assuming is 
there. If you type unique(ts$CA) do you get anything other than 1 and 2? This 
is a common task of figuring out if the problem is with the code or the data.

Tim
From: Neha gupta 
Sent: Friday, January 14, 2022 5:11 PM
To: Ebert,Timothy Aaron 
Cc: Jim Lemon ; r-help mailing list 
Subject: Re: [R] NAs are removed

[External Email]
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)

Is the problem exist here?

On Fri, Jan 14, 2022 at 11:02 PM Ebert,Timothy Aaron 
mailto:teb...@ufl.edu>> wrote:
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 "fraction" is in your program.

Tim

-Original Message-
From: R-help 
mailto:r-help-boun...@r-project.org>> On Behalf 
Of Neha gupta
Sent: Friday, January 14, 2022 4:50 PM
To: Jim Lemon mailto:drjimle...@gmail.com>>
Cc: r-help mailing list mailto:r-help@r-project.org>>
Subject: Re: [R] NAs are removed

[External Email]

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 
mailto:drjimle...@gmail.com>> 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 
> mailto:neha.bologn...@gmail.com>>
> wrote:
> >
> > 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   : num  1 1 1 1 1 1 3 3 3 3 ...
> >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
> >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
> >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
> >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667
> > 0.667
> > 0.667 0.667 ...
> >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
> >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> 1 3
> > 4 7 ...
> >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2
> > 2 2
> 2
> > 2 2 2 2 ...
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To 
> > UNSUBSCRIBE and more, see
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_ma
> > ilman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2k
> > VeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06S
> > kfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
> > PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> g_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeA
> sRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKt
> GPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To 
UNSUBSCRIBE and more, see 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
PLEASE do read the posting guide 

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 previous "A"-event, even if there are 
other non-A events in between.



The code is similar, but we cannot use seq(0, x-1) anymore. Instead, we 
will repeat the time point of the previous A-event. (Last-A Carried forward)



# jrdf = the data frame from my previous mail;
cumEvent = cumsum(jrdf$Event_A);
# we cannot use the actual values of the cumsum,
# but will use the number of (same) values to the previous event;
freqEvent = rle(cumEvent);
freqEvent = freqEvent$lengths;

# repeat the time-points
timesA = jrdf$Time[jrdf$Event_A == 1];
sameTime = rep(timesA, freqEvent);
timeToA = jrdf$Time - sameTime;

### Step 2:
# extract/view the times (as before);
timeToA[jrdf$Event_B >= 1];
# Every Time to A: e.g. for multiple extractions;
cbind(jrdf, timeToA);
# Time to A only for B: set non-B to 0;


# Note:
- the rle() function might be less known;
- it is "equivalent" to:
tbl = table(cumEvent);
# to be on the safe side (as the cumsum is increasing):
id = order(as.numeric(names(tbl)));
tbl = tbl[id];


Hope this helps,


Leonard


On 1/14/2022 3:30 AM, Leonard Mada wrote:

Dear Jeff,


My answer is a little bit late, but I hope it helps.


jrdf = read.table(text="Time   Event_A    Event_B   Lag_B
1  1 1    0
2  0 1    1
3  0 0    0
4  1 0    0
5  0 1    1
6  0 0    0
7  0 1    3
8  1 1    0
9  0 0    0
10 0 1    2",
header=TRUE, stringsAsFactors=FALSE)

Assuming that:
- Time, Event_A, Event_B are given;
- Lag_B needs to be computed;

Step 1:
- compute time to previous Event A;

tmp = jrdf[, c(1,2)];
# add an extra event so last rows are not lost:
tmp = rbind(tmp, c(nrow(tmp) + 1, 1));

timeBetweenA = diff(tmp$Time[tmp$Event_A > 0]);
timeToA = unlist(sapply(timeBetweenA, function(x) seq(0, x-1)))


### Step 2:
# - extract the times;
timeToA[jrdf$Event_B >= 1];
cbind(jrdf, timeToA);


Sincerely,


Leonard




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)

Is the problem exist here?


On Fri, Jan 14, 2022 at 11:02 PM Ebert,Timothy Aaron  wrote:

> 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 "fraction" is in
> your program.
>
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Neha gupta
> Sent: Friday, January 14, 2022 4:50 PM
> To: Jim Lemon 
> Cc: r-help mailing list 
> Subject: Re: [R] NAs are removed
>
> [External Email]
>
> 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 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 <= 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   : num  1 1 1 1 1 1 3 3 3 3 ...
> > >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
> > >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> > >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
> > >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
> > >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667
> > > 0.667
> > > 0.667 0.667 ...
> > >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
> > >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> > 1 3
> > > 4 7 ...
> > >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2
> > > 2 2
> > 2
> > > 2 2 2 2 ...
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_ma
> > > ilman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2k
> > > VeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06S
> > > kfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
> > > PLEASE do read the posting guide
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> > g_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeA
> > sRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKt
> > GPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
> > > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 "fraction" is in your program.

Tim

-Original Message-
From: R-help  On Behalf Of Neha gupta
Sent: Friday, January 14, 2022 4:50 PM
To: Jim Lemon 
Cc: r-help mailing list 
Subject: Re: [R] NAs are removed

[External Email]

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 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 <= 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   : num  1 1 1 1 1 1 3 3 3 3 ...
> >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
> >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
> >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
> >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 
> > 0.667
> > 0.667 0.667 ...
> >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
> >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> 1 3
> > 4 7 ...
> >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 
> > 2 2
> 2
> > 2 2 2 2 ...
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_ma
> > ilman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2k
> > VeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06S
> > kfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
> > PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> g_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeA
> sRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKt
> GPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=LqAgI3qNLyTF5KeFM9sT9jTT4rkvlcJa1V9CIW_SVy4=
PLEASE do read the posting guide 
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=WsafNBaOwXzuF-v3jJZaUbBRngZTxjDnPCJN1jlMOzYqG9yy06SkfQKtGPM2OWM5=hUs_mg3eaWhd-I4H-9rKF6C4B7CFwLsuBkx3Qv68_o0=
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 :
>   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 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 
>> > wrote:
>> > >
>> > > 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   : num  1 1 1 1 1 1 3 3 3 3 ...
>> > >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
>> > >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
>> > >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
>> > >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
>> > >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
>> > > 0.667 0.667 ...
>> > >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
>> > >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13
>> 13
>> > 1 3
>> > > 4 7 ...
>> > >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2
>> 2 2
>> > 2
>> > > 2 2 2 2 ...
>> > >
>> > > [[alternative HTML version deleted]]
>> > >
>> > > __
>> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > > https://stat.ethz.ch/mailman/listinfo/r-help
>> > > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > > and provide commented, minimal, self-contained, reproducible code.
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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 <= 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   : num  1 1 1 1 1 1 3 3 3 3 ...
> >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
> >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
> >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
> >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
> > 0.667 0.667 ...
> >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
> >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> 1 3
> > 4 7 ...
> >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2 2
> 2
> > 2 2 2 2 ...
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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 
> > wrote:
> > >
> > > 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   : num  1 1 1 1 1 1 3 3 3 3 ...
> > >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
> > >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> > >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
> > >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
> > >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
> > > 0.667 0.667 ...
> > >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
> > >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> > 1 3
> > > 4 7 ...
> > >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2
> 2
> > 2
> > > 2 2 2 2 ...
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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 <= 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   : num  1 1 1 1 1 1 3 3 3 3 ...
  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
0.667 0.667 ...
  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13

1 3

4 7 ...
  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2 2

2

2 2 2 2 ...

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 
> wrote:
> >
> > 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   : num  1 1 1 1 1 1 3 3 3 3 ...
> >  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
> >  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
> >  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
> >  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
> >  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
> > 0.667 0.667 ...
> >  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
> >  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13
> 1 3
> > 4 7 ...
> >  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2 2
> 2
> > 2 2 2 2 ...
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 <= 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   : num  1 1 1 1 1 1 3 3 3 3 ...
>  $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
>  $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
>  $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
>  $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
>  $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
> 0.667 0.667 ...
>  $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
>  $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13 1 3
> 4 7 ...
>  $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2 2 2
> 2 2 2 2 ...
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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   : num  1 1 1 1 1 1 3 3 3 3 ...
 $ LOC  : num  3 4 3 3 4 4 10 10 10 10 ...
 $ DepthNested  : num  1 1 1 1 1 1 2 2 2 2 ...
 $ CA   : num  1 1 1 1 1 1 1 1 1 1 ...
 $ CE   : num  2 2 2 2 2 2 2 2 2 2 ...
 $ Instability  : num  0.667 0.667 0.667 0.667 0.667 0.667 0.667 0.667
0.667 0.667 ...
 $ numCovered   : num  0 0 0 0 0 0 0 0 0 0 ...
 $ operator : Factor w/ 16 levels "T0","T1","T2",..: 2 2 4 13 13 13 1 3
4 7 ...
 $ methodReturn : Factor w/ 22 levels "I","V","Z","method",..: 2 2 2 2 2 2
2 2 2 2 ...

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 
over the scatterplot.


I'm not sure what you mean. Confidence ellipses are for regression 
coefficients and so are on the scale of the coefficients; data 
(concentration) ellipses are for and on the scale of the explanatory 
variables. As it turns out, for a linear model, the former is the 
rescaled 90 degree rotation of the latter.


Because the scatterplot of the (two) variables has the variables on the 
axes, a data ellipse but not a confidence ellipse makes sense (i.e., is 
in the proper units). Data ellipses are drawn by car::dataEllipse() and 
(as explained by Martin Maechler) cluster::ellipsoidPoints(); confidence 
ellipses are drawn by car::confidenceEllipse() and the various methods 
of ellipse::ellipse().


I hope this helps,
 John



Any other guidance will be greatly appreciated.

Cheers,

Paul

El vie, 14 ene 2022 a las 11:27, John Fox (>) escribió:


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 first.

You might find the dataEllipse() function in the car package more
convenient (again assuming that you want bivariate-normal density
contours).

I hope this helps,
   John

-- 
John Fox, Professor Emeritus

McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/


On 2022-01-14 10:12 a.m., Paul Bernal wrote:
 > 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 through the net, I came across a
package called
 > ellipse, but I'm not sure if this is the one I should use.
 >
 > Any help and/or guidance will be greatly appreciated.
 >
 > Best regards,
 >
 > Paul
 >
 >       [[alternative HTML version deleted]]
 >
 > __
 > R-help@r-project.org  mailing list
-- To UNSUBSCRIBE and more, see
 > https://stat.ethz.ch/mailman/listinfo/r-help

 > PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html

 > and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
scatterplot.

Any other guidance will be greatly appreciated.


That's exactly what the ellipses package was designed to do.  If you 
don't see how to use it, post an example of the scatterplot and model 
fitting you used, and someone will be able to show you how to draw the 
ellipses.


Duncan Murdoch



Cheers,

Paul

El vie, 14 ene 2022 a las 11:27, John Fox () escribió:


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 first.

You might find the dataEllipse() function in the car package more
convenient (again assuming that you want bivariate-normal density
contours).

I hope this helps,
   John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

On 2022-01-14 10:12 a.m., Paul Bernal wrote:

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 through the net, I came across a package

called

ellipse, but I'm not sure if this is the one I should use.

Any help and/or guidance will be greatly appreciated.

Best regards,

Paul

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.





[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 appreciated.

Cheers,

Paul

El vie, 14 ene 2022 a las 11:27, John Fox () escribió:

> 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 first.
>
> You might find the dataEllipse() function in the car package more
> convenient (again assuming that you want bivariate-normal density
> contours).
>
> I hope this helps,
>   John
>
> --
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> web: https://socialsciences.mcmaster.ca/jfox/
>
> On 2022-01-14 10:12 a.m., Paul Bernal wrote:
> > 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 through the net, I came across a package
> called
> > ellipse, but I'm not sure if this is the one I should use.
> >
> > Any help and/or guidance will be greatly appreciated.
> >
> > Best regards,
> >
> > Paul
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 'cluster' and its
ellipsoidPoints() function:

The result of

 library(cluster)
 example(ellipsoidPoints)

is the attached plot with a classical and
robust (via recommend pkg 'MASS') covariance ellipse drawn.

Best,
Martin

--
Martin Maechler
ETH Zurich; R Core, and maintainer of 'cluster'

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 first.


You might find the dataEllipse() function in the car package more 
convenient (again assuming that you want bivariate-normal density contours).


I hope this helps,
 John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

On 2022-01-14 10:12 a.m., Paul Bernal wrote:

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 through the net, I came across a package called
ellipse, but I'm not sure if this is the one I should use.

Any help and/or guidance will be greatly appreciated.

Best regards,

Paul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 212
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
http://www.uni-giessen.de/eichner
-

Am 14.01.2022 um 16:12 schrieb 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 through the net, I came across a package called
ellipse, but I'm not sure if this is the one I should use.

Any help and/or guidance will be greatly appreciated.

Best regards,

Paul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 through the net, I came across a package called
ellipse, but I'm not sure if this is the one I should use.

Any help and/or guidance will be greatly appreciated.

Best regards,

Paul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.