DiskFrame/disk.frame

Dynamic mutate in a loop returns error

SMousavi90 opened this issue · 2 comments

The problem is that I have an array and I want to add a column to my diskframe(df) for every array item. I do it in this way:

params <- c("col1", "col2")
for (i in params){
      x <- df %>% mutate(!! i := 2)
    }

at the end only the "col2" is added. am I missing something?

actually I put the wrong code here. I tried to simplify it. I edit the code here:

params <- c("col1", "col2")
for (i in par_names) {
        df <- df %>% mutate(!! i := as.numeric(parameters[i,]$param_value))
      } 

param_value is a numeric column in parameters dataframe. after running this when I try to View(collect(df)) this error returns:

Error in View : disk.frame has detected a syntax error in

~

. If you believe your syntax is correct, raise an issue at https://github.com/xiaodaigh/disk.frame with a MWEdisk.frame has detected a syntax error in

chunk_fn(as.data.frame(.x), col2 = ~as.numeric(parameters[i, ]$param_value))

. If you believe your syntax is correct, raise an issue at https://github.com/xiaodaigh/disk.frame with a MWE

it's solved in this way:


for (i in par_names){
      value <- as.numeric(parameters[i,]$param_value)
      df <- df %>% mutate(!! i := value)
    }


now it does not return the error after collect.