Help with barplot

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with barplot

matgopa1
Hello all,

I need to create a horizontal barplot with the following data:

City          Median

Springfield     34
Worcester     66
Fitchburg     65
Lowell       63
Quincy       62
Boston       36
Cambridge    54
Waltham      42
Medford      52
Pittsfield     65
Rensselaer     60
Schenectady     56
Glens Falls     64

The code below produces the bars for the Median, but how or where do I
specify the corresponding city name on the y-axis for the bars.

x<-data.frame(City=ozone.ne.trim$City,Median=ozone.ne.trim$Median)
with (x,
      barplot(Median,horiz=TRUE))

Please help.
Mathangi

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with barplot

Jacques VESLOT
par(mar=par()$mar+c(0,3,0,0))
with(x, barplot(structure(Median, names=as.character(City)),horiz=T,las=2))


[hidden email] a écrit :

>Hello all,
>
>I need to create a horizontal barplot with the following data:
>
>City          Median
>
>Springfield     34
>Worcester     66
>Fitchburg     65
>Lowell       63
>Quincy       62
>Boston       36
>Cambridge    54
>Waltham      42
>Medford      52
>Pittsfield     65
>Rensselaer     60
>Schenectady     56
>Glens Falls     64
>
>The code below produces the bars for the Median, but how or where do I
>specify the corresponding city name on the y-axis for the bars.
>
>x<-data.frame(City=ozone.ne.trim$City,Median=ozone.ne.trim$Median)
>with (x,
>      barplot(Median,horiz=TRUE))
>
>Please help.
>Mathangi
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>  
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html