. Advertisement .
..3..
. Advertisement .
..4..
As advised, I used some code samples in another forum but it could not improve the problem. My question is the “ error in plot.window(…) : need finite ‘xlim’ values ” in r- how to solve it? Command line is:
#define data
x <- c('A', 'B', 'C', 'D', 'E', 'F')
y <- c(3, 6, 7, 8, 14, 19)
#attempt to create scatterplot
plot(x, y)
and the result:
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
What does the message mean? Can you advise me to fix it? If you have other better answers, leave it in the answer box below.
The cause: This error occurs because the vector we used for the x-axis values is a character vector.
Solution: Supplying a numeric vector to the x-axis:
Problem is, you are (probably) trying plot a vector consisting only of missing (
NA
), values. Here’s an example.This means that
plot(costs,pseudor2,type="l")
iscosts
andNA
isplot(costs,pseudor2,type="l")
. This is the reason for your error.Comments:
Scott C Wilson Attempting to use character values in X and Y data is another possible reason for this message. If you suspect this is the problem, you can use class function to verify your x- and y values.
Stevec