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

前端 未结 4 1397
余生分开走
余生分开走 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))

提交回复
热议问题