andrewcparnell / simmr

A stable isotope mixing model in R
https://andrewcparnell.github.io/simmr/
28 stars 8 forks source link

simmr_load error #38

Closed dmb554 closed 1 year ago

dmb554 commented 1 year ago

Hi all,

I keep getting the following error when attempting to load my mixture and source data into simmr:

Error in simmr_load(mixtures = mix, source_names = source_names, source_means = source_means, : Assertion on 'mixtures' failed: Must be of type 'matrix', not 'tbl_df/tbl/data.frame'.

Here is the entire code:

targets = read_excel("Practice.xlsx", sheet = 1) sources = read_excel("Practice.xlsx", sheet = 2) TEFs = read_excel("Practice.xlsx", sheet = 3) as.matrix(targets) as.matrix(sources) as.matrix(TEFs)

mix=targets[, 1:2] colnames(mix) = c('d13C','d15N') source_names = c("Menhaden", "Sand Lance", "Mackerel") source_means = sources[,2:3] source_sds = sources[,4:5] correction_means = TEFs[,2:3] group = as.factor(paste('StrandingState', targets$StrandingState))

simmr_in = simmr_load(mixtures=mix, source_names=source_names, source_means=source_means, source_sds=source_sds, correction_means=TEFs)

All packages and Rstudio are updated to the latest versions. Any help would be greatly appreciated!

emmagovan commented 1 year ago

Hi, I think all that has happened is R isn't saving targets etc as a matrix. Try running simmr_in = simmr_load(mixtures=as.matrix(mix), source_names=source_names, source_means=as.matrix(source_means), source_sds=as.matrix(source_sds), correction_means=as.matrix(TEFs)) This should ensure your data is in the right format.