i may be missing something really obvious here, could you help me?
when i send a date object to seLocalize() function, it returns me as expected for the code that follows (i sent 14-mar-18 and returned 13-mar-18)
seLocalize <- function(dataTeste) {
data <- as.POSIXlt(dataTeste)
if(data$wday != 0) {
data <- data-86400
}
print(data)
}
Although, for following the piece of code, the same test returns "Error: $ operator is invalid for atomic vectors"
seLocalize <- function(dataTeste) {
data <- as.POSIXlt(dataTeste)
while(data$wday != 0) {
data <- data-86400
}
print(data)
}
Why?
I'm having troubles believing this is a proper problem description since that date was in a format that would not be recognized.
So I tried sending what I thought was a possible revised function (for the somewhat obscure coercion induced error ) a proper date value for
as.POSIXlt: