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)

结果:我可以获得第一个情节,但对于第二个情节,我收到以下消息:

错误报告:

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

问题?

由于第二个数据集有一些缺失值(因为观察较少),所以我收到了这个错误。所以,想知道如何处理这个错误。

4

1 回答 1

1

试试这个例如:

在此处输入图像描述

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)
于 2013-06-22T02:47:30.357 回答