rffffbase

Assign value to variable in ff


I am working with a ff dataset (final_faf_data) because of the size of my database. I am trying to create a new variable dpy which has only only one value (365) for all rows. When I try the following cmd (similar to what I would do in a dataframe)

final_faf_data$dpy <- 365

I get the following error

Error in `[[<-.ffdf`(`*tmp*`, i, value = 365) : assigned value must be ff

So my question is how do I assign it? I tried

vmode(final_faf_data$dpy, 365)

But it gives "NULL"

Any insights would be much appreciated.

TIA, Krishnan


Solution

  • Some sample data to reproduce your issue

    L3 <- LETTERS[1:3] fac <- sample(L3, 10, replace = TRUE) df1 <- data.frame(x = 1, y = 1:10, fac = fac) final_faf_data <- as.ffdf(df1)

    Error messages given by the lines below are clear:

    final_faf_data$dpy <- 365
    final_faf_data$dpy <- as.ff(365)
    

    Therefore, modify 365 accordingly:

    final_faf_data$dpy <- as.ff(rep(365, times=nrow(final_faf_data)))`