My code worked last month, so who knows what happened this, but the guy who wrote it is gone, so there that.
I've got a decent sized data frame, and trying to replace all the NA's with 0. I'm using this:
sprink_df[is.na(sprink_df)] <-0
I keep getting the as.POSIXct.numeric(value) : 'origin' must be supplied
error, which I don't fully understand but I've figured out from browsing other answers is that it's related to how it deals with dates. However I'm a little unsure how to fix it.
I have one date column in this data frame, that shouldn't have NAs in it anyway, whose most recent modification before this line is
date <- as.Date(format(neutdf$CreatedTime)
The format is POSIXct and is %Y-%m-%d %H:%M:%OS
I've tried other ways to replace all my NAs only to get numerous errs (based on 1, 2)
It looks like someone had success by manually setting the origin, but when I tried it didn't help. Of course, I could be doing it wrong. My R experience is just playing around with others' code. shrug
I used as.POSIXct(sprink_df$CreatedTime,tz="",origin="1970-01-01")
based on this and also tried
as.date <- function(sprink_df, origin = getOption("date.origin"))
{origin <- ifelse(is.null(origin), "1970-01-01", origin)
as.Date(sprink_df$CreatedTime, origin)}
based on this using the second option.
While I'm not against installing new packages, I'd rather work within what I have for this script - dplyr, rlang, digest, dint.
DATA EXAMPLE
I have 66 variables, of which run the gambmit from chr, num, logi, but the dput() of the column in question is 1548537133.685,1548537156.167, 1548537188.106, 1548537214.205
.
Which is a little different from the str() output for reasons I don't understand. POSIXct[1:61608], format: "2019-01-23 15:20:13" "2019-01-24 19:29:12"