Hola,

Esta es una forma...

> library(lubridate)
> library(dplyr)
>
> fechas <- c("2016-07-15", "2016-10-12", "2017-02-11")
> fechas_new <- ymd(fechas)
>
> res_out <- ifelse(year(fechas_new) > 2016, NA, fechas_new)
> res_out
[1] 16997 17086    NA
> class(res_out) <- class(fechas_new)
> res_out
[1] "2016-07-15" "2016-10-12" NA


No lo había visto hasta ahora, es un caso que se cuenta en la ayuda de
"ifelse()" con un ejemplo...

Saludos,
Carlos Ortega
www.qualityexcellence.es


2018-02-13 0:54 GMT+01:00 patricio fuenmayor <patricio.fuenma...@gmail.com>:

> hola Patricio, usa:
> dplyr::if_else
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

        [[alternative HTML version deleted]]

_______________________________________________
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Reply via email to