Dear David,
simply check str(KD6). My guess (because we don't have your dataset,
only a print of it) is that KD6 is not a matrix but a data.frame. The
problem seems to come from the column "E..coli" which contains commas
instead of periods (so text and not number). There might be other issues
of course.
HTH,
Ivan
On 24/09/2023 20:05, Parkhurst, David 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
3 86.2 10 1.73400 0.0700 0.1720 97.30
4 4.8 5,390 0.40400 0.0060 0.0280 8.50
5 0.3 2,490 0.45800 0.0050 0.0430 19.75
6 0.0 186 0.51200 0.0040 0.0470 12.00
7 11.1 9,835 1.25500 0.0660 0.1450 12.20
Why are these not numeric?
There are some NAs later in the matrix, but I get this same error if I ask for
cor(KD6[1:39,]) to leave out the lines with NAs. Are they a problem anyway?
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.