[R] Plotting using 'if' statements
smurray444 at hotmail.com
Thu Sep 4 18:28:31 CEST 2008
I have a dataset of four columns, and I wish to plot (as a scatter graph) the values of the third column where the values are greater than zero, and the fourth column.
I tried doing this via the plot command itself, but got into a bit of a mess (resulting in errors!). My dataframe is called 'January':
Error: unexpected '>' in "plot(January[3(>"
After a few variations on this, I thought I'd try making a new object which includes all values from the third column of January>0 (to plot in a separate step) as follows:
> JanFilter <- January>0
No error here. However, when I display the 'values' of JanFilter, it shows that instead of keeping the numerical values, the above operation simply displays the results of the logical test:
This is obviously no good for plotting the numerical values on axes!
So my question is, how do I perform 'if' statements in order to filter out various parts of a dataset, for plotting on a graph.
More information about the R-help