user2510725
user2510725

Reputation: 1

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.

Upvotes: 0

Views: 661

Answers (1)

agstudy
agstudy

Reputation: 121568

Try this for example:

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)

Upvotes: 1

Related Questions