[R] Barplot With Selected X-Axis Region

Gundala Viswanath gundalav at gmail.com
Tue Mar 24 08:27:25 CET 2009


Dear all,

I have a data that looks like this:

> print(dat)
             V1   V2
1     -43342073   14
2     -43337730    4
3     -43284676    1
....
11372  75188572   11
11373  75206165    6
11374  75262720   24


What I want to do is to have a barplot where x-axis
is taken from V1 and y-axis taken from V2.

But I only want to plot the those region where V1 >= -500
and <= 500.

But some how this snippet doesn't seem to work:

> xlim = c(-500,500)
> barplot(as.matrix(dat[dat$V1 >= -500 && dat$V1 <=500,dat$V2]),xlim=xlim,axes=TRUE, main =nm);

What's wrong with my approach.

So yes, I do want the V1 information, hence I am aware that
I dont' want:

> plot(hist(dat[dat >=-500 & dat <=500]))

- Gundala Viswanath
Jakarta - Indonesia




More information about the R-help mailing list