[R] have I an actual matrix?
Michael Kubovy
kubovy at virginia.edu
Wed Nov 8 01:33:16 CET 2006
On Nov 7, 2006, at 6:25 PM, Ricardo Rodríguez - Your EPEC ICT Team
wrote:
> library(RMySQL)
> con <- dbConnect(dbDriver
> ("MySQL"),host='localhost',username='root',dbname='ibdona')
> rs <- dbGetQuery (con,"select n,year from ibdona.library_location")
> dbDisconnect(con)
> Graph <- barplot(rs)
>
> And here the error I get...
>
> Error in barplot.default(rs) : 'height' must be a vector or a matrix
>
> paste(rs) gives me...
>
> [1] "c(307, 65, 2, 28, 3, 229, 81, 5, 7, 558, 134, 53, 9)"
> [2] "c(2002, 2002, 2002, 2002, 2002, 2003, 2003, 2003, 2003, 2004,
> 2004, 2004, 2004)"
nums <- c(307, 65, 2, 28, 3, 229, 81, 5, 7, 558, 134, 53, 9)
names(nums) <- c(2002, 2002, 2002, 2002, 2002, 2003, 2003, 2003,
2003, 2004, 2004, 2004, 2004)
barplot(nums)
or
require(gplots)
barplot2(nums, plot.grid = TRUE, las = 1) # offers many nice options
_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400 Charlottesville, VA 22904-4400
Parcels: Room 102 Gilmer Hall
McCormick Road Charlottesville, VA 22903
Office: B011 +1-434-982-4729
Lab: B019 +1-434-982-4751
Fax: +1-434-982-4766
WWW: http://www.people.virginia.edu/~mk9y/
More information about the R-help
mailing list