Am stuck using the ff package. Here is a sample of data.
col1 col2
90
91 21-02-2012 00:00:00 27-02-2009 00:00:00
92 21-02-2012 00:00:00 17-02-2010 00:00:00
93 21-02-2012 00:00:00
94 21-02-2012 00:00:00
95 21-02-2012 00:00:00
What the plan was to convert these dates to numbers and then find the number of days between the dates. What I am stuck on is when I convert the dates to numbers naturally enough I get some NAs which is ok. What I would like to do is convert the NAs to the integer 0. Here is the code I tried:
tfd<-as.ffdf(tfd) #just to get a sample from my data frame
dats<-as.ff(as.numeric(as.Date(tfd[,1],"%d-%m-%Y")))
dats[is.na(dats)]<-0
I get the error:
Error in `[<-.ffdf`(`*tmp*`, is.na(dats), value = 0) :
value must be ffdf if only one index used
I have tried the na.count function but I had no luck. I checked the ffbase and ff pdfs and nothing. I had a good look through the web and nothing that would help with a ff vector.
If anyone has any suggestions that would be great.
Cheers,
Lorcan
Cheers for the help again, your all to kind. A colleague gave me a suggestion about using the ifelse function in R to fill the blanks before with an integer. I couldn’t fill the blanks with a default date, let’s say “2006-01-01” but using integers worked perfectly. Here is the code:
ffdf1 is the ff data frame that I was using. Instead of 0 I decided to use 16,000. ffdf[,3] is the column that contains the dates. This code will work for the dates I gave in the example in the original question. Hope this helps and sorry if the question confused people,
Cheers,
Lorcan