[R] Plotting using 'if' statements
Steve Murray
smurray444 at hotmail.com
Thu Sep 4 18:47:39 CEST 2008
Ah that's great, thank you very much.
As a follow-on, in the same format, how would I plot where column 3 is greater than 0 *but also less than 2*?
Once again, any help is much appreciated.
Thanks,
Steve
________________________________
Date: Thu, 4 Sep 2008 13:39:12 -0300
From: wwwhsd at gmail.com
To: smurray444 at hotmail.com
Subject: Re: [R] Plotting using 'if' statements
CC: r-help at r-project.org
Try this:
plot(January[January[,3]> 0, 3:4])
On Thu, Sep 4, 2008 at 1:28 PM, Steve Murray wrote:
Dear all,
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':
> plot(January[3(>0):4])
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[3]>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:
> head(JanFilter)
Value
[1,] FALSE
[2,] TRUE
[3,] TRUE
[4,] TRUE
[5,] TRUE
[6,] TRUE
[[elided Hotmail spam]]
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.
Many thanks,
Steve
______________________________________________
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list