[R] Help with plot Grouped Bar Plot by using R

Jim Lemon jim at bitwrit.com.au
Wed Mar 7 09:04:52 CET 2012


On 03/06/2012 07:09 PM, R_beginner_starter wrote:
> Thanks a lot, Jim.
> Do you mind to post out the complete content of your R script suggested?
>
> I got add in your R code in my existing R script.
> It shown the following error message:
> Error in rbind(br[, 2] + 1, br[, 4]) : object 'br' not found
>
Hi R_beginner_starter,
As I mentioned, "br" was your data frame. Unless you actually called it 
"br", it won't be there. So, in three easy steps:

# read in the data that you included in your original message
# now I know that the file probably isn't named R_beginner_starter.dat
# but because I don't know what it is named, you will have to change
# the first line below to what the file really is named
br<-read.table("R_beginner_starter.dat",header=TRUE,sep="\t")
# I have made the assumption that the data was a faithful
# representation of what is in your data file. If it is, you should
# now have a data frame named "br" in your R workspace
# Ask what the names of the elements of that data frame are
 > names(br)
[1] "Number.of.Z"     "Number.of.Data1" "Data1.."         "Number.of.Data2"
[5] "Data2.."
# okay, it looks like element numbers 2 and 4 are the ones you want
# to use in your plot. The last step is:
library(plotrix)
barp(t(br[,c(2,4)]))

I get the plot with two big bars on the left and pretty much nothing 
else. If you would like to try the other plot, it should also work.

Jim



More information about the R-help mailing list