[R] NAs introduced by coercion

Jim Lemon drjimlemon at gmail.com
Fri Jan 8 12:20:57 CET 2016


Hi Manish,
Most likely there are one or more negative numbers in mat1.

Jim


On Fri, Jan 8, 2016 at 7:35 PM, Manish MAHESHWARI <manishm at dbs.com> wrote:

> Hi,
>
> In glmnet, while using a matrix as an input, I get an error of NA's
> introduced by coercion. However in the input there is no NA value.
>
> cvfit = cv.glmnet( x = mat1, y = train$response,family="multinomial",
> type.multinomial = "grouped", parallel = TRUE)
> Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  :
>   NA/NaN/Inf in foreign function call (arg 5)
> In addition: Warning message:
> In lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  :
>   NAs introduced by coercion
>
> > anyisna = function(x) {any(is.na(x))}
>
> > nas = apply(mat1, MARGIN = 2, FUN = anyisna)
>
>
>
> > nas[nas==T]
>
> named logical(0)
>
>
>
> > any(is.na(train$response))
>
> [1] FALSE
>
>
> Can you pls throw some light on where is the NA found.
>
> Thanks,
> Manish
>
> CONFIDENTIAL NOTE:
> The information contained in this email is intended on...{{dropped:13}}



More information about the R-help mailing list