I have a blank encounter history dataframe with all zeros. I want to fill it with the value '1' where there is an encounter in a specific year.
My data file (datafile) looks somewhat like this:
Date Name
2007-04-28 a
2007-05-19 a
2007-05-21 b
2008-04-28 a
2009-05-06 c
And the 'empty' data-frame (encounter) that has to be recoded
Name 2007 2008 2009 2010
a 0 0 0 0
b 0 0 0 0
c 0 0 0 0
d 0 0 0 0
e 0 0 0 0
I tried using an if statement:
datafile$Date%>%if(datafile$Date==between(01-01-07&31-12-07)) {encounter$2007=="1"}
But got an error
Error in between(1 - 1 - 7 & 31 - 12 - 7) :
between has been x of type logical
In addition: Warning message:
In if (.) datafile$Date == between(1 - 1 - 7 & 31 - 12 - 7) else { :
the condition has length > 1 and only the first element will be used