[R] dotchart() help

Alexander Nervedi alexnerdy at hotmail.com
Tue Sep 12 02:12:54 CEST 2006


Hi

I am having trouble with dotcharts, and I keep getting the error message:

Error in Summary.data.frame(..., na.rm = na.rm) :
        only defined on a data frame with all numeric or complex variables

I am sure there is a really simple fix, but I am missing it and I wondered 
if you may have some advice. Test code from R help works prefectly, but I 
cant seem to recreate it

# example
>dotchart(VADeaths)
>VADeaths
      Rural Male Rural Female Urban Male Urban Female
50-54       11.7          8.7       15.4          8.4
55-59       18.1         11.7       24.3         13.6
60-64       26.9         20.3       37.0         19.3
65-69       41.0         30.9       54.6         35.1
70-74       66.0         54.3       71.1         50.0

# it works with mssing data

>test <-VADeaths
>test[2,]<- NA
>test
      Rural Male Rural Female Urban Male Urban Female
50-54       11.7          8.7       15.4          8.4
55-59         NA           NA         NA           NA
60-64       26.9         20.3       37.0         19.3
65-69       41.0         30.9       54.6         35.1
70-74       66.0         54.3       71.1         50.0
>dotchart(test)

# So i created my own test data
test<- expand.grid( Educ = c("B", "I", "A"),
                    Prof = c("L", "M","C"),
                    Blacks = NA,
                    Asian = NA,
                    Hispanic = NA,
                    Native = NA,
                    Female = NA)
rownames(test) <- with(test, paste(Educ,Prof, sep = "-"))
test[2:9,3:7] <- 2
temp <- test[,3:7]
temp[1, 2:3] <-5

# I want to plot temp which looks like
>temp
    Blacks Asian Hispanic Native Female
B-L     NA     5        5     NA     NA
I-L        2     2        2      2      2
A-L       2     2        2      2      2
B-M      2     2        2      2      2
I-M       2     2        2      2      2
A-M      2     2        2      2      2
B-C      2     2        2      2      2
I-C      2     2        2      2      2
A-C      2     2        2      2      2
>dotchart(temp)
Error in Summary.data.frame(..., na.rm = na.rm) :
        only defined on a data frame with all numeric or complex variables

Everything in temp is numeric and hence I dont understand the error message. 
Any leads would be most helpful. thank you

Al Nerdy.

_________________________________________________________________
Get the new Windows Live Messenger!



More information about the R-help mailing list