Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Cherry Road, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: Mark Sharp [mailto:msh...@txbiomed.org<mailto:msh...@txbiomed.org>] Sent: Monday, November 10, 2014 12:23 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org<mailto:r-hel

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread William Dunlap
ockville, MD 20857 > Tel: 240-276-1070 > Fax: 240-276-1260 > > > -Original Message- > From: Mark Sharp [mailto:msh...@txbiomed.org] > Sent: Monday, November 10, 2014 12:23 PM > To: Muhuri, Pradip (SAMHSA/CBHSQ) > Cc: r-help@r-project.org > Subject: Re: [R] range () d

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
ad, Room 2-1071 Rockville, MD 20857 Tel: 240-276-1070 Fax: 240-276-1260 -Original Message- From: Mark Sharp [mailto:msh...@txbiomed.org] Sent: Monday, November 10, 2014 12:23 PM To: Muhuri, Pradip (SAMHSA/CBHSQ) Cc: r-help@r-project.org Subject: Re: [R] range () does not remove NA's with

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Mark Sharp
Pradip, For some reason mutate is not setting the is.NA value for the new column. Note the output below using your data structures. > ## It looks at first as if the second element of both columns are NA. > data2$mrjdate[2] [1] NA > data2$oiddate[2] [1] NA > ## for convenience > mrj <- data2$mrjd

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
:30 AM To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org Subject: Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate) Try range(data2$oiddate[complete.cases(data2$oiddate) & is.finite(data2$oiddate)]) #[1] "2006-09-01" "2011-11-0

Re: [R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread arun
Try range(data2$oiddate[complete.cases(data2$oiddate) & is.finite(data2$oiddate)]) #[1] "2006-09-01" "2011-11-04" If you look at the `dput` output, it is `Inf` for oiddate dput(data2$oiddate) structure(c(14078, -Inf, 15260, 13796, 13392, 15252, 15282), class = "Date") A.K. On Monday, Nov

[R] range () does not remove NA's with complete.cases() for dates (dplyr/mutate)

2014-11-10 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello, The range() with complete.cases() removes NA's for the date variables that are read from a data frame. However, the issue is that the same function does not remove NA's for the other date variable that is created using the dplyr/mutate(). The console and the reproducible example are gi