Skip to content

Commit

Permalink
re-export magrittr::%>%
Browse files Browse the repository at this point in the history
  • Loading branch information
kingaa committed Dec 13, 2018
1 parent 29e0e5e commit 1b35922
Show file tree
Hide file tree
Showing 78 changed files with 79 additions and 165 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pomp2
Type: Package
Title: Statistical Inference for Partially Observed Markov Processes
Version: 2.0.6.2
Version: 2.0.7.1
Date: 2018-12-13
Authors@R: c(person(given=c("Aaron","A."),family="King",
role=c("aut","cre"),email="[email protected]"),
Expand All @@ -22,8 +22,8 @@ Authors@R: c(person(given=c("Aaron","A."),family="King",
URL: https://kingaa.github.io/pomp/
Description: Tools for data analysis with partially observed Markov process (POMP) models (also known as stochastic dynamical systems, hidden Markov models, and nonlinear, non-Gaussian, state-space models). The package provides facilities for implementing POMP models, simulating them, and fitting them to time series data by a variety of frequentist and Bayesian methods. It is also a versatile platform for implementation of inference methods for general POMP models.
Depends: R(>= 3.5.0), methods
Imports: stats, graphics, digest, mvtnorm, deSolve, coda, reshape2
Suggests: magrittr, plyr, ggplot2, knitr, tidyr, dplyr, subplex
Imports: stats, graphics, digest, mvtnorm, deSolve, coda, reshape2, magrittr
Suggests: plyr, ggplot2, knitr, tidyr, dplyr, subplex
SystemRequirements: For Windows users, Rtools (see https://cran.r-project.org/bin/windows/Rtools/).
License: GPL-3
LazyData: true
Expand Down Expand Up @@ -106,6 +106,7 @@ Collate:
'ou2.R'
'parmat.R'
'parus.R'
'pipe.R'
'pred_mean.R'
'pred_var.R'
'show.R'
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ S3method(c,Mif2)
S3method(c,Pfilter)
S3method(c,Pmcmc)
S3method(c,Pomp)
export("%>%")
export(Csnippet)
export(as.pomp)
export(bake)
Expand Down Expand Up @@ -159,6 +160,7 @@ importFrom(graphics,polygon)
importFrom(graphics,rect)
importFrom(graphics,text)
importFrom(graphics,title)
importFrom(magrittr,"%>%")
importFrom(mvtnorm,dmvnorm)
importFrom(mvtnorm,rmvnorm)
importFrom(reshape2,melt)
Expand Down
4 changes: 4 additions & 0 deletions R/pipe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
##' @importFrom magrittr %>%
##' @docType import
##' @export
magrittr::`%>%`
4 changes: 4 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
_N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p'

_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _2._0._7:

• The ‘magrittr’ pipe operator, ‘%>%’, is now re-exported.

_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _2._0._6:

• More examples have been included.
Expand Down
5 changes: 5 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
\name{NEWS}
\title{News for package `pomp'}
\section{Changes in \pkg{pomp} version 2.0.7}{
\itemize{
\item The \pkg{magrittr} pipe operator, \code{\%>\%}, is now re-exported.
}
}
\section{Changes in \pkg{pomp} version 2.0.6}{
\itemize{
\item More examples have been included.
Expand Down
5 changes: 4 additions & 1 deletion man/reexports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/R_v_C.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ png(filename="R_v_C-%02d.png",res=100)
## ----packages------------------------------------------------------------
library(pomp2)
library(ggplot2)
library(magrittr)

## ----seed,echo=FALSE-----------------------------------------------------
set.seed(56300069)
Expand Down
9 changes: 4 additions & 5 deletions tests/R_v_C.Rout
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Welcome to pomp version 2!
For information on upgrading your pomp version < 2 code, see the
'pomp version 2 upgrade guide' at https://kingaa.github.io/pomp/.
> library(ggplot2)
> library(magrittr)
>
> ## ----seed,echo=FALSE-----------------------------------------------------
> set.seed(56300069)
Expand Down Expand Up @@ -112,16 +111,16 @@ For information on upgrading your pomp version < 2 code, see the
> ## ----comparison----------------------------------------------------------
> system.time(simulate(gompertz,nsim=10000,format="arrays"))
user system elapsed
7.624 0.064 7.688
8.072 0.064 8.137
> system.time(simulate(Gompertz,nsim=10000,format="arrays"))
user system elapsed
0.356 0.000 0.355
0.396 0.004 0.400
> system.time(pfilter(gompertz,Np=1000))
user system elapsed
0.636 0.000 0.637
0.696 0.000 0.695
> system.time(pfilter(Gompertz,Np=1000))
user system elapsed
0.052 0.000 0.050
0.060 0.000 0.059
>
> dev.off()
null device
Expand Down
1 change: 0 additions & 1 deletion tests/abc.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
png(filename="abc-%02d.png",res=100)

library(pomp2)
library(magrittr)

ou2() -> ou2

Expand Down
1 change: 0 additions & 1 deletion tests/abc.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Type 'q()' to quit R.
Welcome to pomp version 2!
For information on upgrading your pomp version < 2 code, see the
'pomp version 2 upgrade guide' at https://kingaa.github.io/pomp/.
> library(magrittr)
>
> ou2() -> ou2
>
Expand Down
1 change: 0 additions & 1 deletion tests/basic_probes.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
options(digits=3)

library(pomp2)
library(magrittr)
library(dplyr)
library(tidyr)
library(ggplot2)
Expand Down
8 changes: 0 additions & 8 deletions tests/basic_probes.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Type 'q()' to quit R.
Welcome to pomp version 2!
For information on upgrading your pomp version < 2 code, see the
'pomp version 2 upgrade guide' at https://kingaa.github.io/pomp/.
> library(magrittr)
> library(dplyr)

Attaching package: 'dplyr'
Expand All @@ -37,13 +36,6 @@ The following objects are masked from 'package:base':
intersect, setdiff, setequal, union

> library(tidyr)

Attaching package: 'tidyr'

The following object is masked from 'package:magrittr':

extract

> library(ggplot2)
>
> set.seed(255066335)
Expand Down
1 change: 0 additions & 1 deletion tests/concat.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
options(digits=3)

library(pomp2)
library(magrittr)

try(pomp2:::concat())
try(pomp2:::concat("a","b"))
Expand Down
1 change: 0 additions & 1 deletion tests/concat.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Type 'q()' to quit R.
Welcome to pomp version 2!
For information on upgrading your pomp version < 2 code, see the
'pomp version 2 upgrade guide' at https://kingaa.github.io/pomp/.
> library(magrittr)
>
> try(pomp2:::concat())
Error : 'c' is not defined for objects of mixed class.
Expand Down
1 change: 0 additions & 1 deletion tests/covmat.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
options(digits=3)

library(pomp2)
library(magrittr)
library(tidyr)
library(dplyr)

Expand Down
8 changes: 0 additions & 8 deletions tests/covmat.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ Type 'q()' to quit R.
Welcome to pomp version 2!
For information on upgrading your pomp version < 2 code, see the
'pomp version 2 upgrade guide' at https://kingaa.github.io/pomp/.
> library(magrittr)
> library(tidyr)

Attaching package: 'tidyr'

The following object is masked from 'package:magrittr':

extract

> library(dplyr)

Attaching package: 'dplyr'
Expand Down
36 changes: 16 additions & 20 deletions tests/dp.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ png(filename="dp-%02d.png",res=100)

library(pomp2)
library(ggplot2)
library(magrittr)
library(dplyr)
library(tidyr)

Expand Down Expand Up @@ -53,12 +52,11 @@ sims %>%
facet_grid(variable~.id,scales="free_y")+
labs(title="death process, Gillespie",subtitle=expression(mu==0.01))
stopifnot(
sims %>%
group_by(.id) %>%
mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
filter(!Nn) %>%
nrow() %>%
equals(0)
(sims %>%
group_by(.id) %>%
mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
filter(!Nn) %>%
nrow()) == 0
)

create_example(simulator="onestep",times=c(0,1,10,100,1000)) %>%
Expand All @@ -79,14 +77,13 @@ sims %>%
ggplot(aes(x=time,y=value,group=interaction(.id,variable)))+
geom_step()+
facet_grid(variable~.id,scales="free_y")+
labs(title="death process, onestep",subtitle=expression(mu==0.01))
labs(title="death process, onestep",subtitle=expression(mu==0.01))
stopifnot(
sims %>%
group_by(.id) %>%
mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
filter(!Nn) %>%
nrow() %>%
equals(0)
(sims %>%
group_by(.id) %>%
mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
filter(!Nn) %>%
nrow()) == 0
)

create_example(simulator="euler",times=c(0,1,10,100,1000)) %>%
Expand All @@ -109,12 +106,11 @@ sims %>%
facet_grid(variable~.id,scales="free_y")+
labs(title="death process, Euler",subtitle=expression(mu==0.01))
stopifnot(
sims %>%
group_by(.id) %>%
mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
filter(!Nn) %>%
nrow() %>%
equals(0)
(sims %>%
group_by(.id) %>%
mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
filter(!Nn) %>%
nrow()) == 0
)

create_example(mu=1) %>%
Expand Down
43 changes: 16 additions & 27 deletions tests/dp.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Welcome to pomp version 2!
For information on upgrading your pomp version < 2 code, see the
'pomp version 2 upgrade guide' at https://kingaa.github.io/pomp/.
> library(ggplot2)
> library(magrittr)
> library(dplyr)

Attaching package: 'dplyr'
Expand All @@ -39,13 +38,6 @@ The following objects are masked from 'package:base':
intersect, setdiff, setequal, union

> library(tidyr)

Attaching package: 'tidyr'

The following object is masked from 'package:magrittr':

extract

>
> set.seed(49596868L)
>
Expand Down Expand Up @@ -103,12 +95,11 @@ Warning message:
+ facet_grid(variable~.id,scales="free_y")+
+ labs(title="death process, Gillespie",subtitle=expression(mu==0.01))
> stopifnot(
+ sims %>%
+ group_by(.id) %>%
+ mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
+ filter(!Nn) %>%
+ nrow() %>%
+ equals(0)
+ (sims %>%
+ group_by(.id) %>%
+ mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
+ filter(!Nn) %>%
+ nrow()) == 0
+ )
>
> create_example(simulator="onestep",times=c(0,1,10,100,1000)) %>%
Expand Down Expand Up @@ -139,14 +130,13 @@ Warning message:
+ ggplot(aes(x=time,y=value,group=interaction(.id,variable)))+
+ geom_step()+
+ facet_grid(variable~.id,scales="free_y")+
+ labs(title="death process, onestep",subtitle=expression(mu==0.01))
+ labs(title="death process, onestep",subtitle=expression(mu==0.01))
> stopifnot(
+ sims %>%
+ group_by(.id) %>%
+ mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
+ filter(!Nn) %>%
+ nrow() %>%
+ equals(0)
+ (sims %>%
+ group_by(.id) %>%
+ mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
+ filter(!Nn) %>%
+ nrow()) == 0
+ )
>
> create_example(simulator="euler",times=c(0,1,10,100,1000)) %>%
Expand Down Expand Up @@ -179,12 +169,11 @@ Warning message:
+ facet_grid(variable~.id,scales="free_y")+
+ labs(title="death process, Euler",subtitle=expression(mu==0.01))
> stopifnot(
+ sims %>%
+ group_by(.id) %>%
+ mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
+ filter(!Nn) %>%
+ nrow() %>%
+ equals(0)
+ (sims %>%
+ group_by(.id) %>%
+ mutate(s=cumsum(ct),Nn=(N+s)==100) %>%
+ filter(!Nn) %>%
+ nrow()) == 0
+ )
>
> create_example(mu=1) %>%
Expand Down
5 changes: 2 additions & 3 deletions tests/getting_started.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ parus <- pomp(data=parus.dat,time="year",t0=1959,
simStates <- simulate(parus,nsim=10,params=c(r=0.2,K=200,sigma=0.5,N.0=200),format="arrays")$states

## ----logistic-plot1,echo=FALSE-------------------------------------------
library(magrittr)
library(tidyr)

simStates %>%
Expand Down Expand Up @@ -193,10 +192,10 @@ simulate(tm,nsim=10,format="data.frame",include.data=TRUE) %>%
theme_bw()

## ----parus-dprior--------------------------------------------------------
parus %<>%
parus %>%
pomp(dprior=Csnippet("
lik = dunif(r,0,5,1)+dunif(K,100,600,1)+dunif(sigma,0,2,1);
lik = (give_log) ? lik : exp(lik);
"),paramnames=c("r","K","sigma"))
"),paramnames=c("r","K","sigma")) -> parus

dev.off()
Loading

0 comments on commit 1b35922

Please sign in to comment.