Question

I am attempting to use the classInt package in conjunction with rworldmap package in R to construct a choropleth. I want to use the fixedBreaks argument to specify given breaks.

My data looks like this:

> head(Maji)

 Country       waterused  CC
 Afghanistan   36        AFG
 Albania        4        ALB
 Algeria       52        DZA
 Angola         0        AGO
 Antigua       10        ATG
 Argentina      4        ARG

waterused is a percentage (range:0-4600) and CC is the country code (IS03-alpha).

When I attempt,

classInt <- classIntervals(ww[["waterused"]], n=5, style="fixed", fixedBreaks=c(0,25,50,75,100,4565))
**Warning message:
      In classIntervals(ww[["waterused"]], n = 5, style = "fixed", fixedBreaks = c(0,  :
      var has missing values, omitted in finding classes**

I've tried a number of variations of the argument style and have not been successful and consequently my map is not correct. Further, my data frame has no missing data points. Do you have any suggestions/ is there an obvious fix?

No correct solution

OTHER TIPS

There is nothing wrong with your syntax. I copied it to my own dataset and changed the dataframe name and variable name and altered the min/max value and it worked perfectly.

Your problem lies in your assumption that your dataset does not contain any missings. I'll demonstrate using an example dataset (like Victor K. argues).

id        <- c(1:10)
waterused <- c(0, 10, 20, 60, 80, 91, 92, 93, 94, 4565)
classInt  <- classIntervals(ww[["waterused"]], 
                 n=5, style="fixed", fixedBreaks=c(0,25,50,75,100,4565))

This results in no errors + you can check so by running:

str(classInt)

To replicate your error I'll now add a missing value to 'waterused':

ww$waterused[3] <- NA
table(is.na(ww$waterused))    # 1 missing and 9 non-missing values
classInt.na     <- classIntervals(ww[["waterused"]], 
                       n=5, style="fixed", 
                       fixedBreaks=c(0,25,50,75,100,4565))

This results in precisely the same error you report. So please check again for any NA's in your 'waterused' variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top