[R] Validating data type

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri Aug 30 07:42:56 CEST 2013


The answer to your question is yes. You can convert a column of values to Date using the as.Date function with the appropriate format, and then test if any values are NA using the is.na function, and find them with the which function.

If you want something less vague then you should read the Posting Guide mentioned at the bottom of this message and follow the advice about using plain text and providing a sample of data that exhibits the issue and your attempts to solve the problem (code). Sample data is almost always needed... if you don't make it, then we have do so in order to illustrate the solution, but we would be guessing and that is just a waste of time. You may find the following link helpful also: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

jeffjohn at WorldVision.org wrote:
>
>
>I'm very new to R. I have a data file that I have read in via read.csv.
>I
>expect one of the "columns" to be of type date for example. However at
>least one value in that column is not of date type. I know this because
>another program I am trying to process the file with is erroring, yet
>it
>doesn't tell me what row/value is erroring. Does R have a way to: treat
>column x as date type, and print out all values/row numbers do not
>conform
>to that type for that specified column?
>
>Many thanks!
>Jeff
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>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.



More information about the R-help mailing list