[R] If Command in Plot

arun smartpink111 at yahoo.com
Sun Sep 23 06:52:04 CEST 2012


HI,
I guess you want to plot with a subset of your data z1.
z1[with(z1,e>0),]
 plot(y~x,data=z1[with(z1,e>0),])
A.K.






----- Original Message -----
From: Bhupendrasinh Thakre <vickythakre at gmail.com>
To: r-help <r-help at r-project.org>
Cc: 
Sent: Saturday, September 22, 2012 11:48 PM
Subject: [R] If Command in Plot

Hi Team,

I am trying to very simple plot with command plot.

Question : I am trying to plot (x,y) based on the value of Column e.
If column e value is greater than 0 then plot(x,y) otherwise do not plot it.

Data :

structure(list(x = c(1, 1, 1, 2, 2, 2, 3, 3, 3), y = c(1, 2, 
3, 1, 2, 3, 1, 2, 3), e = c(0, -1, -2, 1, 0, -1, 2, 1, 0)), row.names = c(NA, 
-9L), .Names = c("x", "y", "e"), class = "data.frame")

System Info :

R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C/en_US.UTF-8/C/C/C/C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] SemiPar_1.0-3        MASS_7.3-18          nlme_3.1-104         cluster_1.14.2      
[5] RSVGTipsDevice_1.0-4 maptools_0.8-16      lattice_0.20-6       foreign_0.8-50      
[9] rgdal_0.7-18         sp_0.9-99          

loaded via a namespace (and not attached):
[1] RCurl_1.91-1    grid_2.15.1     tools_2.15.1    twitteR_0.99.19

It's very simple but I am not able to plot it with following commands 

for (i in 1:9) {ifelse(z1$e[[i]] > 0 , plot(z1$x,z1$y),plot(z1$x,z1$e))}
Or
ifelse(z1$e > 0,plot(z1$x,z1$y),plot(z1$x,z1$e))


Bhupendrasinh Thakre





    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list