2013-06-22 198 views
0

數據集:兩個二元不等意見:缺少值 - 極座標圖

g_d g_a s_d s_a 
2 27.75047815 2 27.75047815 
2 27.75047815 2 27.75047815 
3 27.75047815 2 27.75047815 
3 27.75047815 2 27.75047815 
3 27.75047815 2 27.75047815 
5 27.75047815 2 27.75047815 
6 27.75047815 2 27.75047815 
8 27.75047815 2 27.75047815 
9 27.75047815 2 27.75047815 
10 27.75047815 2 27.75047815 
3 17.19518769 2 27.75047815 
3 13.21767851 2 27.75047815 
4 13.21767851 3 27.75047815 
4 13.21767851 3 27.75047815 
5 13.21767851 3 27.75047815 
6 13.21767851 3 27.75047815 
6 13.21767851 3 27.75047815 
6 13.21767851 3 27.75047815 
7 13.21767851 3 27.75047815 
8 13.21767851 3 27.75047815 
9 13.21767851 3 27.75047815 
9 13.21767851 3 27.75047815 
11 13.21767851 3 27.75047815 
11 13.21767851  
14 13.21767851  
14 13.21767851  
14 13.21767851  
15 13.21767851  
16 13.21767851  
17 13.21767851  
24 13.21767851  
2 30.90877312  
2 30.90877312  
2 30.90877312  
2 30.90877312  
2 30.90877312  
3 30.90877312  
3 30.90877312  
3 30.90877312  

我嘗試使用以下命令

代碼在同積窗口,使2個極座標圖並排:

d = read.table("D:/POLAR_1.txt", sep="\t", header=T) 
attach(d) 
summary(d) 
library(plotrix) 
par(mfrow=c(1,2)) 

對於第一極座標圖:

polar.plot(NA, NA, clockwise=TRUE, rp.type="", start=90,radial.lim=c(0, 35), 
radial.cex=0.3, box.radial=TRUE, show.grid.labels=1, boxed.radial=FALSE) 

polar.plot(g_d, g_a, clockwise=TRUE, rp.type="s", start=90, point.symbols=19, 
show.grid.labels=3, par(cex=0.8), add=TRUE) 

對於第二極座標圖:

polar.plot(NA, NA, clockwise=TRUE, rp.type="", start=90,radial.lim=c(0, 35), 
radial.cex=0.3, box.radial=TRUE, show.grid.labels=1, boxed.radial=FALSE, add=TRUE) 

polar.plot(s_d, s_a, clockwise=TRUE, rp.type="s", start=90, point.symbols=19, 
show.grid.labels=3, par(cex=0.8), add=TRUE) 

結果:我可以得到1情節但對於第二個情節我收到以下消息:

錯誤報告:

Error in if (grid.pos[1] < radial.lim[1]) grid.pos <- grid.pos[-1] : 
    missing value where TRUE/FALSE needed 

問題?

由於第二數據集有一些缺失值(因爲較少的觀察),所以我得到這個錯誤。所以,想知道如何處理這個錯誤。

+0

重複的例子,將有助於人們提供建議。 –

+0

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example –

+0

對不起,我沒有添加庫:庫(plotrix) – user2510725

回答

1

試試這個,例如:

enter image description here

library(plotrix) 

par(mfrow=c(1,2)) 
polar.plot(NA, NA, clockwise=TRUE, rp.type="", start=90,radial.lim=c(0, 35), 
      radial.cex=0.3, box.radial=TRUE, show.grid.labels=1, boxed.radial=FALSE) 
polar.plot(g_d, g_a, clockwise=TRUE, rp.type="s", start=90, point.symbols=19, 
      show.grid.labels=3, par(cex=0.8), add=TRUE) 

## here remove add=TRUE  
polar.plot(NA, NA, clockwise=TRUE, rp.type="", start=90,radial.lim=c(0, 35), 
      radial.cex=0.3, box.radial=TRUE, show.grid.labels=1, boxed.radial=FALSE) 
## use na.omit to remove missing values 
polar.plot(na.omit(s_d), na.omit(s_a), clockwise=TRUE, rp.type="s", start=90, point.symbols=19, 
      show.grid.labels=3, par(cex=0.8), add=TRUE) 
+0

非常感謝 - @agstudy 。有沒有辦法將徑向軸(0到35)放置在圖的外面?並將圓形軸上的「度」符號作爲上標? – user2510725