This is because reprex() runs your code on a clean R session where the environment is empty so you have to define everything within the code itself, and since you haven't assigned the sample data to any object name, it doesn't exist on that environment.
About your issue, the problem is that your Date column is not an actual "date" variable it has been read as a factor variable so you need to convert it before been able to make comparisons on that way, see this example.
example <- data.frame(
PATIENT_ID = c(-2147483646,-2147483646,-2147483646,
-2147483646,-2147483646,-2147483646,-2147483646,-2147483646,
-2147483646,-2147483646,-2147483645),
FEV1 = c(4.046,4.053,4.024,4.094,4.005,3.869,
4.089,3.879,3.859,3.974,1.577),
FVC = c(5.286,5.043,5.25,5.235,5.265,5.036,
5.154,4.998,5.092,5.198,4.769),
FEF = c(199.3,226.9,196.8,223.4,199.6,212.7,
219.8,205.1,182.9,199.2,59.2),
DATE = as.factor(c("20.08.2018 08:37:23 +02:00","20.08.2018 08:36:55 +02:00",
"20.08.2018 08:36:29 +02:00","15.08.2018 21:38:40 +02:00",
"15.08.2018 21:38:11 +02:00","15.08.2018 21:37:20 +02:00",
"07.08.2018 10:24:26 +02:00",
"07.08.2018 10:23:01 +02:00","07.08.2018 10:22:36 +02:00",
"06.08.2018 13:30:53 +02:00","22.03.2019 19:17:50 +01:00")),
LOCATION = as.factor(c("HOME","HOME","HOME",
"HOME","HOME","HOME","HOME","HOME","HOME",
"HOME","HOME")),
VISIT_DAY = as.factor(c("NO","NO","NO","NO",
"NO","NO","NO","NO","NO","NO","NO"))
)
library(dplyr)
library(lubridate)
example %>%
mutate(DATE = as.Date(dmy_hms(DATE) + hours(2)),
VISIT_DAY = ifelse((PATIENT_ID == "-2147483646" & DATE == dmy("06.08.2018")), "YES", "NO"))
#> PATIENT_ID FEV1 FVC FEF DATE LOCATION VISIT_DAY
#> 1 -2147483646 4.046 5.286 199.3 2018-08-20 HOME NO
#> 2 -2147483646 4.053 5.043 226.9 2018-08-20 HOME NO
#> 3 -2147483646 4.024 5.250 196.8 2018-08-20 HOME NO
#> 4 -2147483646 4.094 5.235 223.4 2018-08-15 HOME NO
#> 5 -2147483646 4.005 5.265 199.6 2018-08-15 HOME NO
#> 6 -2147483646 3.869 5.036 212.7 2018-08-15 HOME NO
#> 7 -2147483646 4.089 5.154 219.8 2018-08-07 HOME NO
#> 8 -2147483646 3.879 4.998 205.1 2018-08-07 HOME NO
#> 9 -2147483646 3.859 5.092 182.9 2018-08-07 HOME NO
#> 10 -2147483646 3.974 5.198 199.2 2018-08-06 HOME YES
#> 11 -2147483645 1.577 4.769 59.2 2019-03-22 HOME NO