0

I'm relatively new to R. I have a dataset which contains average group sizes which I think may be the problem. I have them in a csv file and they are typed as '1-3' and '4-6' for example. When I try to plot this using the code:

plot(mydata$Group.Size, mydata$Time.spent.vigilant..seconds., xlab="Group size", ylab="Time spent vigilant, seconds", main="Group size vs time spent vigilant")

I get the error

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
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

I have tried to expand my plot window but keep getting the error.

Lew
  • 1
  • 1
  • It will be extremely challenging to answer your question without at least a sample of your data. Please [edit] your question with the output of `dput(mydata)` or `dput(head(mydata))` if your data is very large. See [How to make a great R reproducible example](https://stackoverflow.com/a/5963610/) for more. – Ian Campbell May 06 '21 at 16:56

1 Answers1

0

min() returns Inf when applied to NULL:

min(NULL)
[1] Inf
Warning message:
In min(NULL) : no non-missing arguments to min; returning Inf

Check that $Time.spent.vigilant..seconds. exists in mydata

If not:

plot(mtcars$banana)

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
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
Waldi
  • 39,242
  • 6
  • 30
  • 78