[R] plot

Chuck Cleland ccleland at optonline.net
Mon Dec 18 10:46:58 CET 2006


XinMeng wrote:
> Hello sir:
> a data with 2 columns:
> id x
> a  1
> b  2
> c  3
> 
> I wanna get such kind of plot:
> x: a b c
> y:1 2 3
> 
> But the plot command doesn't permit string character as x.
> 
> How can I get it ?

  What sort of plot do you want?  For a barplot() of x with bars labeled
by id you could do this:

df <- data.frame(id = c("a","b","c"), x = 1:3, stringsAsFactors=FALSE)
with(df, barplot(x, names.arg = id))

> Thanks a lot !
> 
> My best
> 
> ______________________________________________
> R-help at 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list