SteffenMoritz/ridge

Error in numeric(nPCs) : invalid 'length' argument

Closed this issue · 4 comments

Here in https://github.com/cran/ridge/blob/master/R/linearRidge.R#L96,

nPCs <- which.max(propVar[propVar < 90]) + 1

what if all the elements in propVar are greater than 90? It will throw an error, which is the title of this issue.

THX for your bug report. I tried to fix it.
Would you mind making a install from Github to see if the error disappeared?

A similar error:

Error in if (which.max(propVar[propVar < 90]) > 0) { :
  argument is of length zero

Hi, I do not mind share my data and code:

mydata = read.csv('https://gist.githubusercontent.com/badbye/c4be83a28f4f6f10e2e067189f67d834/raw/a42b4bc7e4b3c570267902cd9e140a33343bfe8e/test%2520the%2520%2560ridge%2560%2520package')
m = linearRidge(y ~ ., data = mydata)

You can use it to test your code. I know this dataset do not need to use ridge regression. It is still better to make this package more robust. Hope you agree with me.

Took me some time (cause I had multiple other things to do...).
But I think I fixed the issue.

Thanks again badbye for reporting the bug !! :-)