[datatable-help] Replace a character in one data table column
jim holtman
jholtman at gmail.com
Thu Jul 31 15:52:05 CEST 2014
I assume that you could use the following statement to replace the
NA's with a specified date:
DT[is.na(date), date := '2002-06-30']
or
DT[is.na(date), date := as.Date('2002-06-30')] # if 'date' has the "Date" class
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Wed, Jul 30, 2014 at 7:37 AM, Frank S. <f_j_rod at hotmail.com> wrote:
> Thanks for your reply Jim,
>
> I've realized that in my data R recognizes the value "missing" as authentic
> NA. So, in conclusion, I really have:
>
>> DT
>
> id date
> 1: 1 1997-04-26
> 2: 1 NA
> 3: 4 1998-08-25
> 4: 4 NA
> 5: 4 1998-11-07
>
> And if I do:
>
> > sum(is.na(DT$date))
>
> The result is 2. So I've applied your suggestion and there are not changes
> in date variable. Can you help me?
More information about the datatable-help
mailing list