Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Date column returning number if NA is precent

I am trying to incorporate date in a column. But it is returning number since NA is present. Can anyone help me?

asdd <- data.frame(a = c(NA,as.Date(today(),"%m/%d/%Y")), b = c(2,3))
asdd
      a b
1    NA 2
2 19220 3

i want get as Date in the column?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Place the as.Date before c and not inside c.

data.frame(a = as.Date(c(NA, "1970-01-01")), b = c(2,3))
#           a b
#1       <NA> 2
#2 1970-01-01 3
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading