Skip to content

Lack of support for data.table? #10

@simon-lowe

Description

@simon-lowe

Hi,

I think I like this package, but it does seem to not support data.table.
The code below does identical things, except that once it uses data.table and once data.frame. The latter works while the former does not.

rm(list = ls())

N_pop <- 100
dat_frame <- data.frame(x = rnorm(N_pop, 10, 1))
mean(dat_frame$x)

func_frame <- function(N_pop, N_samp){
  tmp <- dat_frame[sample(seq(1:N_pop), N_samp),]
  return(list("mean" = mean(tmp)))
}

func_frame(N_pop, 10)

MC <- MonteCarlo(func = func_frame, nrep = 100, param_list = list("N_pop" = N_pop, "N_samp" = 10), ncpus = 4)


N_pop <- 100
dat_table <- data.table(x = rnorm(N_pop, 10, 1))
mean(dat_table$x)

func_table <- function(N_pop, N_samp){
  tmp <- dat_table[sample(seq(1:N_pop), N_samp),]
  return(list("mean" = mean(tmp$x)))
}

func_table(N_pop, 10)

MC <- MonteCarlo(func = func_table, nrep = 100, param_list = list("N_pop" = N_pop, "N_samp" = 10), ncpus = 4)

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