gastonstat / AssotesteR

R package AssotesteR
13 stars 4 forks source link

CALPHA on one variant #4

Open denisemauldin opened 11 years ago

denisemauldin commented 11 years ago

Should CALPHA test be able to be run on one variant? If so, then the line in CALPHA g = apply(X[y == 1, ], 2, function(x) sum(x > 0, na.rm = TRUE))

is causing an error because X[y==1,] is not a matrix for X with one row.

Following seems to fix it: g = apply(as.matrix(X[y == 1, ]), 2, function(x) sum(x > 0, na.rm = TRUE))

This also happens again in my_calpha_method for line: g = apply(gen[casecon==1,], 2, function(x) sum(x>0, na.rm=TRUE))

Following seems to fix it: g = apply(as.matrix(gen[casecon==1,]), 2, function(x) sum(x>0, na.rm=TRUE))

Does this cause any problems with the statistic that I am unaware of?

gastonstat commented 11 years ago

Your fixes are correct (eg as.matrix(X[y == 1,] ) The main reason is that I force the user to give a matrix, which happens most of the time except when the user wants to run the test on one variant only (like in this example).