1

I am trying to do a scree plot with my data but R keeps telling me:

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

My code is:

screeplot(res.comp, npcs = 24, type = "lines")

and R says:

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

I do not know what this means or how to correct it. I have tried looking around to fix the problem and came up with the solution:

PCA.output <- res.comp

res.comp <- function(xlim, ylim, log="", asp=NA, ...) {
  +    if (!all(is.finite(xlim))) xlim <- c(0,1)
  +    if (!all(is.finite(ylim))) ylim <- c(0,1)
  +    PCA.output(xlim, ylim, log="", asp=NA, ...)}

screeplot(PCA.output, npcs = 24, type = "lines")

But R gave me the same answer:

Error in plot.window(...) : need finite 'ylim' 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

Could anyone help me understand what's going on? Thank you in advance! Bellow is the data I am trying to scree plot.

   Active Aggressive to people  Anxious     Calm Cooperative Curious Depressed Eccentric Excitable
[1,]      6             2.577787 2.097215 4.743244           7       7         1         1         5
[2,]      6             4.000000 4.000000 5.000000           6       2         3         3         2
[3,]      5             2.034049 1.744754 5.249933           7       7         1         1         5
     Fearful of people friendly of people Insecure Playful Self assured Smart Solitary Tense Timid
[1,]                 1                  5        2       4            7     6        4     1     2
[2,]                 2                  6        5       6            6     2        4     2     2
[3,]                 1                  7        2       2            7     7        3     1     2
     Trusting Vigilant Vocal
[1,]        6        7     2
[2,]        6        6     7
[3,]        6        5     1
Natalie
  • 21
  • 2
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. Hard to know what's going on without some data. – MrFlick Feb 20 '20 at 15:49
  • https://stackoverflow.com/questions/25871292/r-need-finite-ylim-values-in-function looks like is the same question – weirdgyn Feb 20 '20 at 15:52
  • You want to `screeplot` the object `res.comp`and then define `res.comp` as a function? Please follow @MrFlick's suggestion and make the example reproducible, like this it's not easy to understand your code. Post enough for us to reproduce the error. – Rui Barradas Feb 20 '20 at 16:14
  • Hi, thank you all for you comments and help so far, I really appreciate it! I have added my data that I am trying to scree plot as the reproducible example. I am sorry, I am still quite new to R. – Natalie Feb 20 '20 at 17:03

0 Answers0