Skip to content

Commit

Permalink
define unbound variables locally
Browse files Browse the repository at this point in the history
fix some more parts using data.table::
  • Loading branch information
walke committed Oct 2, 2019
1 parent 1e7408c commit 23255ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ exportMethods(selectRegion)
exportMethods(selectYears)
exportMethods(show)
importFrom(data.table,":=")
importFrom(data.table,fread)
importFrom(data.table,setnames)
importFrom(methods,new)
importFrom(methods,show)
importFrom(methods,validObject)
15 changes: 10 additions & 5 deletions R/GENESISClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#' @importFrom methods new show validObject
NULL
#' @importFrom data.table :=
#' @importFrom data.table := fread setnames
NULL

####
Expand Down Expand Up @@ -56,13 +56,15 @@ setMethod("show", "RD1",

#' @export
setMethod("selectYears", "RD1", function(x, selectYears) {
Year <- NULL # evoid NOTE
.rd1 <- x@rd1[Year %in% selectYears]
return(new("RD1", header=x@header, footer=x@footer, rd1=.rd1, content=x@content, country=x@country, protocol=x@protocol))
}
)

#' @export
setMethod("selectRegion", "RD1", function(x, selectRegion) {
Region_Code <- NULL # evoid NOTE
.rd1 <- x@rd1[Region_Code %in% selectRegion]
return(new("RD1", header=x@header, footer=x@footer, rd1=.rd1, content=x@content, country=x@country, protocol=x@protocol))
}
Expand Down Expand Up @@ -137,13 +139,15 @@ setMethod("show", "RE1",

#' @export
setMethod("selectYears", "RE1", function(x, selectYears) {
Year <- NULL # evoid NOTE
.re1 <- x@re1[Year %in% selectYears]
return(new("RE1", header=x@header, footer=x@footer, re1=.re1, content=x@content, country=x@country, protocol=x@protocol))
}
)

#' @export
setMethod("selectRegion", "RE1", function(x, selectRegion) {
Region_Code <- NULL # evoid NOTE
.re1 <- x@re1[Region_Code %in% selectRegion]
return(new("RE1", header=x@header, footer=x@footer, re1=.re1, content=x@content, country=x@country, protocol=x@protocol))
}
Expand Down Expand Up @@ -184,11 +188,11 @@ readRegDeath <- function(infile)

rdft <- data.table::fread(infile, skip=h2, nrows=(f1-h2-1))

setnames(rdft, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10"),
data.table::setnames(rdft, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10"),
c("Year","Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female"))

# merge the lower age limit
age_code1 <- data.table(Age_Name=c("unter 1 Jahr","1 bis unter 5 Jahre",
age_code1 <- data.table::data.table(Age_Name=c("unter 1 Jahr","1 bis unter 5 Jahre",
"5 bis unter 10 Jahre","10 bis unter 15 Jahre",
"15 bis unter 20 Jahre","20 bis unter 25 Jahre",
"25 bis unter 30 Jahre","30 bis unter 35 Jahre",
Expand Down Expand Up @@ -223,14 +227,15 @@ readRegExp <- function(infile)

rexpt <- data.table::fread(infile, skip=h2, nrows=(f1-h2-1))

setnames(rexpt, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12"),
data.table::setnames(rexpt, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12"),
c("Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female",
"A_Total","A_Male","A_Female"))
# add the year
Year <- NULL # avoid NOTE
rexpt[, Year:=2016]

# merge the lower age limit
age_code2 <- data.table(Age_Name=c("unter 3 Jahre","3 bis unter 6 Jahre",
age_code2 <- data.table::data.table(Age_Name=c("unter 3 Jahre","3 bis unter 6 Jahre",
"6 bis unter 10 Jahre","10 bis unter 15 Jahre",
"15 bis unter 18 Jahre","18 bis unter 20 Jahre",
"20 bis unter 25 Jahre",
Expand Down
6 changes: 4 additions & 2 deletions R/HMDClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#' @importFrom methods new show validObject
NULL
#' @importFrom data.table :=
#' @importFrom data.table := fread
NULL
####

Expand Down Expand Up @@ -64,7 +64,8 @@ setMethod("show", "LT1",

#' @export
setMethod("selectYears", "LT1", function(x, selectYears) {
.lt1 <- x@lt1[Year %in% selectYears]
Year <- NULL # evoid NOTE
.lt1 <- x@lt1[Year %in% selectYears]
return(new("LT1", header=x@header, lt1=.lt1, content=x@content, country=x@country, protocol=x@protocol))
}
)
Expand Down Expand Up @@ -142,6 +143,7 @@ setMethod("show", "EX1",

#' @export
setMethod("selectYears", "EX1", function(x, selectYears) {
Year <- NULL # evoid NOTE
.ex1 <- x@ex1[Year %in% selectYears]
return(new("EX1", header=x@header, ex1=.ex1, content=x@content, country=x@country, protocol=x@protocol))
}
Expand Down

0 comments on commit 23255ed

Please sign in to comment.