r - Dataframe consisting of factors vs real numbers -


i using bnlearn package, , error comes when run test error in check.data(x) : variables must either real numbers or factors.. dataframe, emg, contains 2 types of numeric values:

1) ~30000 columns of values, many of them being decimals (i believe these interpreted real numbers).

2) ~450000 columns of values either 0, 1, or 2. (i believe these interpreted factors).

how can r believe values in class 2) real numbers, not factors. also, might approaching error wrong way.

the data consists of 129 rows. example of data below.

9.758314     8.290852     0.03077250   0.353504     2        1 9.640181     8.581444     0.02144100   0.381118     0        0 8.898238     8.441256     0.01640670   0.574626     0        0 9.784328     8.406762     0.01525690   0.553795     1        1 11.017669    9.101037     0.01828330   0.489020     1        1 9.400396     8.073811     0.01897480   0.513596     0        0 

in example, believe first 4 columns interpreted real numbers, while last 2 interpreted factors.

when typed function using (gs, part of bnlearn package) r, back:

function (x, cluster = null, whitelist = null, blacklist = null,      test = null, alpha = 0.05, b = null, debug = false, optimized = true,      strict = false, undirected = false)  {     bnlearn(x = x, cluster = cluster, whitelist = whitelist,          blacklist = blacklist, test = test, alpha = alpha, b = b,          debug = debug, optimized = optimized, strict = strict,          undirected = undirected) } <environment: namespace:bnlearn> 

thanks!

you can :

  matrix(as.numeric(as.matrix(emg)),ncol=ncol(emg),byrow=true) 

as.matrix return character matrix, as.numeric numeric vector, , matrix restore original structure.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -