Skip to content
Prev 336798 / 398513 Next

Subset for plot in R

So are the names of the columns in the dataset x, y, and z? or are
they area, concentration, and year?  you seem to be mixing these
together?  If you provide a minimal reproducible example (provide some
data with dput, or the commands to generate random data, or use a
built in dataset) then it makes it easier for us to help you.

Is the z/year variable a set of character strings? a factor? or a
numeric/integer variable?

Assuming the column names are x, y, and z  and that z is the numeric
year and data is a data frame, then here are some options that should
work:

plot( data$x[ data$z >= 2012 ], data$y[ data$z >= 2012 )

with( data[ data$z >= 2012, ], plot(x,y) )

plot( y~x, data=data, subset= z >= 2012 )

Also see `fortune("dog")` about choosing names for data frames.
On Mon, Feb 17, 2014 at 9:18 AM, arun <smartpink111 at yahoo.com> wrote: