Skip to content

Commit 444985f

Browse files
committed
4.0.1 to cran
1 parent 6011def commit 444985f

102 files changed

Lines changed: 23459 additions & 2302 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: fanplot
22
Type: Package
33
Title: Visualisation of Sequential Probability Distributions Using Fan Charts
4-
Version: 4.0.0
4+
Version: 4.0.1
55
Authors@R: c(person(c("Guy", "J."), "Abel", role = c("aut", "cre"),
66
email = "g.j.abel@gmail.com",
77
comment = c(ORCID = "0000-0002-4893-5687")))
@@ -13,13 +13,18 @@ Description: Visualise sequential distributions using a range of plotting
1313
different styles, including fan chart type plots, where a set of coloured
1414
polygon, with shadings corresponding to the percentile values are layered
1515
to represent different uncertainty levels. Full details in R Journal article; Abel (2015) <doi:10.32614/RJ-2015-002>.
16-
License: GPL-2
16+
License: GPL-3
17+
Encoding: UTF-8
1718
URL: http://guyabel.github.io/fanplot/
1819
BugReports: https://github.com/guyabel/fanplot/issues/
19-
Imports:
20-
methods
2120
Depends:
2221
R (>= 2.10)
22+
Imports:
23+
methods
2324
Suggests:
24-
shiny
25+
shiny,
26+
RColorBrewer,
27+
colorspace,
28+
zoo
2529
LazyData: true
30+
RoxygenNote: 7.3.3

NAMESPACE

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
exportPattern("^[[:alpha:]]+")
2-
importFrom("grDevices", "adjustcolor", "heat.colors")
3-
importFrom("graphics", "box", "boxplot", "lines", "plot", "polygon", "rect", "text")
4-
importFrom("stats", "lag", "median", "pnorm", "qnorm", "quantile", "runif", "time", "ts")
5-
importFrom("methods", "is")
6-
7-
8-
2+
importFrom("methods", "is")

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# fanplot 4.0.1
2+
3+
* updated suggests for demo file, as required for CRAN
4+
15
# fanplot 4.0.0
26

37
* Added a `NEWS.md` file to track changes to the package.
@@ -6,6 +10,6 @@
610
* Expanded README
711
* Added hex
812
* Github actions working
9-
* Transferred blog posts from `https://gjabel.wordpress.com/`
13+
* Transferred blog posts from `https://gjabel.wordpress.com/` to `https://guyabel.github.io/fanplot/`
1014

1115

R/fan.R

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fan <-
22
function(data = NULL, data.type="simulations", style = "fan", type = "percentile",
33
probs = if(type=="percentile") seq(0.01, 0.99, 0.01) else c(0.5, 0.8, 0.95),
44
start = 1, frequency = 1, anchor = NULL, anchor.time=NULL,
5-
fan.col = heat.colors, alpha = if (style == "spaghetti") 0.5 else 1,
5+
fan.col = grDevices::heat.colors, alpha = if (style == "spaghetti") 0.5 else 1,
66
n.fan = NULL,
77
ln = if(length(probs)<10) probs else
88
probs[round(probs,2) %in% round(seq(0.1, 0.9, 0.1),2)],
@@ -31,7 +31,7 @@ fan <-
3131
##
3232
##data classes
3333
##
34-
if(is(data, "mts")[1]){
34+
if(methods::is(data, "mts")[1]){
3535
start<-start(data)[1]
3636
frequency<-frequency(data)
3737
}
@@ -59,7 +59,7 @@ fan <-
5959
#work out quantiles
6060
if(data.type=="simulations"){
6161
pp<-as.matrix(data)
62-
pp<-apply(pp,2,quantile,probs=p)
62+
pp<-apply(pp,2,stats::quantile,probs=p)
6363
}
6464
if(data.type=="values"){
6565
pp<-as.matrix(data)
@@ -86,18 +86,18 @@ fan <-
8686

8787

8888
#ts info
89-
if(!is(data, "zoo")[1]){
90-
ppts <- ts(pp, start = start, frequency = frequency)
91-
tt<-time(ppts)
89+
if(!methods::is(data, "zoo")[1]){
90+
ppts <- stats::ts(pp, start = start, frequency = frequency)
91+
tt<-stats::time(ppts)
9292
tt<-as.numeric(tt)
9393
if(!is.null(anchor)){
94-
ppts <- ts(pp, start = time(lag(ppts))[1], frequency = frequency)
95-
tt <- time(ppts)
94+
ppts <- stats::ts(pp, start = stats::time(stats::lag(ppts))[1], frequency = frequency)
95+
tt <- stats::time(ppts)
9696
tt<-as.numeric(tt)
9797
}
9898
}
99-
if(is(data, "zoo")[1]){
100-
tt<-time(data)
99+
if(methods::is(data, "zoo")[1]){
100+
tt<-stats::time(data)
101101
if(!is.null(anchor))
102102
tt<-c(anchor.time,tt)
103103
}
@@ -112,7 +112,7 @@ fan <-
112112
fan.col<-fan.col(floor(n/2))
113113
if(!is.null(n.fan))
114114
fan.col<-fan.col(n.fan)
115-
fan.col<-adjustcolor(fan.col,alpha.f=alpha)
115+
fan.col <- grDevices::adjustcolor(fan.col,alpha.f=alpha)
116116
if(is.null(ln.col))
117117
ln.col<-fan.col[1]
118118
}
@@ -124,7 +124,7 @@ fan <-
124124
fan.fill<-function(ts1, ts2, tt, fan.col="grey"){
125125
xx <- cbind(tt,rev(tt))
126126
yy <- cbind(as.vector(ts1),rev(as.vector(ts2)))
127-
polygon(xx,yy, col=fan.col, border=fan.col)
127+
graphics::polygon(x = xx, y = yy, col = fan.col, border = fan.col)
128128
}
129129
#plot(cpi, type = "l", xlim = c(y0-5, y0+3), ylim = c(-2, 7))
130130
#plot(NULL, type = "n", xlim = c(1, 945), ylim = range(th.mcmc), ylab = "Theta")
@@ -142,7 +142,7 @@ fan <-
142142
x<-pp[,1]
143143
for(i in 1:nrow(pp)){
144144
for(j in 1:floor(n/2)){
145-
rect(xleft=tt[i]-0.5*space, ybottom=pp[i,j], xright=tt[i]+0.5*space, ytop=pp[i,n-j+1], col=fan.col[floor(n/2)+1-j], border=fan.col[floor(n/2)+1-j])
145+
graphics::rect(xleft=tt[i]-0.5*space, ybottom=pp[i,j], xright=tt[i]+0.5*space, ytop=pp[i,n-j+1], col=fan.col[floor(n/2)+1-j], border=fan.col[floor(n/2)+1-j])
146146
}
147147
}
148148
}
@@ -169,12 +169,12 @@ fan <-
169169
#plot lines
170170
if(style=="fan"){
171171
for(i in match(ln0, p))
172-
lines(x=tt, y=pp[,i], col=ln.col)
172+
graphics::lines(x=tt, y=pp[,i], col=ln.col)
173173
}
174174
if(style=="boxfan"){
175175
for(i in 1:nrow(pp)){
176176
for(j in match(ln0, p)){
177-
lines(x=tt[i]+c(-0.5,0.5)*space, y=rep(pp[i,j],2), col=ln.col)
177+
graphics::lines(x=tt[i]+c(-0.5,0.5)*space, y=rep(pp[i,j],2), col=ln.col)
178178
}
179179
}
180180
}
@@ -202,9 +202,9 @@ fan <-
202202
rlab<-round(rlab, 5)
203203
for(i in match(rlab, p)){
204204
if(style=="fan")
205-
text(tt[length(tt)], pp[nrow(pp),i], colnames(pp)[i], pos=rpos, offset=roffset, cex=rcex, col=rcol)
205+
graphics::text(tt[length(tt)], pp[nrow(pp),i], colnames(pp)[i], pos=rpos, offset=roffset, cex=rcex, col=rcol)
206206
if(style=="boxfan")
207-
text(tt[length(tt)]+0.5*space, pp[nrow(pp),i], colnames(pp)[i], pos=rpos, offset=roffset, cex=rcex, col=rcol)
207+
graphics::text(tt[length(tt)]+0.5*space, pp[nrow(pp),i], colnames(pp)[i], pos=rpos, offset=roffset, cex=rcex, col=rcol)
208208
}
209209
if(is.na(sum(match(rlab,p))))
210210
print("some right labels not plotted as conflict with precentiles given in probs")
@@ -224,9 +224,9 @@ fan <-
224224
llab<-rlab
225225
for(i in match(llab, p)){
226226
if(style=="fan")
227-
text(tt[1], pp[1,i], colnames(pp)[i], pos=lpos, offset=loffset, cex=lcex, col=lcol)
227+
graphics::text(tt[1], pp[1,i], colnames(pp)[i], pos=lpos, offset=loffset, cex=lcex, col=lcol)
228228
if(style=="boxfan")
229-
text(tt[1]-0.5*space, pp[1,i], colnames(pp)[i], pos=lpos, offset=loffset, cex=lcex, col=lcol)
229+
graphics::text(tt[1]-0.5*space, pp[1,i], colnames(pp)[i], pos=lpos, offset=loffset, cex=lcex, col=lcol)
230230
}
231231
if(is.na(sum(match(llab,p))))
232232
print("some left labels not plotted as conflict with precentiles given in probs")
@@ -237,28 +237,28 @@ fan <-
237237
if(style=="fan" | style=="boxfan"){
238238
if(med.ln==TRUE & data.type=="simulations"){
239239
pp<-data
240-
pm<-apply(pp,2,median)
240+
pm<-apply(pp,2,stats::median)
241241
if(!is.null(anchor))
242242
pm<-c(anchor,pm)
243243
if(is.null(med.col))
244244
med.col<-ln.col
245245
if(style=="fan"){
246-
lines(x=tt, y=pm, col=med.col)
246+
graphics::lines(x=tt, y=pm, col=med.col)
247247
}
248248
if(style=="boxfan"){
249249
for(i in 1:nrow(pp)){
250250
#lines(x=(i-1)/frequency+c(-0.5,0.5)*space, y=rep(pm[i],2), col=med.col)
251-
lines(x=tt[i]+c(-0.5,0.5)*space, y=rep(pm[i],2), col=med.col)
251+
graphics::lines(x=tt[i]+c(-0.5,0.5)*space, y=rep(pm[i],2), col=med.col)
252252
}
253253
}
254254
if(!is.null(rlab) & style %in% c("fan","spaghetti"))
255-
text(tt[length(tt)], pm[length(pm)], medlab, pos=rpos, offset=roffset, cex=rcex, col=rcol)
255+
graphics::text(tt[length(tt)], pm[length(pm)], medlab, pos=rpos, offset=roffset, cex=rcex, col=rcol)
256256
if(!is.null(rlab) & style=="boxfan")
257-
text(tt[length(tt)]+0.5*space, pm[length(pm)], medlab, pos=rpos, offset=roffset, cex=rcex, col=rcol)
257+
graphics::text(tt[length(tt)]+0.5*space, pm[length(pm)], medlab, pos=rpos, offset=roffset, cex=rcex, col=rcol)
258258
if(any(llab==TRUE,is.numeric(llab)) & style %in% c("fan","spaghetti"))
259-
text(tt[1], pm[1], medlab, pos=lpos, offset=loffset, cex=lcex, col=lcol)
259+
graphics::text(tt[1], pm[1], medlab, pos=lpos, offset=loffset, cex=lcex, col=lcol)
260260
if(any(llab==TRUE,is.numeric(llab)) & style=="boxfan")
261-
text(tt[1]-0.5*space, pm[1], medlab, pos=lpos, offset=loffset, cex=lcex, col=lcol)
261+
graphics::text(tt[1]-0.5*space, pm[1], medlab, pos=lpos, offset=loffset, cex=lcex, col=lcol)
262262
}
263263
}
264264

@@ -272,9 +272,9 @@ fan <-
272272
#add ancohor
273273
if(!is.null(anchor))
274274
ps<-cbind(rep(anchor,nrow(ps)),ps)
275-
spag.col<-adjustcolor(ln.col,alpha.f=alpha)
275+
spag.col <- grDevices::adjustcolor(ln.col,alpha.f=alpha)
276276
for(i in 1:nrow(ps))
277-
lines(x=tt, y=ps[i,], col=spag.col)
277+
graphics::lines(x=tt, y=ps[i,], col=spag.col)
278278
}
279279

280280
##
@@ -288,12 +288,12 @@ fan <-
288288
if(!is.null(anchor))
289289
print("anchor ignored for boxplots plots")
290290
#single time series to use for at=time
291-
p<-ts(pp[1,], start=start, frequency=frequency)
291+
p<-stats::ts(pp[1,], start=start, frequency=frequency)
292292
#plot(NULL, type = "n", xlim = c(1, 10), ylim = range(pp), ylab = "Theta")
293293
for(i in 1:n)
294-
boxplot(pp[,i], add=TRUE, at=time(p)[i], boxwex=space, xaxt = "n", yaxt = "n",...)
294+
graphics::boxplot(pp[,i], add=TRUE, at=stats::time(p)[i], boxwex=space, xaxt = "n", yaxt = "n",...)
295295
}
296-
box()
296+
graphics::box()
297297
}
298298

299299

R/fan0.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fan0 <-
22
function(data = NULL, data.type = "simulations", style = "fan", type = "percentile",
33
probs = if(type=="percentile") seq(0.01, 0.99, 0.01) else c(0.5, 0.8, 0.95),
44
start = 1, frequency = 1, anchor = NULL, anchor.time=NULL,
5-
fan.col = heat.colors, alpha = if (style == "spaghetti") 0.5 else 1,
5+
fan.col = grDevices::heat.colors, alpha = if (style == "spaghetti") 0.5 else 1,
66
n.fan = NULL,
77
ln = NULL, ln.col = if(style=="spaghetti") "gray" else NULL,
88
med.ln = if(type=="interval") TRUE else FALSE, med.col= "orange",

R/psplitnorm.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function(x, mode = 0, sd = 1, skew = 0, sd1 = NULL, sd2 = NULL) {
3434
k[] <- x #change name of x to match formula
3535
k1 <- k <= mode
3636
k2 <- k > mode
37-
f[k1] <- (c[k1] * sqrt(2 * pi) * sd1[k1] * pnorm((k[k1] - mode[k1])/sd1[k1]))
38-
f[k2] <- (1 - c[k2] * sqrt(2 * pi) * sd2[k2] * (1 - pnorm((k[k2] - mode[k2])/sd2[k2])))
37+
f[k1] <- (c[k1] * sqrt(2 * pi) * sd1[k1] * stats::pnorm((k[k1] - mode[k1])/sd1[k1]))
38+
f[k2] <- (1 - c[k2] * sqrt(2 * pi) * sd2[k2] * (1 - stats::pnorm((k[k2] - mode[k2])/sd2[k2])))
3939
return(f)
4040
}

R/qsplitnorm.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function(p, mode = 0, sd = 1, skew = 0, sd1 = NULL, sd2 = NULL) {
3636
p <- psplitnorm(mode, mode = mode, sd1 = sd1, sd2 = sd2)
3737
alpha1 <- alpha <= p
3838
alpha2 <- alpha > p
39-
f[alpha1] <- (mode[alpha1] + sd1[alpha1] * qnorm( alpha[alpha1]/(c[alpha1] * sqrt(2 * pi) * sd1[alpha1])))
40-
f[alpha2] <- (mode[alpha2] + sd2[alpha2] * qnorm((alpha[alpha2]+ c[alpha2] * sqrt(2 * pi) * sd2[alpha2] - 1)/(c[alpha2] * sqrt(2 * pi) * sd2[alpha2])))
39+
f[alpha1] <- (mode[alpha1] + sd1[alpha1] * stats::qnorm( alpha[alpha1]/(c[alpha1] * sqrt(2 * pi) * sd1[alpha1])))
40+
f[alpha2] <- (mode[alpha2] + sd2[alpha2] * stats::qnorm((alpha[alpha2]+ c[alpha2] * sqrt(2 * pi) * sd2[alpha2] - 1)/(c[alpha2] * sqrt(2 * pi) * sd2[alpha2])))
4141
f
4242
}

R/rsplitnorm.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function(n, mode = 0, sd = 1, skew = 0, sd1 = NULL, sd2 = NULL) {
2626
}
2727
if (any(findInterval(skew, c(-1,1), rightmost.closed=TRUE)!=1) )
2828
stop("skew must be between -1 and 1")
29-
u <- runif(n)
29+
u <- stats::runif(n)
3030
f <- qsplitnorm(u, mode = mode, sd = sd, skew = skew, sd1 = sd1, sd2 = sd2)
3131
f
3232
}

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ knitr::opts_chunk$set(
2222
[![R-CMD-check](https://github.com/guyabel/fanplot/workflows/R-CMD-check/badge.svg)](https://github.com/guyabel/fanplot/actions)
2323
<!-- badges: end -->
2424

25-
<img src='https://raw.githubusercontent.com/guyabel/fanplot/master/hex/logo_transp.png' align="right" height="200" style="float:right; height:200px;"/>
25+
<!-- <img src='https://raw.githubusercontent.com/guyabel/fanplot/master/hex/logo_transp.png' align="right" height="180" style="padding-left: 20px; padding-bottom: 20px;" /> -->
2626

2727
Visualise sequential distributions using a range of plotting styles. Sequential distribution data can be input as either simulations or values corresponding to percentiles over time. Plots are added to existing graphic devices using the fan function. Users can choose from four different styles, including fan chart type plots, where a set of coloured polygon, with shadings corresponding to the percentile values are layered to represent different uncertainty levels.
2828

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ superseded](https://img.shields.io/badge/lifecycle-superseded-blue.svg)](https:/
1414
[![R-CMD-check](https://github.com/guyabel/fanplot/workflows/R-CMD-check/badge.svg)](https://github.com/guyabel/fanplot/actions)
1515
<!-- badges: end -->
1616

17-
<img src='https://raw.githubusercontent.com/guyabel/fanplot/master/hex/logo_transp.png' align="right" height="200" style="float:right; height:200px;"/>
17+
<!-- <img src='https://raw.githubusercontent.com/guyabel/fanplot/master/hex/logo_transp.png' align="right" height="180" style="padding-left: 20px; padding-bottom: 20px;" /> -->
1818

1919
Visualise sequential distributions using a range of plotting styles.
2020
Sequential distribution data can be input as either simulations or

0 commit comments

Comments
 (0)