Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Concentration Dependence #113

Open
robertwbuchkowski opened this issue Oct 3, 2017 · 1 comment
Open

Error in Concentration Dependence #113

robertwbuchkowski opened this issue Oct 3, 2017 · 1 comment

Comments

@robertwbuchkowski
Copy link

I am running a mixing model with a single isotope (15N) and concentration dependence. When I load the source data in using concentration dependence I get the error message:

Error in FUN(X[[i]], ...) :
'x' must be an array of at least two dimensions

That arises from the function lapply trying to calculate column means for a list with one dimensional components.

I edited the function by changing the lapply function from colMeans to mean and it appears to work well.

Does this make sense and is this a good fix?

Thanks,

Rob

CODE
if (conc_dep) {
CONC_names <- paste("Conc", mix$iso_names, sep = "")
if (sum(is.na(match(CONC_names, colnames(SOURCE)))) >
0) {
stop(paste("*** Error: Concentration dependence column names mislabeled.\n Should be 'Conc' + iso_names, e.g. 'Concd13C' if iso_names = 'd13C'.\n Please ensure Conc headings in source data file match iso_names\n in mix data file and try again. Alternatively, you may have set conc_dep=T\n by mistake.",
sep = ""))
}
CONC_iso_cols <- match(CONC_names, colnames(SOURCE))

if (length(CONC_iso_cols)>1){
conc <- do.call(rbind, lapply(split(SOURCE[, CONC_iso_cols], 
                                    list(SOURCE[, 1])), colMeans))
}else{
  
  conc <- do.call(rbind, lapply(split(SOURCE[, CONC_iso_cols], 
                                      list(SOURCE[, 1])), mean))
  colnames(conc) = "d15N"
}

}else conc <- NULL

@Heidi550
Copy link

I'm having the same issue as robertwbuchkowski and getting the error:

Error in FUN(X[[i]], ...) :
'x' must be an array of at least two dimensions

How do I access the code that robertwbuchkowski changed? Is there a filename with extension I could search for? Or is changing the code a challenging thing to do? If so, is there another workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants