Skip to content

Vector model parameters in models lead to extremely long file names (which can exceed Windows file name limit) #8

@GForb

Description

@GForb

I've run in to an issue when trying to simulate data from a model with many parameters, including parameters that can be vectors. The names for the model directories for which vector arguments are passed are very long, eventually exceeding Window's permitted file name length leading to an error.

Below is a reproducible example:

library(simulator)

make_data <- function(beta1, beta2, beta3, beta4) {
  new_model(name = "test",
            label = "test",
            params = list(beta1 = beta1, beta2 = beta2, beta3 = beta3, beta4 = beta4),
            simulate = function(nsim, beta1, beta2, beta3, beta4) {
              data <- vector(mode = "list", length = nsim)
              for(i in 1:nsim){
                x <- rnorm(1000)
                x_matrix <- matrix(x, nrow = 200, ncol = 5)
                y1 <- x_matrix %*% beta1
                y2 <- x_matrix %*% beta2
                y3 <- x_matrix %*% beta3
                y4 <- x_matrix %*% beta4
                data[[i]] <- cbind(x_matrix, y1, y2, y3, y4)
              }
              return(data)
            })
}

sim <- new_simulation(name = "long_names",
                      label = "file names get too long") %>%
  generate_model(make_data, seed = 123,
                 beta1 = list(c(1,1,1,1,1), c(2,2,2,2,2)),
                 beta2 = list(c(1,1,1,1,1), c(2,2,2,2,2)),
                 beta3 = list(c(1,1,1,1,1), c(2,2,2,2,2)),
                 beta4 = list(c(1,1,1,1,1), c(2,2,2,2,2)),
                 vary_along = c("beta1", "beta2", "beta3", "beta4")) %>% 
  simulate_from_model(nsim = 2) 
# I get error here as windows cannot create new directories due to file name length

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions