简体   繁体   English

缺失值-极坐标图

[英]Missing value - Polar plot

Dataset: two bivariate unequal observations: 数据集:两个双变量不相等观察值:

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     

I am trying to make 2 polar plots side by side in same plot window using following commands 我正在尝试使用以下命令在同一绘图窗口中并排制作两个极坐标图

Codes: 代码:

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

For first polar plot: 对于第一个极坐标图:

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)

For 2nd polar plot: 对于第二极坐标图:

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)

Result: I can get the 1st plot but for second plot I am getting following message: 结果:我可以获得第一个图,但是对于第二个图,我得到以下消息:

Error report: 错误报告:

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

Question? 题?

As the 2nd dataset have some missing values (because of less observation), so I am getting this error. 由于第二个数据集缺少一些值(由于较少的观察),因此出现此错误。 So, wondering how to deal with this error. 因此,想知道如何处理此错误。

Try this for example: 尝试以下示例:

在此处输入图片说明

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM