sambofra / bnstruct

R package for Bayesian Network Structure Learning
GNU General Public License v3.0
17 stars 11 forks source link

Error in as.matrix(data) + (1 - starts.from) non-numeric argument to binary operator #14

Closed aeclmic closed 4 years ago

aeclmic commented 4 years ago

Hello,

For my research I have mixed (discrete and continuous), incomplete data. There is 37 variables and 707 observations.
I am trying to use the bnstruct package, but as early as loading in my data I get the above error.

The problem seems to be in the following line of code: https://github.com/cran/bnstruct/blob/698c10013bf9ec7246a302b30544d3a03aac8fb6/R/BNDataset-methods.R#L97 trying to apply the binary operator + to a matrix. Is there something wrong with my data format, or what can be the issue here?

Furthermore, when I force my way around this issue by changing + to %+%, I get the error message the following error message:

"Dataset contains values out of bounds for variables xxx", where xxx is all my variables. See below link for corresponding code.

https://github.com/cran/bnstruct/blob/698c10013bf9ec7246a302b30544d3a03aac8fb6/R/BNDataset-methods.R#L159

What can I do to fix this? Thanks in advance.

albertofranzin commented 4 years ago

Hi,

without knowing the data and the command you use is difficult to say with certainty, but some possibilities are:

Your second error message seems to be related to the latter case (bnstruct expects values from 1 to k but it sees values outside that range); but you shouldn't have observed that in the first place anyway.

These are the only possible issues that I can think of. If none of them is your case, check the formatting of your input files (the reading isn't too robust at the moment). If you still have the same issue, then post here the commands you use, and, if possible, a snippet of the data and metadata.

albertofranzin commented 4 years ago

I'm closing this issue, feel free to reopen it if you still get the error.