Reputation: 345
when I perform
files <- c("2-16-(-02)_2012","2-16-(-02)_2013","2-16-(+02)_2012","2-16-(+02)_2013")
id <- unique(substr(files,1,10))
year <- unique(substr(files,12,15))
y <- year[1]
i <- id[1]
f1 <- grep(i,files,value = TRUE,perl = TRUE)
f2 <- grep(y,files,value = TRUE,perl = TRUE)
f1 is an empty character, while f2 contains two elements. I need also f1 to contain the two files with the ID.
Upvotes: 0
Views: 37
Reputation: 1278
i
has unescaped parentheses in it. Either escape then manually, or change from perl = TRUE
to fixed = TRUE
.
Upvotes: 3