[R] How to fix this problem

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Sep 25 10:38:30 CEST 2023

On Sun, 24 Sep 2023 18:05:43 +0000
"Parkhurst, David" <parkhurs using indiana.edu> wrote:

> I have a matrix, KD6, and I_m trying to get a correlation matrix from
> it.  When I enter cor(KD6), I get the message _Error in cor(KD6) :
> 'x' must be numeric_.
> Here are some early lines from KD6:
>        Flow   E..coli        TN    SRP     TP    TSS
> 1      38.8    2,420    1.65300 0.0270 0.0630  66.80
> 2     133.0    2,420    1.39400 0.0670 0.1360   6.80

Use str(KD6) to find out the types of every column of the KD6 data
frame. There may be some non-numeric strings later in the document
preventing R from converting them to numeric automatically. A brute
force solution is as.numeric(), perhaps preceded by some string
manipulation, but it's better to find out why the strings were
considered non-numeric in the first place.

Best regards,

More information about the R-help mailing list