Skip to content

Commit

Permalink
Updated reference to new HICP Manual plus examples for CRAN checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sweinand committed Feb 28, 2024
1 parent 38df4a6 commit 041bd2a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions man/coicop.relatives.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Function \code{is.coicop()} returns a logical vector and function \code{level()}
}
\examples{
require(data.table)
### EXAMPLE 1
# validity of coicop id:
Expand All @@ -67,8 +65,11 @@ parent(id=ids, flag=FALSE, unbundle=FALSE, direct=TRUE)
parent(id=ids, flag=FALSE, unbundle=TRUE, direct=TRUE)
### EXAMPLE 2
\donttest{
# set cores for testing on CRAN:
library(restatapi)
options(restatapi_cores=1)
library(data.table)
# load hicp item weights:
coicops <- hicp.dataimport(id="prc_hicp_inw", filter=list(geo="EA"))
Expand All @@ -86,5 +87,4 @@ coicops[, "has_child":=child(id=coicop, flag=TRUE), by="time"]
coicops[has_child==FALSE, sum(values, na.rm=TRUE), by="time"]
# coicop bundles and their component ids are both taken into
# account. this double counting explains some differences
}
}
}}
10 changes: 5 additions & 5 deletions man/coicop.tree.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ A logical vector of the same length as \code{id}.
}

\examples{
require(data.table)

### EXAMPLE 1

# flag lowest possible level to be used as COICOP tree:
Expand All @@ -59,8 +57,11 @@ tree(id=c("08","081","082_083"), w=c(0.25,0.05,0.2), unbundle=FALSE)
tree(id=c("08","081","082","08"), by=c(1,1,1,2))

### EXAMPLE 2

\donttest{
# set cores for testing on CRAN:
library(restatapi)
options(restatapi_cores=1)
library(data.table)

# load hicp item weights:
coicops <- hicp.dataimport(
Expand Down Expand Up @@ -90,5 +91,4 @@ coicops[tree3==TRUE,
list("n"=uniqueN(coicop), # same selection over time and across countries
"w"=sum(values, na.rm=TRUE)), # weight sums should equal 1000
by=c("geo","time")]
}
}
}}
7 changes: 4 additions & 3 deletions man/hicp.data.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ See Eurostat's public database at \url{https://ec.europa.eu/eurostat/web/main/da
}

\examples{
\donttest{
\donttest{# set cores for testing on CRAN:
library(restatapi)
options(restatapi_cores=1)

# view available datasets:
hicp.datasets()
Expand All @@ -50,5 +52,4 @@ hicp.datafilters(id="prc_hicp_inw")

# download item weights for euro area from 2015 on:
hicp.dataimport(id="prc_hicp_inw", filters=list("geo"="EA"), date.range=c("2015", NA))
}
}
}}
12 changes: 6 additions & 6 deletions man/index.aggregation.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ Function \code{aggregate()} returns a \code{data.table} of aggregated values at
}

\references{
Eurostat (2018), \emph{Harmonised Index of Consumer Prices (HICP) Methodological Manual}, online available at: \url{https://ec.europa.eu/eurostat/web/products-manuals-and-guidelines/-/ks-gq-17-015}.
Eurostat (2024), \emph{Harmonised Index of Consumer Prices (HICP): Methodological Manual}, Luxembourg: Publications Office of the European Union, online available at: \url{https://ec.europa.eu/eurostat/web/products-manuals-and-guidelines/w/ks-gq-24-003}.
}

\examples{
require(data.table)
library(data.table)

### EXAMPLE 1

Expand Down Expand Up @@ -100,10 +100,11 @@ dt[, aggregate(x=price, w0=weight, grp=coicop,
add=list("FOOD"=c("01111","021"), "MISS"=c("021","09"))),
by="time"]


### EXAMPLE 2: Index aggregation using published HICP data

\donttest{
# set cores for testing on CRAN:
library(restatapi)
options(restatapi_cores=1)

# import monthly price indices:
prc <- hicp.dataimport(id="prc_hicp_midx", filter=list(unit="I15", geo="EA"))
Expand Down Expand Up @@ -174,5 +175,4 @@ agg.comp <- merge(

# no differences -> consistent in aggregation:
head(agg.comp[abs(index_stpwse-index_direct)>1e-4,])
}
}
}}
13 changes: 6 additions & 7 deletions man/rates.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ For \code{contrib()}, a numeric vector of the same length as \code{x}.
}

\references{
Eurostat (2018), \emph{Harmonised Index of Consumer Prices (HICP) Methodological Manual}, online available at: \url{https://ec.europa.eu/eurostat/web/products-manuals-and-guidelines/-/ks-gq-17-015}.
Eurostat (2024), \emph{Harmonised Index of Consumer Prices (HICP): Methodological Manual}, Luxembourg: Publications Office of the European Union, online available at: \url{https://ec.europa.eu/eurostat/web/products-manuals-and-guidelines/w/ks-gq-24-003}.
}

\examples{
require(data.table)

### EXAMPLE 1

P <- rnorm(n=25,mean=100,sd=5)
Expand All @@ -48,10 +46,12 @@ rates(x=P, type="annual")
rates(x=P, type="annual-average")
rates(x=P, t=t, type="annual-average")


### EXAMPLE 2: Contributions using published HICP data

\donttest{
# set cores for testing on CRAN:
library(restatapi)
options(restatapi_cores=1)
library(data.table)

# import monthly price indices:
prc <- hicp.dataimport(id="prc_hicp_midx", filter=list(unit="I15", geo="EA"))
Expand Down Expand Up @@ -92,5 +92,4 @@ dt.comp <- merge(x=hicp.ctrb,
by=c("coicop","time"),
all=TRUE)
head(dt.comp[!is.na(values) & abs(values-ribe)>0.1, ]) # should be empty
}
}
}}

0 comments on commit 041bd2a

Please sign in to comment.