Error in plot.window(…) : need finite 'xlim' values

前端 未结 4 1352
余生分开走
余生分开走 2020-12-03 20:55

What should i do for this error? My code is :

library(e1071)
library(hydroGOF)
donnees <- read.csv("F:/new work with shahab/Code-SVR/SVR/MainData.csv&         


        
相关标签:
4条回答
  • 2020-12-03 21:13

    The problem is that you're (probably) trying to plot a vector that consists exclusively of missing (NA) values. Here's an example:

    > x=rep(NA,100)
    > y=rnorm(100)
    > plot(x,y)
    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
    

    In your example this means that in your line plot(costs,pseudor2,type="l"), costs is completely NA. You have to figure out why this is, but that's the explanation of your error.


    From comments:

    Scott C Wilson: Another possible cause of this message (not in this case, but in others) is attempting to use character values as X or Y data. You can use the class function to check your x and Y values to be sure if you think this might be your issue.

    stevec: Here is a quick and easy solution to that problem (basically wrap x in as.factor(x))

    0 讨论(0)
  • 2020-12-03 21:23

    This error appears when the column contains character, if you check the data type it would be of type 'chr' converting the column to 'Factor' would solve this issue.

    For e.g. In case you plot 'City' against 'Sales', you have to convert column 'City' to type 'Factor'

    0 讨论(0)
  • 2020-12-03 21:34

    I had the same problem. I solve it when I convert string to factor. In your case, check the class of variable and check if they are numeric and 'train and test' should be factor.

    0 讨论(0)
  • 2020-12-03 21:38

    I had the same problem. My solution was to make all vectors numeric.

    0 讨论(0)
提交回复
热议问题