On Tue, 12 Sep 2006, Alexander Nervedi wrote: > 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.
>From the help page of dotchart: x: either a vector or matrix of numeric values ('NA's are allowed). If 'x' is a matrix the overall plot consists of juxtaposed dotplots for each row. > class(temp) [1] "data.frame" which is neither. Try as.matrix(temp). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.