NAs introduced by coercion

From the ggm docs, it looks like the pcor() function, pcor(u, S) takes arguments:

  • u: a vector of integers of length > 1. The first two integers are the indices of variables the correlation of which must be computed. The rest of the vector is the conditioning set.
  • S: a symmetric positive definite matrix, a sample covariance matrix.

Not knowing what your data looks like, it's hard to say, but NAs by coersion occur when, for example, you try to convert a character to numeric.

as.numeric("a")
#> Warning: NAs introduced by coercion
#> [1] NA

Given that the arguments for pcor() are numeric, you might be passing character strings where the function requires numeric.

It will help us help you if you can put your issue in the form of a self-contained reprex (short for reproducible example)

install.reprex("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ, linked to below.

1 Like