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

Hi
I know this has been discussed already, but the answers I found do not solved my issue.

Here the code
R_code <- plot(CHD~genotype, data=peptide)

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

In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
5: In min(x) : no non-missing arguments to min; returning Inf
6: In max(x) : no non-missing arguments to max; returning -Inf

"CHD" and "genotype" are categorical variables. However, even when I try to run the same function with numerical variables (from another dataset) I get the same error message.
I have loaded the datased from a .csv
The only thing that these datasets have in commond is that they all come from csv files, but I can't figure out what is the problem and how I can fix it.

Any help is really appreciated.
THanks

What is the output of

summary(peptide[, c("CHD", "genotype")]

It seems that you are trying to plot columns that are full of NA.

summary(peptide[, c("CHD", "genotype")]

This code seems incomplete, as R does not run it
Output of
summary(peptide) is

summary(peptide)
CHD genotype
Length:1071 Length:1071
Class :character Class :character
Mode :character Mode :character

peptide object should not contain any NA as when I run the following code I get zero NA

sum(is.na(peptide$genotype) + is.na(peptide$CHD))
[1] 0

Please post the output of

dput(head(peptide, 20))

Place three back ticks on the line just before and just after the output, like this
```
Your output here
```

structure(list(CHD = c("no", "no", "no", "no", "no", "no", "no", 
"no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", 
"no", "no"), genotype = c("ins-ins", "ins-ins", "ins-ins", "ins-ins", 
"ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", 
"ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", 
"ins-ins", "ins-ins", "ins-ins", "ins-ins")), row.names = c(NA, 
-20L), class = c("tbl_df", "tbl", "data.frame"))

It seems that the plot() function requires that the columns be factors instead of character. Try running the following code to see the difference. The plot is not very interesting since each column only has one value.

DF <- structure(list(CHD = c("no", "no", "no", "no", "no", "no", "no", 
                             "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", "no", 
                             "no", "no"), genotype = c("ins-ins", "ins-ins", "ins-ins", "ins-ins", 
                                                       "ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", 
                                                       "ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", "ins-ins", 
                                                       "ins-ins", "ins-ins", "ins-ins", "ins-ins")), row.names = c(NA, 
                                                                                                                   -20L), class = c("tbl_df", "tbl", "data.frame"))
plot(CHD~genotype,data=DF)
DF$CHD <- factor(DF$CHD)
DF$genotype <- factor(DF$genotype)
plot(CHD~genotype,data=DF)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.