Home:ALL Converter>R script plotting data

R script plotting data

Ask Time:2021-09-22T05:50:19         Author:sacha

Json Formatter

Welcome: I am running an R script that plots data graphically. I am getting an error message that I hope you can resolve. Thank you.

HERE IS THE CODE:

makeProfilePlot <- function(mylist,names)
  {
     require(RColorBrewer)
     # find out how many variables we want to include
     numvariables <- length(mylist)
     # choose 'numvariables' random colours
     colours <- brewer.pal(numvariables,"Set1")
     # find out the minimum and maximum values of the variables:
     mymin <- 1e+20
     mymax <- 1e-20
     for (i in 1:numvariables)
     {
        vectori <- mylist[[i]]
        mini <- min(vectori)
        maxi <- max(vectori)
        if (mini < mymin) { mymin <- mini }
        if (maxi > mymax) { mymax <- maxi }
     }
     # plot the variables
     for (i in 1:numvariables)
     {
        vectori <- mylist[[i]]
        namei <- names[i]
        colouri <- colours[i]
        if (i == 1) { plot(vectori, col=colouri, type="l", ylim=c(mymin,mymax)) }
        else        { points(vectori, col=colouri, type="l")                    }
        lastxval <- length(vectori)
        lastyval <- vectori[length(vectori)]
        text((lastxval-10),(lastyval),namei,col="black",cex=0.6)
     }
  }


names <- c("V2","V3","V4","V5","V6")
mylist <- list(wine$V2,wine$V3,wine$V4,wine$V5,wine$V6)
makeProfilePlot(mylist,names)

AND HERE IS THE ERROR MESSAGE:

Error in plot.window(...) : need finite 'xlim' values Calls: makeProfilePlot -> plot -> plot.default -> localWindow -> plot.window In addition: There were 12 warnings (use warnings() to see them) Execution halted

Author:sacha,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275918/r-script-plotting-data
yy