You are simply missing a bracket in basedf
:
basedf <- data.frame(Date = as.Date(character(),
sulfate = numeric(),
nitrate = numeric(),
ID = numeric()))
Then everything should work fine.
Alternatively, you could have the bracket at the end of as.Date as stated by flamenco, but your function will still compile either way. It depends on what the purpose of your function is.