r - na.locf() for an FFDF -
i have large data set have use ffdf, , stuck trying fill na values using last observation carried forward operation. below sample of data looks i'm trying operation on:
require("zoo") require("ff") id <- c(1:21) start <- c(11288475000, na, na, na, na, na, na,            11299487500, na, na, na, na, na, na,            12398646000, na, na, na, na, na, na)) frame <- data.frame(id, start) frame.ffdf <- as.ffdf(frame) with regular data frame easy operation using zoo package:
frame$start <- na.locf(frame$start) however same not work on ffdf:
>frame.ffdf$start <- na.locf(frame.ffdf$start) error in which(l) : argument 'which' not logical i tried using within() solves problems have when using ffdf, threw error:
>frame.ffdf$start <- within(frame.ffdf,                             na.locf(start)) error in `[[<-.ffdf`(`*tmp*`, i, value = list(virtual = list(virtualvmode = c("integer",  :    assigned value must ff so tried following, threw following error:
>frame.ffdf$start <- ff(within(frame.ffdf,                         na.locf(start))) error in ff(within(frame.ffdf, na.locf(start))) :    initdata[1] must atomic i found this question replacing na values set value, haven't been able find 1 using na.locf() type function. know can accomplish for loop, take entirely long due size of data sets.
i don't know ffdf, seems $ doesn't work same way in data.frame, column operators do:
library(ff)#you should include in example, had google library library(zoo) na.locf(frame$start)#this works na.locf(frame.ffdf$start)#this doesn't na.locf(frame.ffdf[,2])#this (why?) na.locf(frame.ffdf[,'start'])#this (why?) frame.ffdf[,2] = na.locf(frame.ffdf[,2])#whatever, take can so yeah, i'm not sure why works, if use column operators instead of $ operators should fine.
Comments
Post a Comment